Bus Pirate AVR Programming
The Bus Pirate can be used to program Atmel AVR microcontrollers. AVRDUDE version 5.8 and later support the Bus Pirate as a programmer directly. There is also an alternate firmware that can be installed on to Bus Pirate to make it an STK500 v2 AVR programmer clone.
Note: AVRDude is the most common software for programming AVR microcontrollers. Many packages such as WinAVR and the Arduino IDE bundle a version of AVRDude. The instructions on this page should be applicable to those packages with include AVRDude.
Connecting the Bus Pirate
The AVR ISP (in-system programming) is typically done the either a 6 pin (2 x 3) header or a 10 pin (2 x 5) header. It is essentially a 3 wire SPI interface, with Vcc, ground, and inverted reset. The 6 pin header found on Arduino and other AVR type boards. Since the Bus Pirate can provide Vcc, it is also possible to connect it directly to the AVR either on a breadboard or by using the Bus Pirate probe cable.
AVR ISP Header
|AVR 6 pin ISP Header (Arduino, etc.)||AVR 10 Pin ISP Header|
Bus Pirate AVR programming connections
|BusPirate Signal||AVR Signal||ISP pin (6)||ATtiny2313 Pin||ATmega328P pin|
|+5V or +3.3V||Vcc||2||20||7|
- Printable pin-out cheat sheet - Covers ISP, a few AVRs, and the Bus Pirate. Available as PDF and SVG. Note: Bus Pirate pin-out on this cheat sheet is rotated 180 degrees from what is conventional in Dangerous Prototypes documentation.
- Bus Pirate References:
AVRDude & Bus Pirate Version Compatibility
Using AVRDude with the Bus Pirate firmware requires both a compatible versions of AVRDude and the Bus Pirate Firmware. Support for the Bus Pirate was added to AVRDude starting with AVRDude version 5.8 and was compatible with the Bus Pirate version 4.x firmware available at that time. However, Bus Pirate firmware 5.0-5.9 introduced some changes that were incompatible with AVRDude's Bus Pirate support. In order to retain compatibility with the released versions of AVRDude, some desired changes were backed out Bus Pirate 5.10 firmware that will be brought back in the future when a newer version of AVRDude is released. Bus Pirate firmware 5.10 and later includes a new compound SPI operation that can be used by later versions of AVRDude to significantly speed up AVR programming. As of November 2010, patches for AVRDude 5.10 have made available for testing, but have yet to be incorporated into an AVRDude release.
Note: Unfortunately the current AVRDude and Bus Pirate firmware version numbering is very similar (5.x) and is easy to confuse. Take care to make sure you have the right version of the AVRDude software and Bus Pirate firmware installed before reporting problems.
- Patched version of AVRDude for testing (Nov. 2010) with a number of improvements. Should be compatible with Bus Pirate firmware 5.10+ / 6.x.
Check the Bus Pirate AVR Programming Forum for the current state of development.
Known working combinations of Bus Pirate firmware and AVRDude releases
|AVRDude Release||Bus Pirate Firmware||Notes|
|AVRDude 5.8 and later||BP firmware 4.x|
|AVRDude 5.8 and leter||BP firmware 5.10||May not be compatible with all future BP firmware releases|
|AVRDude Future release with patches||BP firmware 5.10+||Higher speed AVR programming|
Known broken versions
|AVRDude before 5.8||No Bus Pirate support, see STK500 clone|
|Bus Pirate Firmware 5.0-5.9||Not compatible with AVRDude 5.8 - 5.10, use Bus Pirate Firmware 5.10 or later|
Using AVRDude with Bus Pirate support
From the command line
AVRDude's -c option specifies which programmer to use. For the Bus Pirate, it should be
buspirate. The device name where the Bus Pirate is connected such be specified with
-P (uppercase P). The chip is specified with
-p (lowercase p). The general form for using AVRDude from the command line is:
$ avrdude -c buspirate -P <bus pirate comm port> -p <chipname> ...
Tip: To get a list of chip your version of AVRDude supports, give a bogus -p option,
avrdude -p help.
From an IDE
To use the Bus Pirate for AVR programming from an IDE or other environment where you don't have direct access to the command line, you will need to find where in the IDE's configuration settings the AVR programmer type is specified. In some cases, you may need to edit a config file to list the Bus Pirate as one of the available programmer choices.
Other Bus Pirate & AVRDude Tutorials
- Hintshop Bus Pirate AVR Programming - Michal who added Bus Pirate support to AVRDude, has a tutorial on programming one or multiple AVRs with the Bus Pirate.
Example: Testing connection and reading Fuses
$ avrdude -c buspirate -P /dev/ttyUSB0 -p attiny2313 -v avrdude: Version 5.10, compiled on Jan 19 2010 at 19:05:56 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2009 Joerg Wunsch System wide configuration file is "/etc/avrdude/avrdude.conf" User configuration file is "/home/rt/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyUSB0 Using Programmer : buspirate AVR Part : ATtiny2313 Chip Erase delay : 9000 us PAGEL : PD4 BS2 : PD6 RESET disposition : possible i/o RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 6 4 0 no 128 4 0 4000 4500 0xff 0xff flash 65 6 32 0 yes 2048 32 64 4500 4500 0xff 0xff signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 calibration 0 0 0 0 no 2 0 0 0 0 0x00 0x00 Programmer Type : BusPirate Description : The Bus Pirate Detecting BusPirate... avrdude: buspirate_readline(): # avrdude: buspirate_readline(): RESET avrdude: buspirate_readline(): ** avrdude: buspirate_readline(): Bus Pirate v3 ** Bus Pirate v3 avrdude: buspirate_readline(): Firmware v4.2 Bootloader v4.1 ** Firmware v4.2 Bootloader v4.1 avrdude: buspirate_readline(): DEVID:0x0447 REVID:0x3042 (B4) ** DEVID:0x0447 REVID:0x3042 (B4) avrdude: buspirate_readline(): http://dangerousprototypes.com ** http://dangerousprototypes.com avrdude: buspirate_readline(): HiZ> ** BusPirate: using BINARY mode BusPirate binmode version: 1 BusPirate SPI version: 1 avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.02s avrdude: Device signature = 0x1e910a avrdude: safemode: lfuse reads as 64 avrdude: safemode: hfuse reads as DF avrdude: safemode: efuse reads as FF avrdude: safemode: lfuse reads as 64 avrdude: safemode: hfuse reads as DF avrdude: safemode: efuse reads as FF avrdude: safemode: Fuses OK BusPirate is back in the text mode avrdude done. Thank you.
These are the most common errors we see in the forum.
initialization failed, rc=-2
BusPirate: using BINARY mode BusPirate binmode version: 1 BusPirate SPI version: 1 avrdude: initialization failed, rc=-2 Double check connections and try again, or use -F to override this check.
The Bus Pirate is working fine in this example, but the AVR chip is not responding.
- Incorrect connection to target AVR chip. Check connections and try again
- Programming clock speed too high. Reduce clock and try again
- Target voltage too low, some chips cannot be programmed at 3.3volts. Check the datasheet, increase the power supply to eg 5volts if needed
Using STK500 v2 Alternate firmware
Alternate firmware is available for the Bus Pirate that allows it to emulate the STK500 v2 programmer. The advantage of this alternate firmware is that any AVR programming software that supports the STK 500 v2 will work with the Bus Pirate. The disadvantage of this approach is that when the alternate STK 500 v2 firwmare is installed on your Bus Pirate, it will no longer function as a Bus Pirate. In order to use Bus Pirate functionality again, the Bus Pirate firmware will need to be re-flashed back to the Bus Pirate.
The recommended approach: if you can use a recent enough version of AVRDude, use that with a current version of the Bus Pirate firmware. This will allow you to use your Bus Pirate to program AVRs and retains all of the Bus Pirate functionality without having to reflash the firmware on the Bus Pirate. However, if you are stuck with AVR programming software that doesn't support the Bus Pirate natievly, then the STK 500 clone firmware provides a solution.