tl;dr - adding the command which hopefully fixes reading large flash parts doesn’t appear to affect reading smaller parts
Did a little experiment with this today. I only have one device with an ATMega128, but the board doesn’t have the ISP pins pulled out. I only have one of the devices, so I don’t want to go hacking on it too much - it’s something I can’t replace.
Anyway, on re-reading the datasheet, I saw that the note that says: Not all instructions are applicable for all parts. My concern was that adding instruction 0x4d - Load Address Extended High Byte
could cause problems on AVR parts that have flash sizes less that 128K. Maybe even cause it to error out of SPI programming mode.
Just to be sure, I loaded the latest onto my BP5 and did an avrdude command:
┌──(matty💊s76)-[~/data/tmp/binmode]
└─$ avrdude -c buspirate -P /dev/ttyACM1 -p m328p -U flash:r:dmp.bin:r
attempting to initiate BusPirate binary mode ...
avrdude: paged flash write enabled
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: reading flash memory ...
Reading | ################################################## | 100% 60.42 s
avrdude: writing output file dmp.bin
avrdude done. Thank you.
I checked the binary to be sure it was the correct image of what I expected to be on that particular chip. I then loaded my test build with the additional SPI write for extended high byte (at line 699 of src/binmode/legacy4third.c):
hwspi_write_read(0x4d); // AVR_LOAD_ADDRESS_EXTENDED_HIGH_BYTE_COMMAND
hwspi_write_read(0x00);
hwspi_write_read((addr >> 16) & 0x03); // just the two lowest bits
hwspi_write_read(0x00);
and then ran the avrdude command again:
$ avrdude -c buspirate -P /dev/ttyACM1 -p m328p -U flash:r:dmp_new.bin:r
which completed with no errors. I compared the two files:
┌──(matty💊s76)-[~/data/tmp/binmode]
└─$ cmp dmp.bin dmp_new.bin
┌──(matty💊s76)-[~/data/tmp/binmode]
└─$
So, this tells me that adding the command doesn’t cause any problems with smaller parts, well at least the 32K flash ATMega328p, which is good news! I was concerned that I’d have to add some logic to only do the ‘0x4d’ on larger addresses. Not a big deal, but I’d rather make the fewest changes necessary.
I wanted to document this, because sooner or later someone else will think of it 