The common linker script for stm32 based platforms doesn't take into account that on some platforms the available RAM is split up in different RAM sections e.g. SRAM1 & SRAM2.
On some MCUs there is a hardware feature to remap the address space of SRAM2 consecutively after SRAM1, there it doesn't actually impose a problem. This feature is not available on all MCUs though.
On stm32l476rg for example SRAM1 is at 0x20000000 while SRAM2 resides at 0x10000000. After SRAM1 unmapped address space is located (see RM0351 reference manual page 73).
I stumbled across this when testing low power RAM retention which is only available on SRAM2 on the named MCU.
As a minimum fix the RAM_LEN value in stm32_mem_lengths.mk for affected platforms should be reduced to the minimum consecutively addressable amount (96K in the above case).
A better fix would need to add another ram section to cortexm.ld and cortexm_base.ld and respectively additional parameters to stm32_mem_lengths.mk.
I'd like to use this Issue to collect which other MCUs are affected by this (if any) and discussion on how to properly integrate the split RAM to the linker scripts before opening up a PR. Feel free to help, of course ;)
edit
Just checked the RIOT-supported L4 MCUs.
no automatic remap (problem exists):
stm32l475vg (b-l475e-iot01a)
stm32l476rg (nucleo-l476rg)
stm32l476vg (stm32l476g-disco)
automatic remap (no problem):
stm32l432kc
stm32l433rc
stm32l452re
stm32l496zg
The common linker script for stm32 based platforms doesn't take into account that on some platforms the available RAM is split up in different RAM sections e.g. SRAM1 & SRAM2.
On some MCUs there is a hardware feature to remap the address space of SRAM2 consecutively after SRAM1, there it doesn't actually impose a problem. This feature is not available on all MCUs though.
On stm32l476rg for example SRAM1 is at 0x20000000 while SRAM2 resides at 0x10000000. After SRAM1 unmapped address space is located (see RM0351 reference manual page 73).
I stumbled across this when testing low power RAM retention which is only available on SRAM2 on the named MCU.
As a minimum fix the RAM_LEN value in stm32_mem_lengths.mk for affected platforms should be reduced to the minimum consecutively addressable amount (96K in the above case).
A better fix would need to add another ram section to cortexm.ld and cortexm_base.ld and respectively additional parameters to stm32_mem_lengths.mk.
I'd like to use this Issue to collect which other MCUs are affected by this (if any) and discussion on how to properly integrate the split RAM to the linker scripts before opening up a PR. Feel free to help, of course ;)
edit
Just checked the RIOT-supported L4 MCUs.
no automatic remap (problem exists):
stm32l475vg (b-l475e-iot01a)
stm32l476rg (nucleo-l476rg)
stm32l476vg (stm32l476g-disco)
automatic remap (no problem):
stm32l432kc
stm32l433rc
stm32l452re
stm32l496zg