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:08 UTC

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

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;
-}