Atmega32U4 Flash auslesen

Flash auslesen

To read out the contents of the flash memory of your AVR, you just need to hook up your ISP programmer to the target board, and run an appropriate avrdude command to read out the flash. For “dumping” out the contents of an ATmega328P, for example, you might use the command:

avrdude -p m328p -P usb -c usbtiny -U flash:r:flash.bin:r

Der Chiptyp im Parameter -p muss exakt der Schreibweise im AVRDUDE-Handbuch entsprechen.

Board uController -p
Arduino Uno Atmega328P m328p
Arduino Leonardo Atmega32U4 m32u4

„-P usb“ means that we’re using a usb-connected programmer, and “usbtiny” is the programmer type (again, taken from the list in the documentation).

The real heart of the command is the last part, -U flash:r:”flash.bin”:r. This tells avrdude to read the contents of the flash (“flash:r”), save it to a file named “flash.bin,” and specifies the format (“:r”), in this case raw binary.

When the lock bits prevent reading the actual flash memory contents, you won’t get an error message. The binary file will be created just as it would without the lock bits set, but it contains nonsense (or, more precisely, the lower 8 bits of word address of the memory location). So you will have to open the binary file with a hex editor (I recommend frhed for windows and dhex for linux/console, if you’re using KDE then khexedit might be a good choice). If it contains a pattern like

00 00 01 01 02 02 03 03 04 04

and so on, the AVR is most probably locked.