TinyCan:
I don't really have a clue how I would go about getting the .hex files from my Arduino Mega
Here are the instructions:
First, we’re going to do a dummy upload in the Arduino IDE in order to get it to help us generate the avrdude command used to read the program from the Arduino board:
Plug your Arduino board into your computer.
Select your board from the Arduino IDE’s Tools > Board menu.
Select your board’s port from the Tools > Port menu.
VERY IMPORTANT: Unplug your board from your computer.
File > Preferences
Check the box next to “Show verbose output during > upload”.
Click “OK”.
Sketch > Upload
Wait for the upload to fail.
Scroll up the black console window at the bottom of the Arduino IDE window until you see the avrdude command that was generated for the upload. It will look something like this:
E:\Arduino\hardware\tools\avr\bin\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i
Select the full text of the upload command.
Press Ctrl + C. This will copy the upload command to the clipboard.
Next, you need to modify the upload command to read the hex file out of your Arduino board:
Start a text editor program.
In the text editor window, press Ctrl + V. This will paste the command into the text editor. The end of the command will look something like this:
-D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i
That is the part of the command that tells it to write.
Replace that part of the command with the command that tells AVRDUDE to read:
-Uflash:r:readfile.hex:i
That will cause the read file to be named “readfile.hex”, which will be saved to whichever folder you run the command from. So now the full command looks something like this:
E:\Arduino\hardware\tools\avr\bin\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:r:readfile.hex:i
If the paths in the command contain spaces, wrap the paths in quotes.
Plug your Arduino board into your computer.
Copy and paste the command from the text editor to the command line and run it.
Wait for the command to finish successfully.