Browse Source

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.
pull/3137/merge
Ayke van Laethem 7 years ago
committed by Damien George
parent
commit
4231d4311f
  1. 7
      ports/nrf/boards/common.ld
  2. 11
      ports/nrf/boards/feather52/custom_nrf52832_dfu_app.ld
  3. 11
      ports/nrf/boards/microbit/custom_nrf51822_s110_microbit.ld
  4. 11
      ports/nrf/boards/nrf51x22_256k_16k.ld
  5. 13
      ports/nrf/boards/nrf51x22_256k_16k_s110_8.0.0.ld
  6. 11
      ports/nrf/boards/nrf51x22_256k_32k.ld
  7. 11
      ports/nrf/boards/nrf51x22_256k_32k_s110_8.0.0.ld
  8. 11
      ports/nrf/boards/nrf51x22_256k_32k_s120_2.1.0.ld
  9. 11
      ports/nrf/boards/nrf51x22_256k_32k_s130_2.0.1.ld
  10. 11
      ports/nrf/boards/nrf52832_512k_64k.ld
  11. 11
      ports/nrf/boards/nrf52832_512k_64k_s132_2.0.1.ld
  12. 11
      ports/nrf/boards/nrf52832_512k_64k_s132_3.0.0.ld
  13. 3
      ports/nrf/boards/nrf52832_512k_64k_s132_5.0.0.ld
  14. 3
      ports/nrf/boards/nrf52840_1M_256k.ld
  15. 2
      ports/nrf/mpconfigport.h

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

11
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"

11
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"

11
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"

13
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"

11
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"

11
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"

11
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"

11
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"

11
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"

11
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"

11
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"

3
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"

3
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"

2
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)

Loading…
Cancel
Save