The Digital Cave

Primitive Life in a Technological World

 

AVR Programming

Programmer / Target Board

While I have looked around for a cheaper version of a programmer (possibly using an Arduino with a special sketch), I finally decided that my time was worth the cost, and bought a USBTiny programmer from Lady Ada. I wired up a quick and dirty target board with a couple of sockets and jumper pins, and all is working perfectly. (My target board supports both 8 and 28 pin AVRs, specifically the ATtiny13 and the ATmega168, although in theory any AVR with the same programming pinout as these chips should work.) Quite an adaptable system for about $25.

Uploading a HEX file directly to an Arduino

Behind the scenes, the Arduino is just using avrdude to upload sketches; the bootloader emulates a (subset) of the stk500 programmer. While using the Arduino IDE is nice for many scenarios, sometimes you just want to be able to upload a file directly.

Well as it turns out, this is quite easy. First, you will need to use the avrdude which is bundled with Arduino; I don't know if they have modified it, or if that particular version just plays nicer with the bootloader, but whatever the case it seems to just work. Next, you will use the following command to upload your program: avrdude -V -F -c stk500v1 -p atmega168 -P /dev/tty.usbserial-A8007UF6 -b 19200 -U flash:w:main.hex You will want to change the serial device as required, and replace the 'main.hex' with whatever your .hex file is called.

(Thanks to Warren for sending me this command)

AVRDude Cheat Sheet

To program AVR chips using this setup, I use AVRDude. Some common commands are included below.

Programmer / Chip Verification

This first test will verify that you have your programmer and chip hooked up correctly. If it works, you should see a 'Reading' progress bar, a device signature, and some other text. avrdude -c usbtiny -p m168 Note that -p is the 'part' argument; change this to match your destination chip. See man page or config file avrdude.conf to find correct part name for your chip.

Uploading Program

Coming Soon

Reading Fuses

Coming Soon

Burning Fuses

The first step to burning AVR fuses is to figure out what they should be. You can use the very handy Fuse Calculator for this. Be sure to double check your fuse values, as incorrect ones can brick your chips.

AVRDude details Coming Soon