I acquired an Arduino PCB with an ATmega2560, already programmed with the Arduino bootloader and some program. I do have the sketch, but before fiddling with it, I'd like to backup the current binary that is in the controller. As most Arduinos, it's connected to the PC using an USB-to-serial converter connected to TX0 and RX0 and there is no ISP interface.

Apparently there is code for reading in the Arduino bootloader, but I have no idea which tool to use to access it as there is no menu item in the Arduino IDE.

What software do I need to read the program from the Arduino?

  • \$\begingroup\$ Found code for reading in the bootloader, edited question. \$\endgroup\$ – AndreKR Jun 13 '12 at 17:32
  • \$\begingroup\$ this dosent awnser your question, but you can export your arduino skeches as a .HEX file. \$\endgroup\$ – uranium Lees Jul 18 '18 at 21:05

The Arduino bootloader is a variant of the original STK500 protocol (1.x). The character 't' (ASCII 0x74) is the "Read Page" command. So perhaps it is possible to pull the program out through the serial port via the bootloader using AVRDUDE... But at best I reckon it will take some fancy timing to pull it off.


I've dumped a memory from Duemillenova with ATMega328P with the following command:

avrdude -C avrdude.conf -v -v -v -v -p atmega328p -c stk500 -U flash:r:"c:/arduino.hex":r -P\\.\COM2 -b57600
  • 1
    \$\begingroup\$ attention that the programmer applicable is probably arduino and not stk500. \$\endgroup\$ – Paulo Neves Jan 13 '16 at 20:54
  • \$\begingroup\$ Why are four -vs necessary? \$\endgroup\$ – Peter Mortensen Apr 17 '17 at 1:05
  • \$\begingroup\$ From AVRDUDE documentation, "2.1 Option Descriptions": "... -v Enable verbose output. More -v options increase verbosity level." \$\endgroup\$ – Peter Mortensen Apr 17 '17 at 23:00
  • \$\begingroup\$ This should be the accepted answer. \$\endgroup\$ – Caterpillaraoz Dec 1 '17 at 9:51
  • \$\begingroup\$ YES! The pro micro bootloader didn't work on my pro micro clone. I dumped the flash from a working pro micro clone and saved to the one that needed a bootloader. Using an Arduino as ISP (linux) -- dump: ./avrdude -C ../etc/avrdude.conf -v -v -v -v -p ATmega32u4 -c arduino -b 19200 -U flash:r:"/tmp/dump.bin":r -P /dev/ttyUSB0; write: ./avrdude -C ../etc/avrdude.conf -v -v -v -v -p ATmega32u4 -c arduino -b 19200 -U flash:w:"/tmp/dump.bin":r -P /dev/ttyUSB0; verify: ./avrdude -C ../etc/avrdude.conf -v -v -v -v -p ATmega32u4 -c arduino -b 19200 -U flash:v:"/tmp/dump.bin":r -P /dev/ttyUSB0 \$\endgroup\$ – b_laoshi Jan 4 at 7:40

Does the Backup AVR with avrdude thread answer your question? Basically you can read all memory from an AVR as long as the protection fuse isn't set.

This is the setup I use for ATtiny's and ATmega's.

On the board shown:

  • 11 = MOSI
  • 12 = MISO
  • 13 = SCLK

Refer to the datasheet of the controller which exact pin to use. There are quite a few websites on Internet writing about programming AVR's using an Arduino, eg.: http://hlt.media.mit.edu/?p=1229

  • \$\begingroup\$ I need a second arduino for that, right? I don't have one. \$\endgroup\$ – AndreKR Jun 13 '12 at 17:21
  • 1
    \$\begingroup\$ This is a two Arduino method, yes. \$\endgroup\$ – jippie Jun 13 '12 at 19:12
  • \$\begingroup\$ And, although it's a bit hard to see in the picture, the pins used on the target Arduino are not TX0 and RX0 either, are they? \$\endgroup\$ – AndreKR Jun 14 '12 at 22:49
  • \$\begingroup\$ No, TX and RX are not used for ICP. Updated the answer a bit. \$\endgroup\$ – jippie Jun 15 '12 at 7:00
  • \$\begingroup\$ Well, I think you missed the whole point of my question, probably because I gave it a bad title. I rephrased the whole question. \$\endgroup\$ – AndreKR Jun 16 '12 at 0:52

As far as I can see form the Arduino bootloader source code, there's no way to 'dump' all memory from it. The bootloader does support a 'monitor' mode which allows you to dump one memory byte at a time. However, as per the source code comments "/* monitor functions will only be compiled when using ATmega128, due to bootblock size constraints */"

As such, I guess you're out of luck if you don't want to use ISP, change the bootloader or upload a sketch to do it.

  • \$\begingroup\$ I was referring to the section that starts in line 701 with else if(ch=='t') {. \$\endgroup\$ – AndreKR Jun 16 '12 at 16:48
  • \$\begingroup\$ Good point - hadn't seen that. \$\endgroup\$ – RJR Jun 26 '12 at 10:57

I thought there was a menu option for that but I'm not finding it right now. If you have an ISP programmer, you can use AVR Studio to Read the memory image off the chip and save it off in a HEX file, that would allow you to restore it through the same means.


In response to your comment - that's easy! You need to assimilate two diagrams worth of information to pull it off. The first is the Arduino / ATMega2560 Pin Mapping.

enter image description here

The second is the ISP Header / AVR Pin Mapping:

enter image description here

Armed with these two pictures, you should be able to see how to wire it up.

  • Run a wire from DIG50 to Dragon ISP header pin 1
  • Run a wire from VCC to Dragon ISP header pin 2
  • Run a wire from DIG52 to Dragon ISP header pin 3
  • Run a wire from DIG51 to Dragon ISP header pin 4
  • Run a wire from RESET to Dragon ISP header pin 5
  • Run a wire from GND to Dragon ISP header pin 6

With those in place, you should be able to use AVR Studio to read the Hex file off the chip - let me know if you need more guidance.

  • \$\begingroup\$ I have a Dragon, but I don't know which pins on the Dragon to connect to the serial interface of the Arduino. \$\endgroup\$ – AndreKR Jun 13 '12 at 17:23
  • \$\begingroup\$ @AndreKR see my edited answer for more info \$\endgroup\$ – vicatcu Jun 14 '12 at 4:28
  • \$\begingroup\$ As stated in my question, I know how to read the program using ISP, of course. What I want to know is how to do it using the serial interface (TX0 and RX0) - the same way the programs are uploaded to the controller in the Arduino world. \$\endgroup\$ – AndreKR Jun 14 '12 at 22:47
  • \$\begingroup\$ @AndreKR I'm confused... you have a dragon, why would you not want to read the program in the normal way - I misunderstood your comment about not knowing which pins to connect to the "serial interface" \$\endgroup\$ – vicatcu Jun 16 '12 at 2:05
  • \$\begingroup\$ The PCB I have doesn't have an ISP header. However, it has a serial interface and an Arduino bootloader. That way the programs are uploaded in the Arduino world, and apparently they can be downloaded the same way. \$\endgroup\$ – AndreKR Jun 16 '12 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.