ESP32-C3 CAN'T Upload New Sketch After Previous Upload

Hopefully some of you experts can help me out here,
My Story (This Time)
OK, so after a long time away from Arduino I'm trying to get reacquainted. Got some ESP32-C3 Boards and was starting to get the hang of them with Arduino 2.3.2. I downloaded the ESP32-c3 PDF manual posted on the hardware section of the Arduino forums. copied a few simple code examples from that manual and ran them with no problem. From the Manual I copied and uploaded the following Code to my test board and ran it NOW I can not get anything else to
upload to the board. I'm thinking because the Baud rate for this code is set at 115200 then it is somehow blocking the IDE from changing the Baud to 92160 that it uses for uploading, but IDK. USB CDC On Boot on the toolbar IS Set to Enabled and I have held down the BOOT button while pressing the RESET button then releasing the Boot button as suggested when Serial is not working.
I DO have things set to ERASE All Flash Before Sketch Upload.
(CODE)

#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);}

(CODE END)

OUTPUT (Showing Error)
Sketch uses 234184 bytes (17%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13676 bytes (4%) of dynamic memory, leaving 314004 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM5
Connecting...
Chip is ESP32-C3 (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 64:e8:33:8a:d5:b0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
A fatal error occurred: No serial data received.
Failed uploading: uploading error: exit status 2

Hi @oldguy_47 ,

Sorry for the troubles..
Don't think this has anything to do with your code..
Could just be a bad cable/ loose connection??

I've also seen this error go away by using a slower upload speed which probably really again points to a weak cable but worth a try..

USB CDC On Boot, I got this disabled on my esp32s3 and I don't erase all flash..
Here's a pic of the settings I was using..

I've also heard about having to do the button presses but thought you had to do this just as it starts trying to upload??

good luck.. ~q

Hi qubits-us, Thanks for taking a look ad sharing your thoughts. I tried a number of things different USB cable, USB Port, Different Computer, Slowed Upload Speed. Even went to the Windows Device Manager and set the Baud for the connected Com port to match what Arduino had for an upload speed. Looks like I simply BRICKED that Board (probably damaged something inside the USB connector on the board, plugging and unplugging). I'm still hesitant to load that code on another one of those boards, I only bought five of them this time to try out.

Thanks Again, Happy Coding & Hacking

1 Like

Haha, did that with the first one, to try to get it back to factory default.
Did also wipe the USB port. :frowning:
If you see "ESP32S3 Dev Module" in the IDE behind the port, then I think you're still ok.
(yes, S3, not C3 as expected).

I only ever did the "release reset button before boot button" just before uploading.
But sometimes I have to open the serial monitor twice after an upload, or power-cycle the board.

I do have a while loop at the start of setup().

  Serial.begin(115200);
  while (!Serial); // soft USB

I have seen errors without this.
Leo..

@oldguy_47

I wouldn't give up on it yet, you could try erasing all flash with the esptool.exe.

esptool.exe should get installed with the esp32 board package so you should have it already.

It's easy and goes like this

Make sure there are no other microcontrollers connected to your PC

Open the Windows cmd prompt and type the following

esptool.exe --port COM5 --baud 921600 erase_flash

If you get the message "Chip erase completed successfully" open the Arduino IDE and see if you can compile and upload the blink.ino sketch

@sumguy
There is also an "Erase all flash before upload" option in the tools menu of the IDE.
But as said, it erases also the USB port if the ESP32 doesn't have a hardware serial<>USB chip.
(I am using the ESP32-C3 Super-Mini, with integrated-USB).

I'll be interested in a method to get the port back, but maybe I should open a new thread for that.
Leo..

@oldguy_47 ,
You know, I wonder..
Found this topic..
Maybe try, GPIO9 to ground, cycle power on board..
It's still lives, I think..

good luck.. ~q

Thanks @Wawa , I see how that is a problem, I am glad you mentioned it because I have some c3's from Seeed studio on the way and looking at their link

I should be able to re-flash the bootloader with factory firmware with a tool they provide.

If I ever got to that situation I would certainly try @qubits-us suggestion first though

I just accidentally revived my ESP32-C3 Super Mini. As said, I deleted all the flash.
But the USB port was still visible in (Win11) Device Manager.
There, in properties, I had the option to forcefully enable the port.
Win11 rebooted (without my permission). After that the ESP was back in the IDE.
Just ordered another dozen. Never know when I do something stupid again.
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.