Skip to main content
Graduate II
July 7, 2023
Question

Merging Boot and Application firmware in STM32CubeIDE

  • July 7, 2023
  • 6 replies
  • 6057 views

Hi,

I need to develop a bootloader for my application using the STM32G030C8 and went through the "How to create a super simple bootloader" videos (https://www.youtube.com/playlist?list=PLnMKNibPkDnEb1sphpdFJ3bR9dNy7S6mO). These videos showed a very handy feature of the STM32CubeIDE when you can debug the bootloader and application together, thus being able to see a correct jump from the bootloader to the application. This is done by loading both the bootloader and application projects in the IDE and select both projects in the debug setting. 

My question is, is there a similar way to compile a single HEX files which includes both the bootloader and application firmware?

Thanks

 

 

    This topic has been closed for replies.

    6 replies

    Super User
    July 7, 2023

    The usual method is to compile each program separately, then use srecord (the program at https://sourceforge.net/projects/srecord/ , not "srecord" the hex file format) or something like that to combine the hex or binary files into a single image.

    ST Employee
    July 7, 2023

    Hello @DDeba.1 

    First let me thank you for posting.

    Such feature is not supported stock on STM32CubeIDE. However you can use srec_cat.exe utility as a post command in the build setting.

    This utility will combine the two .hex files to a single one.

    If this proposition helped you, don't hesitate to select it as a solution.

    BR,

    Semer.

    DDeba.1Author
    Graduate II
    July 10, 2023

    Hi,

     

    Thank you all for the replies.

    I am trying to add srec_cat.exe to the post build options but I'm not managing. I never used post build options before. I am currently using the syntax "srec_cat app -intel boot -intel -o outfile -intel" to have the files in intel hex format merged in a single file. Im am getting errors that the system cannot find the specified path. Can anyone tell me about additional steps I need to take for the IDE to find the paths for my app.hex, boot.hex, and the srec_cat.exe. file?

    PS: I am putting the post-build command in the app build settings and building the app. Is the the correct way or should it be placed in the boot project?

    Thanks

    Super User
    July 10, 2023

    The pre and post-build steps take place in the target directory.  For example, for "debug" builds the  current directory is "MyProject/Debug".  You will need to specify paths to your hex files accordingly (typically relative paths unless you can always assume the exact same directory structure where ever that project might be built).

    Typically the bootloader is built first, then the app.  So combining them is (in my experience) done in the app build process.  In my case, the same bootloader is used for multiple applications.

    Visitor II
    May 16, 2024

    if issue was sloved please provide solution 

    DDeba.1Author
    Graduate II
    May 16, 2024

    Hi, 

    Not really. Right now, I'm opening both the bootloader and the application hex files and merge them manually (literally copy and past in a single hex file). Would be of help if there is a way where this is done automatically. 

    Visitor II
    May 16, 2024
    Graduate II
    May 16, 2024

    Bin is usable only when memories continues and between boot and app area isnt other thinks.

    Most simple way is use system command 

    copy file1.hex + file2.hex result.hex
    or append
    type file2.hex >> file1.hex
    or many more utils in any OS