2024-07-08 01:11 AM
I used CubeMX to generate CMake project for STM32H750XBH6.
Then I have to modify STM32H750XBHx_FLASH.ld because DMA1 can't access the DTCMRAM.
/* Specify the memory areas */
MEMORY
{
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
}
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >DTCMRAM
But everytime I use CubeMX regenerate the project, STM32H750XBHx_FLASH.ld will be recovered. My changes didn't save.
How can I save this modified STM32H750XBHx_FLASH.ld when CubeMX regenerates project?
Solved! Go to Solution.
2024-07-09 06:27 AM
Hello @Nobody233
First let me thank you for posting.
In fact, this is a known behavior of STM32CubeMX and under investigation.
As a temporary solution I propose that you make modification on a back up linker file. Then use a script to copy it and replace the one imported by STM32CubeMX at each code generation.
The script could be executed using the "User action" feature in STM32CubeMX.
BR,
Semer.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-07-09 06:27 AM
Hello @Nobody233
First let me thank you for posting.
In fact, this is a known behavior of STM32CubeMX and under investigation.
As a temporary solution I propose that you make modification on a back up linker file. Then use a script to copy it and replace the one imported by STM32CubeMX at each code generation.
The script could be executed using the "User action" feature in STM32CubeMX.
BR,
Semer.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-07-09 07:07 AM
Or, as a alternative you can create a new file STM32H750XBHx_FLASH_CUSTOM.ld with the modifications you want in it. And use this one as the linker script in your project configuration :
Then on your next CubeMX generations, the STM32H750XBHx_FLASH.ld will be regenerate but not the STM32H750XBHx_FLASH_CUSTOM.ld which will still be the one used by your compiler.
2024-07-10 02:19 AM
Hi, @Semer CHERNI
Thanks for your reply.
Firstly, it could be work as your suggestion.
Secondly, I found another solution.
I found that "cmake\gcc-arm-none-eabi.cmake" and "CMakeLists.txt" will not be covered when CubeMX regenerates project. Then I modified this two files to use another .ld file. The STM32H750XBHx_FLASH.ld would still exist but not be used.
1. add the new .ld file.
2. add target_link_options in "CMakeLists.txt".
# Setup linker parameters
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE
-T "${CMAKE_SOURCE_DIR}/STM32H750XBHx_RAM.ld"
# -u _printf_float # STDIO float formatting support (remove if not used)
)
3. remove the STM32H750XBHx_FLASH.ld in "cmake\gcc-arm-none-eabi.cmake"
set(CMAKE_C_LINK_FLAGS "${TARGET_FLAGS}")
# set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -T \"${CMAKE_SOURCE_DIR}/STM32H750XBHx_FLASH.ld\"")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --specs=nano.specs")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--start-group -lc -lm -Wl,--end-group")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--print-memory-usage")
By the way, the 4th line of step 4 could enable the printf of float value.
BR,
Nobody.
2024-07-10 02:27 AM
Hi, @SMarie .
Thanks for your reply.
Sorry about the point that I didn't mentioned is I'm using VS Code.
And I found another solution for VS Code, see upper floor.
Thanks for your kindness.
BR,
nobody.