espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.26k stars 7.35k forks source link

v3.0 couldn't keep the correct serial port with Arduino Nano ESP32 once RST button is pressed #10025

Open riywo opened 1 month ago

riywo commented 1 month ago

Board

Arduino Nano ESP32

Device Description

Vanilla Arduino Nano ESP32

Hardware Configuration

No GPIO

Version

v3.0.2

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

?

PSRAM enabled

no

Upload speed

115200

Description

I tried to use v3.0.2 of esp32 board manager with Arduino Nano ESP32 but it couldn't keep the correct serial port. Let me describe the repro steps (I'm using Arduino IDE):

  1. Enter the ROM Boot Mode (i.e. firmware download mode, see also this doc)
  2. Select COM11 (ESP32 Family Device)
  3. Upload Using Programmer (Esptool) with AnalogReadSerial example sketch
  4. Press RST button
  5. However, the serial port is still COM11 (ESP32 Family Device) and no output is coming

The only way to work with v3.0.2 is entering Bootloader-mode, then COM12 (Arduino Nano ESP32, Arduino Nano ESP32) is showed up. Once I upload the same sketch without Programmer, serial output works. However, when I press RST button, COM12 is gone and COM11 is back. In other words, the workaround is that using Bootloader-mode whenever I reset the board, that is insane.

This behavior only happens with v3.0 of esp32, though. I checked v2.0.17 of esp32, then RST button correctly keeps COM12 and the serial port is working. Same as the Arduino's Arduino ESP32 Boards, RST keeps COM12.

Sketch

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);  // delay in between reads for stability
}

Debug Message

N/A

Other Steps to Reproduce

Note: When I use Blink sketch, LED properly blinks after RST even though the serial port is wrong (COM11).

Note: When the correct port is showed up (i.e. after uploading with Bootloader-mode), physically reconnecting USB cable still remains the correct port (COM12). However, once I press RST button, it never goes back to COM12 even after reconnecting USB cable again. Bootloader-mode is the only way to recover. => Update: The first half isn't true. It sometimes changes to the wrong port by just reconnecting USB cable.

Note: Also, re-uploading a new sketch when the correct port is showed up doesn't change the serial port. Only pressing RST button triggers this problematic behavior.

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

me-no-dev commented 1 month ago

cc @pillo79

pillo79 commented 1 month ago

@riywo thanks for the detailed report! We will try to investigate and let you know.

riywo commented 1 month ago

@pillo79 Please let me know if any more data you need from my board for your further investigation. This issue is pretty annoying to me as I can't run my sketch on Arduino Nano ESP32 without USB serial connection (USB battery won't work). I really want to workaround this issue.

BTW, the reason why I want to use v3.0 is the new I2S library. It's cool!

riywo commented 1 month ago

Another finding if it helps: I tried to use 5V VIN today.

So, by this way, I could use this board without USB serial somehow (Power on 5V VIN, plug USB serial then unplug). Hope this helps the investigation...

pillo79 commented 1 month ago

Thanks for these updates! I see you are referring to multiple ways of powering the board - does this issue happen also in the simplest case, with a Blink sketch and no electronics attached except for the USB-C cable powering the board? If this is true I would concentrate on this situation since it is much easier to replicate.

I tried to do so in Linux using IDE 2.3.2, ESP32 core rev 3.0.2 and FQBN esp32:esp32:nano_nora, but I could not: a single "Upload with programmer" here does result in a correct flash and the DFU works just after the first reset (so it would have been detected as your COM12, if I understand correctly).

I am not very skilled in Windows issues. I have escalated this internally so someone can try and replicate on a Windows machine. We haven't yet completed these tests for 3.0, so for the time being we still advise Nano ESP32 users to hold on 2.0.x (2.0.17 will soon be released!) for stability. But thanks for being on the bleeding edge and providing feedback!

riywo commented 1 month ago

@pillo79 Thank you for your investigation! Yes, it happens with the simplest case:

I have Raspberry Pi 5, so let me try Linux later!

JAndrassy commented 1 month ago

and if you then do a normal upload from IDE?

riywo commented 1 month ago

@JAndrassy Thank you for the suggestion. It can't upload through COM11 because "USB DFU" isn't working properly? (I can't see something like "2-5 USB DFU" with COM11 while there is with COM12):

Sketch uses 325557 bytes (10%) of program storage space. Maximum is 3145728 bytes.
Global variables use 30696 bytes (9%) of dynamic memory, leaving 296984 bytes for local variables. Maximum is 327680 bytes.
dfu-util 0.11-arduino4

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

No DFU capable USB device available
Failed uploading: uploading error: exit status 74

Screenshot 2024-07-16 102428

riywo commented 1 month ago

Arduino IDE 2 doesn't support ARM, so I couldn't try Linux on Raspberry Pi. Thus, I tried macOS Apple Silicon instead. In summary, it worked well, so the problem looks like happening only on (my) Windows.

JAndrassy commented 1 month ago

and on Windows you can do a normal upload to COM12 after you uploaded Blink with esptool?

riywo commented 1 month ago

Sure as long as COM12 is active. The problem is that whenever I press RST or reconnect USB-C cable, it goes back to COM11 and I need to enable Bootloader-mode (press RST twice) that activates COM12 then I need to re-upload the same sketch again.

JAndrassy commented 1 month ago

after the reset/reconnect normal upload to COM11 doesn't work?

riywo commented 1 month ago

No, never. COM11 can only work with ROM Boot Mode but normal upload won't work.

DonWT commented 2 days ago

I see the same problem on my Win11 computer using the Arduino IDE 2.3.2 and both a Nano ESP32 and a Waveshare clone of the Nano ESP32 (a Waveshare ESP32-S3-Nano) and version 3.0.3 of the Espressif esp32 board manager.

If I configure the board to use the Arduino ESP32 Boards version 2.0.13 board manager then I do not see this problem.

I used the standard 'Blink' sketch with an added Serial.println statement:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  delay(2000);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
  Serial.println("Here");
}

I am using a 'bare' Arduino Nano ESP32 with no additional circuitry. I am using the Arduino IDE 2.3.2 on a Windows 11 computer.

Arduino ESP32 Boards by Arduino:

Compile and (normal) upload with the board set to 'Arduino Nano ESP32' using the 'Arduino ESP32 Boards' version 2.0.13

  1. Compiles and uploads OK, flashes LED and prints 'Here' every two seconds.

  2. Press reset and the board disconnects briefly then reconnects and works the same as in 1.

  3. Disconnect and reconnect the USB cable and the board restarts and works the same as in 1.

  4. Redo the compile and upload without going into boot mode and, again, it works the same as in 1.

All as expected.

esp32 boards by Espressif:

Compile and upload with the board set to 'Arduino Nano ESP32' using the 'esp 32 boards' version 3.0.3

  1. Compiles and (normal) uploads OK, flashes LED and prints 'Here' every two seconds.

  2. Press reset and the board disconnects and stays disconnected, LED flashes but no serial prints. Notifications say: Port monitor error: command 'open' failed: Serial port not found. Could not connect to COM4 serial port. Compile and upload now fails with: No DFU capable USB device available Failed uploading: uploading error: exit status 74

  3. (I needed to double press the reset button to get it to compile and upload.) Disconnect and reconnect the USB cable and the board restarts, the LED flashes but, again, it fails to connect so there are no serial prints. Same notifications as in 2. Again, I need to double press the reset button to go into boot mode before I can compile and upload again.