Could you give avrdude v8.3 a quick test with the Bus Pirate? Just check that you can read and write flash, EEPROM, fuses and lock bits on whatever AVRs you have. If anything goes wrong, let me know and I’ll look into whether it’s a BP firmware issue or something else. Thanks!
Dreg’s TEST TABLE (read+write) - 10 cm dupont cable
I spent the whole morning chasing something weird. I have some tests that write random data to the AVR flash, and every now and then things got really strange afterwards. Turns out that, by pure chance, the random data sometimes happened to be valid code that messed everything up and made later tests fail in very odd ways (RCCTRL, I’m looking at you). And on top of that, I just found a new avrdude bug, damn it:
avrdude -c buspirate on Bus Pirate 5 and 6 (legacy binary mode): ISP test results
All 15 combinations of Bus Pirate and board passed every test.
Setup
avrdude git main 6e1b3f3f with #2219 and #2222, on Windows 11.
Bus Pirate firmware main 322c452 with #312, binmode “Legacy Binary Mode for Flashrom and AVRdude”, power supply 5.0 V with a 200 mA limit.
Wiring: IO4 to MISO, IO5 (CS) to RESET, IO6 to SCK, IO7 to MOSI, VOUT to 5 V, GND to GND. Dupont wires, so 1 MHz was the top speed. The boards were also on USB, except the ATmega128 board.
avrdude -c buspirate -P COMx -p <part> [-x spifreq=N]: 30 kHz without spifreq; 1, 2 and 3 give 125 kHz, 250 kHz and 1 MHz.
Board
MCU
Flash / EEPROM
Bootloader
Arduino Leonardo
ATmega32U4
32 KiB / 1 KiB
Caterina
Arduino UNO
ATmega328P
32 KiB / 1 KiB
optiboot
Arduino MEGA 2560
ATmega2560
256 KiB / 4 KiB
stk500v2
ATmega128 board (AliExpress)
ATmega128
128 KiB / 4 KiB
none, no USB
Ruggeduino
ATmega328P
32 KiB / 1 KiB
optiboot
Results
At each speed, new random images the exact size of the flash and the EEPROM: one avrdude run erases, writes and verifies both, a second run reads them back, and the read-back is compared byte for byte. Times are m:ss, write and verify / read. Byte mode is a flash write and verify at 1 MHz with -x nopagedwrite -x nopagedread.
Bus Pirate
Board
30 kHz
125 kHz
250 kHz
1 MHz
Byte mode
BP6
Leonardo
1:39 / 0:44
0:31 / 0:13
0:21 / 0:08
0:12 / 0:04
0:31
BP6
UNO
1:38 / 0:44
0:30 / 0:13
0:21 / 0:08
0:12 / 0:04
0:31
BP6
MEGA 2560
14:15 / 8:04
4:02 / 2:00
2:11 / 1:02
1:09 / 0:19
5:13
BP6
ATmega128
7:50 / 4:07
2:33 / 1:02
1:37 / 0:33
1:05 / 0:11
1:48
BP6
Ruggeduino
1:38 / 0:44
0:31 / 0:13
0:21 / 0:08
0:12 / 0:04
0:32
BP5 REV10
Leonardo
1:43 / 0:45
0:38 / 0:14
0:25 / 0:09
0:21 / 0:06
2:05
BP5 REV10
UNO
1:41 / 0:45
0:36 / 0:14
0:26 / 0:09
0:20 / 0:05
1:50
BP5 REV10
MEGA 2560
14:43 / 8:10
4:18 / 2:05
2:45 / 1:08
1:30 / 0:26
24:17
BP5 REV10
ATmega128
8:06 / 4:11
2:46 / 1:06
1:58 / 0:38
1:24 / 0:16
7:01
BP5 REV10
Ruggeduino
1:42 / 0:45
0:36 / 0:14
0:25 / 0:09
0:21 / 0:06
1:58
BP5 REV8
Leonardo
1:42 / 0:45
0:38 / 0:14
0:25 / 0:09
0:21 / 0:05
1:59
BP5 REV8
UNO
1:42 / 0:45
0:38 / 0:13
0:24 / 0:09
0:21 / 0:06
2:00
BP5 REV8
MEGA 2560
14:44 / 8:09
4:18 / 2:04
2:46 / 1:08
1:28 / 0:25
23:19
BP5 REV8
ATmega128
8:07 / 4:11
2:47 / 1:06
2:03 / 0:38
1:24 / 0:17
7:43
BP5 REV8
Ruggeduino
1:42 / 0:45
0:38 / 0:14
0:26 / 0:09
0:21 / 0:05
1:58
Also passed on every row:
-x pullups and -x hiz at 1 MHz: new random images written, verified and read back.
Chip erase: flash and EEPROM blank, lock bits unprogrammed.
Fuses: one harmless bit of each fuse byte written, read back and restored. With EESAVE programmed a chip erase kept the EEPROM; without it, the EEPROM was cleared.
Lock bits: in mode 3 the flash and EEPROM no longer read back, and a chip erase unlocks the chip.
Arduino bootloader (all but the ATmega128 board): written by ISP the way the Arduino IDE’s Burn Bootloader does it, then the whole flash read back over the board’s USB through that bootloader.
Notes
ATmega128 board: powered by the Bus Pirate only. Its factory lfuse 0xE1 (internal RC at 1 MHz) keeps ISP below 250 kHz, so the tests ran with 0xE4 (RC at 8 MHz) and 0xE1 went back afterwards.
NVM write times, measured outside avrdude at 1 MHz with Poll RDY/BSY (USB polling latency included), 99th percentile: flash page 4.5 to 5.9 ms, EEPROM byte 3.7 to 4.9 ms; chip erase 8.5 to 10.7 ms. The ATmega128 has no Poll RDY/BSY, which avrdude’s buspirate programmer does not use.
Keep RESET on CS (IO5). The legacy binary mode does not drive AUX, so -x reset=aux and -x reset=aux2 only worked because RESET was on CS. -x cpufreq, -x rawfreq and -x ascii are not supported: avrdude exits with an error and the next session works. Both checked with the two BP5.
The firmware’s tools/legacy4third_usbtest.py passed on all three Bus Pirates: no packet loss, framing error or stall.
What the PRs fix
avrdude #2219: EEPROM writes could fail, or lose a byte with no error in terminal mode, when a 0xFF goes over a cell that is not 0xFF. It affects buspirate and the other programmers that write the EEPROM one byte at a time: m328p since avrdude 7.2, m32u4 and m2560 always.
avrdude #2222: initialization failed (rc = -2) when the code on the AVR drives SCK high, for example Blink on an UNO (D13 is SCK). A Bus Pirate v3.5 fails the same way. With the PR, avrdude pulses RESET and sends Programming Enable again, as the datasheets say. The Ruggeduino’s own sketch, a Blink, needed it.
BusPirate5-firmware #312: the legacy binary mode no longer restarts the power supply at every 0x4x command (VCC dipped to 3.25 V for 3.5 ms each time), drives CS like the original Bus Pirate, and waits 20 ms after it pulls RESET low, the datasheets’ wait before Programming Enable.
Good news: avrdude -c buspirate testing through the legacy binary mode is done and everything passed. BP6, BP5 REV10 and BP5 REV8, each with a Leonardo, an UNO, a MEGA 2560, an ATmega128 board and a Ruggeduino: random data over the whole flash and EEPROM from 30 kHz to 1 MHz, plus byte mode, pullups, hiz, chip erase, fuses, lock bits and the Arduino bootloader checked over USB. That is with avrdude git main plus my PRs #2219 and #2222, and the firmware with #312. When the next avrdude release is out, I’ll run the whole battery again with it and post the results.
I just added to the Bus Pirate legacy mode the ability to generate a clock, so you can program the ChipWhisperer NotDuino and AVR chips without a crystal using avrdude.
The two PRs looked good to the avrdude devs, so in the next release everything will go great. The massive amount of testing work I’ve been putting in has been worth it.