ESP32-C3 firmware update

s-light
Posts: 13
Joined: Mon Oct 29, 2018 6:50 pm

ESP32-C3 firmware update

Postby s-light » Tue Nov 02, 2021 7:08 pm

i currently research and think about the possibilities to initial flash and later update the firmware on an ESP32 based product.

from the price point i would like to use an ESP32-C3 and use the build in USB-port to flash & update firmware.
that indeed would save the USB2UART chip...
i can not go with the S2 as i need WiFi and Bluetooth.

but i did not find any tutorial / extended info if / how this is possible.
the only things i found: so i currently do not know if it is possible..

hope anybody can shine some light into this for me ;-)

sunny greetings
stefan
Last edited by s-light on Wed Nov 03, 2021 8:08 am, edited 1 time in total.

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

Re: ESP32-C3 firmware update

Postby ESP_Sprite » Wed Nov 03, 2021 2:51 am

The C3 has an USB device that effectively replaces an external USB-serial and USB-jtag chip; you should be able to use that to flash updates.

s-light
Posts: 13
Joined: Mon Oct 29, 2018 6:50 pm

Re: ESP32-C3 firmware update

Postby s-light » Wed Nov 03, 2021 7:53 am

thanks for the fast response!
do you have any pointers to some tutorials about this?
or can i try with the S2 tutorials?

i will try it as soon as i get my hands on an ESP32-C3 board :-)

sunny greetings
stefan

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

Re: ESP32-C3 firmware update

Postby ESP_Sprite » Thu Nov 04, 2021 7:29 am

It's not the same as USB in the S2, sorry. Once you have your board, you can try it by connecting the relevant GPIOs directly to an USB connector or cable.

PeterMikeSmooth3
Posts: 5
Joined: Wed Aug 31, 2022 10:07 am

Re: ESP32-C3 firmware update

Postby PeterMikeSmooth3 » Wed Aug 31, 2022 10:21 am

Hello !

I use ESP32-C3-DevKitM-1.

I flash without issue using the embedded CP2102 :

Code: Select all

