The Bus Pirate can serve as a programmer and dumper for AVR chips, using the command-line utility AVRDUDE.

For those who prefer a graphical user interface, AVRDUDESS offers a user-friendly front-end for AVRDUDE. Both tools together provide a powerful setup for working with AVR chips.

In this demo we’ll program the ATmega32U4 chip found on the Arduino Leonardo through the ICSP header.

Connections

Bus PirateArduino LeonardoDescription
MISOICSP-1Master In Slave Out
VOUTICSP-2Power Supply (5 volts)
CLKICSP-3Clock
MOSIICSP-4Master Out Slave In
CSICSP-5(RST/RESET)Chip Select
GNDICSP-6Ground

Connect the Bus Pirate to the ICSP header according to the table above.

Setup

Bus Pirate [/dev/ttyS0]
HiZ> binmode

 1. SUMP logic analyzer
 2. BPIO2 flatbuffer interface
 3. Arduino CH32V003 SWIO
 4. Follow along logic analyzer
 5. Legacy Binary Mode for Flashrom and AVRdude
 6. IRMAN IR decoder (LIRC, etc)
 7. AIR capture (AnalysIR, etc)
Select binary mode
x to exit (1) > 5

Binmode selected: Legacy Binary Mode for Flashrom and AVRdude
Binmode active. Terminal locked

In the Bus Pirate terminal use the binmode command to select the “Legacy Binary Mode for Flashrom and AVRdude”.

Bus Pirate [/dev/ttyS0]
Set OUTPUT HOLD(IO2) & WP(IO3) pins? (no=INPUT)
y/n, x to exit (Y) > n

Clock on IO0 for avrdude -x cpufreq?
y/n, x to exit (Y) > n

Power supply
Volts (0.80V-5.00V)
x to exit (3.30) > 5

Maximum current (0mA-500mA)
x to exit (200.00) > 150

Power supply set to 5.00V, 150mA

Done! Just execute flashrom or avrdude using the binary com port
To exit: press the button, or type 'q' here and confirm with 'y'.
Either way the Bus Pirate resets on exit.

First it asks about the HOLD and WP pins: answer n, they are not used here. The IO0 clock is only for an AVR without a crystal (see below): the Leonardo has one, so answer n. Then select 5 volts and a current limit of 150 mA.

The terminal is locked in this mode. To exit, press the button, or type q and confirm with y.

Dumping Flash memory

Command Line

avrdude -c buspirate -P COM5 -p m32u4 -U flash:r:dump.bin:r

This command uses avrdude to read the flash memory of the ATmega32U4 and saves it to a file named dump.bin.

  • The correct COM/serial port is the Bus Pirate binary interface, this is not the same as the terminal serial port used to enter binmode.
  • For Linux, the serial port usually starts with /dev/ttyUSB
attempting to initiate BusPirate binary mode ...
avrdude: paged flash write enabled
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9587 (probably m32u4)

avrdude: processing -U flash:r:dump.bin:r
avrdude: reading flash memory ...
Reading | ################################################## | 100% 42.14 s
avrdude: writing output file dump.bin

avrdude done.  Thank you.

AVRDUDESS

Using AVRDUDESS is easy and straightforward. Just select:

  • “The Bus Pirate” as the programmer
  • ATmega32U4 as the target (MCU)
  • Port COM (the port where the Bus Pirate binmode is connected)
  • Baud rate: 115200

Select “Read” and click “Go” button to dump the flash memory.

AVR without a crystal

An AVR whose fuses select an external clock needs a clock on XTAL1 before it can be programmed. Answer y to “Clock on IO0 for avrdude -x cpufreq?”, connect IO0 to XTAL1, and give AVRDUDE the frequency in kHz (125 to 4000):

avrdude -c buspirate -P COM5 -p m328p -x cpufreq=4000 -U flash:r:dump.bin:r

IO0 gives the clock while AVRDUDE runs; firmware that does not ask this question has no clock on IO0. Keep the SPI clock under a quarter of that frequency: the default 30 kHz works with any -x cpufreq, and with -x cpufreq=4000 you can go up to -x spifreq=2 (250 kHz).