Showing results for 
Search instead for 
Did you mean: 

Merging Boot and Application firmware in STM32CubeIDE

Associate III


I need to develop a bootloader for my application using the STM32G030C8 and went through the "How to create a super simple bootloader" videos ( 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?




Bob S

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

ST Employee

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.



To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Associate III



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?


Bob S

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.

Associate II

if issue was sloved please provide solution 


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. 

Senior II

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