Firmware backup from Arduino and ESP8266, ESP32

Is it possible to backup firmware from these 3 types of boards?

if a backup is possible then will it backup with EEPROM data?

A compiled program is a binary file. Just numbers absolutely not readable by humans. So if you are interested in a backup of something that is readable by humans you have to backup the source-code. The *.ino-files.

You can create the binary file that is uploaded with the Arduino-IDE
with
sktech - export compiled binary.

There are also functions for uploading such a binary to the microcontroller.
I guess the content of the eeprom is not included in this.

If you describe the final purpose of your backup and the EEPROM-content
a better advice can be given.

With ESP8266 and ESP32 you can save data with SPIFFSS or
for ESP8266 with the "LittleFS.h"-libarary

for ESP32 with the "LITTLEFS.h"-library (do you see the difference? ESP32 is all UPPERCASE)

I guess there are special libraries that could read out the binary content of the Flash-memory.

But as a microcontroller is not a full-blown operating system there is no easy way like on a windows, Linux or mac computer or a android-device to execute a command "copy file "xy" to ....

best regards Stefan

@StefanL38
Before i start messing with a new gadget, i usually first try to backup its stock firmware. It comes very handy when trying to unbrick something :stuck_out_tongue_closed_eyes:

@psp50
For ESP32 and ESP2866 you can use this guide.

About Arduino, you didn't specify which board, so i'll assume it's about Uno.
The Uno R3 has two chips with firmware - the main MCU ATmega328P, and the ATmega16U2 which is used as a USB>Serial adapter. You'll need to backup both.
There is a guide here.
I use USBasp (clone) programmer and avrdude for this purpose.
Here is one of my backup batch scripts for the 328P as example:

ECHO OFF
CLS
set bakdir="S:\Embedded\_Backup\ATmega328P"
ECHO.
ECHO BATCH COPY ATMEGA328P-PU VIA USBasp
CD "S:\Embedded\USBasp\AVRDUDESS-2.13-portable"
ECHO ENSURE MASTER CHIP IS IN THE READER
ECHO CTRL+C to abort OR PRESS Any key to begin copy...
ECHO.
pause >nul
ECHO Creating hexadecimal binary files of ATmel328P contents...
>stdout.log 2>&1 (
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U flash:r:%bakdir%\backup_flash.hex:i
ECHO flash has been sAVED to backup_flash.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U eeprom:r:%bakdir%\backup_eeprom.hex:i
ECHO eeprom has been SAVED to backup_eerpom.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U hfuse:r:%bakdir%\backup_hfuse.hex:i
ECHO hfuse has been SAVED to backup_hfuse.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U lfuse:r:%bakdir%\backup_lfuse.hex:i
ECHO lfuse has been SAVED to backup_lfuse.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U efuse:r:%bakdir%\backup_efuse.hex:i
ECHO efuse has been SAVED to backup_efuse.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U lock:r:%bakdir%\backup_lock.hex:i
ECHO lock has been SAVED to backup_lock.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U calibration:r:%bakdir%\backup_calibration.hex:i
ECHO calibration has been SAVED to backup_calibration.hex
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U signature:r:%bakdir%\backup_signature.hex:i
ECHO signature has been SAVED to backup_signature.hex
)
ECHO Hexadecimal files created.
ECHO.
ECHO Starting Notepad editor to display log file.
start notepad "S:\Embedded\USBasp\AVRDUDESS-2.13-portable\stdout.log"
ECHO.
ECHO Press Any key to close this window...
pause >nul

And here is my restore batch script:

ECHO OFF
CLS
set bakdir="\Embedded\_Backup\ATmega328P"
CD "S:\Embedded\USBasp\AVRDUDESS-2.13-portable"
ECHO INSERT THE NEW CHIP INTO ARDUINO ISP PROGRAMMER
ECHO PRESS Any key to write new chip (CTRL+C to abort)
ECHO ...
PAUSE >nul
REM Paste 328: Note that the path cannot contain the drive letter "C:" so you cannot use %temp% as previously
REM Reference:http://savannah.nongnu.org/bugs/index.php Bug report #39230
REM.
>stdout.log 2>&1 (
DIR %bakdir%\*.hex
ECHO ATmel328P-PU duplication is beginning now...
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U flash:w:%bakdir%\backup_flash.hex
ECHO flash WRITTEN
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U eeprom:w:%bakdir%\backup_eeprom.hex
ECHO eeprom WRITTEN
REM high_fuses=0xDA
REM REM avrdude -c arduino -P com9 -p ATMEGA328P -b 19200 -U hfuse:w:0xDA:m
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U hfuse:w:%bakdir%\backup_hfuse.hex
ECHO hfuse WRITTEN
REM low_fuses=0xE2
REM avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U lfuse:w:0xE2:m
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U lfuse:w:%bakdir%\backup_lfuse.hex
ECHO lfuse WRITTEN
REM extended_fuses=0x05
REM avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U efuse:w:0x05:m
avrdude -c usbasp-clone -p ATMEGA328P -b 19200 -U efuse:w:%bakdir%\backup_efuse.hex
ECHO efuse WRITTEN
)
REM.
REM Chip duplication is complete... starting display of log file.
start notepad S:\Embedded\USBasp\AVRDUDESS-2.13-portable\stdout.log
ECHO.
ECHO Press Any key to close this window...
PAUSE >nul

Unless you have a board that comes with custom firmware, backing up the ATmega16U2 firmware is almost "doomsday prepper" level. The reason is because both the source code and binaries of the stock firmware are stored here and also on your computer with your installation of the "Arduino AVR Boards" platform.

As for the ATmega328P. I would not bother doing it if I had access to the source code for the sketch and its dependencies. However, it is a valuable technique in the rare case where you don't have access to the source code the binary on the board was produced from.

The problem is some people is cloning my developed devices.

I have outsourced my coding works and developer have provided me the .bin files according to my use and it is working fine for my device. But the problem is people is cloning my devices.

Is it possible to lock ESP board firmware?
so people can not clone any devices.

I did a quoogling
https://www.google.de/search?as_q=esp32+lock+flash+memory

and found this:

after a first quick cross-reading this looks promising.
As an entreprenuer you should be able to do such researches on your own

best regards Stefan

Another one, heh...

Got some example to show us what is so good about your devices that people would bother cloning them?
A store link or website?

... after a week...
Won't even bother to reply, heh?!
Now i regret wasting my time to answer such a person.

sorry, but I have found the solution.
now ESP32 is the last solution.

sorry for the delayed reply.

Espressif chips:
https://cyberblogspot.com/how-to-save-and-restore-esp8266-and-esp32-firmware/