Can't upload using native USB port on ESP32S2 and VS Code

lmagalhaes
Posts: 9
Joined: Tue Apr 07, 2020 4:20 pm

Can't upload using native USB port on ESP32S2 and VS Code

Postby lmagalhaes » Mon Apr 19, 2021 8:01 am

Hi there,

I have a ESP32S2 module on a custom PCB and I was already able to upload some code to the module. However, I was having trouble building new projects, so I reinstalled everything and now I can't upload the code to the module. I get this issue:

Executing task: d:\esp\.espressif\python_env\idf4.2_py3.8_env\Scripts\python.exe d:\esp-idf\components\esptool_py\esptool\esptool.py -p COM5 -b 460800 --after hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 wifi_softAP.bin <

esptool.py v3.0
Serial port COM5
Connecting...
Detecting chip type...
Traceback (most recent call last):
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 3969, in <module>
_main()
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 3962, in _main
main()
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 3541, in main
esp = ESPLoader.detect_chip(each_port, initial_baud, args.before, args.trace,
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 313, in detect_chip
chip_magic_value = detect_port.read_reg(ESPLoader.CHIP_DETECT_MAGIC_REG_ADDR)
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 562, in read_reg
val, data = self.command(self.ESP_READ_REG, struct.pack('<I', addr))
File "d:\esp-idf\components\esptool_py\esptool\esptool.py", line 402, in command
self._port.timeout = saved_timeout
File "D:\esp\.espressif\python_env\idf4.2_py3.8_env\lib\site-packages\serial\serialutil.py", line 372, in timeout
self._reconfigure_port()
File "D:\esp\.espressif\python_env\idf4.2_py3.8_env\lib\site-packages\serial\serialwin32.py", line 222, in _reconfigure_port
raise SerialException(
serial.serialutil.SerialException: Cannot configure port, something went wrong. Original message: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command d:\esp\.espressif\python_env\idf4.2_py3.8_env\Scripts\python.exe d:\esp-idf\components\esptool_py\esptool\esptool.py -p COM5 -b 460800 --after hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 wifi_softAP.bin" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Also, on the device manager, the ESP32S2 appears with a yellow triangle indicating some problem with the drivers. I'm using Windows 10 64 bits with the latest updates.

ESP_bignacio
Posts: 229
Joined: Wed May 02, 2018 12:12 pm

Re: Can't upload using native USB port on ESP32S2 and VS Code

Postby ESP_bignacio » Mon Apr 19, 2021 9:36 am

Make sure drivers are configured correctly as specified in https://docs.espressif.com/projects/esp ... ction.html

lmagalhaes
Posts: 9
Joined: Tue Apr 07, 2020 4:20 pm

Re: Can't upload using native USB port on ESP32S2 and VS Code

Postby lmagalhaes » Tue Apr 20, 2021 3:39 pm

It was a combination of using Zadig to fix the drivers to WinUSB and a folder with a space that was making the upload fail. It's working now, thank you.

svcguy
Posts: 4
Joined: Wed Oct 31, 2018 4:25 am

Re: Can't upload using native USB port on ESP32S2 and VS Code

Postby svcguy » Sun Jul 25, 2021 5:31 pm

Can you share details on your setup? I'm looking for a solution to getting ESP-IDF, the VSCode extension and an ESP32-S2 board to work with native USB-CDC. Is this possible?

Thanks,

andershedberg
Posts: 1
Joined: Sun Oct 24, 2021 1:54 pm

Re: Can't upload using native USB port on ESP32S2 and VS Code

Postby andershedberg » Sun Oct 24, 2021 2:02 pm

svcguy wrote:
Sun Jul 25, 2021 5:31 pm
Can you share details on your setup? I'm looking for a solution to getting ESP-IDF, the VSCode extension and an ESP32-S2 board to work with native USB-CDC. Is this possible?

Thanks,
Hi, yes, it is possible as I am using it right now. However - it's a nightmare to configure correctly and I need to resort to a simple demo project that I keep copying. Unfortunately it contains some stuff I can't share, so I will only answer the last question - From Visual studio - View->Command Palette "ESP-IDF: SDK Configuration Editor (menuconfig)"

Then search for "CDC" and you will see the following settings that you can enable, and then the console log will go through the native USB connector without needing to add code for it.

Code: Select all

Component config
Common ESP-related
Channel for console output

USB CDC
Size of USB CDC RX buffer
64

Enable esp_rom_printf / ESP_EARLY_LOG via USB CDC
For the first flashing of your program you need to add the special drivers as described by others and hold down the "boot" button while resetting. The comports number do changes between these two settings, which is annoying, but it do work.

Who is online

Users browsing this forum: No registered users and 23 guests