1
\$\begingroup\$

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
\$\endgroup\$
2
  • 2
    \$\begingroup\$ Which pins are you using for I2C? \$\endgroup\$
    – Polynomial
    Commented Nov 15, 2022 at 18:06
  • \$\begingroup\$ Its was GPIO 2 and 0 for SDA and SCL respectively. \$\endgroup\$
    – Neil
    Commented Nov 15, 2022 at 19:54

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Yes, that worked for me. I have now changed the I2C pins to GPIO 17 & 5 and the program uploads without any issues. \$\endgroup\$
    – Neil
    Commented Nov 17, 2022 at 18:11
1
\$\begingroup\$

Is the flash chip connected to I2C? Connecting the sensor might introduce sufficient capacitance to the bus that the communication to the flash chip is unreliable, or they share an address and conflict on the bus.

You can try looking at the I2C bus while programming with and without the sensor connected with a logic analyzer or an oscilloscope to see if there are issues.

If it is that, you can try reducing the pull up resistors on the SDA and SCL lines to try and get the rise times to be compliant with allowable rise times for the flash chip/sensors

\$\endgroup\$
1
  • \$\begingroup\$ Stick to the scope. The logic analyzer will hide the details of signal integrity. \$\endgroup\$
    – Aaron
    Commented Nov 15, 2022 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.