I was investigating how to feed a custom linker file to compiler while building a project based on famework-stm32cube. (Project is generated via stm32CubeMx, and the linker file is in "project_root_dir/*_FLASH.ld)
I’ve got the following message: Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
There is only chance to copy the linker file to .platformio root … framework … ldscripts directory.
Is there any other way to point to this file in my project directory?
Hi @valeros ! Thanks for the answer. I’ve tried this earlier: -Wl,-T$PROJECT_DIR/STM32F401RE_FLASH.ld
This doesn’t work for me, still got Warning! Cannot find a linker script for the required board! Firmware will be linked with a default linker script!
Any ideas?
Still have to copy the .ld file to .framework-stm32cube directory. This is not convenient way that does not allow doing it automatically after each code generation.
Don’t copy it to the framework folder, because with the next update it will be deleted. Just keep your ld script in the root folder of your project, add it to your project using build flags and you should be fine. You also can give your script a notable name so you can distinguish between your script and the default one.
Hi @valeros! I’m aware of copying it to the framework directory. buiild_flags directive doesn’t work for me. My guess that there is a way to declare the path that still out of my knowledge in PlatformIO.
I suppose that warning might be a bit misleading, we will try to reimplement it or change the text in the next release. As for now, it’s fine to see that warning even when you specified your own linker script as long as you can successfully compile your project.
Hi @Sergio and @valeros ,
While browsing the forum, I found the following way to specify a custom linkerscript. In the platformio.ini file, you can define an environment like this:
The board_build.ldscript option overwrites the ldscript entry from the board’s json file, such that the linker uses your file 'my_linkerscript.ld' in the project folder , instead of the default one.
Note:
If not specified, the default linkerscript would be: ~/.platformio/packages/tool-ldscripts-ststm32/stm32l4/STM32L476RGTX_FLASH.ld
Hi @kristof.mulier ! Thanks for sharing this with us. However as I remember I’ve tried something similar already.
May be I’ll get back to that issue to check if that is true.