You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/06/17 11:22:05 UTC

[mynewt-core] branch master updated (7091e33 -> de20336)

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


    from 7091e33  bus/i2c_nrf5x: Assert on not supported usage
     new fee9bdc  hal: Add common _sbrk function
     new 84e5b91  Remove redundant sbrk.c files form bsps
     new e1da7a4  stm32: Add call to _sbrkInit to startup files
     new 054d3c9  hal: Make common native sbrk implementation
     new fa41580  bsp/apollo2_evb: Unify sbrk
     new de20336  hal: Update syscfg for BSPs with own copy of _sbrk

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 hw/bsp/ada_feather_nrf52/src/sbrk.c                | 59 ---------------------
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../apollo2_evb/src/arch/cortex_m4/gcc_startup.s   |  1 +
 hw/bsp/apollo2_evb/src/sbrk.c                      | 51 ------------------
 hw/bsp/arduino_primo_nrf52/src/sbrk.c              | 59 ---------------------
 .../src/arch/cortex_m0/startup_stm32l072xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32l475xx.s       |  4 ++
 hw/bsp/bbc_microbit/src/sbrk.c                     | 57 --------------------
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 hw/bsp/ble400/src/sbrk.c                           | 57 --------------------
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 hw/bsp/bmd200/src/sbrk.c                           | 57 --------------------
 hw/bsp/bmd300eval/src/sbrk.c                       | 57 --------------------
 hw/bsp/calliope_mini/src/sbrk.c                    | 57 --------------------
 hw/bsp/ci40/syscfg.yml                             |  3 ++
 hw/bsp/dialog_cmac/src/sbrk.c                      | 58 ---------------------
 hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c            | 57 --------------------
 hw/bsp/dwm1001-dev/src/sbrk.c                      | 59 ---------------------
 hw/bsp/embarc_emsk/src/sbrk.c                      | 60 ----------------------
 hw/bsp/fanstel-ev-bt840/src/sbrk.c                 | 59 ---------------------
 hw/bsp/frdm-k64f/syscfg.yml                        |  3 ++
 hw/bsp/frdm-k82f/syscfg.yml                        |  3 ++
 hw/bsp/hifive1/src/sbrk.c                          | 59 ---------------------
 hw/bsp/native-mips/src/sbrk.c                      | 60 ----------------------
 hw/bsp/native/src/sbrk.c                           | 60 ----------------------
 hw/bsp/nina-b1/src/sbrk.c                          | 59 ---------------------
 hw/bsp/nordic_pca10028-16k/src/sbrk.c              | 57 --------------------
 hw/bsp/nordic_pca10028/src/sbrk.c                  | 57 --------------------
 hw/bsp/nordic_pca10040/src/sbrk.c                  | 59 ---------------------
 hw/bsp/nordic_pca10056/src/sbrk.c                  | 59 ---------------------
 hw/bsp/nordic_pca10090/src/sbrk.c                  | 60 ----------------------
 hw/bsp/nordic_pca10095/src/sbrk.c                  | 60 ----------------------
 hw/bsp/nordic_pca10095_net/src/sbrk.c              | 60 ----------------------
 hw/bsp/nordic_pca20020/src/sbrk.c                  | 59 ---------------------
 .../src/arch/cortex_m0/gcc_startup_nrf51.s         |  4 ++
 hw/bsp/nrf51-arduino_101/src/sbrk.c                | 49 ------------------
 hw/bsp/nrf51-blenano/src/sbrk.c                    | 57 --------------------
 .../src/arch/cortex_m0/startup_stm32f030x8.s       |  4 ++
 .../src/arch/cortex_m0/startup_stm32f072xb.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f303x8.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f303xe.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m4/startup_STM32F411.s         |  4 ++
 .../src/arch/cortex_m4/startup_stm32f413xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f439xx.s       |  4 ++
 .../src/arch/cortex_m7/startup_stm32f746xx.s       |  4 ++
 .../src/arch/cortex_m7/startup_stm32f767xx.s       |  4 ++
 .../src/arch/cortex_m0/startup_stm32l073xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32l476xx.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m4/startup_stm32wb55xx_cm4.s   |  4 ++
 hw/bsp/pic32mx470_6lp_clicker/syscfg.yml           |  3 ++
 hw/bsp/pic32mz2048_wi-fire/syscfg.yml              |  5 +-
 hw/bsp/pinetime/src/sbrk.c                         | 58 ---------------------
 hw/bsp/puckjs/src/sbrk.c                           | 59 ---------------------
 hw/bsp/rb-blend2/src/sbrk.c                        | 59 ---------------------
 hw/bsp/rb-nano2/src/sbrk.c                         | 59 ---------------------
 hw/bsp/reel_board/src/sbrk.c                       | 59 ---------------------
 hw/bsp/ruuvitag_rev_b/src/sbrk.c                   | 59 ---------------------
 .../src/arch/cortex_m4/startup_stm32f303xc.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F411.s         |  4 ++
 .../src/arch/cortex_m4/startup_STM32F429x.s        |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m7/startup_stm32f746xx.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32l152xc.s       |  4 ++
 hw/bsp/telee02/src/sbrk.c                          | 59 ---------------------
 hw/bsp/usbmkw41z/src/sbrk.c                        | 57 --------------------
 hw/bsp/vbluno51/src/sbrk.c                         | 59 ---------------------
 hw/bsp/vbluno52/src/sbrk.c                         | 59 ---------------------
 .../src/hal_system.c => hal/src/sbrk.c}            | 50 +++++++++---------
 .../native-armv7/src/sbrk.c => hal/src/sbrk_sim.c} |  6 +++
 hw/hal/syscfg.yml                                  |  6 ++-
 hw/mcu/stm/stm32_common/src/sbrk.c                 | 50 ------------------
 75 files changed, 165 insertions(+), 2226 deletions(-)
 delete mode 100644 hw/bsp/ada_feather_nrf52/src/sbrk.c
 delete mode 100644 hw/bsp/apollo2_evb/src/sbrk.c
 delete mode 100644 hw/bsp/arduino_primo_nrf52/src/sbrk.c
 delete mode 100644 hw/bsp/bbc_microbit/src/sbrk.c
 delete mode 100644 hw/bsp/ble400/src/sbrk.c
 delete mode 100644 hw/bsp/bmd200/src/sbrk.c
 delete mode 100644 hw/bsp/bmd300eval/src/sbrk.c
 delete mode 100644 hw/bsp/calliope_mini/src/sbrk.c
 delete mode 100644 hw/bsp/dialog_cmac/src/sbrk.c
 delete mode 100644 hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c
 delete mode 100644 hw/bsp/dwm1001-dev/src/sbrk.c
 delete mode 100644 hw/bsp/embarc_emsk/src/sbrk.c
 delete mode 100644 hw/bsp/fanstel-ev-bt840/src/sbrk.c
 delete mode 100644 hw/bsp/hifive1/src/sbrk.c
 delete mode 100644 hw/bsp/native-mips/src/sbrk.c
 delete mode 100644 hw/bsp/native/src/sbrk.c
 delete mode 100644 hw/bsp/nina-b1/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10028-16k/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10028/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10040/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10056/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10090/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10095/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca10095_net/src/sbrk.c
 delete mode 100644 hw/bsp/nordic_pca20020/src/sbrk.c
 delete mode 100644 hw/bsp/nrf51-arduino_101/src/sbrk.c
 delete mode 100644 hw/bsp/nrf51-blenano/src/sbrk.c
 delete mode 100644 hw/bsp/pinetime/src/sbrk.c
 delete mode 100644 hw/bsp/puckjs/src/sbrk.c
 delete mode 100644 hw/bsp/rb-blend2/src/sbrk.c
 delete mode 100644 hw/bsp/rb-nano2/src/sbrk.c
 delete mode 100644 hw/bsp/reel_board/src/sbrk.c
 delete mode 100644 hw/bsp/ruuvitag_rev_b/src/sbrk.c
 delete mode 100644 hw/bsp/telee02/src/sbrk.c
 delete mode 100644 hw/bsp/usbmkw41z/src/sbrk.c
 delete mode 100644 hw/bsp/vbluno51/src/sbrk.c
 delete mode 100644 hw/bsp/vbluno52/src/sbrk.c
 copy hw/{mcu/microchip/pic32mz2048efg100/src/hal_system.c => hal/src/sbrk.c} (65%)
 rename hw/{bsp/native-armv7/src/sbrk.c => hal/src/sbrk_sim.c} (94%)
 delete mode 100644 hw/mcu/stm/stm32_common/src/sbrk.c

[mynewt-core] 04/06: hal: Make common native sbrk implementation

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 054d3c9d21931114a04f9b1bc6ffba7814d3562e
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 17 09:17:48 2021 +0200

    hal: Make common native sbrk implementation
    
    All sbrk.c files for sim were identical.
    This moves code to one place
---
 hw/bsp/native-mips/src/sbrk.c                      | 60 ----------------------
 hw/bsp/native/src/sbrk.c                           | 60 ----------------------
 hw/hal/src/sbrk.c                                  |  2 +-
 .../native-armv7/src/sbrk.c => hal/src/sbrk_sim.c} |  6 +++
 4 files changed, 7 insertions(+), 121 deletions(-)

diff --git a/hw/bsp/native-mips/src/sbrk.c b/hw/bsp/native-mips/src/sbrk.c
deleted file mode 100644
index f122dd8..0000000
--- a/hw/bsp/native-mips/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include <hal/hal_bsp.h>
-
-extern int getpagesize(void);
-
-static void *cont;
-static int sys_pagesize;
-static int cont_left;
-
-void *
-_sbrk(int incr)
-{
-    void *result;
-
-    if (!sys_pagesize) {
-        sys_pagesize = getpagesize();
-    }
-    if (cont && incr <= cont_left) {
-        result = cont;
-        cont_left -= incr;
-        if (cont_left) {
-            cont = (char *)cont + incr;
-        } else {
-            cont = NULL;
-        }
-        return result;
-    }
-    result = mmap(NULL, incr, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED,
-      -1, 0);
-    if (result) {
-        cont_left = sys_pagesize - (incr % sys_pagesize);
-        if (cont_left) {
-            cont = (char *)result + incr;
-        } else {
-            cont = NULL;
-        }
-    }
-    return result;
-}
diff --git a/hw/bsp/native/src/sbrk.c b/hw/bsp/native/src/sbrk.c
deleted file mode 100644
index f122dd8..0000000
--- a/hw/bsp/native/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include <hal/hal_bsp.h>
-
-extern int getpagesize(void);
-
-static void *cont;
-static int sys_pagesize;
-static int cont_left;
-
-void *
-_sbrk(int incr)
-{
-    void *result;
-
-    if (!sys_pagesize) {
-        sys_pagesize = getpagesize();
-    }
-    if (cont && incr <= cont_left) {
-        result = cont;
-        cont_left -= incr;
-        if (cont_left) {
-            cont = (char *)cont + incr;
-        } else {
-            cont = NULL;
-        }
-        return result;
-    }
-    result = mmap(NULL, incr, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED,
-      -1, 0);
-    if (result) {
-        cont_left = sys_pagesize - (incr % sys_pagesize);
-        if (cont_left) {
-            cont = (char *)result + incr;
-        } else {
-            cont = NULL;
-        }
-    }
-    return result;
-}
diff --git a/hw/hal/src/sbrk.c b/hw/hal/src/sbrk.c
index 1c11031..3a54b5e 100644
--- a/hw/hal/src/sbrk.c
+++ b/hw/hal/src/sbrk.c
@@ -19,7 +19,7 @@
 
 #include <syscfg/syscfg.h>
 
-#if MYNEWT_VAL(HAL_SBRK)
+#if MYNEWT_VAL(HAL_SBRK) && !MYNEWT_VAL(BSP_SIMULATED)
 
 static char *sbrk_base;
 static char *sbrk_limit;
