cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a FSBL Application for a custom STM32N6 board

cp5900
Associate II
Context : I want to write a FSBL load and run application on a custom minimal PCB based on STM32N6-DK design. The board uses SMPS power supply and not the default power supply of the STM32N6-DK. I follow this original tutorial  as a main example.
 
Problem faced: CubeProgrammer SigningTool version compatibility and header size
 
1) Write a custom external bootloader to write and read external flash memory
  • 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
 
 
2) Modify SigningTool header generation command in FSBL post-build
 
  • 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
 
 
3) Program flash and debug
 
  • 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.

0 REPLIES 0