3.4. Programming with AVRDUDE

After you have compiled a HEX file, you can load it onto your AVR using Atmel Studio as described in Section 3.3 or by using a separate command-line utility named AVRDUDE. This utility is free and included in the WinAVR package.

First you need to locate the HEX file. If you compiled it using Atmel Studio, it should have the extension “.hex” and be in your Atmel Studio project folder, in a subfolder named Debug or Release. Open a Command Prompt and navigate to that folder. Then to program your AVR, you would type something similar to this:

avrdude -p m328p -P COM6 -c avrispv2 -U flash:w:test.hex 
  • The argument following the -p is the part number of the AVR. For an Orangutan or 3pi Robot, the part number should be m328p, m1284p, m324p, m644p, m168, or m48.
  • The argument following the -P is the port name. You can determine your device’s programming port name by looking in the “Ports (COM & LPT)” list of the Device Manager. Using \\.\USBSER000 will also usually work.
  • The argument following the -c is the programmer protocol and should be avrispv2.
  • The -U option is used for writing, reading, or verifying flash, EEPROM, fuses, or lock bits. In this example we are using -U to write test.hex to flash.

Please see the AVRDUDE documentation for more detailed information.

Note for Orangutan SVP and X2 users: AVRDUDE has incorrect chip erase delay settings for the ATmega324P, ATmega644P, ATmega1284P. This means that when you try to program, the erase operation will take longer than AVRDUDE expects and AVRDUDE will interpret this as an error. The workaround is to find the AVRDUDE configuration file, avrdude.conf, and increase the chip erase delay for the m324p/m644p/m1284p to 55000. The file is located in C:\WinAVR-20100110\bin by default in Windows.