AnsweredAssumed Answered

General question about Bootloaders and .hex/.bin files

Question asked by Salieri on Aug 19, 2015
Latest reply on Aug 19, 2015 by Salieri

I have a very general question regarding using an external uC, an EEPROM and an ethernet PHY IC to implement a reflash-through-ethernet capability on a custom board.

My question is about the program data that the compiler produces and stores into a .hex or a .bin file. The usecase I'm looking at is feeding one of these two files into an PC-based application which would fragment the raw machine code and send it through ethernet to the module which is being upgraded and the difference between the two file types.

As far as I understand, the .hex file contains a set of ASCII characters which represent hexadecimal values, whereas two consecutive characters represent a byte to be written into the uC program memory. Every line in a .hex file ends with an ASCII characters for a newline and the new line is preceded by a ASCII character ":"

The question here is: Is my understanding correct, and are there any superfluous characters or padding which should not be parsed by the application which job it is to extract the raw programming bytes which are to be sent to the module and then uploaded into the uC program memory. The specific compiler being used is gcc.

As far as .bin files go, it's my understanding that they contain raw hexadecimal values of the intended program, without any ASCII delimiters or superfluous symbols. Case in point, the question here is:

Can the PC-based application simply read the .bin file and expect all bytes  within to be valid for the write into the program memory of the uC, without any external parsing.

The application is not required to make the code user-readable, so just feeding it the .bin file and then picking up from there would be the best option. What I'm trying to ask is if my understanding of the file formats is correct, so I reduce the chance I could run into any problems down the road. It's my first time doing something like this.