0
\$\begingroup\$

My MSP430 program consists of serial bootloader and application hex files. While programming I load bootloader program using JTAG and then load application program using bootloader.

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Tom Carpenter Nov 9 '15 at 15:33
1
\$\begingroup\$

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
 Bytes Addr  Type Data                             Checksum

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.

If now you have a look at your two HEX files from the two projects, you'll notice that they contain data to be written to different memory addresses. However, some lines may write to the same addresses. This may be:

  • Configuration bits / bytes. They are set in both projects, and should be equal, if you used the same settings.
  • Jump command. I once found a command for the very first bytes of memory address in a HEX file, which causes the MCU to directly jump to the address, where your main program resides. But as the boot loader should sit at the beginning of the memory, this one had to be deleted.
|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

Use srec_cat :

srec_cat boot.hex -intel main.hex -intel -o mergedfile.hex -intel
|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.