-
Notifications
You must be signed in to change notification settings - Fork 2
Bus Pirate
The Bus Pirate is a versatile, low-cost multi-protocol hacking tool. Amongst its many other capabilities, it can be used to program the ATMega328p (and many other AVR devices) in conjunction with the AVRDUDE software.
You can get a Bus Pirate from at least:
The easiest way to get an up-to-date AVRDUDE on Mac OS X is to use MacPorts. Once you have installed !MacPorts, installing AVRDUDE is as simple as:
# sudo port install avrdude
Make sure that /opt/local/bin
is on your path.
Most Linux distributions have an installable package for AVRDUDE. See your distribution's documentation for help with finding and installing packages.
The easiest way to get AVRDUDE for Windows is to install WinAVR. Some more detail here would be nice
The Arduino environment uses a private copy of AVRDUDE to perform its programming. You can look inside the Arduino installation to locate both the tool and its required configuration file. You will need to pass the location of the configuration file with the -C option on the commandline if you decide to go this route.
There are two ways to use the Bus Pirate with AVRDUDE. The first is to use it in 'native' mode, and the second is to upload new firmware to the Bus Pirate that emulates the Atmel STK500. (Note that you can use the Bus Pirate with the STK500 emulation with !AVRStudio and avoid using AVRDUDE if you choose).
The only differences between these modes are what you tell AVRDUDE it's talking to (and that at the time of writing the 'native' mode is not working for the author on a Bus Pirate v3 with the v5.4 firmware, although this appears to be fixed in the AVRDUDE svn at r946).
If you are going to use the Bus Pirate in STK500 mode, follow the instructions on the Bus Pirate wiki.
http://ardupilot-mega.googlecode.com/svn/ArduPilotMegaImages/BusPirate.jpg
In the above illustration, the Bus Pirate is connected using the SparkFun Bus Pirate cable. The SeeedStudio cable uses the same wire colours.
Bus Pirate Pin | AVR ISP Pin # |
MISO | 1 (square pad) |
3v3 | 2 |
CLK | 3 |
MOSI | 4 |
CS | 5 |
GND | 6 |
Download the PPM Encoder zip file here. Unpack the Zip file and locate the {{{firmware.hex}}} file it contains.
Connect the Bus Pirate and check that everything is working. You will need to use the same technique to locate the serial port name for the Bus Pirate that you use with Arduino. Note that if you are using the Bus Pirate in 'native' mode, use -c buspirate
instead.
# avrdude -p m328p -c stk500 -P <serial port>
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.09s
avrdude: Device signature = 0x1e950f
avrdude: current erase-rewrite cycle count is 775041024 (if being tracked)
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Once you have the above process working, you are ready to flash the new firmware:
# avrdude -p m328p -c stk500 -P <serial port> -U firmware.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.09s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: current erase-rewrite cycle count is 775041024 (if being tracked)
avrdude: erasing chip
avrdude: reading input file "/Users/msmith/Downloads/PPM_encoder/firmware.hex"
avrdude: input file /Users/msmith/Downloads/PPM_encoder/firmware.hex auto detected as Intel Hex
avrdude: writing flash (2736 bytes):
Writing | ################################################## | 100% 0.90s
avrdude: 2736 bytes of flash written
avrdude: verifying flash memory against /Users/msmith/Downloads/PPM_encoder/firmware.hex:
avrdude: load data flash data from input file /Users/msmith/Downloads/PPM_encoder/firmware.hex:
avrdude: input file /Users/msmith/Downloads/PPM_encoder/firmware.hex auto detected as Intel Hex
avrdude: input file /Users/msmith/Downloads/PPM_encoder/firmware.hex contains 2736 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.71s
avrdude: verifying ...
avrdude: 2736 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Disconnect the Bus Pirate and restore it to the original firmware (if required). Re-assemble the !ArduPilot Mega and verify that the encoder is working correctly.