AVRDUDESS Flash dump error

I get the following error when trying to dump the flash of an atmega128 chip:

attempting to initiate BusPirate binary mode …
Paged flash write enabled
Reading flash memory …
Reading | #################################################- | 99% 158.54s
Error: paged read command returned zero.

Dumping the EEPROM works fine, I’ve tried on another chip and managed to dump both flash and EEPROM. Has anyone run into this issue before? I’ve only found a handful of threads on it and I can’t seem to find a difinitive answer to what this issue is other then maybe there’s an issue with the buspirate firmware. Any help would be great

Thanks

2 Likes

It seems like it’s getting to the end and the final transaction is aborted. Does it actually save anything even though it aborts? If so, how big is the dump file? Maybe one page shorter than expected?

No it doesn’t save anything unfortunately. The dump file is 0kb with nothing inside. Still waiting on another board with the same chip to see if I get the same error.

2 Likes

There’s mention of the error here: [bug #51614] BusPirate: Paged Read command returned zero. With m1284p flash. · Issue #459 · avrdudes/avrdude · GitHub

He also gets to 99% and then gets the same error

They claim that the bus pirate has issues dumping flash data over 128kb (the atmega is 128) and suggest moving to STK500v2 firmware, that firmware is 16 years old though and I’m using the Bus pirate 6

2 Likes

Interesting. The bug report is about the old hardware and firmware. @dreg wrote the legacy support binmode, so maybe the big was copied over as well lol.

Are you able to get the verbose output mentioned in the bug report and paste it here?

1 Like

Avrdude version 8.0
Copyright see avrdude/AUTHORS at main · avrdudes/avrdude · GitHub

System wide configuration file is C:\Program Files (x86)\AVRDUDESS\avrdude.conf

Using port : COM13
Using programmer : buspirate
Setting baud rate : 115200
AVR part : ATmega128
Programming modes : SPM, ISP, HVPP, JTAG, JTAGmkI

Memory Size Pg size

eeprom 4096 8
flash 131072 256
lfuse 1 1
hfuse 1 1
efuse 1 1
lock 1 1
prodsig/sigrow 24 1
sernum 10 1
io 224 1
sram 4096 1
calibration 4 1
signature 3 1

Variants Package F max T range V range

ATmega128-16AN TQFP64 16 MHz [-40 C, 105 C] [4.5 V, 5.5 V]
ATmega128-16ANR TQFP64 16 MHz [-40 C, 105 C] [4.5 V, 5.5 V]
ATmega128-16AU TQFP64 16 MHz [-40 C, 85 C] [4.5 V, 5.5 V]
ATmega128-16AUR TQFP64 16 MHz [-40 C, 85 C] [4.5 V, 5.5 V]
ATmega128-16MN MLF64 16 MHz [-40 C, 105 C] [4.5 V, 5.5 V]
ATmega128-16MNR MLF64 16 MHz [N/A, N/A] [4.5 V, 5.5 V]
ATmega128-16MU MLF64 16 MHz [-40 C, 85 C] [4.5 V, 5.5 V]
ATmega128-16MUR MLF64 16 MHz [-40 C, 85 C] [4.5 V, 5.5 V]
ATmega128L-8AN TQFP64 8 MHz [-40 C, 105 C] [3 V, 5.5 V]
ATmega128L-8ANR TQFP64 8 MHz [-40 C, 105 C] [3 V, 5.5 V]
ATmega128L-8AU TQFP64 8 MHz [-40 C, 85 C] [2.7 V, 5.5 V]
ATmega128L-8AUR TQFP64 8 MHz [-40 C, 85 C] [2.7 V, 5.5 V]
ATmega128L-8MN MLF64 8 MHz [-40 C, 105 C] [3 V, 5.5 V]
ATmega128L-8MNR MLF64 8 MHz [N/A, N/A] [2.7 V, 5.5 V]
ATmega128L-8MU MLF64 8 MHz [-40 C, 85 C] [2.7 V, 5.5 V]
ATmega128L-8MUR MLF64 8 MHz [-40 C, 85 C] [2.7 V, 5.5 V]

Programmer type : BusPirate
Description : The Bus Pirate in AVR programming mode
attempting to initiate BusPirate binary mode …
BusPirate binmode version: 1
BusPirate SPI version: 1
Paged flash write enabled
AVR Extended Commands version 1

AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
Device signature = 1E 97 02 (ATmega128, ATmega128A)
Reading flash memory …
Reading | #################################################- | 99% 158.59s
Error buspirate_paged_load() buspirate.c 952: paged read command returned zero

2 Likes

I’m going to take advantage of this moment and talk to the AVRDude devs to see how we can support more families in the simplest way possible for both sides.

1 Like

Issue opened—let’s see what we can do. Fingers crossed!

1 Like

Thankyou very much for the quick reply. Happy to help in anyway I can going further in terms of dumping flash/eeprom memory from atmega chips as well as testing both the buspirate and avrdude software.

3 Likes

Good news @chickendipper ! I’m already working on this with the AVRDude developers to see if we can get it fixed. I’m going to buy an AVR like the one you have and see how it goes… (see the GitHub issue)

2 Likes

Purchased! I should have the board at home in about a month.

2 Likes

Given 32K vs 128K of flash, I would look for a uint16_t is being used where a uin32_t is needed. Just a wild guess without knowing anything going on under the hood.

1 Like

Sweet, It’s the same board I ordered. Should be coming in the next couple of days

1 Like

Just jumping in here… I’ve done a lot of AVR c and assembly, but I’ve never looked under the hood of AVRDude (just used it :wink: )

The AVR uses word addressing for flash, so a uint16_t will address all flash, regardless of variant or flash size. For the larger flash variants, it is still 16-bit word addressing, but there is a register called rampz used to select the bank. I remember using it when writing a custom bootloader on the ATMega256 device.

I also used the Z pointer with the SPM/LPM when using the flash to store large fixed data structures. I think avr-gcc has PROGMEM or something to do this for you.

From the ATMega datasheet:

This all applies to “self programming” - programming “main” flash area from “bootloader” flash area. According to the datasheet, JTAG/ISP programming uses the same thing - select the write address sending the extended byte (rampz register), then the high byte (ZH/R31), then the low byte (ZL/R30). The only thing I’m not sure of is what DUDE is doing? Does it send a 32-bit address and leave it up to the programming device to break that into the 3 registers?

Anyway, I don’t mean to confuse the issue; just refreshing my brain on this and maybe helping :slight_smile:

@mbrugman take a look!

1 Like

From a quick glance, the code does not seem to deal with load extended address byte command which is needed by m1284p and it should have the same problem for ATmega2560 and similar parts.

Comment on that thread seems to be what mbrugman writes about above. Internally AVR dude has a uint32_t or larger address counter, which the Bus Pirate code then needs to send the lower 16 bits + the 2 Z selection bits.

1 Like

@mbrugman So the issue could be coming from not handling the RAMPZ register?

1 Like

That would make sense…. Still looking at the code you mentioned me in

@Dreg - take a look at line 684 of legacy4third.c

Do you want to compare to 0x2ffff instead of 0xffff?

Ugh, just stepped away from computer; trying to review code on a mobile device sucks for an old man

That code you’re seeing is a quick-and-dirty port I did from the original Bus Pirate v3 code… I’m not really sure why they added so many things in there, haha.

Anyway… if one extra byte per operation is needed, AVRDude should have no problem—it can just send 3 bytes by tricking the len, right?