How to read arduino flash memory

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


Solution 1:

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/