How to write a FSBL Application for a custom STM32N6 board
- Modify the power supply parameter (System Core --> RCC --> SupplySource) in CubeMX to `PWR_SMPS_SUPPLY`
- Generate ExtMemLoader template from CubeMX
- Build ExtMemLoader to generate .stldr file
- make sure the post build script can be executed
- manually copy the .stldr file generated in `/STM32CubeProgrammer.app/Contents/Resources/bin/ExternalLoader/` if necessary
- Build FSBL & Application following the original tutorial
- Check heading size, it might be different from the 0x400 that is defined in CubeMX (caused by uninstalling then reinstalling CubeProgrammer thus SigningTool)
- look for this message *[Header v2.3] Do not align the payload to the 0x400 offset, No padding bytes at the beginning of the payload*
- Vector Table cannot be located at 0x240 for hardware alignment constraint, therefore it needs to be at 0x400 (following the header)
- Add `--align` at the end of the SigningTool command to add padding bytes and get a 0x400 header (`STM32_SigningTool_CLI -bin FSBL.bin ... --align`)
- Then rebuild and make sure header size is 0x400
- Select the custom .stldr as External loaders in CubeProgrammer
- Write trusted.bin files for both FSBL and Application following the original tutorial
- To use the Debugger in CubeIDE you also need to add the custom .stldr file previously generated in Debug Configurations --> C/C++ Application --> Debugger --> External loaders). Follow the instructions from this tutorial
I hope this short guide will help some of you. Feel free to reach out if you have any question.
