STM32H7: Don't use DTCM memory for heap #396
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
The change that I made a month or two ago to use DTCM as the default heap on STM32H7 has caused some unforseen consequences. Basically, the DMA controller cannot access anything in DTCM in any shape or form, so using SDIO, Ethernet, or DMA SPI with heap-allocated buffers will cause a crash or unintended behavior.
This PR updates the STM32H7 linker scripts (soooo glad there are only 4 of them now!) to use main SRAM as heap 0 and SRAM_D2/SRAM_AXI as heap. This way, we still can take advantage of two of the memory banks for heap size, but we don't have to deal with the issues caused by DTCM. DTCM provides a big performance boost, make no mistake, but I think it's best left as a power user only option.
I also made one other change in this, which is that until now, targets which implemented split heap still had to provide the end and __HeapLimit symbols in the linker script in order for the
mbed_heap_start/size
variables to be correct, even though the actual heap allocator did not use them. This consolidates those so that only the "new style" symbols are needed if you have split heap, and only the "old style" symbols are needed if you don't. I like this because__end__
is a super vague name and while Mbed only uses it as the start of heap, it's hard to say if everyone agrees that's what it means, so I would rather move away from using it.Impact of changes
MBED_SPLIT_HEAP
, the linker script only needs to define __mbed_sbrk_start/__mbed_sbrk_start_0 and __mbed_krbs_start/__mbed_krbs_start_0, not end and __HeapLimit.Migration actions required
Documentation
Pull request type
Test results
The following tests passed on NUCLEO_H743ZI2: