Dump and Disassemble AVR µC Flash Memory

dump truck

Read Flash Memory

To dump the contents of the flash memory of an AVR microcontroller, you simply need to connect an ISP programmer, and execute the appropriate avrdude command. For example, to dump an ATmega328P based arduino, using an USBTiny ISP device, execute the following:

avrdude -c usbtiny -p m328p -P usb -U flash:r:"C:\download.hex":i

This downloads the memory contents in the Intel HEX file format, which is the default format used for programming the AVR µC.

Note: if the lock bits are set, this method will not work. The only way to reset the lock bits is by erasing the entire device.

Disassemble the file

To disassemble the file, execute the appropriate avr-objdump command. Continuing with the example above, to disassemble the ATmega328P based arduino file, execute the following:

avr-objdump –j .sec1 –d –m avr5 download.hex > download.txt

It will be left to the reader to determine how to read the EEPROM or fuse bytes via a similar method.

Advertisements

About Jim Eli

µC experimenter
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

3 Responses to Dump and Disassemble AVR µC Flash Memory

  1. Ray Pasco says:

    The command line for the current version of avr-objdump is not correct: There aren’t “-j” and “m” option flags !
    ============================
    avr-objdump
    Usage: avr-objdump
    Display information from object .
    At least one of the following switches must be given:
    -a, –archive-headers Display archive header information
    -f, –file-headers Display the contents of the overall file header
    -p, –private-headers Display object format specific file header contents
    -h, –[section-]headers Display the contents of the section headers
    -x, –all-headers Display the contents of all headers
    -d, –disassemble Display assembler contents of executable sections
    -D, –disassemble-all Display assembler contents of all sections
    -S, –source Intermix source code with disassembly
    -s, –full-contents Display the full contents of all sections requested
    -g, –debugging Display debug information in object file
    -e, –debugging-tags Display debug information using ctags style
    -G, –stabs Display (in raw form) any STABS info in the file
    -W, –dwarf Display DWARF info in the file
    -t, –syms Display the contents of the symbol table(s)
    -T, –dynamic-syms Display the contents of the dynamic symbol table
    -r, –relocate Display the relocation entries in the file
    -R, –dynamic-reloc Display the dynamic relocation entries in the file
    @ Read options from
    -v, –version Display this program’s version number
    -i, –info List object formats and architectures supported
    -H, –help Display this information

    avrdude version 5.10, URL: <http://savannah.nongnu.org/projects/avrdude/

    • Jim Eli says:

      Ray, It’s there:

      C:\>avr-objdump –version
      GNU objdump (AVR_8_bit_GNU_Toolchain_3.5.2_1680) 2.26.20160125
      Copyright (C) 2015 Free Software Foundation, Inc.
      This program is free software; you may redistribute it under the terms of
      the GNU General Public License version 3 or (at your option) any later version.
      This program has absolutely no warranty.

      C:\>avr-objdump -j

      The following switches are optional:
      -b, –target=BFDNAME Specify the target object format as BFDNAME
      -m, –architecture=MACHINE Specify the target architecture as MACHINE
      -j, –section=NAME Only display information for section NAME

      Plus, your link appears to be to avrdude, not avr-objdump.

      • Ray says:

        Yup – sorry ! I didn’t guess that avr-objdump would -not- just automatically list all option flags when it is called without any flags.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s