4716fc929d
Normally, statically allocated data goes in .bss, followed by the initial stack, followed by HEAP. However, any data that is statically allocated in SRAM4 with __attribute__ ((section (".sram4"))) will clobber, and be clobbered by, the HEAP. On STM32H7, BDMA can only access SRAM4. Therefore any BDMA buffers (or any other data) placed in SRAM4 will expose this problem. In one case, this manifested as a failure of NSH to start, because the SPI6 BDMA buffers clobbered the /dev/console inode structs, which the OS allocated earlier. This PR ensures that only the rest of SRAM4, after any static data, is added to the heap. This PR also allows SRAM4 to be completely excluded from the heap by a new Kconfig, CONFIG_STM32H7_SRAM4EXCLUDE, similar to what CONFIG_STM32H7_DTCMEXCLUDE does for the DTCM region. Change required in linker scripts: Every STM32H7 linker script must replace this: .sram4 : { } > sram4 with this: .sram4_reserve (NOLOAD) : { *(.sram4) . = ALIGN(4); _sram4_heap_start = ABSOLUTE(.); } > sram4 or link will fail with: undefined reference to '_sram4_heap_start'. The Release Notes should document this for users with out-of-tree boards. arch/arm/src/stm32h7/Kconfig: * Add config STM32H7_SRAM4EXCLUDE to allow excluding all of SRAM4 from the HEAP. arch/arm/src/stm32h7/stm32_allocateheap.c: * Only when including SRAM4 in the heap, define HAVE_SRAM4, SRAM4_START, SRAM4_END, and SRAM4_HEAP_START. * Add "Private Data" section. * Add extern for_sram4_heap_start, which must be defined in the board's linker script. * arm_addregion(): Only add SRAM4 to the heap when configured to do so, i.e., unless CONFIG_STM32H7_SRAM4EXCLUDE is defined, and only add the portion of SRAM4 that is past any static data. boards/arm/stm32h7/nucleo-h743zi/scripts/flash.ld: boards/arm/stm32h7/nucleo-h743zi/scripts/kernel.space.ld: boards/arm/stm32h7/nucleo-h743zi2/scripts/flash.ld: boards/arm/stm32h7/stm32h747i-disco/scripts/flash.ld: boards/arm/stm32h7/stm32h747i-disco/scripts/kernel.space.ld: * Update all in-tree STM32H7 board linker scripts as described in "Change required in linker scripts" above. Testing: * Successfully built all of the following configurations: nucleo-h743zi2:jumbo nucleo-h743zi2:nsh nucleo-h743zi:nxlines_oled nucleo-h743zi:elf nucleo-h743zi:otg_fs_host nucleo-h743zi:nsh nucleo-h743zi:netnsh nucleo-h743zi:pwm stm32h747i-disco:nsh * Tested with custom board. * nxstyle. References: [1] See the dev@nuttx.a.o mailing list discussion started 2021/03/25: "How to ensure HEAP will not overlap static DMA buffer?" https://lists.apache.org/thread.html/recf2bb9043f8c9f53c10917e2adb2ec64fe35dc5e6f9a695a7ac6ecc%40%3Cdev.nuttx.apache.org%3E [2] See arm_addregion() in arch/arm/src/stm32h7/stm32_allocateheap.c Thanks to Gregory Nutt and David Sidrane for suggestions and reviews. |
||
---|---|---|
.. | ||
a1x/pcduino-a10 | ||
am335x/beaglebone-black | ||
c5471/c5471evm | ||
cxd56xx | ||
dm320/ntosd-dm320 | ||
efm32 | ||
eoss3/quickfeather | ||
imx6/sabre-6quad | ||
imxrt | ||
kinetis | ||
kl | ||
lc823450/lc823450-xgevk | ||
lpc17xx_40xx | ||
lpc31xx | ||
lpc43xx | ||
lpc54xx/lpcxpresso-lpc54628 | ||
lpc214x | ||
lpc2378/olimex-lpc2378 | ||
max326xx/max32660-evsys | ||
moxart/moxa | ||
nrf52 | ||
nuc1xx/nutiny-nuc120 | ||
rp2040 | ||
s32k1xx | ||
sam34 | ||
sama5 | ||
samd2l2 | ||
samd5e5 | ||
samv7 | ||
stm32 | ||
stm32f0l0g0 | ||
stm32f7 | ||
stm32h7 | ||
stm32l4 | ||
stm32l5 | ||
str71x/olimex-strp711 | ||
tiva | ||
tms570 | ||
xmc4 |