Pocket AVR Programmer Hookup Guide
If you’re looking for more control over your AVR Pocket Programmer – and the AVR it’s connected to – follow along below. We’ll demonstrate how to use AVRDUDE, an open-source command line wonder-utility for reading, writing and manipulating AVRs.
If you have Arduino, then you already have AVRDUDE installed – it’s the tool Arduino uses under the hood to upload sketches. If you need to install AVRDUDE separately, check out the download documentation.
Sanity Check – Device Signature Verification
AVRDUDE is a command-line tool, so, in order to use it, you’ll need to open up the “Command Prompt” (Windows) or “Terminal” (Mac/Linux).
To make sure AVRDUDE is working, and your AVR Pocket Programmer is connected correctly, it’s good to do a little sanity check first. Type this into your command prompt:
avrdude -c usbtiny -p atmega328p
(Note: This is all assuming you have an ATmega328P connected at the other end of your programmer. If you have a different type of microcontroller, you’ll need to formulate a slightly different command, check the Specify AVR Device section below.)
If everything is connected correctly, you should get a response like this:
This basic command defines the programmer type you’re using and the AVR it’s talking to. AVRDUDE will attempt to read the Device Signature from your AVR, which is different for each AVR type out there. Every ATmega328P should have a device signature of
Now that you’ve verified that everything is in working order, you can do all sorts of memory reading and writing with AVRDUDE. The main piece of memory you probably want to write is flash – the non-volatile memory where the programs are stored.
This command will perform a basic write to flash (using this HEX file as an example):
avrdude -c usbtiny -p atmega328p -U flash:w:blink.hex
Writing to flash will take a little longer than reading the signature bits. You’ll see a text status bar scroll by as the device is read, written to, and verified.
-U option command handles all of the memory reads and writes. We tell it we want to work with
flash memory, do a write with
w, and then tell it the location of the hex file we want to write.
-U command can also be used to read the memory contents of an AVR. A command like below, for example, will read the contents of your AVR and store them into a file called “mystery.hex”.
avrdude -c usbtiny -p atmega328p -U flash:r:mystery.hex:r
This is incredibly useful if you want to copy the contents of one Arduino to another. Or maybe you’re a masochist, and you want to try reverse-engineering the mystery code in an AVR.
Here are just a few last AVRDUDE tips and tricks before we turn you loose on the AVR world.
Two options required for using AVRDUDE are the programmer type and AVR device specification. The programmer definition, assuming you’re using the AVR Pocket Programmer, will be
-c usbtiny. If you need to use a different programmer check out this page and CTRL+F to “-c programmer-id”.
The AVR device type is defined with the
-p option. We’ve shown a few examples with the ATmega328P, but what if you’re using an ATtiny85? In that case, you’ll want to put
-p t85 instead. Check out the top of this page for an exhaustive list of compatible AVR device types.
Adding one, or more
-v’s to your AVRDUDE command will enable various levels of verbosity to the action. This is handy if you need a summary of your configuration options, or an in-depth view into what data is being sent to your AVR.
There’s plenty more where that came from. Check out the AVRDUDE Option Documentation for the entire list of commands.