diff --git a/hw/bsp/native-armv7/src/sbrk.c b/hw/hal/src/sbrk_sim.c
similarity index 94%
rename from hw/bsp/native-armv7/src/sbrk.c
rename to hw/hal/src/sbrk_sim.c
index f122dd8..2434a47 100644
--- a/hw/bsp/native-armv7/src/sbrk.c
+++ b/hw/hal/src/sbrk_sim.c
@@ -17,6 +17,10 @@
  * under the License.
  */
 
+#include <syscfg/syscfg.h>
+
+#if MYNEWT_VAL(HAL_SBRK) && MYNEWT_VAL(BSP_SIMULATED)
+
 #include <sys/mman.h>
 #include <unistd.h>
 
@@ -58,3 +62,5 @@ _sbrk(int incr)
     }
     return result;
 }
+
+#endif

[mynewt-core] 03/06: stm32: Add call to _sbrkInit to startup files

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit e1da7a4b032756551efb745624c1a56a202121cd
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 16 12:18:31 2021 +0200

    stm32: Add call to _sbrkInit to startup files
    
    Previously STM32 based BSP provided own version of _sbrk
    that relayed on __HeabBase, __HeapLimit symbols provided by
    linker.
    BSP for other mcus has explicit call to _sbrkInit in startup
    files.
    
    This makes STM32 startup files look more like most other startup
    files.
    
    Also common stm32 sbrk.c file is dropped in favor of one that is in
    hal.
---
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m0/startup_stm32l072xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32l475xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 .../src/arch/cortex_m0/startup_stm32f030x8.s       |  4 ++
 .../src/arch/cortex_m0/startup_stm32f072xb.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f303x8.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f303xe.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m4/startup_STM32F411.s         |  4 ++
 .../src/arch/cortex_m4/startup_stm32f413xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32f439xx.s       |  4 ++
 .../src/arch/cortex_m7/startup_stm32f746xx.s       |  4 ++
 .../src/arch/cortex_m7/startup_stm32f767xx.s       |  4 ++
 .../src/arch/cortex_m0/startup_stm32l073xx.s       |  4 ++
 .../src/arch/cortex_m4/startup_stm32l476xx.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32f103xb.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m4/startup_stm32wb55xx_cm4.s   |  4 ++
 .../src/arch/cortex_m4/startup_stm32f303xc.s       |  4 ++
 .../src/arch/cortex_m4/startup_STM32F411.s         |  4 ++
 .../src/arch/cortex_m4/startup_STM32F429x.s        |  4 ++
 .../src/arch/cortex_m4/startup_STM32F40x.s         |  4 ++
 .../src/arch/cortex_m7/startup_stm32f746xx.s       |  4 ++
 .../src/arch/cortex_m3/startup_stm32l152xc.s       |  4 ++
 hw/mcu/stm/stm32_common/src/sbrk.c                 | 50 ----------------------
 28 files changed, 108 insertions(+), 50 deletions(-)

diff --git a/hw/bsp/ada_feather_stm32f405/src/arch/cortex_m4/startup_STM32F40x.s b/hw/bsp/ada_feather_stm32f405/src/arch/cortex_m4/startup_STM32F40x.s
index e84feac..e5db67f 100644
--- a/hw/bsp/ada_feather_stm32f405/src/arch/cortex_m4/startup_STM32F40x.s
+++ b/hw/bsp/ada_feather_stm32f405/src/arch/cortex_m4/startup_STM32F40x.s
@@ -228,6 +228,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/b-l072z-lrwan1/src/arch/cortex_m0/startup_stm32l072xx.s b/hw/bsp/b-l072z-lrwan1/src/arch/cortex_m0/startup_stm32l072xx.s
index 0d8bb94..9cf280b 100644
--- a/hw/bsp/b-l072z-lrwan1/src/arch/cortex_m0/startup_stm32l072xx.s
+++ b/hw/bsp/b-l072z-lrwan1/src/arch/cortex_m0/startup_stm32l072xx.s
@@ -111,6 +111,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/b-l475e-iot01a/src/arch/cortex_m4/startup_stm32l475xx.s b/hw/bsp/b-l475e-iot01a/src/arch/cortex_m4/startup_stm32l475xx.s
index 4891d0e..06cc2f0 100644
--- a/hw/bsp/b-l475e-iot01a/src/arch/cortex_m4/startup_stm32l475xx.s
+++ b/hw/bsp/b-l475e-iot01a/src/arch/cortex_m4/startup_stm32l475xx.s
@@ -108,6 +108,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/black_vet6/src/arch/cortex_m4/startup_STM32F40x.s b/hw/bsp/black_vet6/src/arch/cortex_m4/startup_STM32F40x.s
index e84feac..e5db67f 100644
--- a/hw/bsp/black_vet6/src/arch/cortex_m4/startup_STM32F40x.s
+++ b/hw/bsp/black_vet6/src/arch/cortex_m4/startup_STM32F40x.s
@@ -228,6 +228,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/bluepill/src/arch/cortex_m3/startup_stm32f103xb.s b/hw/bsp/bluepill/src/arch/cortex_m3/startup_stm32f103xb.s
index dec755f..a0044a3 100644
--- a/hw/bsp/bluepill/src/arch/cortex_m3/startup_stm32f103xb.s
+++ b/hw/bsp/bluepill/src/arch/cortex_m3/startup_stm32f103xb.s
@@ -122,6 +122,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call libc's entry point.*/
diff --git a/hw/bsp/nucleo-f030r8/src/arch/cortex_m0/startup_stm32f030x8.s b/hw/bsp/nucleo-f030r8/src/arch/cortex_m0/startup_stm32f030x8.s
index af6514d..63e4892 100755
--- a/hw/bsp/nucleo-f030r8/src/arch/cortex_m0/startup_stm32f030x8.s
+++ b/hw/bsp/nucleo-f030r8/src/arch/cortex_m0/startup_stm32f030x8.s
@@ -113,6 +113,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr     r0, =__HeapBase
+  ldr     r1, =__HeapLimit
+  bl      _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call the application's entry point.*/
diff --git a/hw/bsp/nucleo-f072rb/src/arch/cortex_m0/startup_stm32f072xb.s b/hw/bsp/nucleo-f072rb/src/arch/cortex_m0/startup_stm32f072xb.s
index f9c1bd8..16a5af5 100755
--- a/hw/bsp/nucleo-f072rb/src/arch/cortex_m0/startup_stm32f072xb.s
+++ b/hw/bsp/nucleo-f072rb/src/arch/cortex_m0/startup_stm32f072xb.s
@@ -113,6 +113,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call the application's entry point.*/
diff --git a/hw/bsp/nucleo-f103rb/src/arch/cortex_m3/startup_stm32f103xb.s b/hw/bsp/nucleo-f103rb/src/arch/cortex_m3/startup_stm32f103xb.s
index dec755f..a0044a3 100644
--- a/hw/bsp/nucleo-f103rb/src/arch/cortex_m3/startup_stm32f103xb.s
+++ b/hw/bsp/nucleo-f103rb/src/arch/cortex_m3/startup_stm32f103xb.s
@@ -122,6 +122,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call libc's entry point.*/
diff --git a/hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s b/hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s
index 04e8147..36fa04d 100644
--- a/hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s
+++ b/hw/bsp/nucleo-f303k8/src/arch/cortex_m4/startup_stm32f303x8.s
@@ -103,6 +103,10 @@ LoopFillZerobss:
 	cmp	r2, r3
 	bcc	FillZerobss
 
