## 2.3 Example Command Line Invocations

Download 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

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.03s

    avrdude: Device signature = 0x1e9702
    avrdude: erasing chip
    avrdude: done.
    avrdude: performing op: 1, flash, 0, diag.hex
    avrdude: reading input file "diag.hex"
    avrdude: input file diag.hex auto detected as Intel Hex
    avrdude: writing flash (19278 bytes):

    Writing | ################################################## | 100% 7.60s

    avrdude: 19456 bytes of flash written
    avrdude: verifying flash memory against diag.hex:
    avrdude: load data flash data from input file diag.hex:
    avrdude: input file diag.hex auto detected as Intel Hex
    avrdude: input file diag.hex contains 19278 bytes
    avrdude: reading on-chip flash data:

    Reading | ################################################## | 100% 6.83s

    avrdude: verifying ...
    avrdude: 19278 bytes of flash verified

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    %

Upload the flash memory from the ATmega128 connected to the STK500 programmer and save it in raw binary format in the file named `c:/diag flash.bin`:

    % avrdude -p m128 -c stk500 -U flash:r:"c:/diag flash.bin":r

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.03s

    avrdude: Device signature = 0x1e9702
    avrdude: reading flash memory:

    Reading | ################################################## | 100% 46.10s

    avrdude: writing output file "c:/diag flash.bin"

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    %

Using the default programmer, download the file `diag.hex` to flash, `eeprom.hex` to EEPROM, and set the Extended, High, and Low fuse bytes to 0xff, 0x89, and 0x2e respectively:

    % avrdude -p m128 -u -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

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.03s

    avrdude: Device signature = 0x1e9702
    avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "diag.hex"
    avrdude: input file diag.hex auto detected as Intel Hex
    avrdude: writing flash (19278 bytes):

    Writing | ################################################## | 100% 7.60s

    avrdude: 19456 bytes of flash written
    avrdude: verifying flash memory against diag.hex:
    avrdude: load data flash data from input file diag.hex:
    avrdude: input file diag.hex auto detected as Intel Hex
    avrdude: input file diag.hex contains 19278 bytes
    avrdude: reading on-chip flash data:

    Reading | ################################################## | 100% 6.84s

    avrdude: verifying ...
    avrdude: 19278 bytes of flash verified

    [ ... other memory status output skipped for brevity ... ]

    avrdude done.  Thank you.

    %

Connect to the JTAG ICE mkII which serial number ends up in 1C37 via USB, and enter terminal mode:

    % avrdude -c jtag2 -p m649 -P usb:1c:37 -t

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.03s

    avrdude: Device signature = 0x1e9603

    [ ... terminal mode output skipped for brevity ... ]

    avrdude done.  Thank you.

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:xx -v
    [...]
             Using Port            : usb:xxx
             Using Programmer      : jtag2
    avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C6B
    avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C3A
    avrdude: usbdev_open(): Found JTAG ICE, serno: 00A000001C30
    avrdude: usbdev_open(): did not find any (matching) USB device "usb:xxx"