/home/petermike/.arduino15/packages/esp32/tools/riscv32-esp-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/riscv32-esp-elf-size -A /tmp/arduino_build_61120/Blink.ino.elf
Sketch uses 217074 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 9948 bytes (3%) of dynamic memory, leaving 317732 bytes for local variables. Maximum is 327680 bytes.
python3 /home/petermike/.arduino15/packages/esp32/tools/esptool_py/3.3.0/esptool.py --chip esp32c3 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 /tmp/arduino_build_61120/Blink.ino.bootloader.bin 0x8000 /tmp/arduino_build_61120/Blink.ino.partitions.bin 0xe000 /home/petermike/.arduino15/packages/esp32/hardware/esp32/2.0.4/tools/partitions/boot_app0.bin 0x10000 /tmp/arduino_build_61120/Blink.ino.bin 
esptool.py v3.3-dev
Serial port /dev/ttyUSB1
Connecting....
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 10:91:a8:3a:23:a4
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
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 0x00047fff...
Flash params set to 0x022f
Compressed 12912 bytes to 9261...
Writing at 0x00000000... (100 %)
Wrote 12912 bytes (9261 compressed) at 0x00000000 in 0.4 seconds (effective 290.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 440.0 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 577.2 kbit/s)...
Hash of data verified.
Compressed 227104 bytes to 127799...
Writing at 0x00010000... (12 %)
Writing at 0x0001ab9c... (25 %)
Writing at 0x0002180b... (37 %)
Writing at 0x0002781c... (50 %)
Writing at 0x0002dc1b... (62 %)
Writing at 0x00033a5e... (75 %)
Writing at 0x0003b741... (87 %)
Writing at 0x000426bb... (100 %)
Wrote 227104 bytes (127799 compressed) at 0x00010000 in 3.6 seconds (effective 498.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Now I want to use the build-in USB Serial/JTAG

Connected USB like so :

19 : D+ (green)
18 : D- (white)
GND (black)
+5V (red)

Serial USB device detected once plugged :

Code: Select all

[14538.348726] usb 3-2.1: new full-speed USB device number 25 using xhci_hcd
[14538.450014] usb 3-2.1: New USB device found, idVendor=067b, idProduct=2303
[14538.450021] usb 3-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[14538.450024] usb 3-2.1: Product: USB-Serial Controller
[14538.450028] usb 3-2.1: Manufacturer: Prolific Technology Inc.
[14538.507505] usbcore: registered new interface driver pl2303
[14538.507532] usbserial: USB Serial support registered for pl2303
[14538.507574] pl2303 3-2.1:1.0: pl2303 converter detected
[14538.509036] usb 3-2.1: pl2303 converter now attached to ttyUSB0
Here is my Arduino board config :
Board : ESP32C3 Dev Module
Upload Speed : 921600
USB CDC On Boot: "Disabled"
CPU Frequency : 160 Mhz (Wifi)
Flash Frequency : 80 Mhz
Flash mode : "QIO"


But when trying to flash though the build-in USB Serial/JTAG I get the following error :

Code: Select all

Sketch uses 217074 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 9948 bytes (3%) of dynamic memory, leaving 317732 bytes for local variables. Maximum is 327680 bytes.
python3 /home/petermike/.arduino15/packages/esp32/tools/esptool_py/3.3.0/esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 /tmp/arduino_build_61120/Blink.ino.bootloader.bin 0x8000 /tmp/arduino_build_61120/Blink.ino.partitions.bin 0xe000 /home/petermike/.arduino15/packages/esp32/hardware/esp32/2.0.4/tools/partitions/boot_app0.bin 0x10000 /tmp/arduino_build_61120/Blink.ino.bin 
esptool.py v3.3-dev
Serial port /dev/ttyUSB0
Connecting......................................

A fatal error occurred: Failed to connect to ESP32-C3: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
the selected serial port For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
 does not exist or your board is not connected
Any idea what could cause that ?

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

Re: ESP32-C3 firmware update

Postby ESP_Sprite » Thu Sep 01, 2022 1:05 am

PeterMikeSmooth3 wrote:
Wed Aug 31, 2022 10:21 am
Serial USB device detected once plugged :

Code: Select all

[14538.348726] usb 3-2.1: new full-speed USB device number 25 using xhci_hcd
[14538.450014] usb 3-2.1: New USB device found, idVendor=067b, idProduct=2303
[14538.450021] usb 3-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[14538.450024] usb 3-2.1: Product: USB-Serial Controller
[14538.450028] usb 3-2.1: Manufacturer: Prolific Technology Inc.
[14538.507505] usbcore: registered new interface driver pl2303
[14538.507532] usbserial: USB Serial support registered for pl2303
[14538.507574] pl2303 3-2.1:1.0: pl2303 converter detected
[14538.509036] usb 3-2.1: pl2303 converter now attached to ttyUSB0
That is not the USB-serial-JTAG device. The USB-serial-JTAG device plugin looks something like this:

Code: Select all

[240881.602296] usb 3-1.4: new full-speed USB device number 65 using xhci_hcd
[240881.625327] usb 3-1.4: New USB device found, idVendor=303a, idProduct=1001, bcdDevice= 1.01
[240881.625336] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[240881.625339] usb 3-1.4: Product: USB JTAG/serial debug unit
[240881.625342] usb 3-1.4: Manufacturer: Espressif
[240881.625344] usb 3-1.4: SerialNumber: aa:bb:cc:xx:yy:zz
[240881.639920] cdc_acm 3-1.4:1.0: ttyACM0: USB ACM device
Also note that it shows up as /dev/ttyACM0, not /dev/ttyUSB0.

axellin
Posts: 197
Joined: Mon Sep 17, 2018 9:09 am

Re: ESP32-C3 firmware update

Postby axellin » Thu Sep 01, 2022 1:30 am

ESP_Sprite wrote:
Wed Nov 03, 2021 2:51 am
The C3 has an USB device that effectively replaces an external USB-serial and USB-jtag chip; you should be able to use that to flash updates.
https://github.com/espressif/esp-idf/issues/8507

PeterMikeSmooth3
Posts: 5
Joined: Wed Aug 31, 2022 10:07 am

Re: ESP32-C3 firmware update

Postby PeterMikeSmooth3 » Thu Sep 01, 2022 11:14 am

That is not the USB-serial-JTAG device. The USB-serial-JTAG device plugin looks something like this:

Code: Select all

[240881.602296] usb 3-1.4: new full-speed USB device number 65 using xhci_hcd
[240881.625327] usb 3-1.4: New USB device found, idVendor=303a, idProduct=1001, bcdDevice= 1.01
[240881.625336] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[240881.625339] usb 3-1.4: Product: USB JTAG/serial debug unit
[240881.625342] usb 3-1.4: Manufacturer: Espressif
[240881.625344] usb 3-1.4: SerialNumber: aa:bb:cc:xx:yy:zz
[240881.639920] cdc_acm 3-1.4:1.0: ttyACM0: USB ACM device
The USB I cut and soldered to the DevKit had a built-in PL2303, haha :D

I cut and soldered an other USB cable (tried with 2 cables actually). But that time I get the following :

Code: Select all

[11262.330078] usb 3-2.1: new full-speed USB device number 28 using xhci_hcd
[11262.409997] usb 3-2.1: device descriptor read/64, error -32
[11262.598075] usb 3-2.1: device descriptor read/64, error -32
[11262.786022] usb 3-2.1: new full-speed USB device number 29 using xhci_hcd
[11262.865985] usb 3-2.1: device descriptor read/64, error -32
[11263.054000] usb 3-2.1: device descriptor read/64, error -32
[11263.162052] usb 3-2-port1: attempt power cycle
[11265.401995] usb 3-2.1: new full-speed USB device number 31 using xhci_hcd
[11265.481998] usb 3-2.1: device descriptor read/64, error -32
[11265.670001] usb 3-2.1: device descriptor read/64, error -32
[11265.857977] usb 3-2.1: new full-speed USB device number 32 using xhci_hcd
[11265.941981] usb 3-2.1: device descriptor read/64, error -32
[11266.129999] usb 3-2.1: device descriptor read/64, error -32
[11266.238039] usb 3-2-port1: attempt power cycle
[11267.505894] usb 3-2.1: new full-speed USB device number 33 using xhci_hcd
[11267.506054] usb 3-2.1: Device not responding to setup address.
[11267.714086] usb 3-2.1: Device not responding to setup address.
[11267.921913] usb 3-2.1: device not accepting address 33, error -71
[11268.001915] usb 3-2.1: new full-speed USB device number 34 using xhci_hcd
[11268.002078] usb 3-2.1: Device not responding to setup address.
[11268.210039] usb 3-2.1: Device not responding to setup address.
[11268.417898] usb 3-2.1: device not accepting address 34, error -71
[11268.418049] usb 3-2-port1: unable to enumerate USB device

Any Idea what could it be ?

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

Re: ESP32-C3 firmware update

Postby ESP_Sprite » Fri Sep 02, 2022 12:29 am

Can you manually force the C3 into download mode (pull GPIO9 low and reset the chip), see if it detects it then?

PeterMikeSmooth3
Posts: 5
Joined: Wed Aug 31, 2022 10:07 am

Re: ESP32-C3 firmware update

Postby PeterMikeSmooth3 » Fri Sep 23, 2022 6:12 pm

ESP_Sprite wrote:
Fri Sep 02, 2022 12:29 am
Can you manually force the C3 into download mode (pull GPIO9 low and reset the chip), see if it detects it then?
It does work then !

Code: Select all

[35265.501975] usb 3-2.3: USB disconnect, device number 39
[35265.799982] usb 3-2.3: new full-speed USB device number 40 using xhci_hcd
[35265.883932] usb 3-2.3: device descriptor read/64, error -32
[35266.071926] usb 3-2.3: device descriptor read/64, error -32
[35266.259962] usb 3-2.3: new full-speed USB device number 41 using xhci_hcd
[35266.339989] usb 3-2.3: device descriptor read/64, error -32
[35266.527943] usb 3-2.3: device descriptor read/64, error -32
[35266.636044] usb 3-2-port3: attempt power cycle
[35268.795922] usb 3-2.3: new full-speed USB device number 43 using xhci_hcd
[35268.875885] usb 3-2.3: device descriptor read/64, error -32
[35269.063945] usb 3-2.3: device descriptor read/64, error -32
[35269.251916] usb 3-2.3: new full-speed USB device number 44 using xhci_hcd
[35269.331930] usb 3-2.3: device descriptor read/64, error -32
[35269.519936] usb 3-2.3: device descriptor read/64, error -32
[35269.628019] usb 3-2-port3: attempt power cycle
[35270.479833] usb 3-2.3: new full-speed USB device number 45 using xhci_hcd
[35270.479968] usb 3-2.3: Device not responding to setup address.
[35270.687935] usb 3-2.3: Device not responding to setup address.
[35270.895879] usb 3-2.3: device not accepting address 45, error -71
[35270.975845] usb 3-2.3: new full-speed USB device number 46 using xhci_hcd
[35270.975932] usb 3-2.3: Device not responding to setup address.
[35271.183897] usb 3-2.3: Device not responding to setup address.
[35271.391821] usb 3-2.3: device not accepting address 46, error -71
[35271.391944] usb 3-2-port3: unable to enumerate USB device
[35276.987789] usb 3-2.3: new full-speed USB device number 47 using xhci_hcd
[35277.089483] usb 3-2.3: New USB device found, idVendor=303a, idProduct=1001
[35277.089490] usb 3-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[35277.089494] usb 3-2.3: Product: USB JTAG/serial debug unit
[35277.089497] usb 3-2.3: Manufacturer: Espressif
[35277.089500] usb 3-2.3: SerialNumber: 10:91:A8:3A:23:A4
[35277.090778] cdc_acm 3-2.3:1.0: ttyACM0: USB ACM device
[35278.557874] usb 3-2.3: USB disconnect, device number 47
[35279.291749] usb 3-2.3: new full-speed USB device number 48 using xhci_hcd
[35279.393406] usb 3-2.3: New USB device found, idVendor=303a, idProduct=1001
[35279.393413] usb 3-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[35279.393417] usb 3-2.3: Product: USB JTAG/serial debug unit
[35279.393421] usb 3-2.3: Manufacturer: Espressif
[35279.393424] usb 3-2.3: SerialNumber: 10:91:A8:3A:23:A4
[35279.394323] cdc_acm 3-2.3:1.0: ttyACM0: USB ACM device
What is interesting is that when I tried with an other DevKitM-1 v1.0 it work all the time : I mean, I never get "device descriptor read/64, error -32".

Any idea what could cause that difference ? Could it some high Z unconnected pins that change the state of the chip ?

I'd like to use that feature on my design, but I'm afraid to get a "device descriptor read/64, error -32" on some product. Especially if I don't want to include push buttons to pull GPIO9 low and reset the chip. What do you think ?

Thank you !

Who is online

Users browsing this forum: No registered users and 59 guests