Skip to content

Conversation

avolmat-st
Copy link

This PR first goal is to introduce usage of the LINKER_DT_NODE_REGION_NAME within the STM32 LTDC driver in order to benefit from the Zephyr linker script generated based on zephyr,memory-region. With that done it is no more necessary to rely on STM32 specific linker scripts to select the area to store the framebuffer and simply point to the node of that memory using the ext-sdram property of the LTDC.
(btw, might want to change that property name, since this is not only SDRAM however maybe another PR, including migration-guide update might be better for that ...).

For this to work, regions to hold that framebuffer must have the right compatible in order to have Zephyr generate the linker-script properly. Looking within stm32 dtsi/dts files, I noticed that some were missing, especially for the STM32L4 for which I targetted that in the first place.

The first commit is thus adding the missing zephy,memory-region compatibles. While some are really necessary, I have doubt regarding some others. Since over the zephyr,sram is also pointing to such memory area, this leads also to cases where there is two lines printed in the print-memory-usage at the end of the build, such as below:

Memory region         Used Size  Region Size  %age Used
           FLASH:       45672 B         2 MB      2.18%
             RAM:       25088 B       192 KB     12.76%
           SRAM0:          0 GB       192 KB      0.00%
           SRAM1:          0 GB        64 KB      0.00%
           SRAM2:      304200 B       384 KB     77.36%
        IDT_LIST:          0 GB        32 KB      0.00%

Above, the RAM and SRAM0 are actually the same region. Adding the zephyr,memory-region to SRAM0 makes it appears in the memory usage summary, and wrongly mentioned as usage is 0 while it is actually also RAM, hence 12.76% in the case above.
At the same time, the choice of having zephyr,sram pointing to the sram0 can vary (not always though) from a board / variant to another so it sounds like a good thing to have sram0 described as compatible zephyr,memory-region from within the .dtsi.
So, here a discussion point.

In a second commit, LTDC driver is updated to rely on the LINKER_DT_NODE_REGION_NAME macro to figure out the attribute to where store the framebuffer instead of STM32 specific hardcoded region names.

My understanding is that memc stm32 specific linker scripts were added for this purpose, so since LTDC do not need them anymore I removed them. If there were another usage for those linker scripts, then 3rd commit might not be needed.

Alain Volmat added 3 commits September 1, 2025 21:43
Add the compatible zephyr,memory-region for all mmio-sram region
which do not have yet that compatible as well as add the label to
those regions. This allow to have a linker memory report which list
all areas and also have all regions accessible via the linker script.

Signed-off-by: Alain Volmat <[email protected]>
Use the LINKER_DT_NODE_REGION_NAME macro in order to get the
memory-region into which to put the framebuffer for the LTDC.
This is made possible since all memory areas have the
zephyr,memory-region compatible, allowing to have each region
referenced within the linker script generated by Zephyr.

Signed-off-by: Alain Volmat <[email protected]>
SDRAM1 / SDRAM2 / PSRAM sections were being referenced in order to make
them accessible for the framebuffer. This is now addressed via the
mechanism provided by Zephyr hence this is no more necessary.

Signed-off-by: Alain Volmat <[email protected]>
Copy link

sonarqubecloud bot commented Sep 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants