You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/26 00:56:28 UTC

[3/7] incubator-mynewt-larva git commit: Move initial stack to CCMRAM from end of RAM.

Move initial stack to CCMRAM from end of RAM.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/110883b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/110883b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/110883b8

Branch: refs/heads/master
Commit: 110883b8201bc6c06a9fb7d11129edcf7a7444d1
Parents: 7ede884
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 25 15:45:50 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 25 15:45:50 2015 -0800

----------------------------------------------------------------------
 hw/bsp/stm32f3discovery/src/sbrk.c          | 13 +++----------
 hw/bsp/stm32f3discovery/stm32f3discovery.ld | 20 ++++++++++++--------
 2 files changed, 15 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/110883b8/hw/bsp/stm32f3discovery/src/sbrk.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/src/sbrk.c b/hw/bsp/stm32f3discovery/src/sbrk.c
index f1bbba9..73abc2f 100644
--- a/hw/bsp/stm32f3discovery/src/sbrk.c
+++ b/hw/bsp/stm32f3discovery/src/sbrk.c
@@ -17,7 +17,7 @@
 #include <errno.h>
 
 extern char _end;
-extern char _estack;
+extern char _user_heap_end;
 
 void *
 _sbrk(int incr)
@@ -28,17 +28,10 @@ _sbrk(int incr)
 
     if (incr < 0) {
         /* Returning memory to the heap. */
-        incr = -incr;
-        if (brk - incr < &_estack) {
-            prev_brk = (void *)-1;
-            errno = EINVAL;
-        } else {
-            prev_brk = brk;
-            brk -= incr;
-        }
+        prev_brk = (void *)-1;
     } else {
         /* Allocating memory from the heap. */
-        if (&_estack - brk >= incr) {
+        if (&_user_heap_end - brk >= incr) {
             prev_brk = brk;
             brk += incr;
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/110883b8/hw/bsp/stm32f3discovery/stm32f3discovery.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/stm32f3discovery.ld b/hw/bsp/stm32f3discovery/stm32f3discovery.ld
index cd770b5..2b6b536 100755
--- a/hw/bsp/stm32f3discovery/stm32f3discovery.ld
+++ b/hw/bsp/stm32f3discovery/stm32f3discovery.ld
@@ -46,7 +46,7 @@
 ENTRY(Reset_Handler)
 
 /* Highest address of the user mode stack */
-_estack = 0x20009FFF;    /* end of RAM */
+_estack = 0x10002000;    /* end of CCMRAM */
 
 /* Generate a link error if heap and stack don't fit into RAM */
 _Min_Heap_Size = 0x200;      /* required amount of heap  */
@@ -55,9 +55,9 @@ _Min_Stack_Size = 0x200; /* required amount of stack */
 /* Specify the memory areas */
 MEMORY
 {
-FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 256K
-RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 40K
-CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 8K
+	FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 256K
+	RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 40K
+	CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 8K
 }
 
 /* Define output sections */
@@ -187,17 +187,21 @@ SECTIONS
   } >RAM
 
   /* User_heap_stack section, used to check that there is enough RAM left */
-  ._user_heap_stack :
+  ._user_heap :
   {
     . = ALIGN(4);
     PROVIDE ( end = . );
     PROVIDE ( _end = . );
     . = . + _Min_Heap_Size;
-    . = . + _Min_Stack_Size;
     . = ALIGN(4);
-  } >RAM
+  } >RAM  
 
-  
+  _user_heap_end = ORIGIN(RAM) + LENGTH(RAM);
+
+  .stack_dummy :
+  {
+    . = . + _Min_Stack_Size;
+  } > CCMRAM
 
   /* Remove information from the standard libraries */
   /DISCARD/ :