Converting from *.hex to *.bin for ARM on Linux

Jacajack picture Jacajack · Nov 16, 2014 · Viewed 20.8k times · Source

I want to upload program to my STM32F4 Discovery board using st-flash command. Problem is when I try to upload *.hex or *.elf file it is just not working. I tried many ways ( like using xxd ) of converting from *.elf or *.hex to *.bin but it is still not working when I upload it. And yes, I tried uploading hex file from other Windows computer and it works.

Sample ( first three lines, just to show you how it looks inside ) of hex file:

:020000040800F2
:100000000000022099020008A1020008A5020008D1
:10001000A9020008AD020008B102000800000000BB

My OS is Ubuntu 14.04 LTS.

Thanks for help!

Answer

A. Genchev picture A. Genchev · May 14, 2016

I assume you have linux and you have installed binutils, so you just do:

objcopy --input-target=ihex --output-target=binary code00.hex code00.bin