ESP32 USB Army Knife Tutorial

Last Modified: Thu, 13 Feb 2025 02:56:52 +0000 ; Created: Mon, 10 Feb 2025 23:29:57 +0000

Wanted to blog about playing with the USB Army Knife on a LilyGo T-Dongle S3 USB device (ESP32-S3) and steps I took to implement it. I did not develop the tool, but I wanted to try out each of the tool features and write about it. Some helpful references to start:

I used the LilyGo T-Dongle S3 USB device because it was easy to source on Amazon.com for about $25. I also purchased a 32GB microSD card for best compatibility. Short video showing the first boot with OEM firmware.

On windows the command to install the esptool software: python -m esptool version

Backup existing firmware

  1. Inserted USB device, did not have to hold down any button on the device
  2. python -m esptool flash_id
  3. Observed "Detected flash size" of 16MB for the LilyGo
  4. python -m esptool --baud 115200 --port COM3 read_flash 0x0 0x1000000 fw-backup-16MiB.bin
    • Adjust port per previous flash_id
    • 16MiB = hex 0x1000000
    • For many devices you can change the baud rate to something faster (922190) and the device will auto-adjust.
  5. It may take a little bit for the complete flash to dump

Getting necessary firmware

You can use a web browser to flash firmware, but I wanted to have a CLI method. The download files come from the GitHub Wiki instructions.
  1. Go to the git commits page
  2. Click on the title of the first (top-most) result
  3. Look under Artifacts
  4. Download the LILYGO-T-Dongle-S3 Firmware binaries
  5. Extract the zip file
  6. Download the raw boot_app0.bin from espressif

Installation

Pieces of command syntax from https://docs.espressif.com/projects/esptool/en/latest/esp32/esptool/flashing-firmware.html
  1. Open a terminal/command prompt (admin not necessary)
  2. cd into the directory where all the firmware .bin files are located
  3. Plug in your device, holding down any boot button that may exist
  4. python -m esptool --baud 922190 --before default_reset --after hard_reset write_flash 0x0000 bootloader.bin 0x8000 partitions.bin 0xE000 boot_app0.bin
  5. python -m esptool --baud 922190 --before default_reset --after hard_reset write_flash 0x10000 firmware.bin
    • I'm not sure why, but I had to do this separate to avoid "Detected overlap at address: 0x10000 for file: firmware.bin"
You may find python -m esptool flash_id useful for getting your device flash size and Crystal speed (e.g. --flash_freq 40m), but I found leaving it in auto-detect worked fine.