Converting Binary Files to Intel Hex Format with the SRecord Tool

I’m dealing a lot with bootloaders recently (see “Flash-Resident USB-HID Bootloader with the NXP Kinetis K22 Microcontroller“), and bootloaders are sometimes very picky about what file format they are able to consume. So what if I have a binary (see “S-Record, Intel Hex and Binary Files“) file and I need to convert it into the Intel Hex format?

converted binary to intel hex

converted binary to intel hex

Using the ‘SRecord‘ tool it is actually very simple:

srec_cat.exe srcFile.bin -binary -output dstFile.hex -Intel

With the -binary option I load the binary file and with the -Intel option used with the -output I can convert the file.

Below it shows a binary and its converted version in Eclipse (see “5 Best Eclipse Plugins: #4 (EHEP)“).

converted binary to intel hex

converted binary to intel hex

Done :-).

Happy Hexing πŸ™‚


7 thoughts on “Converting Binary Files to Intel Hex Format with the SRecord Tool

  1. hex format is what is needed for a boot loader for the most part. They have horizontal checksums on each line which makes sure you’re reading each line correctly. What this particular one is lacking is vertical checksums.

    There needs to be chain of custody when updating code like that in the field and the file itself should have some sort of checksum to it so that when you tell the processor to go ahead and reboot, it can compare what it has written with you think it should be before you go ahead and brick it.


  2. Eric

    Take a look at the uTasker conversion tools too:
    These allow combining boot loaders with applications, converting formats (including Motorola Binary which older CW tools produced, rather than raw binary), or converting binary file, images, web pages etc. into arrays for including in programs.
    They also allow authenticating/encrypting applications for working with secure boot loaders.
    Basically they are utilities which have evolved over the years to do thing that are always needed again and again in real-world embedded projects to avoid the need to search for various tools to do the different jobs.




  3. Pingback: Generating Intel Hex Files with a given Length using srec_cat | MCU on Eclipse

  4. I use srec_cat all the time to create my bootloader+firmware secure srec files. One important option is the -offset parameter which allows you to shift the starting address +- as opposed to the default of 0. The unfill option is also useful for removing large holes in the code which makes for a smaller file. happy S19ing.

    Liked by 1 person

What do you think?

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

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.