From 57d1e9a6c5863bb62f7d57324250d17463fb3bb7 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Thu, 20 Oct 2022 11:51:15 +0200 Subject: [PATCH] bricks/_common_stm32/link: Use full remaining RAM for stack. Also rename the hub-specific value to explain that it is not the actual stack size but only a lower bound to force a build error, similar to upstream MicroPython. --- bricks/_common_stm32/link.ld | 4 ++-- bricks/cityhub/city_hub.ld | 5 ++++- bricks/debug/debug.ld | 4 +++- bricks/essentialhub/essential_hub.ld | 5 ++++- bricks/movehub/move_hub.ld | 5 ++++- bricks/primehub/prime_hub.ld | 4 +++- bricks/technichub/technic_hub.ld | 5 ++++- 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bricks/_common_stm32/link.ld b/bricks/_common_stm32/link.ld index 674090eae..e7928e7db 100644 --- a/bricks/_common_stm32/link.ld +++ b/bricks/_common_stm32/link.ld @@ -4,7 +4,6 @@ /* top end of the stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); -_sstack = _estack - _stack_size; /* define output sections */ SECTIONS @@ -81,7 +80,8 @@ SECTIONS .stack : { . = ALIGN(4); - . = . + _stack_size; /* will cause linker error if there is not enough space for stack. */ + _sstack = .; + . = . + _minimal_stack_size; /* will cause linker error if there is not enough space for stack. */ . = ALIGN(4); } >RAM diff --git a/bricks/cityhub/city_hub.ld b/bricks/cityhub/city_hub.ld index aef4b071b..2f2a38089 100644 --- a/bricks/cityhub/city_hub.ld +++ b/bricks/cityhub/city_hub.ld @@ -23,7 +23,10 @@ MEMORY } "MAGIC_OFFSET" = 0x100; -_stack_size = 4K; + +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 4K; /* Start of data storage. */ _pbdrv_block_device_storage_start = ORIGIN(FLASH_USER_0); diff --git a/bricks/debug/debug.ld b/bricks/debug/debug.ld index cfc4d301e..e94b35789 100644 --- a/bricks/debug/debug.ld +++ b/bricks/debug/debug.ld @@ -9,4 +9,6 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K } -_stack_size = 8K; +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 8K; diff --git a/bricks/essentialhub/essential_hub.ld b/bricks/essentialhub/essential_hub.ld index 330910c0e..f41e4e92f 100644 --- a/bricks/essentialhub/essential_hub.ld +++ b/bricks/essentialhub/essential_hub.ld @@ -18,4 +18,7 @@ MEMORY } "FW_INFO_OFFSET" = 0x200; -_stack_size = 16K; + +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 12K; diff --git a/bricks/movehub/move_hub.ld b/bricks/movehub/move_hub.ld index 50f533d13..f167bd2f6 100644 --- a/bricks/movehub/move_hub.ld +++ b/bricks/movehub/move_hub.ld @@ -23,7 +23,10 @@ MEMORY } "MAGIC_OFFSET" = 0x100; -_stack_size = 3K; + +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 3K; /* Start of data storage. */ _pbdrv_block_device_storage_start = ORIGIN(FLASH_USER_0); diff --git a/bricks/primehub/prime_hub.ld b/bricks/primehub/prime_hub.ld index 0c23e34a5..b2440e5a6 100644 --- a/bricks/primehub/prime_hub.ld +++ b/bricks/primehub/prime_hub.ld @@ -17,4 +17,6 @@ MEMORY RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K } -_stack_size = 16K; +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 16K; diff --git a/bricks/technichub/technic_hub.ld b/bricks/technichub/technic_hub.ld index 99ac77543..ed0059b7f 100644 --- a/bricks/technichub/technic_hub.ld +++ b/bricks/technichub/technic_hub.ld @@ -23,7 +23,10 @@ MEMORY } "MAGIC_OFFSET" = 0x200; -_stack_size = 8K; + +/* Minimal stack size to allow the build to proceed. The actual stack size is whatever is left after + statically allocated memory. It can be tuned by setting PBSYS_CONFIG_PROGRAM_LOAD_RAM_SIZE. */ +_minimal_stack_size = 8K; /* Start of data storage. */ _pbdrv_block_device_storage_start = ORIGIN(FLASH_USER_0);