I need to check if the code burned on the some Arduino is the same one as I have. I know how to get the hex file from the Arduino. My question is what influence the hex code? Board Type? Microprocessor type? avrdude version? anything else?


The lines in a typical hex file include a VLI (variable length indicator). The hex files output from the IDE might have different lengths than those produced by avrdude. As a simple example:

File 1:


File 2:


Those files will compare differently to each other but convey the same information, split differently between lines.

To do a genuine comparison you would need to account for that.

Board Type?

Different boards, but with the same processor, might have identical files.

Microprocessor type?

Different processor would almost certainly have different hex files.

avrdude version?

Probably not, however see my comments above about the VLIs.

anything else?

As I said, the compiler may generate lines with (say) 16 bytes per line, but avrdude might read back lines with 32 bytes per line. Thus they would look different but convey the same hex codes, once you allow for that.

| improve this answer | |
  • You may be able to use the copy of avr-objcopy included in the Arduino installation to copy a hex file to a newly generated hex file passing it through the same output generating code as would be used for a newly complied project made with that toolchain. Then you can use diff. – Chris Stratton May 6 '18 at 16:36
  • dose compiler version also influance Hex file? – Ditza May 7 '18 at 7:37
  • It might, because of different levels of optimization. Or even, that the command-line switches sent to your compiler are different to the ones used to make the hex file. – Nick Gammon May 7 '18 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.