[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AVRDUDE error messages, warnings and progress reports are generally
written to stderr which can, in bash, be turned off by 2>/dev/null
or by using increasingly more -q
options to suppress them. Terminal
output of commands or that of the -U
command with an output file
named -
are written to stdout. In some examples empty lines are
shown for clarity that are not printed by AVRDUDE or the shell.
Write the file diag.hex
to the ATmega128 chip using the
STK500 programmer connected to the default serial port:
$ avrdude -p m128 -c stk500 -e -U flash:w:diag.hex Reading 19278 bytes for flash from input file diag.hex Writing 19278 bytes to flash Writing | ################################################## | 100% 7.60 s Reading | ################################################## | 100% 6.83 s 19278 bytes of flash verified Avrdude done. Thank you. |
Same but in quell-progress-reporting (silent) mode -qq
:
$ avrdude -qq -p m128 -c stk500 -e -U flash:w:diag.hex |
Using &&
to confirm that the silent AVRDUDE command went OK:
$ avrdude -qq -p m128 -c stk500 -e -U flash:w:diag.hex && echo OK OK |
Save flash memory in raw binary format to the file named c:/diag flash.bin
:
$ avrdude -p m128 -c stk500 -U flash:r:"c:/diag flash.bin":r Reading flash memory ... Reading | ################################################## | 100% 6.90 s Writing 19278 bytes to output file diag flash.bin Avrdude done. Thank you. |
Read the fuses and print their values in different formats (hexadecimal, binary and octal):
$ avrdude -cusbasp -patmega128 -qq -Ulfuse:r:-:h -Uhfuse:r:-:b -Uefuse:r:-:o 0xbf 0b11000110 0377 |
Using the default programmer, write the file diag.hex
to flash, the
file eeprom.hex
to EEPROM, and set the extended, high, and
low fuse bytes to 0xff, 0x89, and 0x2e respectively:
$ avrdude -p m128 -U flash:w:diag.hex \ -U eeprom:w:eeprom.hex \ -U efuse:w:0xff:m \ -U hfuse:w:0x89:m \ -U lfuse:w:0x2e:m Processing -U flash:w:diag.hex:i Reading 19278 bytes for flash from input file diag.hex Writing 19278 bytes to flash Writing | ################################################## | 100% 7.60 s Reading | ################################################## | 100% 6.81 s 19278 bytes of flash verified Processing -U eeprom:w:eeprom.hex:i Reading 3328 bytes for eeprom from input file eeprom.hex Writing 3328 bytes to eeprom Writing | ################################################## | 100% 1.20 s Reading | ################################################## | 100% 0.70 s 3328 bytes of eeprom verified Processing -U efuse:w:0xff:m Reading 1 byte for efuse from input file 0xff Writing 1 byte (0xFF) to efuse, 1 byte written, 1 verified Processing -U hfuse:w:0x89:m Reading 1 byte for hfuse from input file 0x89 Writing 1 byte (0x89) to hfuse, 1 byte written, 1 verified Processing -U lfuse:w:0x2e:m Reading 1 byte for lfuse from input file 0x2e Writing 1 byte (0x2E) to lfuse, 1 byte written, 1 verified Avrdude done. Thank you. |
Write data from stdin (standard input) to EEPROM; no error output means all went fine:
$ echo 'The quick brown fox' | avrdude -c usbasp -p attiny13 -qq -U eeprom:w:-:r |
Execute multiple terminal mode commands separated by semicolons:
$ echo 'write eeprom 0 "Bonjour"; write ee 0x18 0x12345678; dump eeprom 0 0x20' | \ avrdude -qqcdryrun -patmega328p -t 0000 42 6f 6e 6a 6f 75 72 00 ff ff ff ff ff ff ff ff |Bonjour.........| 0010 ff ff ff ff ff ff ff ff 78 56 34 12 ff ff ff ff |........xV4.....| |
Read EEPROM and write content to stdout (standard output):
$ avrdude -qq -cusbasp -pattiny13 -Ueeprom:r:-:i :20000000E2809954686520717569636B2062726F776E20666F78E280990AFFFFFFFFFFFFD3 :20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0 :00000001FF |
Same but redirect stderr (standard error output) to /dev/null
instead of using -qq
:
$ avrdude -cusbasp -pattiny13 -Ueeprom:r:-:i 2>/dev/null :20000000E2809954686520717569636B2062726F776E20666F78E280990AFFFFFFFFFFFFD3 :20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0 :00000001FF |
Using the Avrdude output to print strings present in flash memory:
$ avrdude -pattiny13 -qq -U flash:r:-:r | strings Main menu Distance: %d cm Exit |
List the serial numbers of all JTAG ICEs attached to USB; this is done by specifying an invalid serial number, and increasing the verbosity level:
$ avrdude -c jtag2 -p m128 -P usb:xxx -v Avrdude version 7.3-20240815 (e230d889) Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS System wide configuration file is /usr/local/etc/avrdude.conf User configuration file is /home/srueger/.avrduderc Using port : usb:xxx Using programmer : jtag2fast Programmer baud rate : 115200 Usbdev_open(): Found JTAG ICE, serno: 00A000001C6B Usbdev_open(): Found JTAG ICE, serno: 00A000001C3A Usbdev_open(): Found JTAG ICE, serno: 00A000001C30 Error: did not find any (matching) USB device usb:xxx (03eb:2103) Error: unable to open port usb:xxx for programmer jtag2fast Avrdude done. Thank you. |
Connect to the JTAG ICE mkII with a serial number ending in 1C37 via USB, enter interactive terminal mode, list all commands for the connected part and quit:
$ avrdude -c jtag2 -p m649 -P usb:1c:37 -t avrdude> help Valid commands: dump : display a memory section as hex dump read : alias for dump disasm : disassemble a memory section write : write data to memory; flash and EEPROM are cached save : save memory segments to file backup : backup memories to file restore : restore memories from file verify : compare memories with file flush : synchronise flash and EEPROM cache with the device abort : abort flash and EEPROM writes, ie, reset the r/w cache erase : perform a chip or memory erase config : change or show configuration properties of the part factory : reset part to factory state regfile : I/O register addresses and contents include : include contents of named file as if it was typed sig : display device signature bytes part : display the current part information send : send a raw command to the programmer verbose : display or set -v verbosity level quell : display or set -q quell level for progress bars help : show help message ? : same as help quit : synchronise flash/EEPROM cache with device and quit q : abbreviation for quit For more details about a terminal command cmd type cmd -? Other: !<line> : run the shell <line> in a subshell, eg, !ls *.hex # ... : ignore rest of line (eg, used as comments in scripts) Note that not all programmer derivatives support all commands. Flash and EEPROM type memories are normally read and written using a cache via paged read and write access; the cache is synchronised on quit or flush commands. The part command displays valid memories for use with dump and write. avrdude> quit Avrdude done. Thank you. |
Factory fuse setting of a device:
$ avrdude -patmega328p/St | grep initval .ptmm ATmega328P lfuse initval 0x62 .ptmm ATmega328P hfuse initval 0xd9 .ptmm ATmega328P efuse initval 0xff .ptmm ATmega328P lock initval 0xff |
List of all parts known to AVRDUDE:
$ avrdude -p*/d | cut -f2 -d"'" ATtiny11 ATtiny12 ATtiny13 ATtiny13A ATtiny15 AT89S51 [...] AVR64EA48 LGT8F88P LGT8F168P LGT8F328P |
List of all modern AVR parts (with UPDI interface) known to AVRDUDE:
$ avrdude -p*/Ud | cut -f2 -d"'" ATtiny202 ATtiny204 ATtiny402 [...] AVR64EA28 AVR64EA32 AVR64EA48 |
List of all curently plugged-in serial devices known to the libserialport library:
$ avrdude -P ?s Possible candidate serial ports are: -P /dev/ttyUSB0 or -P ft232r:A600K203 -P /dev/ttyUSB1 or -P ft232r:MCU8 -P /dev/ttyUSB3, -P ch340 or -P ch340-115k Note that above ports might not be connected to a target board or an AVR programmer. Also note there may be other direct serial ports not listed above. |
List of all serial adapters known to AVRDUDE, i.e., defined in avrdude.conf:
$ avrdude -P ?sa Valid serial adapters are: ch340 = [usbvid 0x1a86, usbpid 0x7523] ch341a = [usbvid 0x1a86, usbpid 0x5512] ch342 = [usbvid 0x1a86, usbpid 0x55d2] ch343 = [usbvid 0x1a86, usbpid 0x55d3] ch344 = [usbvid 0x1a86, usbpid 0x55d5] ch347 = [usbvid 0x1a86, usbpid 0x55da 0x55db 0x55dd 0x55de] ch9102 = [usbvid 0x1a86, usbpid 0x55d4] ch9103 = [usbvid 0x1a86, usbpid 0x55d7] cp210x = [usbvid 0x10c4, usbpid 0xea60 0xea70 0xea71] ft2232h = [usbvid 0x0403, usbpid 0x6010] ft231x = [usbvid 0x0403, usbpid 0x6015] ft234x = [usbvid 0x0403, usbpid 0x6015] ft230x = [usbvid 0x0403, usbpid 0x6015] ft232h = [usbvid 0x0403, usbpid 0x6014] ft232r = [usbvid 0x0403, usbpid 0x6001] ft4232h = [usbvid 0x0403, usbpid 0x6011] pl2303 = [usbvid 0x067b, usbpid 0x2303 0x2304 0x23a3 0x23b3 0x23c3 0x23d3 0x23e3] |
Output a list of non-bootloader programmers that can be used for a part. Note that 2>&1 folds stderr into stdout in a bash shell:
$ avrdude -c"?" -pavr32ea32 2>&1 | grep -v bootloader Valid programmers for part AVR32EA32 are: atmelice_updi = Atmel-ICE (ARM/AVR) via UPDI dryrun = Emulates programming without a programmer via UPDI jtag2updi = JTAGv2 to UPDI bridge via UPDI nanoevery = JTAGv2 to UPDI bridge via UPDI jtag3updi = Atmel AVR JTAGICE3 via UPDI pickit4_updi = MPLAB(R) PICkit 4 via UPDI pickit5_updi = MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC mode) via UPDI pkobn_updi = Curiosity nano (nEDBG) via UPDI powerdebugger_updi = Atmel PowerDebugger (ARM/AVR) via UPDI serialupdi = SerialUPDI via UPDI snap_updi = MPLAB(R) SNAP via UPDI xplainedmini_updi = Atmel AVR XplainedMini via UPDI xplainedpro_updi = Atmel AVR XplainedPro via UPDI |
Print filename of last stored sketch with its date stamp (only with urclock programmer):
$avrdude -qq -curclock -P/dev/ttyUSB0 -pattiny13 -x showdate -x showfilename 2023-05-19 11.13 blink.hex |
AVRDUDE in a bash script creating terminal scripts that reset a part to factory settings:
$ cat make-init-scripts #!/bin/bash mkdir /tmp/factory for part in $(avrdude -p*/d | grep = | cut -f2 -d"'"); do echo $part avrdude -p$part/St | grep initval | cut -f3,5 | grep -ve-1 \ | sed "s/.*/write &/" >/tmp/factory/$part.ini done |
Run above script and use one of the created terminal scripts:
$ ./make-init-scripts $ cat /tmp/factory/ATmega328P.ini write lfuse 0x62 write hfuse 0xd9 write efuse 0xff write lock 0xff $ avrdude -qq -cusbasp -pATmega328P -t < /tmp/factory/ATmega328P.ini |
Create a bash function avrdude-elf
that takes an elf file as input,
with support for optional Avrdude flags at the end, and writes to all memories
specified in the elf file. In this example, the elf file did not contain any
EEPROM data:
# Show all writable memories present for the ATtiny13 $ echo $(avrdude -pattiny13/ot | grep write | cut -f3 | uniq) eeprom flash lfuse hfuse lock # Function that writes to all memories present in the elf file avrdude-elf() { avrdude -cusbasp -pattiny13 -U{eeprom,flash,{l,h}fuse,lock}:w:"$1":e "${@:2}" } # Run function where -B8 and -V is appended to the Avrdude command $ avrdude-elf blink.elf -B8 -V Set SCK frequency to 93750 Hz Processing -U eeprom:w:blink.elf:e Reading 64 bytes for eeprom from input file blink.elf Writing 64 bytes to eeprom Writing | ################################################## | 100% 0.08 s 64 bytes of eeprom written Processing -U flash:w:blink.elf:e Reading 1024 bytes for flash from input file blink.elf Writing 1024 bytes to flash Writing | ################################################## | 100% 0.12 s 1024 bytes of flash written Processing -U lfuse:w:blink.elf:e Reading 1 byte for lfuse from input file blink.elf Writing 1 byte (0x6A) to lfuse, 1 byte written Processing -U hfuse:w:blink.elf:e Reading 1 byte for hfuse from input file blink.elf Writing 1 byte (0xFF) to hfuse, 1 byte written Processing -U lock:w:blink.elf:e Reading 1 byte for lock from input file blink.elf Writing 1 byte (0xFF) to lock, 1 byte written Avrdude done. Thank you. |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 30, 2024 using texi2html 5.0.