+    ldr r0, =__HeapBase
+    ldr r1, =__HeapLimit
+    bl  _sbrkInit
+
 /* Call the clock system intitialization function.*/
     bl  SystemInit
 /* Call the application's entry point.*/
diff --git a/hw/bsp/nucleo-f303re/src/arch/cortex_m4/startup_stm32f303xe.s b/hw/bsp/nucleo-f303re/src/arch/cortex_m4/startup_stm32f303xe.s
index ce585a1..b5b58ac 100644
--- a/hw/bsp/nucleo-f303re/src/arch/cortex_m4/startup_stm32f303xe.s
+++ b/hw/bsp/nucleo-f303re/src/arch/cortex_m4/startup_stm32f303xe.s
@@ -103,6 +103,10 @@ LoopFillZerobss:
 	cmp	r2, r3
 	bcc	FillZerobss
 
+	ldr r0, =__HeapBase
+	ldr r1, =__HeapLimit
+	bl  _sbrkInit
+
 /* Call the clock system intitialization function.*/
     bl  SystemInit
 /* Call static constructors */
diff --git a/hw/bsp/nucleo-f401re/src/arch/cortex_m4/startup_STM32F40x.s b/hw/bsp/nucleo-f401re/src/arch/cortex_m4/startup_STM32F40x.s
index e84feac..e5db67f 100644
--- a/hw/bsp/nucleo-f401re/src/arch/cortex_m4/startup_STM32F40x.s
+++ b/hw/bsp/nucleo-f401re/src/arch/cortex_m4/startup_STM32F40x.s
@@ -228,6 +228,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/nucleo-f411re/src/arch/cortex_m4/startup_STM32F411.s b/hw/bsp/nucleo-f411re/src/arch/cortex_m4/startup_STM32F411.s
index f16f419..5116aa5 100644
--- a/hw/bsp/nucleo-f411re/src/arch/cortex_m4/startup_STM32F411.s
+++ b/hw/bsp/nucleo-f411re/src/arch/cortex_m4/startup_STM32F411.s
@@ -232,6 +232,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/nucleo-f413zh/src/arch/cortex_m4/startup_stm32f413xx.s b/hw/bsp/nucleo-f413zh/src/arch/cortex_m4/startup_stm32f413xx.s
index ca70bd1..754073d 100644
--- a/hw/bsp/nucleo-f413zh/src/arch/cortex_m4/startup_stm32f413xx.s
+++ b/hw/bsp/nucleo-f413zh/src/arch/cortex_m4/startup_stm32f413xx.s
@@ -123,6 +123,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/nucleo-f439zi/src/arch/cortex_m4/startup_stm32f439xx.s b/hw/bsp/nucleo-f439zi/src/arch/cortex_m4/startup_stm32f439xx.s
index be1f048..38ce2bb 100644
--- a/hw/bsp/nucleo-f439zi/src/arch/cortex_m4/startup_stm32f439xx.s
+++ b/hw/bsp/nucleo-f439zi/src/arch/cortex_m4/startup_stm32f439xx.s
@@ -123,6 +123,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s b/hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s
index 7f01ec8..40f1073 100644
--- a/hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s
+++ b/hw/bsp/nucleo-f746zg/src/arch/cortex_m7/startup_stm32f746xx.s
@@ -123,6 +123,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s b/hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s
index eddc2c2..51c7e13 100644
--- a/hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s
+++ b/hw/bsp/nucleo-f767zi/src/arch/cortex_m7/startup_stm32f767xx.s
@@ -125,6 +125,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/nucleo-l073rz/src/arch/cortex_m0/startup_stm32l073xx.s b/hw/bsp/nucleo-l073rz/src/arch/cortex_m0/startup_stm32l073xx.s
index 85768a8..cbd3ac2 100644
--- a/hw/bsp/nucleo-l073rz/src/arch/cortex_m0/startup_stm32l073xx.s
+++ b/hw/bsp/nucleo-l073rz/src/arch/cortex_m0/startup_stm32l073xx.s
@@ -111,6 +111,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/nucleo-l476rg/src/arch/cortex_m4/startup_stm32l476xx.s b/hw/bsp/nucleo-l476rg/src/arch/cortex_m4/startup_stm32l476xx.s
index f37f643..4ea43d8 100644
--- a/hw/bsp/nucleo-l476rg/src/arch/cortex_m4/startup_stm32l476xx.s
+++ b/hw/bsp/nucleo-l476rg/src/arch/cortex_m4/startup_stm32l476xx.s
@@ -124,6 +124,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/olimex-p103/src/arch/cortex_m3/startup_stm32f103xb.s b/hw/bsp/olimex-p103/src/arch/cortex_m3/startup_stm32f103xb.s
index dec755f..a0044a3 100644
--- a/hw/bsp/olimex-p103/src/arch/cortex_m3/startup_stm32f103xb.s
+++ b/hw/bsp/olimex-p103/src/arch/cortex_m3/startup_stm32f103xb.s
@@ -122,6 +122,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call libc's entry point.*/
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/arch/cortex_m4/startup_STM32F40x.s b/hw/bsp/olimex_stm32-e407_devboard/src/arch/cortex_m4/startup_STM32F40x.s
index e84feac..e5db67f 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/arch/cortex_m4/startup_STM32F40x.s
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/arch/cortex_m4/startup_STM32F40x.s
@@ -228,6 +228,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/p-nucleo-wb55/src/arch/cortex_m4/startup_stm32wb55xx_cm4.s b/hw/bsp/p-nucleo-wb55/src/arch/cortex_m4/startup_stm32wb55xx_cm4.s
index 1c3f4b0..01de29b 100644
--- a/hw/bsp/p-nucleo-wb55/src/arch/cortex_m4/startup_stm32wb55xx_cm4.s
+++ b/hw/bsp/p-nucleo-wb55/src/arch/cortex_m4/startup_stm32wb55xx_cm4.s
@@ -97,6 +97,10 @@ LoopFillZeroCoreBss:
   cmp r2, r4
   bcc FillZeroCoreBss
 
