I’m trying to understand the difference between the hex file that avrasm2 creates and I write to flash using avrdude and the same flash that I read back again using avrdude.
I'm using a homebrew board with an ATMEGA328P and a USBtiny programmer. I’m experimenting with very simple and short programs.
Assembling the program:
avrasm2 -fI blink.asm
The size of the hex file is 181 bytes.
Writing the program to the ATMEGA328P”
avrdude -p m328p -c USBtiny -b 57600 -U flash:w:blink.hex
The program works ok.
Then reading the program back from the ATMEGA328P:
avrdude -p m328p -c USBtiny -b 57600 -U flash:r:"blink2.hex":i
The size of this hex file is 288 bytes. It’s difficult to match this hex file to the original. I see some parts that are the same but obviously it includes more of something. Variables are not stored in flash, so that shouldn’t account for the extra bytes.
I can rewrite either of these 2 hex files back to the ATMEGA328P, and they both work ok, even though blink2.hex is 107 bytes longer. Some other programs are 300-400 bytes longer.
Does this have something to do with how avrdude works? Or maybe flash page sizes in AVR chips?