A Mutable Log

A blog by Devendra Tewari


Project maintained by tewarid Hosted on GitHub Pages — Theme by mattgraham

Convert a bin file to hex

I was doing some work today that required converting a raw bin file, read from flash memory using JTAG, to hex.

I found the excellent srecord utility that does the job, as follows

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

As I am hacking a AT32UC3 based board, offset 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 large offset address will result in a binary file that is more than 8 MB long.

HxD is a nice freeware binary file editor that you can use to edit the binary file.