[solved] Download project from arduino board

Hi Guys,

I flashed a couple of arduinos some time ago but lost my program trough a ssd defect.
Now I want to download the code from my arduino boards in order to change it.
I installed VSC and PlatformiO but i dont know how to download the data from my
boards. Can you help me out here?

Thx and brgds,

Claus

This is not easily possible.

The program’s source code was compiled to machine code during the compilation process and written into the flash of the microcontroller.

For almost all microcontrollers, you can read back the content of the flash (if it wasn’t specially secured by some readout protection). See e.g. for AVR chips or ESP8266/ESP32. However, then you have exactly that – the machine code. The original C/C++ code is not on the board.

Turning the readout flash content / machine code back into the original C/C++ code that it was before compilation is a process called reverse engineering. Programs like IDA (Pro) and Ghidra by the NSA are designed for that, with their builtin disassemblers and decompilers. This is however a very manual process if you want well-readable code back – you have to rename all the functions and variables (as there are no names of that saved in the machine cade), reconstruct the originally used datatypes, etc. In case where you only have a disassembler (like radare2), you need to convert the machine code into C/C++ functions back yourself. In any case it is advised to know a lot about the CPU architecture and instruction set of your target board to make any sense out of the retrieved content.

See related topics:

In short, reverse-engineering is a very deep and involved topic, and my estimate is that someone needs to spend at least half a year to be any good at it (if a good background in computer programmming is already there). If you absolutely must get this exact code back, that is one avenue that through extreme amount of work will eventually work.

You might want to explore other avenues like performing / having someone perfom data recovery on your SSD to get the data back.

Or, rewrite the firmwares you’ve lost, if your memory is still fresh on them, and from there, always follow backup strategies.

Hi Max,
thx for the information and the fast response!
Then I´ll just rewrite the code!
Thx and brgds,
Claus