+  ldr r0, =__HeapBase
+  ldr r1, =__HeapLimit
+  bl  _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl SystemInit
 /* Call the application s entry point.*/
diff --git a/hw/bsp/stm32f3discovery/src/arch/cortex_m4/startup_stm32f303xc.s b/hw/bsp/stm32f3discovery/src/arch/cortex_m4/startup_stm32f303xc.s
index 5270ffb..d62443f 100644
--- a/hw/bsp/stm32f3discovery/src/arch/cortex_m4/startup_stm32f303xc.s
+++ b/hw/bsp/stm32f3discovery/src/arch/cortex_m4/startup_stm32f303xc.s
@@ -119,6 +119,10 @@ LoopFillZeroCoreBss:
 	cmp   r2, r3
 	bcc   FillZeroCoreBss
 
+	ldr   r0, =__HeapBase
+	ldr   r1, =__HeapLimit
+	bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
 	bl  SystemInit
 /* Call the application's entry point.*/
diff --git a/hw/bsp/stm32f411discovery/src/arch/cortex_m4/startup_STM32F411.s b/hw/bsp/stm32f411discovery/src/arch/cortex_m4/startup_STM32F411.s
index f16f419..5116aa5 100644
--- a/hw/bsp/stm32f411discovery/src/arch/cortex_m4/startup_STM32F411.s
+++ b/hw/bsp/stm32f411discovery/src/arch/cortex_m4/startup_STM32F411.s
@@ -232,6 +232,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/stm32f429discovery/src/arch/cortex_m4/startup_STM32F429x.s b/hw/bsp/stm32f429discovery/src/arch/cortex_m4/startup_STM32F429x.s
index c7f483f..70eb4fa 100644
--- a/hw/bsp/stm32f429discovery/src/arch/cortex_m4/startup_STM32F429x.s
+++ b/hw/bsp/stm32f429discovery/src/arch/cortex_m4/startup_STM32F429x.s
@@ -107,6 +107,10 @@ LoopFillZerobss:
   cmp  r2, r3
   bcc  FillZerobss
 
+  ldr  r0, =__HeapBase
+  ldr  r1, =__HeapLimit
+  bl   _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call the application's entry point.*/
diff --git a/hw/bsp/stm32f4discovery/src/arch/cortex_m4/startup_STM32F40x.s b/hw/bsp/stm32f4discovery/src/arch/cortex_m4/startup_STM32F40x.s
index e84feac..e5db67f 100644
--- a/hw/bsp/stm32f4discovery/src/arch/cortex_m4/startup_STM32F40x.s
+++ b/hw/bsp/stm32f4discovery/src/arch/cortex_m4/startup_STM32F40x.s
@@ -228,6 +228,10 @@ Reset_Handler:
     strlt   r0, [r1], #4
     blt    .LC3
 
+    ldr     r0, =__HeapBase
+    ldr     r1, =__HeapLimit
+    bl      _sbrkInit
+
 /* Call system initialization and startup routines */
     ldr    r0, =SystemInit
     blx    r0
diff --git a/hw/bsp/stm32f7discovery/src/arch/cortex_m7/startup_stm32f746xx.s b/hw/bsp/stm32f7discovery/src/arch/cortex_m7/startup_stm32f746xx.s
index f037eb3..80b06a2 100644
--- a/hw/bsp/stm32f7discovery/src/arch/cortex_m7/startup_stm32f746xx.s
+++ b/hw/bsp/stm32f7discovery/src/arch/cortex_m7/startup_stm32f746xx.s
@@ -122,6 +122,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system initialization function.*/
   bl  SystemInit
 /* Call the libc entry point.*/
diff --git a/hw/bsp/stm32l152discovery/src/arch/cortex_m3/startup_stm32l152xc.s b/hw/bsp/stm32l152discovery/src/arch/cortex_m3/startup_stm32l152xc.s
index 032bd44..6d5950d 100644
--- a/hw/bsp/stm32l152discovery/src/arch/cortex_m3/startup_stm32l152xc.s
+++ b/hw/bsp/stm32l152discovery/src/arch/cortex_m3/startup_stm32l152xc.s
@@ -121,6 +121,10 @@ LoopFillZeroCoreBss:
   cmp   r2, r3
   bcc   FillZeroCoreBss
 
+  ldr   r0, =__HeapBase
+  ldr   r1, =__HeapLimit
+  bl    _sbrkInit
+
 /* Call the clock system intitialization function.*/
   bl  SystemInit
 /* Call libc's entry point.*/
diff --git a/hw/mcu/stm/stm32_common/src/sbrk.c b/hw/mcu/stm/stm32_common/src/sbrk.c
deleted file mode 100644
index 34edf72..0000000
--- a/hw/mcu/stm/stm32_common/src/sbrk.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-extern char __HeapBase;
-extern char __HeapLimit;
-
-void *
-_sbrk(int incr)
-{
-    static char *brk = &__HeapBase;
-
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < &__HeapBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (&__HeapLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}

[mynewt-core] 02/06: Remove redundant sbrk.c files form bsps

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 84e5b91b857af31ee61e75a6d3488ab9124d4070
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 16 10:54:30 2021 +0200

    Remove redundant sbrk.c files form bsps
    
    All bsps that had similar implementation of _sbrk and _sbrkInit
    are now using those functions provided by hal
---
 hw/bsp/ada_feather_nrf52/src/sbrk.c                | 59 ---------------------
 hw/bsp/arduino_primo_nrf52/src/sbrk.c              | 59 ---------------------
 hw/bsp/bbc_microbit/src/sbrk.c                     | 57 --------------------
 hw/bsp/ble400/src/sbrk.c                           | 57 --------------------
 hw/bsp/bmd200/src/sbrk.c                           | 57 --------------------
 hw/bsp/bmd300eval/src/sbrk.c                       | 57 --------------------
 hw/bsp/calliope_mini/src/sbrk.c                    | 57 --------------------
 hw/bsp/dialog_cmac/src/sbrk.c                      | 58 ---------------------
 hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c            | 57 --------------------
 hw/bsp/dwm1001-dev/src/sbrk.c                      | 59 ---------------------
 hw/bsp/embarc_emsk/src/sbrk.c                      | 60 ----------------------
 hw/bsp/fanstel-ev-bt840/src/sbrk.c                 | 59 ---------------------
 hw/bsp/hifive1/src/sbrk.c                          | 59 ---------------------
 hw/bsp/nina-b1/src/sbrk.c                          | 59 ---------------------
 hw/bsp/nordic_pca10028-16k/src/sbrk.c              | 57 --------------------
 hw/bsp/nordic_pca10028/src/sbrk.c                  | 57 --------------------
 hw/bsp/nordic_pca10040/src/sbrk.c                  | 59 ---------------------
 hw/bsp/nordic_pca10056/src/sbrk.c                  | 59 ---------------------
 hw/bsp/nordic_pca10090/src/sbrk.c                  | 60 ----------------------
 hw/bsp/nordic_pca10095/src/sbrk.c                  | 60 ----------------------
 hw/bsp/nordic_pca10095_net/src/sbrk.c              | 60 ----------------------
 hw/bsp/nordic_pca20020/src/sbrk.c                  | 59 ---------------------
 .../src/arch/cortex_m0/gcc_startup_nrf51.s         |  4 ++
 hw/bsp/nrf51-arduino_101/src/sbrk.c                | 49 ------------------
 hw/bsp/nrf51-blenano/src/sbrk.c                    | 57 --------------------
 hw/bsp/pinetime/src/sbrk.c                         | 58 ---------------------
 hw/bsp/puckjs/src/sbrk.c                           | 59 ---------------------
 hw/bsp/rb-blend2/src/sbrk.c                        | 59 ---------------------
 hw/bsp/rb-nano2/src/sbrk.c                         | 59 ---------------------
 hw/bsp/reel_board/src/sbrk.c                       | 59 ---------------------
 hw/bsp/ruuvitag_rev_b/src/sbrk.c                   | 59 ---------------------
 hw/bsp/telee02/src/sbrk.c                          | 59 ---------------------
 hw/bsp/usbmkw41z/src/sbrk.c                        | 57 --------------------
 hw/bsp/vbluno51/src/sbrk.c                         | 59 ---------------------
 hw/bsp/vbluno52/src/sbrk.c                         | 59 ---------------------
 35 files changed, 4 insertions(+), 1978 deletions(-)

diff --git a/hw/bsp/ada_feather_nrf52/src/sbrk.c b/hw/bsp/ada_feather_nrf52/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/ada_feather_nrf52/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/arduino_primo_nrf52/src/sbrk.c b/hw/bsp/arduino_primo_nrf52/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/arduino_primo_nrf52/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/bbc_microbit/src/sbrk.c b/hw/bsp/bbc_microbit/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/bbc_microbit/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/ble400/src/sbrk.c b/hw/bsp/ble400/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/ble400/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/bmd200/src/sbrk.c b/hw/bsp/bmd200/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/bmd200/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/bmd300eval/src/sbrk.c b/hw/bsp/bmd300eval/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/bmd300eval/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/calliope_mini/src/sbrk.c b/hw/bsp/calliope_mini/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/calliope_mini/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/dialog_cmac/src/sbrk.c b/hw/bsp/dialog_cmac/src/sbrk.c
deleted file mode 100644
index 6402c8a..0000000
--- a/hw/bsp/dialog_cmac/src/sbrk.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c b/hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/dialog_da1469x-dk-pro/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/dwm1001-dev/src/sbrk.c b/hw/bsp/dwm1001-dev/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/dwm1001-dev/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/embarc_emsk/src/sbrk.c b/hw/bsp/embarc_emsk/src/sbrk.c
deleted file mode 100644
index 779f978..0000000
--- a/hw/bsp/embarc_emsk/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/fanstel-ev-bt840/src/sbrk.c b/hw/bsp/fanstel-ev-bt840/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/fanstel-ev-bt840/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/hifive1/src/sbrk.c b/hw/bsp/hifive1/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/hifive1/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nina-b1/src/sbrk.c b/hw/bsp/nina-b1/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/nina-b1/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10028-16k/src/sbrk.c b/hw/bsp/nordic_pca10028-16k/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/nordic_pca10028-16k/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10028/src/sbrk.c b/hw/bsp/nordic_pca10028/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/nordic_pca10028/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10040/src/sbrk.c b/hw/bsp/nordic_pca10040/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/nordic_pca10040/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10056/src/sbrk.c b/hw/bsp/nordic_pca10056/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/nordic_pca10056/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10090/src/sbrk.c b/hw/bsp/nordic_pca10090/src/sbrk.c
deleted file mode 100644
index 779f978..0000000
--- a/hw/bsp/nordic_pca10090/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10095/src/sbrk.c b/hw/bsp/nordic_pca10095/src/sbrk.c
deleted file mode 100644
index 779f978..0000000
--- a/hw/bsp/nordic_pca10095/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca10095_net/src/sbrk.c b/hw/bsp/nordic_pca10095_net/src/sbrk.c
deleted file mode 100644
index 779f978..0000000
--- a/hw/bsp/nordic_pca10095_net/src/sbrk.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nordic_pca20020/src/sbrk.c b/hw/bsp/nordic_pca20020/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/nordic_pca20020/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nrf51-arduino_101/src/arch/cortex_m0/gcc_startup_nrf51.s b/hw/bsp/nrf51-arduino_101/src/arch/cortex_m0/gcc_startup_nrf51.s
index 4b2a5e4..1bcd1bc 100644
--- a/hw/bsp/nrf51-arduino_101/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51-arduino_101/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -180,6 +180,10 @@ Reset_Handler:
     bgt    .LC1
 .LC0:
 
+    LDR     R0, =__HeapBase
+    LDR     R1, =__HeapLimit
+    BL      _sbrkInit
+
     LDR     R0, =SystemInit
     BLX     R0
 
diff --git a/hw/bsp/nrf51-arduino_101/src/sbrk.c b/hw/bsp/nrf51-arduino_101/src/sbrk.c
deleted file mode 100644
index cee2590..0000000
--- a/hw/bsp/nrf51-arduino_101/src/sbrk.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-extern char __HeapBase;
-extern char __HeapLimit;
-
-static char *brk = &__HeapBase;
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < &__HeapBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (&__HeapLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/nrf51-blenano/src/sbrk.c b/hw/bsp/nrf51-blenano/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/nrf51-blenano/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/pinetime/src/sbrk.c b/hw/bsp/pinetime/src/sbrk.c
deleted file mode 100644
index 6402c8a..0000000
--- a/hw/bsp/pinetime/src/sbrk.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit)
-{
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/puckjs/src/sbrk.c b/hw/bsp/puckjs/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/puckjs/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/rb-blend2/src/sbrk.c b/hw/bsp/rb-blend2/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/rb-blend2/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/rb-nano2/src/sbrk.c b/hw/bsp/rb-nano2/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/rb-nano2/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/reel_board/src/sbrk.c b/hw/bsp/reel_board/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/reel_board/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/ruuvitag_rev_b/src/sbrk.c b/hw/bsp/ruuvitag_rev_b/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/ruuvitag_rev_b/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/telee02/src/sbrk.c b/hw/bsp/telee02/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/telee02/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/usbmkw41z/src/sbrk.c b/hw/bsp/usbmkw41z/src/sbrk.c
deleted file mode 100644
index 3fe253e..0000000
--- a/hw/bsp/usbmkw41z/src/sbrk.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/vbluno51/src/sbrk.c b/hw/bsp/vbluno51/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/vbluno51/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}
diff --git a/hw/bsp/vbluno52/src/sbrk.c b/hw/bsp/vbluno52/src/sbrk.c
deleted file mode 100644
index 5df43c9..0000000
--- a/hw/bsp/vbluno52/src/sbrk.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <hal/hal_bsp.h>
-
-/* put these in the data section so they are not cleared by _start */
-static char *sbrkBase __attribute__ ((section (".data")));
-static char *sbrkLimit __attribute__ ((section (".data")));
-static char *brk __attribute__ ((section (".data")));
-
-void
-_sbrkInit(char *base, char *limit) {
-    sbrkBase = base;
-    sbrkLimit = limit;
-    brk = base;
-}
-
-void *
-_sbrk(int incr)
-{
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < sbrkBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (sbrkLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}

[mynewt-core] 01/06: hal: Add common _sbrk function

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fee9bdc49621b46e9f419cd8b2b89417e7cfacfc
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 16 09:59:03 2021 +0200

    hal: Add common _sbrk function
    
    _sbrk implementations are put in every bsp.
    Almost all implementations are identical with
    some slight variations.
    This adds implementation that will fit most
    and bsps' versions can be removed if needed.
---
 hw/hal/src/sbrk.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/hal/syscfg.yml |  6 +++++-
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/hw/hal/src/sbrk.c b/hw/hal/src/sbrk.c
new file mode 100644
index 0000000..1c11031
--- /dev/null
+++ b/hw/hal/src/sbrk.c
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <syscfg/syscfg.h>
+
+#if MYNEWT_VAL(HAL_SBRK)
+
+static char *sbrk_base;
+static char *sbrk_limit;
+static char *brk;
+
+void
+_sbrkInit(char *base, char *limit)
+{
+    sbrk_base = base;
+    sbrk_limit = limit;
+    brk = base;
+}
+
+void *
+_sbrk(int incr)
+{
+    char *prev_brk;
+    char *new_brk = brk + incr;
+
+    if (new_brk < sbrk_base || new_brk > sbrk_limit) {
+        prev_brk = (char *)-1;
+    } else {
+        prev_brk = brk;
+        brk = new_brk;
+    }
+
+    return prev_brk;
+}
+
+#endif
diff --git a/hw/hal/syscfg.yml b/hw/hal/syscfg.yml
index 29bd002..381609f 100644
--- a/hw/hal/syscfg.yml
+++ b/hw/hal/syscfg.yml
@@ -42,7 +42,11 @@ syscfg.defs:
             If set to 0 software breakpoints placed with HAL_DEBUG_BREAK macro will not
             be executed.
         value: 1
-
+    HAL_SBRK:
+        description: >
+            If set HAL provides standard implementation of _sbrk function.
+            It also provides _sbrkInit function that sets up heap space for malloc.
+        value: 1
 syscfg.vals.OS_DEBUG_MODE:
     HAL_FLASH_VERIFY_WRITES: 1
     HAL_FLASH_VERIFY_ERASES: 1

[mynewt-core] 05/06: bsp/apollo2_evb: Unify sbrk

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fa415805670807c2a7b203a08d4d5a2e850f97b2
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 17 09:27:39 2021 +0200

    bsp/apollo2_evb: Unify sbrk
    
    sbrk.c is now removed
    call to _sbrkInit was missing in startup file
---
 .../apollo2_evb/src/arch/cortex_m4/gcc_startup.s   |  1 +
 hw/bsp/apollo2_evb/src/sbrk.c                      | 51 ----------------------
 2 files changed, 1 insertion(+), 51 deletions(-)

diff --git a/hw/bsp/apollo2_evb/src/arch/cortex_m4/gcc_startup.s b/hw/bsp/apollo2_evb/src/arch/cortex_m4/gcc_startup.s
index 4196dd2..75eb4f5 100644
--- a/hw/bsp/apollo2_evb/src/arch/cortex_m4/gcc_startup.s
+++ b/hw/bsp/apollo2_evb/src/arch/cortex_m4/gcc_startup.s
@@ -166,6 +166,7 @@ Reset_Handler:
 
     LDR     R0, =__HeapBase
     LDR     R1, =__HeapLimit
+    BL      _sbrkInit
 
     LDR     R0, =SystemInit
     BLX     R0
diff --git a/hw/bsp/apollo2_evb/src/sbrk.c b/hw/bsp/apollo2_evb/src/sbrk.c
deleted file mode 100644
index 804c8f9..0000000
--- a/hw/bsp/apollo2_evb/src/sbrk.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-extern char __HeapBase;
-extern char __HeapLimit;
-
-void *
-_sbrk(int incr)
-{
-    static char *brk = &__HeapBase;
-
-    void *prev_brk;
-
-    if (incr < 0) {
-        /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < &__HeapBase) {
-            prev_brk = (void *)-1;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
-    } else {
-        /* Allocating memory from the heap. */
-        if (&__HeapLimit - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
-        } else {
-            prev_brk = (void *)-1;
-        }
-    }
-
-    return prev_brk;
-}

[mynewt-core] 06/06: hal: Update syscfg for BSPs with own copy of _sbrk

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit de203365f207dda658657a7525253e02f68503a1
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 17 09:53:31 2021 +0200

    hal: Update syscfg for BSPs with own copy of _sbrk
    
    This adds syscfg value:
        HAL_SBRK: 0
    
    to BSPs that have private non standard version.
    They still may be unified in the future though.
---
 hw/bsp/ci40/syscfg.yml                   | 3 +++
 hw/bsp/frdm-k64f/syscfg.yml              | 3 +++
 hw/bsp/frdm-k82f/syscfg.yml              | 3 +++
 hw/bsp/pic32mx470_6lp_clicker/syscfg.yml | 3 +++
 hw/bsp/pic32mz2048_wi-fire/syscfg.yml    | 5 ++++-
 5 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/hw/bsp/ci40/syscfg.yml b/hw/bsp/ci40/syscfg.yml
index b002a25..e765762 100644
--- a/hw/bsp/ci40/syscfg.yml
+++ b/hw/bsp/ci40/syscfg.yml
@@ -32,3 +32,6 @@ syscfg.defs:
 
 syscfg.vals:
     CONSOLE_UART_DEV: '"uart1"'
+
+    # BSP uses private version of _sbrk
+    HAL_SBRK: 0
diff --git a/hw/bsp/frdm-k64f/syscfg.yml b/hw/bsp/frdm-k64f/syscfg.yml
index 0ba243e..1eacc43 100644
--- a/hw/bsp/frdm-k64f/syscfg.yml
+++ b/hw/bsp/frdm-k64f/syscfg.yml
@@ -69,3 +69,6 @@ syscfg.vals:
     REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
     NFFS_FLASH_AREA: FLASH_AREA_NFFS
     COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
+
+    # BSP uses private version of _sbrk
+    HAL_SBRK: 0
diff --git a/hw/bsp/frdm-k82f/syscfg.yml b/hw/bsp/frdm-k82f/syscfg.yml
index 94cec45..3cb1104 100644
--- a/hw/bsp/frdm-k82f/syscfg.yml
+++ b/hw/bsp/frdm-k82f/syscfg.yml
@@ -93,3 +93,6 @@ syscfg.vals:
     CRYPTO_HW_AES_CTR: 1
 
     BOOTUTIL_SWAP_USING_MOVE: 1
+
+    # BSP uses private version of _sbrk
+    HAL_SBRK: 0
diff --git a/hw/bsp/pic32mx470_6lp_clicker/syscfg.yml b/hw/bsp/pic32mx470_6lp_clicker/syscfg.yml
index e81b044..1557d15 100644
--- a/hw/bsp/pic32mx470_6lp_clicker/syscfg.yml
+++ b/hw/bsp/pic32mx470_6lp_clicker/syscfg.yml
@@ -59,3 +59,6 @@ syscfg.vals:
     I2C_0: 1
     SPI_0_MASTER: 1
     SPI_1_MASTER: 1
+
+    # BSP uses private version of _sbrk
+    HAL_SBRK: 0
diff --git a/hw/bsp/pic32mz2048_wi-fire/syscfg.yml b/hw/bsp/pic32mz2048_wi-fire/syscfg.yml
index 90ccaf9..ee8df93 100644
--- a/hw/bsp/pic32mz2048_wi-fire/syscfg.yml
+++ b/hw/bsp/pic32mz2048_wi-fire/syscfg.yml
@@ -87,4 +87,7 @@ syscfg.defs:
         value:  1
 
 syscfg.vals:
-    CONSOLE_UART_DEV: '"uart3"'
\ No newline at end of file
+    CONSOLE_UART_DEV: '"uart3"'
+
+    # BSP uses private version of _sbrk
+    HAL_SBRK: 0