Clear Filters
Clear Filters

How do I use a custom linker file with the STM32 Support Package?

16 views (last 30 days)
Is there a way to specify a custom linker file for the "Embedded Coder® Support Package for STMicroelectronics® STM32 Processors"?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Sep 2024 at 0:00
The STM32 support package currently does not offer a built-in way to specify a custom linker file. This is because we use the linker file generated by the STM32CubeMX tool.
As a workaround, you can overwrite the generated linker file with the desired custom linker file using the "Post Code Generation Command" after the code generation has occurred but before the build process starts.
More information on customizing the build process using the Post Code Generation Command can be found here: https://www.mathworks.com/help/rtw/ug/customizing-post-code-generation-build-processing.html
Assuming your custom linker file is located at <sourceLDFile>, and the automatically generated linker file from CubeMX is in <destinationLDFile>. The generated linker file should be inside a folder named "STM32CubeIDE" at the same level as the IOC project file.
In the parameters of the Simulink model, append the following string under:
Hardware > Hardware settings > Code Generation > Advanced Parameters > Post Code Generation Command
;copyfile('<sourceLDFile>', '<destinationLDFile>','f');
where <sourceLDFile> and <destinationLDFile> are the absolute paths to the custom linker file and the generated linker file, respectively.
See the following screenshot for reference:

More Answers (0)

Tags

No tags entered yet.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!