Troubleshooting
Flashing problems can be fiddly to troubleshoot. The underlying issue can be caused by the drivers, OS, hardware, or even a combination of these. If your board is a custom design, check the ESP Hardware Design Guidelines or consider using our free-of-charge schematic and PCB review service.
Try the following suggestions if your issues persist:
Bootloader Won’t Respond
If you see errors like “Failed to connect” then your chip is probably not entering the bootloader properly:
Check you are passing the correct serial port on the command line.
Check you have permissions to access the serial port, and other software (such as modem-manager on Linux) is not trying to interact with it. A common pitfall is leaving a serial terminal accessing this port open in another window and forgetting about it.
Check the chip is receiving 3.3V from a stable power source (see Insufficient Power for more details.)
Check that all pins are connected as described in Boot Mode Selection. Check the voltages at each pin with a multimeter, “high” pins should be close to 3.3V and “low” pins should be close to 0V.
If you have connected other devices to GPIO pins, try removing them and see if esptool starts working.
Try using a slower baud rate (
-b 9600
is a very slow value that you can use to verify it’s not a baud rate problem).
Writing to Flash Fails Part Way Through
If flashing fails with random errors part way through, retry with a lower baud rate.
Power stability problems may also cause this (see Insufficient Power.)
Writing to Flash Succeeds but Program Doesn’t Run
If esptool can flash your module with write_flash
but your program doesn’t run, check the following:
Wrong Flash Mode
Some devices only support the dio
flash mode. Writing to flash with qio
mode will succeed but the chip can’t read the flash back to run - so nothing happens on boot. Try passing the -fm dio
option to write_flash
.
See the SPI Flash Modes page for a full description of the flash modes and how to determine which ones are supported on your device.
Insufficient Power
The 3.3V power supply for the ESP chip has to supply large amounts of current (up to 70mA continuous, 200-300mA peak, might be slightly higher). You also need sufficient capacitance on the power circuit to meet large spikes of power demand.
Insufficient Capacitance
If you’re using a pre-made development board or module then the built-in power regulator & capacitors are usually good enough, provided the input power supply is adequate.
Note
This is not true for some very simple pin breakout modules - similar to this. These breakouts do not integrate enough capacitance to work reliably without additional components. Surface mount OEM modules like ESP-WROOM02 and ESP-WROOM32 require an external bulk capacitor on the PCB to be reliable, consult the module datasheet.
Power Supply Rating
It is possible to have a power supply that supplies enough current for the serial bootloader stage with esptool, but not enough for normal firmware operation. You may see the 3.3V VCC voltage droop down if you measure it with a multimeter, but you can have problems even if this isn’t happening.
Try swapping in a 3.3V supply with a higher current rating, add capacitors to the power line, and/or shorten any 3.3V power wires.
The 3.3V output from FTDI FT232R chips/adapters or Arduino boards do not supply sufficient current to power an ESP chip (it may seem to work sometimes, but it won’t work reliably). Other USB TTL/serial adapters may also be marginal.
Missing Bootloader
ESP-IDF and uses a small firmware bootloader program. The hardware bootloader in ROM loads this firmware bootloader from flash, and then it runs the program. On ESP32-C6, the bootloader image should be flashed by ESP-IDF at offset 0x0.
Refer to ESP-IDF documentation for details regarding which binaries need to be flashed at which offsets.
SPI Pins Which Must Be Disconnected
Compared to the ROM bootloader that esptool talks to, a running firmware uses more of the chip’s pins to access the SPI flash.
If you set “Quad I/O” mode (-fm qio
, the esptool default) then GPIOs 7, 8, 9 & 10 are used for reading the SPI flash and must be otherwise disconnected.
If you set “Dual I/O” mode (-fm dio
) then GPIOs 7 & 8 are used for reading the SPI flash and must be otherwise disconnected.
Try disconnecting anything from those pins (and/or swap to Dual I/O mode if you were previously using Quad I/O mode but want to attach things to GPIOs 9 & 10). Note that if GPIOs 9 & 10 are also connected to input pins on the SPI flash chip, they may still be unsuitable for use as general purpose I/O.
In addition to these pins, GPIOs 6 & 11 are also used to access the SPI flash (in all modes). However flashing will usually fail completely if these pins are connected incorrectly.
Early Stage Crash
Use any of serial terminal programs to view the boot log. (ESP32-C6 baud rate is 115200bps). See if the program is crashing during early startup or outputting an error message.
Issues and Debugging in USB-Serial/JTAG or USB-OTG modes
When working with ESP chips that implement a USB-Serial/JTAG or a USB-OTG console (you are not using a classic USB-to-Serial adapter), it’s essential to be aware of potential issues related to the loaded application interfering with or reprogramming the GPIO pins used for USB communication.
If the application accidentally reconfigures the USB peripheral pins or disables the USB peripheral, the device disappears from the system. You can also encounter unstable flashing or errors like OSError: [Errno 71] Protocol error
.
If that happens, try to manually enter the download mode and then use the erase_flash command to wipe the flash memory. Then, make sure to fix the issue in the application before flashing again.
On boards with two USB ports (usually marked as USB and UART), you can use the USB port for flashing while listening on the UART port for debugging purposes. This setup is useful for retrieving core dumps or the reset reason in the event of a crash. To implement this, connect the UART port to another instance of any of the serial terminal programs, while repeating the failing action over the USB port. You’ll be able to monitor the crash log without interference from the USB port used for communication or it disappearing due to a firmware crash. If your devkit doesn’t have a dedicated USB port connected to an on-board USB-to-UART bridge, you can use a separate adapter to connect to the UART pins on the board.
Serial Terminal Programs
There are many serial terminal programs suitable for debugging & serial interaction. The pySerial module (which is required for esptool
) includes one such command line terminal program - miniterm.py. For more details see the related pySerial documentation or run miniterm -h
.
For exact serial port configuration values, see Serial Port Settings.
Tracing Esptool Interactions
Running esptool.py --trace
will dump all serial interactions to the standard output (this is a lot of output). This can be helpful when debugging issues with the serial connection, or when providing information for bug reports.
See the related Advanced Topics page for more information.
Configuration File
Although esptool.py
has been tuned to work in the widest possible range of environments, an incompatible combination of hardware, OS, and drivers might cause it to fail. If you suspect this is the case, a custom configuration of internal variables might be necessary.
These variables and options can be specified in a configuration file. See the related Configuration File page for more information.
Common Errors
This is a non-exhaustive list of the most common esptool errors together with explanations of possible causes and fixes. Before reading any error-specific advice, it is highly recommended to go through all of the Troubleshooting section first.
No serial data received.
Esptool didn’t receive any byte of data or a successful slip packet. This error usually implies some kind of a hardware issue. This may be because the hardware is not working properly at all, the RX/TX serial lines are not connected, or because there is some problem with resetting into the download mode.
Wrong boot mode detected (0xXX)! The chip needs to be in download mode.
Communication with the chip works (the ROM boot log is detected), but it is not being reset into the download mode automatically.
To resolve this, check the autoreset circuitry (if your board has it), or try resetting into the download mode manually. See Manual Bootloader for instructions.
Download mode successfully detected, but getting no sync reply: The serial TX path seems to be down.
The chip successfully resets into the download mode and sends data to the host computer, but doesn’t receive any response sent by esptool
. This implies a problem with the TX line running from the host to the ESP device. Double-check your board or breadboard circuit for any problems.
Invalid head of packet (0xXX): Possible serial noise or corruption.
This error is usually caused by one of the following reasons:
Using bad quality USB cable.
Sometimes breadboards can short the SPI flash pins on the board and cause this kind of problem. Try removing your development board from the breadboard.
The chip might be browning out during flashing. FTDI chips’ internal 3.3V regulator is not enough to power an ESP, see Insufficient Power.
Other things to try:
Try to sync and communicate at a much lower baud rate, e.g.
esptool.py --baud 9600 ...
.Try tracing the interactions running
esptool.py --trace ...
and see if anything is received back at all.Try skipping chip autodetection by specifying the chip type, run
esptool.py --chip ESP32-C6 ...
.
If none of the above mentioned fixes help and your problem persists, please open a new issue.
A serial exception error occurred
esptool.py
uses the pySerial Python module for accessing the serial port.
If pySerial cannot operate normally, it raises an error and terminates.
An example of a pySerial error:
A serial exception error occurred: read failed: [Errno 6] Device not configured
Errors originating from pySerial are, therefore, not a problem with esptool.py
, but are usually caused by a problem with hardware or drivers.
Some of the most common pySerial error causes are:
The port is being already used by other software.
The port doesn’t exist.
The device gets unexpectedly disconnected.
The necessary serial port drivers are not installed or are faulty.
You don’t have permission to access the port.
On Linux, read and write access the serial port over USB is necessary. You can add your user to the dialout
or uucp
group to grant access to the serial port. See Adding user to dialout or uucp on Linux.