Skip to content

technopolistv/ESP32-SelfDestruct-Payload

Repository files navigation

Self-destructing Arduino ESP32 Firmware - Stage 2

Arduino ESP32 Self-destructing Firmware

Is it possible to erase the firmware of an ESP32 from within itself? Let's try to find out.

If you want to erase the ESP32's flash content, the easiest way would be using esptool.py with the erase_flash parameter. But how we can do this from within the running Arduino Sketch?

Installation

PlatformIO

Open the ESP32-SelfDestruct-Payload project. Click on the PlatformIO Icon on the sidebar. Under General click on Build.

Copy the firmware.bin file under the folder .pio/build/{BOARD}/firmware.bin into the data folder of the ESP32-SelfDestruct project.

Do not upload this code to your ESP32! Just build the project and move the firmware.bin into the data folder of the ESP32-SelfDestruct project and read the instructions.

Demo Screenshot

The green part highlights the main firmware (Stage 1) and the red part the stub firmware (Stage 2).

Serial Monitor Arduino ESP32 Self-destructing Firmware

Partition layout of Self-Destructing Firmware

Offset Before Update After Update After Erase
0x9000 NVS (Data) NVS (Data) NVS (Empty)
0xe000 OTA
OTA OTA (Empty)
0x10000 APP0 (Firmware) APP0 (Firmware disabled) APP0 (Empty)
0x150000 APP1 (Empty) APP1 (Stub Firmware actived) APP1 (Stub Firmware)
0x290000 SPIFFS (Stub Firmware) SPIFFS (Stub Firmware) SPIFFS (Empty)

More

✍️ Blog: https://www.technopolis.tv/PlatformIO-Self-destructing-Arduino-ESP32-Firmware/

About

Is it possible to erase the firmware of an ESP32 from within itself? Let's try to find out.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages