How to save a program from arduino to PC?

I have received this arduino (together with other hardware) with a demo program installed. I would like to save the program on my PC just in case i would need it to test the hardware one day. Is this possible somehow? It's a mega, btw. So i cannot take the uC out... I'm running Linux on the PC.

Of course this would give the binary and not the source.

This comes up from time to time. No it is not a very practical thing to do.
In your case when you just want to restore something that is already in then you could use a programmer to do a memory dump and store it as a file. Then restore it again with a programmer. But there is no way to do it without buying extra hardware that you will only use for this task, unless you get into blowing your own bootloaders.

If its code that you have the right to, then just ask for the source code.

Unless protection fuse bits have been set, you can use avrdude to read the ATmega memory and save it in a hex file on your workstation.

Then, later, you can use avrdude to upload that hex file back to the ATmega.

The avrdude program is part of the Arduino distribution. You can use it (by itself) from a command line.

Regards,

Dave

Thanks for all the answers.

Time to study avrdude and maybe improvise programmer hardware. That will be handy anyway, sooner or later... Of course I will first try to get the source.

Time to study avrdude

If you have an Arduino board, it has the Arduino bootloader, right? (If you can talk to it through the Arduino IDE, it has the Arduino bootloader.)

As long as the bootloader is in place, the serial (USB) interface can be used by avrdude to read and write the ATmega memory with no other programmer hardware or software required.

Regards,

Dave