Hex files vs Bin files

05 Nov 2011

I have a MBed which is about a year old. I just got back to the system. The OP system is Windows 7. Just got the computer on line. After a compile a .bin file is available. When is downloads the blue light blinks but when I reset nothing happens. If I go to the MBed drive and sometimes there is a Hex file available. If I download the hex file the program will execute. What am I doing wrong at build time?

05 Nov 2011

Hi Martin,

The compiler outputs a standard raw ARM binary file, with the extension .bin. When you save this on the mbed and hit reset, it is loaded in to the MCU FLASH.

I'm not sure I quite understand the explanation of the behaviour you are seeing; by HEX file, do you mean a file with a .hex extension (unlikely), or are you looking inside it and interpreting something about the format? Certainly the mbed doesn't generate files, so this would be something to do with files your browser or OS are generating. Maybe it is changing the file extension somehow, so not being seen by the mbed?

A couple of things to try could be:

  • Assuming you are using the LPC1768, try downloading the precompiled hello world and check that runs: http://mbed.org/nxp/lpc1768/
  • Try a different browser for the compiler, and check you get the same behaviour
  • Format the mbed drive if you are still having problems

Report back if you are still having problems; i'm sure it is something that can be tracked down.

Simon

05 Nov 2011

While the code for most of my projects still starts out being tested on my mbed module, I fairly quickly move to a dedicated PCB with a LPC1768 on board. Then I have to follow the path spelled out in Chris Styles 'Prototype to hardware', and convert the BIN file to a HEX file that can be loaded using Flash Magic, using Bin2hex.exe.

To take some of the tedium out of repeatedly going through this process I use a batch file like this:

cd C:\mbed work\CSM_CM rename CSM_CM*.bin CSM_CM.bin bin2hex /4 CSM_CM.bin CSM_CM.hex

The second line shortens the default BIN file name to fit the required 8.3 format, and the '/4' in the third line allows BIN files larger than 64K to be converted to ARM format rather than Intel 'Extended Address' format.

Maybe someone may find these two tips useful, but my main reason for posting to to ask "Why is there not provision for getting either HEX or BIN file output from the mbed compiler?" Most other ARM compilers give you this option.

05 Nov 2011

The HEX mystery was solved. I used the Keil system to compile and it generated a hex file. This happened over a year ago All the .hex files are how deleted. The download was also solved. With both Foxfire and Windows browsers the .bin file goes to the system downloads file. The .bin file in the Downloads folder then has to be manually SEND to G.mbed. Thanks for the help. The .bin file going to the downloads file was a big surprise. Martin

04 Feb 2017

Hello Martin,

we are facing the similar issue. I compiled code using Keil uVision 5, and it generates HEX file. i converted HEX file to BIN file using fromelf.exe utility. when I use this BIN file, to update firmware by copying this file into serial flash of of Dragonfly board, and reset the system, the firmware is not working.

One observation is that BIN file generated by Keil does not include boot loader code, whereas BIN file generated by mbed online compiler tool, has it.

Do you know, how to include boot loader code as part of application, while compiling using Keil?