2
\$\begingroup\$

When I download a .hex file using avrdude, I'm seeing a difference between the input and output size. For example, the size of the .hex file is 856 bytes, and what I see in the message is '... avrdude: 298 bytes of flash written ...'

I'm curious as to where the difference is coming from (the .hex file is larger). And would the answer to what is the machine code size (for the corresponding source code .c file), be 298 bytes?

asked Apr 20, 2015 at 16:10
\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

As the name implies, a hex file contains its data encoded in hexadecimal. Specifically, in intel hex format. If you open the file in a text editor, you'll see it's a series of lines, each starting with a colon, some header data, and a fixed number of hex digits.

Hexadecimal requires two characters to store one byte, so that doubles your filesize right away. Add to that the overhead for the format (specifying addresses to write to, lengths, checksums etc) and you arrive at the final file size.

If AVRDude is reporting 298 bytes written, that is indeed the compiled size of your program.

answered Apr 20, 2015 at 16:30
\$\endgroup\$
1
\$\begingroup\$

To expand upon @Nick's answer, here are some related questions.

Number of bytes and file size(HEX)

Will my HEX file fit in my microcontroller?

answered Apr 20, 2015 at 16:42
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.