Device Firmware Upgrade (DFU) through USB
Device Firmware Upgrade (DFU) is a mechanism for upgrading the firmware of devices through Universal Serial Bus (USB). There are a few requirements that need to be met:
DFU is supported by ESP32-S2 and ESP32-S3 chips.
You will need to do some electrical connection work. Here is a guide for the ESP32-S2 board. The necessary connections for the USB peripheral are shown in the following table.
GPIO |
USB |
---|---|
20 |
D+ (green) |
19 |
D- (white) |
GND |
GND (black) |
+5V |
+5V (red) |
After meeting the above requirements:
The chip needs to be in bootloader mode for detection as a DFU device and flashing. This can be achieved by pulling GPIO0 down (e.g., pressing the BOOT button), pulsing RESET down for a moment, and releasing GPIO0.
Install USB drivers (Windows only). The drivers can be installed by the Zadig tool. - Ensure that the device is in download mode before running the tool and that it detects the device before installing the drivers. - The Zadig tool might detect several USB interfaces of the target. Install the WinUSB driver only for the interface without a driver installed (likely Interface 2), and avoid re-installing drivers for other interfaces. - Manual driver installation via Device Manager in Windows is not recommended, as it might cause flashing issues.
After meeting the above requirements, you can proceed to build and flash via DFU. To use DFU:
Edit the active launch configuration.
In the main tab, select the Flash over DFU option.
Select a suitable IDF target for DFU.
When using the build command, an extra file (
dfu.bin
) will be created, which can be used later for flashing.
Additional information, including common errors and known issues, is available in this.