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!
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
Have you considered using arm-none-linux-gnueabi-objcopy (or similar) instead of xxd? This can be found in any ARM toolchain.
.hex
file format is documented on the web. You need a loader program capable to understand it, as it has several kinds of registers to control the loading process. Some of the registers control entry point address. Others are data to be loaded at some fixed address.
You can get information at the wikipedia (I have found it there) for Intel Hex format (that's how it is called). If all the data is on only one segment and no entry point is specified, theoretically you can convert it to binary data to be loaded, but that's improbable.
It is a text file made of lines beginning with ':' character, then comes a two field hex number representing the number of bytes of data this record has, then the address this data is to be loaded on, then the type of file, it can be one of:
Then comes n bytes (n is the value of the first field) of data (hex coded) to be loaded and finally a checksum byte (the sum in two's complement of all the record bytes from the colon up).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With