Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32-S3-DevKitC-1-N16R8V does not restart after unplugging #8322

Closed
1 task done
ReyWamba opened this issue Jun 16, 2023 · 9 comments
Closed
1 task done

ESP32-S3-DevKitC-1-N16R8V does not restart after unplugging #8322

ReyWamba opened this issue Jun 16, 2023 · 9 comments
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@ReyWamba
Copy link

Board

ESP32-S3-DevKitC-1-N16R8V

Device Description

Nothing attached.

Hardware Configuration

Nothing attached.

Version

v2.0.9

IDE Name

PlatformIO

Operating System

Windows 10, Macos Ventura 13.4

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

I can upload and monitor sketches on my device in both Plarformio and Arduino IDEs, by opening the corresponding port. However, when I disconnect the device, and reconnect it, either to the same port, or to an external source, or to another PC, the app does not start. The reset button has no effect.

If I reopen the port in an IDE to monitor it, the app starts instantly.

This is tested with different ESP32-S3-DevKitC-1-N16R8V (I bought 3), both on Windows and Mac, and with my own sketches or with the examples (blink or hello).

I have worked with other ESP32 devkits before and never had this problem.

What can I do? Is there any software or config solution?

(apologies for my English).

Sketch

Checked with blink and hello examples.

Debug Message

Nothing.

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@ReyWamba ReyWamba added the Status: Awaiting triage Issue is waiting for triage label Jun 16, 2023
@Xylopyrographer
Copy link
Contributor

Dollars to donuts this is the Serial bug seen when using USB CDC. Search the issues for Serial.flush and a few items will pop up from others who've hit this problem.
#7779
#8238
#7721

@ReyWamba
Copy link
Author

Thank you @Xylopyrographer.

Indeed it seems to be a problem of Serial communication.

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

fix the problem... but obviously it is not the solution.

I have tried the following, with no results:

However, I owe you half a dozen donuts for guiding me to the solution, even though I haven't found it yet. Thanks again.

@Xylopyrographer
Copy link
Contributor

Xylopyrographer commented Jun 18, 2023 via email

@me-no-dev
Copy link
Member

if you have while(!Serial); in the beginning, the code will wait for the USB Serial to be attached, since you are not actually opening the port when powering externally... the sketch hangs

@ReyWamba
Copy link
Author

Hello again, @Xylopyrographer:

I have no Serial.flush() in my code, and I had already tried the solution of Serial.setTxTimeoutMs( 0 ) (it was mentioned in some of the links you mentioned to me in your first reply), even trying to upload the program in all USB modes (ESP-PROG, USB-JTAG and ESP USB Brigde), and both with -D ARDUINO_USB_MODE=1 enabled and disabled in platformio.ini, and nothing.

However, thanks to your and @me-no-dev 's suggestions, I have solved the problem (I explain how in the following answer).

So thanks again, and I owe you a dozen donuts!!!

@ReyWamba
Copy link
Author

if you have while(!Serial); in the beginning, the code will wait for the USB Serial to be attached, since you are not actually opening the port when powering externally... the sketch hangs

Hello, @me-no-dev:

Indeed, it is the while(!Serial); that causes the boot to fail when it is not connected to an opening port.

However, in Arduino IDE and with other ESP32 boards, this statement never gave me problems. The apps booted without problems when connected to any source. It was the acquisition of the ESP-32S3 boards (my app was running low on memory on 4Mb modules) that forced me to migrate to platformio.

The solution that I have applied and that works for me is to wait a few seconds for Serial to connect to the COM port, and if not, let it continue loading without waiting any longer:

void _setup()
{
  const uint16_t maxWaitForSerial = 3000;
  uint16_t startSerial = millis();
  uint16_t waitingForSerial = 0;
  
  Serial.begin(115200);

  while (waitingForSerial < maxWaitForSerial)
  {
    if (Serial) break;
    waitingForSerial = millis() - startSerial;
    delay(100);
  }
  .....
}

Thank you very much for your answer.

@Xylopyrographer
Copy link
Contributor

Xylopyrographer commented Jun 19, 2023 via email

@me-no-dev
Copy link
Member

However, in Arduino IDE and with other ESP32 boards, this statement never gave me problems.

That is because they have a separate USB-Serial chip that we have no idea when is connected. On newer chips we have integrated USB, which we can detect when connected and wait for it. Same goes for Arduino Leonardo for example. Arduino UNO will boot regardless, but Leonardo will wait.

@ReyWamba
Copy link
Author

I am a simple amateur, and these things are beyond my knowledge. The truth is that they waste a lot of time.

Thank you very much for your help again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

3 participants