Custom linker script STM32CUBE

Hi @u306060 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:

[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg
board_build.ldscript = $PROJECT_DIR/my_linkerscript.ld
framework = stm32cube

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

PS: I found this thanks to @maxgerhardt , who helped me specify custom paths in projects (see PlatformIO integration into Embeetle IDE)

1 Like