ESP32C3 keep resetting and not able to be successfully flashed via USB CDC

zjustin
Posts: 18
Joined: Wed Jun 03, 2020 6:00 am

ESP32C3 keep resetting and not able to be successfully flashed via USB CDC

Postby zjustin » Mon Jan 30, 2023 2:35 pm

I am using ESP32C3, my whole board is working fine.
Now I am trying to switch to USB CDC for most of the development and flashing .
While, it is perfectly okay via normal serial connection. the USB CDC seems to be less reliable.

below is one of the issue I notice a couple of times.

USB CDC flashing of firmware seems to be sometime not really successful , even though the esp tool script shows that is done properly at 100% and then reset successfully.
but then I found the board is actually keep on resetting by itself. see below screen shot
photo_2023-01-30_22-14-15.jpg
photo_2023-01-30_22-14-15.jpg (115.81 KiB) Viewed 3062 times
So I tried to use USB CDC to flash it again, but then it will always fail at 13-15% , it seems that during the flashing of firmware halfway, the device goes reset again, so the USB CDC connection lost. However, if I switch to serial connection to flash the device use a real FTDI connector, it will work fine again. after which, I can again enable CDC and flash via CDC normally.
may I know if anyone encounter this ?
"/Users/arduino_dev1/Library/Arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool" --chip esp32c3 --port "/dev/cu.usbmodem1101" --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 "/private/var/folders/ls/rxbwzr2952n2f074glgnd4ch0000gr/T/arduino-sketch-76728B121972EF8B94861C5A6BFA9059/tackfw_v3.ino.bootloader.bin" 0x8000 "/private/var/folders/ls/rxbwzr2952n2f074glgnd4ch0000gr/T/arduino-sketch-76728B121972EF8B94861C5A6BFA9059/tackfw_v3.ino.partitions.bin" 0xe000 "/Users/arduino_dev1/Library/Arduino15/packages/esp32/hardware/esp32/2.0.6/tools/partitions/boot_app0.bin" 0x10000 "/private/var/folders/ls/rxbwzr2952n2f074glgnd4ch0000gr/T/arduino-sketch-76728B121972EF8B94861C5A6BFA9059/tackfw_v3.ino.bin"
esptool.py v4.2.1
Serial port /dev/cu.usbmodem1101
Connecting...
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 34:b4:72:e8:36:18
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x001fafff...
Compressed 12944 bytes to 9310...
Writing at 0x00000000... (100 %)
Wrote 12944 bytes (9310 compressed) at 0x00000000 in 0.3 seconds (effective 331.9 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 433.1 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 525.1 kbit/s)...
Hash of data verified.
Compressed 2008624 bytes to 1110539...
Writing at 0x00010000... (1 %)
Writing at 0x0001b164... (2 %)
Writing at 0x00028dc3... (4 %)
Writing at 0x00034ec4... (5 %)
Writing at 0x0004215d... (7 %)
Writing at 0x0004eedf... (8 %)
Writing at 0x000597ea... (10 %)
Writing at 0x000656b6... (11 %)
Writing at 0x000707c4... (13 %)
Writing at 0x0007b4f8... (14 %)
Traceback (most recent call last):
File "serial/serialposix.py", line 575, in read
OSError: [Errno 6] Device not configured

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool/loader.py", line 375, in command
File "esptool/loader.py", line 307, in read
File "esptool/loader.py", line 1402, in slip_reader
File "serial/serialposix.py", line 581, in read
serial.serialutil.SerialException: read failed: [Errno 6] Device not configured

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "serial/serialposix.py", line 398, in _reconfigure_port
termios.error: (6, 'Device not configured')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "esptool.py", line 34, in <module>
File "esptool/__init__.py", line 1004, in _main
File "esptool/__init__.py", line 806, in main
File "esptool/cmds.py", line 502, in write_flash
File "esptool/loader.py", line 108, in inner
File "esptool/loader.py", line 963, in flash_defl_block
File "esptool/loader.py", line 406, in check_command
File "esptool/loader.py", line 393, in command
File "serial/serialutil.py", line 372, in timeout
File "serial/serialposix.py", line 401, in _reconfigure_port
serial.serialutil.SerialException: Could not configure port: (6, 'Device not configured')
[86605] Failed to execute script 'esptool' due to unhandled exception!
Failed uploading: uploading error: exit status 1

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32C3 keep resetting and not able to be successfully flashed via USB CDC

Postby ESP_Sprite » Tue Jan 31, 2023 9:10 am

It's a known issue that is resolved in the latest main esptool.py, but that hasn't tricked down to Arduino yet. Effectively, with the version of esptool you're using, if the firmware is corrupted it's not possible to upload new firmware if it's larger than a certain size. The workaround would be to manually put the ESP32C3 into download mode by shorting IO9 to ground while resetting; that allows you to flash firmware normally again.

Who is online

Users browsing this forum: No registered users and 140 guests