4

Imagine i'have lost my source code. Is there a way to dump an arduino flash memory ? What i want to do is to get an hex file on my PC that represent byte per byte the arduino flash memory (including bootloader)

I have 3 arduino types:

  • Arduino UNO (rev3)
  • Arduino MEGA
  • Leonardo Ethernet

Thanks

2
  • This might depend on your particular model. Commented Mar 13, 2017 at 17:57
  • thanks. See my edits Commented Mar 13, 2017 at 17:59

2 Answers 2

6

avrdude can do that for you. The specifics will depend on which arduino you have, but something like:

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

will get you the contents of the flash memory.

Here's a site with more info:

http://www.evilmadscientist.com/2011/avr-basics-reading-and-writing-flash-contents/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks: Do you know which programmer i should pass as -c argument for this device: store.arduino.cc/product/A000092
1

It seems that using an Arduino board, the programmer (option -c) must be set to arduino (see the avrdude manual for details). Also, I had to specify the ACM port (in my case /dev/ttyACM0 on a Linux machine).

The full command to read (and backup the flash to flash.bin) is thus:

avrdude -p m328p -P /dev/ttyACM0 -c arduino -U flash:r:flash.bin:r

And to restore the flash, you can use:

avrdude -p m328p -P /dev/ttyACM0 -c arduino -U flash:w:flash.bin

2 Comments

can i read only the bootloader?!
@aleXela, yes you can, see the details for the option -U in the manual. In my case, it would have been avrdude -p m328p -P /dev/ttyACM0 -c arduino -U boot:r:bootloader.bin:r

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.