A fatal error occurred: The chip stopped responding. *** [upload] Error 2

Hard time for uploading!

Can’t finish uploading to ESP32-WROOM-32!

A couple of years ago I’ve used this same device successfully. Now I can’t anymore!

What might be wrong?

Thank you.
Regards,
Ciro.

Serial port /dev/cu.SLAB_USBtoUART
Connecting..........
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:62:ab:dc:a9:38
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00058fff...
Compressed 17536 bytes to 12202...
Writing at 0x00001000... (100 %)
Traceback (most recent call last):
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 1032, in _main
    main()
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 832, in main
    operation_func(esp, args)
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/cmds.py", line 586, in write_flash
    esp.flash_defl_block(block, seq, timeout=timeout)
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 131, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 1030, in flash_defl_block
    self.check_command(
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 435, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 404, in command
    p = self.read()
        ^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 337, in read
    return next(self._slip_reader)
           ^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

A fatal error occurred: The chip stopped responding.
*** [upload] Error 2
=================================================== [FAILED] Took 15.96 seconds ===================================================

Try a chip erase:

image

Hello, @sivar2311 .

I’ve tried it and it has worked fine:

(...)
Looking for serial port...
Using manually specified: /dev/cu.SLAB_USBtoUART
Erasing...
esptool.py v4.5.1
Serial port /dev/cu.SLAB_USBtoUART
Connecting........
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:62:ab:dc:a9:38
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 14.0s
Hard resetting via RTS pin...
================================================== [SUCCESS] Took 19.34 seconds ==================================================

But with regard of flashing the new code, no results yet!

I’ve also placed an external 3V3 power supply to the board in order to guarantee the voltage stability during the flashing. Also, no results yet.

I recal these boards have some trick to enable flashing. Something like EN pin must be grounded the recover from reset. I’m trying to keep RST and BOOT buttons pressed, releasing RST first and then BOOT while the terminal says:

esptool.py v4.5.1
Serial port /dev/cu.SLAB_USBtoUART
Connecting...................

But it has also been unsuccessful!

esptool.py v4.5.1
Serial port /dev/cu.SLAB_USBtoUART
Connecting........
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:62:ab:dc:a9:38
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 13.7s
Hard resetting via RTS pin...
================================================== [SUCCESS] Took 18.94 seconds ==================================================

Thank you.
Regards,
Ciro

You might need to press and hold the BOOT button until the upload starts.
Some ESP32 boards lack a capacitor to enter the automatic upload mode.

A small 10uF capacitor between EN and GND helps here:

I don’t have now a 10µF. Instead, I’ve placed a 100µF, as well as an auxiliar power supply for 3V3. Didn’t work as well.

Hasn’t worked as well!

One more mistery in this project…

Which ESP32-Dev board do you have exactly?

A popular 38-pin dev. ESP-WROMM-32.

I can’t upload its picture now from the cell phone. I can send you later.

Open the serial monitor @ 115200 baud.
Press and hold the BOOT button, then press the RST button and release the BOOT button.

You should see in the serial monitor:

rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download

Now the ESP is in download mode.

Make sure nothing is connected to the strapping pins (GPIOs: 0, 2, 4, 5, 12, 15)
See Boot Mode Selection - ESP32 - — esptool.py latest documentation

Hello Boris.
How do you do?

So far, I’ve been using the ports reserved for TFT display only, which are:

| GPIO5	  | VSPI SS  	  |  TFT_CS    | J2-03 |
| GPIO18  | VSPI SCK  	  |  TFT_SCLK  | J2-07 |
| GPIO23  | VSPI MOSI	  |  TFT_MOSI  | J2-06 |
| GPIO33  | DO 33         | TFT_DC     | J2-05 |

For this reason, I’ve tried it with GPIO 5 connected to TFT, as well as disconnected. The results have been the same.

By simply watching the serial interface, I can read continuously this:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

After pressing BOOT button only:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download

And it stops sending messages.

Just after pressing RST button only, there appears once:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

And then it continues showing sequentially:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

By pressing and holding BOOT button, then RST Button, it stops sending messages after:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
ets Jun  8 2016 00:22:57

Then, after releasing BOOT only, no new message is received.
Further, after releasing RST button, there appears this message once:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

Then it continues showing this message sequentially:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

This is expected behavior when no firmware is present on the chip.

That message says, that the chip is now in download mode and waits for a new firmware.
At this point you should be able to upload your firmware.

Click the upload button to upload your firmware. What happens?

I recommend to do this step by step and keep it as simple as possible:

  • Disconnect everything from your ESP32.
  • Use a simple “Hello world” sketch. Nothing complicated like dealing with a display, motors or something else.

Good Morning Boris.
How do you do?

Did it!

#include <Arduino.h>
void setup() {
  delay(200);
  Serial.begin(/*baud rate*/115200, /*config*/134217756U, /*rxPin*/3, /*txPin*/1);
  delay(200);
  Serial.print("Hello World\n");
}
void loop() {
Serial.printf("Elapsed time: %lu s\n", millis()/1000);
delay(1000);
}

But:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20014.231204 (2.0.14) 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-mkfatfs @ 2.0.1 
 - tool-mklittlefs @ 1.203.210628 (2.3) 
 - tool-mkspiffs @ 2.230.0 (2.30) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.5% (used 21408 bytes from 327680 bytes)
Flash: [==        ]  20.1% (used 263901 bytes from 1310720 bytes)
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...
Using manually specified: /dev/cu.SLAB_USBtoUART
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v4.5.1
Serial port /dev/cu.SLAB_USBtoUART
Connecting................
Chip is ESP32-D0WDQ6 (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 24:62:ab:dc:a9:38
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00050fff...
Compressed 17536 bytes to 12202...
Writing at 0x00001000... (100 %)
Traceback (most recent call last):
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 1032, in _main
    main()
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 832, in main
    operation_func(esp, args)
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/cmds.py", line 586, in write_flash
    esp.flash_defl_block(block, seq, timeout=timeout)
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 131, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 1030, in flash_defl_block
    self.check_command(
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 435, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 404, in command
    p = self.read()
        ^^^^^^^^^^^
  File "/Users/cirobruno/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 337, in read
    return next(self._slip_reader)
           ^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

A fatal error occurred: The chip stopped responding.
*** [upload] Error 2
=================================================== [FAILED] Took 17.93 seconds ===================================================

I guess I’ll have to reinstall device’s bootloader or order a new board!

What do you think?

Thank you.
Regards,
Ciro.

That is the bootloader.

Usually it continues with

Wrote 17536 bytes (12202 compressed) at 0x00001000 in 0.6 seconds (effective 220.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 178.2 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 476.9 kbit/s)...
Hash of data verified.
Compressed 266256 bytes to 147693...
Writing at 0x00010000... (10 %)
Writing at 0x0001c4b5... (20 %)
Writing at 0x00024bc8... (30 %)
Writing at 0x00029cef... (40 %)
Writing at 0x0002f20b... (50 %)
Writing at 0x00034950... (60 %)
Writing at 0x0003dd06... (70 %)
Writing at 0x00045fbe... (80 %)
Writing at 0x0004b4b8... (90 %)
Writing at 0x00050ee0... (100 %)
Wrote 266256 bytes (147693 compressed) at 0x00010000 in 4.1 seconds (effective 524.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

I’m afraid the flash chip of your ESP32 seems to be broken.

It’s possible. Nevertheless it has been erased successfully.

I’ve already ordered new boards. They’ll be here tomorrow by the evening.

Thank you!

There must be something very wrong here.

Now I’m trying to upload a simple code to an Arduino Nano 328. I’ve already tried it in VSCode in Mac OS environment as well as in VSCode in Windows environment!

The result is the same: the firmware won’t upload!

Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR (5.0.0) > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr @ 5.2.0
 - tool-avrdude @ 1.60300.200527 (6.3.0)
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\nanoatmega328\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.0% (used 226 bytes from 2048 bytes)
Flash: [=         ]   6.3% (used 1934 bytes from 30720 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Using manually specified: COM5
Uploading .pio\build\nanoatmega328\firmware.hex
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x60
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x66
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x9e
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x1e
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x06
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x06
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x9e
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x06
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x66
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x06

avrdude done.  Thank you.

*** [upload] Error 1
===================================== [FAILED] Took 5.65 seconds =====================================

Using the same code, it compiles and is successfully uploaded to the device via Arduino IDE for Windows, but not in Arduino IDE for Mac OS!

So you have the following situtation?

MacOS Windows
ArduinoIDE No Yes
PlatformIO No No

Questions:

  • Does Windows run natively on a PC or is it emulated on your Mac?
  • Does MacOS require permissions to access serial port?

That’s it.

My Windows runs under Parallels virtual machine.

Yes. Parallels allows the choice between Mac and Windows, when it’s running.

I’ve been using this configuration for more than 10 years and I’ve never had troubles with ports so far.

These two devices (Nano and ESP32) have already been flashed in this same computer before.

Which ArduinoIDE version is it (1.8x or 2.x)? Maybe the permission must be refreshed during some updates. Unfortunately I am not familiar with MacOS and or VMs running on a Mac.

Interestingly the ArduinoIDE also fails under your MacOS. So platformio can be rouled out.

I don’t think so. It doesn’t work in Windows!

Mac OS:

  • Arduino IDE 2.1.1
  • VSCode 1.85.2
  • PlatformIO Core 6.1.14, Home 3.4.4

Windows:

  • Arduino 2.3.2
  • VSCode 1.87.2 (user setup) … what would there “user setup” mean?
  • PlatformIO Core 6.1.14, Home 3.4.4

I really don’t know what it is!

Would this message have any relation to this problem? It uses to appear every time I open VS Code:

[cmake] -- The CXX compiler identification is unknown
[cmake] CMake Error in CMakeLists.txt:
[cmake]   The CMAKE_C_COMPILER:
[cmake] 
[cmake]     /Library/Developer/CommandLineTools/usr/bin/cc
[cmake] 
[cmake]   is not a full path to an existing compiler tool.
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
[cmake]   the compiler, or to the compiler name if it is in the PATH.
[cmake] 
[cmake] 
[cmake] CMake Error in CMakeLists.txt:
[cmake]   The CMAKE_CXX_COMPILER:
[cmake] 
[cmake]     /Library/Developer/CommandLineTools/usr/bin/c++
[cmake] 
[cmake]   is not a full path to an existing compiler tool.
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
[cmake]   to the compiler, or to the compiler name if it is in the PATH.
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "/Users/cirobruno/Documents/PlatformIO/Projects/Teste_ESP-IDF_01/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "/Users/cirobruno/Documents/PlatformIO/Projects/Teste_ESP-IDF_01/build/CMakeFiles/CMakeError.log".
[proc] O comando: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S/Users/cirobruno/Documents/PlatformIO/Projects/Teste_ESP-IDF_01 -B/Users/cirobruno/Documents/PlatformIO/Projects/Teste_ESP-IDF_01/build -G Ninja saiu com o código: 1

Thank you.
Best regards,
Ciro.

This looks like an IDF Project!?!

Do you have multiple projects open in VS Code?