EEPROM and AVRDUDE weirdness

in a sketch running on a Mega2560: using EEPROM library I wrote "757343238393515142B0" starting at location Zero

char buffer[] = "757343238393515142B0";
for (int i=0; i<21; i++) {
      EEPROM.write(i,buffer[i]);
 }

reading it works fine

char buffer2[21] 
for (int i=0; i<21; i++) {
      buffer2[i] = EEPROM.read(i);
 }


buffer2[20]='\0';
Serial.printlin (buffer2);

prints "757343238393515142B0" to serial

when i download the EEPROM memory using AVRDude, i get no errors.
looking at the file with a hexdump utility, i see
0000-0010: 3a 32 30 30-30 30 30 30-30 33 37 33-35 33 37 33 :2000000 03735373
0000-0020: 33 33 34 33-33 33 32 33-33 33 34 33-32 34 32 33 33433323 33432423
0000-0030: 30 30 30 46-46 46 46 46-46 46 46 46-46 46 46 46 000FFFFF FFFFFFFF
0000-0040: 46 46 46 46-46 46 46 46-46 46 46 46-46 46 46 46 FFFFFFFF FFFFFFFF

which has only 12 of the bytes i wrote to EEPROM
hex 37 35 37 33 34 33 32 33 34 32 42 30
ascii 7 5 7 3 4 3 2 3 4 2 B 0

i wrote 20 bytes 757343238393515142B0
so the download doesn't have 8 bytes in the middle.
the bytes missing start at position 7 and are the 8 bytes 83935151
so the download has the first 7 bytes of what i wrote
plus the last 4, but lacks bytes 8 thru 15

any idea how avrdude's download would disagree with what the arduino sketch can READ??

i used
avrdude -p m2560 -c wiring -P [port] -U eeprom:r:file.hex:i

there is no such thing as buffer2[21]... index stops at 20 since you defined it as

āžœ indexes go from 0 to 20


side note: Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (include code tags).

thanks- should have pasted it directly from the sketch, and i have since edited it with tags

Rather than dumping the file.hex file (a text file) in hex, just print out the file.hex file. The hex dump of the text file only shows 27.5 bytes of the 32 data bytes in the first line of hex.

thanks
b':2000000037353733343332333432423000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF79\n:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0\n:20004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0\n

etcetera

(Spaces added for clarity.)

That is strange. It looks like the data is not reading out properly. My best guess is that some avrdude configuration setting, like EEPROM page size, may be misconfigured.

thanks i will look at the .conf file

the previous testing was done with a 'brew' installation of avrdude

when using the latest arduino IDE avrdude and ITS .conf fie, the same happens

Hey thanks for that: page size in conf file for ATmega2560 was 8.
I am now using 256, which is the same as the page size for Flash uploads for the ATmega2560
still a bit of a mystery - i guess not many developers using downloading eeprom.

further examination reveals that changing

paged  = no;  -> paged = yes;
page_size = 8; -> page_size = 64
and adding
num_pages = 64; 

seems to get a properly downloaded EEPROM.

this can be done by copying the entire ATmega2560 section from the global avrdude configuration file to " /User/username/.avrduderc" and making the above edits

the real answer:
the MEGA 2560 rev 3 wiring bootloader has an issue with EEPROM

read the groups response to my question here:

https://github.com/avrdudes/avrdude/issues/1011

so what i posted earlier is only a work around, and probably one that will only get the first 64 bytes properly (which is sufficient for my needs)

the github post does reveal great info