ESP32 – Firmware Upload Failure Troubleshooting

esp32sensor

I am fairly new to the ESP32 IDF programming environment. Whenever I compile and upload my firmware to the ESP32 board which has no other connections, it works fine. But when I connect an I2C based sensor to my ESP32 development board and try to upload, I get the following error.

Initially I thought it was the sensor, so I tried different I2C sensors and it gives me the same error. I am trying to understand what causes this error and how do I solve it.

Linking .pio\build\heltec_wifi_kit_32\firmware.elf
Retrieving maximum program size .pio\build\heltec_wifi_kit_32\firmware.elf
Checking size .pio\build\heltec_wifi_kit_32\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.7% (used 11988 bytes from 327680 bytes)
Flash: [==        ]  23.8% (used 249549 bytes from 1048576 bytes)
Building .pio\build\heltec_wifi_kit_32\firmware.bin
esptool.py v3.3
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM5
Uploading .pio\build\heltec_wifi_kit_32\firmware.bin
esptool.py v3.3
Serial port COM5
Connecting....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 26MHz
MAC: 7c:9e:bd:5b:52:ec
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
WARNING: Failed to communicate with the flash chip, read/write operations will fail. Try checking the chip connections or removing any other hardware connected to IOs.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x0004dfff...
Compressed 25264 bytes to 15799...
Writing at 0x00001000... (100 %)

A fatal error occurred: Serial data stream stopped: Possible serial noise or corruption.
*** [upload] Error 2

Best Answer

You've put your I2C lines on pins 0 and 2.

I2C requires pullups, which means these pins are being pulled up to VCC at boot.

Both pins 0 and 2 must be low to enter flashing mode.

Put your I2C on different GPIOs and it should just work.

Related Topic