Convert a bin file to hex


I was doing some work today, that needed converting a raw bin file (read from flash memory using JTAG) to hex. I found the excellent srecord utility, which can be used as follows:

srec_cat.exe file.bin -binary -offset 0x80800000  -o file.hex -intel --line-length=44

I am hacking a AT32UC3 based board, offset above is where the application is located on that board. line-length of 44 produces a hex file that has the same line length as the avr32-objcopy utility.

To convert a hex file to binary:

srec_cat.exe file.hex -intel -offset -0x80800000 -o file.bin -binary

Note the negative offset. Without it the binary file generated will be more than 8 MB long, because of the large offset address. HxD is a nice freeware binary file editor that you can use to edit the binary file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s