diff options
| author | Ayke van Laethem <aykevanlaethem@gmail.com> | 2018-02-14 22:33:17 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2018-07-18 17:12:25 +1000 |
| commit | 4231d4311fa5983b03b821631299e415f9169881 (patch) | |
| tree | 4f4fe3ab312db9c777a183f51af602ff51b0da22 | |
| parent | 987381dfa047ad5374fd7acf67a70a973ed576d8 (diff) | |
nrf: Fix stack size in ld script and enable MICROPY_STACK_CHECK.
The nrf51x22_256k_16k_s110_8.0.0.ld had a stack size of only 1kB, which
is way too low. Additionally, the indicated _minimum_stack_size (set at
2kB for that chip) isn't respected.
This commit sets the heap end based on the stack size (heap end = RAM
end - stack size) making it much easier to configure.
Additionally, the stack/heap size of nrf52 chips has been set to a more
sane value of 8kB.
| -rw-r--r-- | ports/nrf/boards/common.ld | 7 | ||||
| -rw-r--r-- | ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_16k.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld | 13 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_32k.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52832_512k_64k.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld | 11 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld | 3 | ||||
| -rw-r--r-- | ports/nrf/boards/nrf52840_1M_256k.ld | 3 | ||||
| -rw-r--r-- | ports/nrf/mpconfigport.h | 2 |
15 files changed, 21 insertions, 117 deletions
diff --git a/ports/nrf/boards/common.ld b/ports/nrf/boards/common.ld index c8f3227af..fa1fbde99 100644 --- a/ports/nrf/boards/common.ld +++ b/ports/nrf/boards/common.ld @@ -77,7 +77,7 @@ SECTIONS .stack : { . = ALIGN(4); - . = . + _minimum_stack_size; + . = . + _stack_size; . = ALIGN(4); } >RAM @@ -94,5 +94,10 @@ SECTIONS .ARM.attributes 0 : { *(.ARM.attributes) } } +/* Define heap and stack areas */ +_ram_end = ORIGIN(RAM) + LENGTH(RAM); +_estack = ORIGIN(RAM) + LENGTH(RAM); +_heap_end = _ram_end - _stack_size; + _flash_user_start = ORIGIN(FLASH_USER); _flash_user_end = ORIGIN(FLASH_USER) + LENGTH(FLASH_USER); diff --git a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld index 442ce19e2..ac7786b5c 100644 --- a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld +++ b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld @@ -14,16 +14,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 8K; _minimum_heap_size = 16K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20007000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld b/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld index 71d57aeb0..a3962074f 100644 --- a/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld +++ b/ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 2K; _minimum_heap_size = 1K; -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20003c00; /* tunable */ - INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_16k.ld b/ports/nrf/boards/nrf51x22_256k_16k.ld index c63968191..9963a2535 100644 --- a/ports/nrf/boards/nrf51x22_256k_16k.ld +++ b/ports/nrf/boards/nrf51x22_256k_16k.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 4K; +_stack_size = 4K; _minimum_heap_size = 8K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20002000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld b/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld index 2e274920a..ae301eb6f 100644 --- a/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld +++ b/ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; -_minimum_heap_size = 1K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20003c00; /* tunable */ +_stack_size = 2K; +_minimum_heap_size = 4K; INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_32k.ld b/ports/nrf/boards/nrf51x22_256k_32k.ld index e4aa6f9ca..c9b70b6d0 100644 --- a/ports/nrf/boards/nrf51x22_256k_32k.ld +++ b/ports/nrf/boards/nrf51x22_256k_32k.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 4K; +_stack_size = 4K; _minimum_heap_size = 24K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20006000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld b/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld index 1252710f8..1979dfa95 100644 --- a/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld +++ b/ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 4K; _minimum_heap_size = 1K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20005000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld b/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld index 210680ded..3b7240e3b 100644 --- a/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld +++ b/ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 4K; _minimum_heap_size = 4K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20003000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld b/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld index ba2aec4c4..9309f17d7 100644 --- a/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld +++ b/ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld @@ -13,16 +13,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 4K; _minimum_heap_size = 6K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20002000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52832_512k_64k.ld b/ports/nrf/boards/nrf52832_512k_64k.ld index e547abe79..05e3a6f8a 100644 --- a/ports/nrf/boards/nrf52832_512k_64k.ld +++ b/ports/nrf/boards/nrf52832_512k_64k.ld @@ -12,16 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 8K; _minimum_heap_size = 32K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20008000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld b/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld index 45dd19dd7..324d710a3 100644 --- a/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld +++ b/ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld @@ -12,16 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 8K; _minimum_heap_size = 16K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20007000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld b/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld index 68a02a5b0..d1153d69e 100644 --- a/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld +++ b/ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld @@ -12,16 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 8K; _minimum_heap_size = 16K; - -/* top end of the stack */ - -/*_stack_end = ORIGIN(RAM) + LENGTH(RAM);*/ -_estack = ORIGIN(RAM) + LENGTH(RAM); - -/* RAM extents for the garbage collector */ -_ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20007000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld b/ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld index 9d830bb45..d4982565e 100644 --- a/ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld +++ b/ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld @@ -12,7 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 2K; +_stack_size = 8K; _minimum_heap_size = 16K; /* top end of the stack */ @@ -22,6 +22,5 @@ _estack = ORIGIN(RAM) + LENGTH(RAM); /* RAM extents for the garbage collector */ _ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20007000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/boards/nrf52840_1M_256k.ld b/ports/nrf/boards/nrf52840_1M_256k.ld index 555ba0bc6..05984fd19 100644 --- a/ports/nrf/boards/nrf52840_1M_256k.ld +++ b/ports/nrf/boards/nrf52840_1M_256k.ld @@ -12,7 +12,7 @@ MEMORY } /* produce a link error if there is not this amount of RAM for these sections */ -_minimum_stack_size = 40K; +_stack_size = 8K; _minimum_heap_size = 128K; /* top end of the stack */ @@ -22,6 +22,5 @@ _estack = ORIGIN(RAM) + LENGTH(RAM); /* RAM extents for the garbage collector */ _ram_end = ORIGIN(RAM) + LENGTH(RAM); -_heap_end = 0x20020000; /* tunable */ INCLUDE "boards/common.ld" diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index cfb7187b7..97d64bddb 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -43,7 +43,7 @@ #define MICROPY_READER_VFS (MICROPY_VFS) #define MICROPY_ENABLE_GC (1) #define MICROPY_ENABLE_FINALISER (1) -#define MICROPY_STACK_CHECK (0) +#define MICROPY_STACK_CHECK (1) #define MICROPY_HELPER_REPL (1) #define MICROPY_REPL_EMACS_KEYS (0) #define MICROPY_REPL_AUTO_INDENT (1) |
