The fastest way to learn embedded development is also the fastest way to turn a board into a paperweight. The good news: an ESP32 is remarkably hard to truly brick, as long as you keep the bootloader reachable.

Back up before you write

Before flashing anything, read the full flash to a file. If a write goes wrong, you can always restore the exact bytes that shipped from the factory.

esptool.py --chip esp32 --port /dev/ttyUSB0 \
  read_flash 0x0 0x400000 stock-backup.bin
NoteHold the BOOT button while connecting if the chip will not enter download mode. On many boards this is the only way to recover after a bad write.

Write the new image

With a verified backup in hand, writing the replacement image is the easy part. Match the flash mode and frequency to your board or you will get a boot loop that looks scarier than it is.

firmwareesp32tutorial