LinuxCommandLibrary

avrdude

Upload/download data to/from AVR microcontrollers

TLDR

[r]ead the flash ROM of a AVR microcontroller with a specific [p]art ID

$ avrdude -p [part_no] -c [programmer_id] -U flash:r:[file.hex]:i
copy

[w]rite to the flash ROM AVR microcontroller
$ avrdude -p [part_no] -c [programmer] -U flash:w:[file.hex]
copy

List available AVR devices
$ avrdude -p \?
copy

List available AVR programmers
$ avrdude -c \?
copy

SYNOPSIS

avrdude [options]

Example usage:
avrdude -p m328p -c arduino -P /dev/ttyUSB0 -b 115200 -U flash:w:firmware.hex:i
This command programs an ATmega328P using an Arduino-compatible programmer on /dev/ttyUSB0 at 115200 baud, writing the firmware.hex file to flash memory in Intel Hex format.

PARAMETERS

-p
    Specify the microcontroller part number (e.g., m328p, attiny85).

-c
    Specify the programmer ID (e.g., usbasp, arduino, stk500v2).

-P
    Specify the port where the programmer is connected (e.g., /dev/ttyUSB0, com1, usb).

-b
    Override the programmer's default serial port baud rate (e.g., 115200).

-U :r|w|v:[:format]
    Memory operation: read, write, verify. memtype can be flash, eeprom, fuse, lock, etc. format can be i (Intel Hex) or h (raw binary).

-F
    Override signature check. Use with caution as it can lead to programming the wrong device.

-e
    Perform a chip erase cycle before programming. This is often done implicitly during flash writes but can be forced.

-V
    Do not verify after writing memory. This skips the verification step for faster programming, but is less safe.

-q
    Quiet mode. Suppress output messages, except for errors.

-v
    Verbose mode. Increase verbosity level. Can be repeated (e.g., -vvvv) for more detailed output.

-t
    Enter terminal mode, allowing direct communication with the programmer and chip.

-D
    Disable auto erase for flash memory. Useful when you only want to write certain parts.

-C
    Specify an alternative or additional configuration file to load instead of or in addition to the default.

-B
    Specify the bit clock period for ISP protocol in microseconds (e.g., 1.0 for 1MHz SCL). Lower values mean faster programming.

-O
    Do not attempt to reset the AVR at the beginning of the session. Useful for specific programmer setups.

DESCRIPTION

avrdude is a powerful, open-source command-line utility designed to program Atmel AVR microcontrollers. It supports a wide range of AVR devices and various programming hardware (programmers) including ISP, JTAG, and HVSP. Users can upload compiled firmware (hex files) to the microcontroller's flash memory, read data from flash or EEPROM, verify content, and manipulate fuse bits and lock bits. It acts as the bridge between your computer and the AVR chip, making it an essential tool for embedded systems development, particularly in the Arduino ecosystem where it's used behind the scenes. Its flexibility allows for both simple firmware uploads and complex low-level chip configuration.

CAVEATS

Incorrect Configuration: Using wrong part numbers, programmer IDs, or fuse settings can permanently damage (brick) your microcontroller. Always double-check your configuration.
Port Permissions: On Linux, programming often requires access to serial or USB ports, which may necessitate adding your user to groups like dialout or uucp, or running avrdude with sudo (not recommended for routine use due to security).
Timing Issues: ISP programming speed (bitclock) can be sensitive. If programming fails, try adjusting the -B option to a larger value (slower speed).
Configuration File Complexity: The avrdude.conf file, which defines all supported programmers and devices, can be complex to modify or troubleshoot.

MEMORY TYPES FOR -U OPTION

When using the -U (memory operation) option, memtype specifies the type of memory or register to operate on. Common types include:
flash: Main program memory.
eeprom: Electrically Erasable Programmable Read-Only Memory.
fuse (or lfuse, hfuse, efuse): Configuration bits that control fundamental chip behavior (e.g., clock source, brown-out detection).
lock: Lock bits that prevent unauthorized reading or writing of the chip's memory.
signature: Unique device signature bytes.
calibration: Internal oscillator calibration bytes.

<I>AVRDUDE.CONF</I> CONFIGURATION FILE

avrdude relies heavily on its configuration file, typically named avrdude.conf. This file defines all supported AVR microcontrollers (with their memory maps, fuse bits, and signatures) and all supported programming hardware (programmers), including their communication protocols and capabilities. avrdude looks for this file in standard system locations (e.g., /etc/avrdude.conf, /usr/local/etc/avrdude.conf) or can be specified with the -C option. Incorrect or outdated configuration files can lead to "device signature mismatch" errors or unsupported programmer messages.

HISTORY

avrdude was originally developed by Brian Dean and released as part of the GNU AVR toolchain. It quickly became the de facto standard command-line utility for programming Atmel AVR microcontrollers due to its open-source nature, broad support for devices and programmers, and active community development. Its integration into development environments like the Arduino IDE has further cemented its role as an indispensable tool for hobbyists, educators, and professional embedded systems engineers worldwide. It continues to be maintained and updated to support new AVR devices and programming protocols.

SEE ALSO

avr-gcc(1), make(1), stty(1), picocom(1), minicom(1)

Copied to clipboard