Skip to main content
Associate II
February 16, 2026
Solved

Can I include two .hex files into my final .hex build?

  • February 16, 2026
  • 2 replies
  • 137 views

Is there a build tool to insert two .hex files into my final image? 

 

I am retroactively updating an existing firmware by moving a bootloader I've created from an unused place in the updated image into its proper sector. But to do this, I need to insert the bootloader into the image I am updating with. 

(Update image contains existing code + boot image1 + boot image2)

 

My main update image will be contained in sector 0 - 5. My first separately built bootloader.hex file must be squeezed into sector 6, and my second separately build bootloader2.hex must be squeezed into sector 7. 

 

I have found it is possible to use the linker file to insert raw hexadecimal bytes, but this requires converting the .hex file to an ascii hex array, copying it over and then building. 

Is there a command line build tool alternative to do this cleanly?

2 replies

TDK
TDKBest answer
Super User
February 16, 2026
"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate II
February 16, 2026

I tried srec_cat and since my original .hex files are not at the address I need to insert them to the output is not correct. Tried doing this:

srec_cat update-image.hex -intel boot-stage1.hex -intel -offset 0x40000 boot-stage2.hex -intel -offset -0x80000 -o final_image.hex -intel

 

Output is not at correct addresses though... I'll go with the primitive method of just creating a hex ascii array and using the linker to keep the array.