# Merging 2 Hex files

I am looking for a way so that first time I can program bootloader and application as single hex file image. So that I can use bootloader only for code updates if required.

I can't compile the code due to 2 main() functions hence only option available to me is merging 2 hex files.

• Is it an intel hex file? If so have you tried just copying the lines from the bootloader hex file into the program hex file? – Tom Carpenter Nov 9 '15 at 15:33

I agree with @TomCarpenter. If it's an Intel HEX file (Most HEX files are Intel or a derivative), read this page on wiki about the HEX file

The HEX file usually contains lines like the first one of this (without spaces):

:10    0120  00   194E79234623965778239EDA3F01B2CA A7

This line says that there are 16 bytes (0x10) to be written at address 0x0120. Note that if Type is not 00, this may alter the address.
srec_cat boot.hex -intel main.hex -intel -o mergedfile.hex -intel