Getting code from at mega chip

I have been looking everywhere to try and find an easy way to just transfer my code (through binary) from one at mega chip to another because I was working very hard on a project of mine and I wanted to create more of the project but I deleted my code and I don't want to program it again on all my devices. Is there a possible way to pull the binary code from on at mega chip and just post it on another at mega chip?

Yeah - dump the hex file with avrdude over serial (if it's got a bootloader), or via ISP programmer.

For "xeroxing" chips, I normally reach for USBAsp and eXtremeBurner AVR - plug in old chip, "read all", plug in new chip, "write all", done.

Yep, you can use AVRdude to download the hex and upload it again. Google for AVRdude and download hex. But you will need a programmer (or another Arduino programmed as programmer) to do so.

But don't expect it to give you code you can work with. But pure duplication can be done.

When you say that I need a programmer would a raspberry pi work as the programmer

Yes, you can use Raspberry as ISP programmer.

https://oxygene.sk/2015/02/using-raspberry-pi-as-an-arduino-avr-programmer/

or

How would I download it using the raspberry pi. Do I have to use the LX terminal to get the program downloaded.

Buildarobot:
How would I download it using the raspberry pi. Do I have to use the LX terminal to get the program downloaded.

Click the links he posted above, they both give step-by-step instructions (I think the adafruit one is better of the two), what do you want us to do, retype the instructions in this thread?!

In any event - make sure you're doing it right with a chip that doesn't have the sketch you're trying to extract - so if you do something wrong, you won't lose your only copy of the sketch you're trying to duplicate.

Would this also be able to be done on a Rom chip or is that completely different?

Do you mean masked ROM, PROM, EPROM, EEPROM, Flash, or something else?

You can read out any of these (as binary or hexadecimal) with appropriate hardware and software, and you will need an appropriate programmer to write it into a blank chip. Of course, the appropriate programmer for a masked ROM is a mask.

To read some sort of ROM/PROM/EEPROM/etc you would almost certainly need to write a sketch to talk to the chip in the manner it requires, and print the contents to serial. The difficulty of this varies from something I could write in 5 minutes to something that would take days of work and additional hardware, depending on what kind of ROM you're reading from.

IS there a place that i can learn to do that?

I would say the datasheet is a good place to start :slight_smile: And if you want to write a sketch for it you of course need to master C++.