Description
Board
ESP32-C3 dev board
Device Description
espressif ESP32-C3 devKitC-02-v1.1
Hardware Configuration
raw USB cable on pins 18, 19, 5V and gnd
Version
latest master
IDE Name
Arduino IDE
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
native
Description
A plain blink/serial print sketch will print to the usb native CDC port just fine.
Running anything with WiFi such as the Wifiscan example distributed with esp core, causes the USB CDC to disconnect and no longer enumerate until a hard reset
both blink/serial and wifiscan work ok if using the usb to serial CP2012n converter port.
Sketch
Working just fine either native or usb-serial port:
int led = 4;
void setup() {
Serial.begin(115200);
pinMode(led, OUTPUT);
}
int i=0;
void loop() {
Serial.printf("hello %d!\n\r", i++);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for a second
}
Works only when using the cp2102n-usb-serial port. when enabling built in CDC on boot, USB port disappears once scan start:
/*
* This sketch demonstrates how to scan WiFi networks.
* The API is almost the same as with the WiFi Shield library,
* the most obvious difference being the different file you need to include:
*/
#include "WiFi.h"
void setup()
{
Serial.begin(115200);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
}
void loop()
{
Serial.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(5000);
}
Debug Message
monitoring the uart output when USB CDC on Boot is enabled, shows the core is still running, just USB task no longer active:
23:00:27.558 -> ESP-ROM:esp32c3-api1-20210207
23:00:27.558 -> Build:Feb 7 2021
23:00:27.558 -> rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
23:00:27.558 -> SPIWP:0xee
23:00:27.558 -> mode:DIO, clock div:1
23:00:27.558 -> load:0x3fcd6100,len:0x38c
23:00:27.558 -> load:0x403ce000,len:0x6a8
23:00:27.558 -> load:0x403d0000,len:0x2370
23:00:27.558 -> SHA-256 comparison failed:
23:00:27.605 -> Calculated: 912c8ece44dc10c27ac7d0fbc21c881181838b5f87f42e05d6797a997e755775
23:00:27.605 -> Expected: e48257ed72b4ed90fbd1c7429f3866f76aab94952c8871b8e364f6e503cebde8
23:00:27.605 -> Attempting to boot anyway...
23:00:27.605 -> entry 0x403ce000
23:00:27.749 -> [ 170][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 0 - WIFI_READY
23:00:27.749 -> [ 209][V][WiFiGeneric.cpp:272] _arduino_event_cb(): STA Started
23:00:27.796 -> [ 210][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 2 - STA_START
23:00:30.681 -> [ 3135][V][WiFiGeneric.cpp:306] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 10
23:00:30.681 -> [ 3136][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 1 - SCAN_DONE
...
last message on usb CDC before disappearing is
23:04:22.557 -> [ 5170][D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 0 - WIFI_READY
Other Steps to Reproduce
running micropython on an esp32-c3 with no cp2102n (only native usb cdc), wifi scan works just fine so it does not appear to be a hardware issue.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
me-no-dev commentedon Feb 12, 2022
@Spritetm PTAL :)
dronecz commentedon Feb 14, 2022
I have same issue with support >2.0.0 . It is working in 2.0.0 . I tried WiFiScan & WiFiClientBasic sketch in Arduino 1.8.13 and 1.8.19
Here is USB info when I´m not using WiFi:

and here is when I´m using WiFi:
.
ladyada commentedon Feb 14, 2022
oh good idea, yes i can verify it works in 2.0.0
me-no-dev commentedon Feb 15, 2022
We are looking into the issue. I hope to have results by tomorrow
Spritetm commentedon Feb 15, 2022
Looks like it's an ESP-IDF (4.4) issue. Long story short: ESP-IDF disables the USB PHY when WiFi is started if it thinks it's not being used, as it has a very slight impact (-1dB or so) on three of the WiFi channels. It seems it's a bit too pro-active on that, and it also disables it when the USB-serial-JTAG device is selected as a secondary console, which it is in the Arduino default setup. This, as the meme goes, kills the USB.
We'll get this fixed in ESP-IDF. Meanwhile, here's a workaround you can use:
Fix CDC+JTAG is disabled when WiFi is used on ESP32-C3
Fix CDC+JTAG is disabled when WiFi is used on ESP32-C3
me-no-dev commentedon Feb 15, 2022
Could you please try #6287 and see if that fixes the issue? cc @Jason2866
24 remaining items