Closed Xylopyrographer closed 4 months ago
and what is the issue here? (!Serial)
will fail until you connect the port, if you want not to wait, just remove the while. It is working exactly as expected or am I missing something here?
Issue is differing implementations of a function across the ESP32 variants. When S3 support was first added, the workaround was to add Serial.setTxTimeoutMs( 0 );
to prevent the S3 hanging. In revising an S3 code base that used an earlier version of the core, the issue came up again.
In trying to follow the bouncing ball of documentation across core releases I guess I missed the official position from Arduino (thanks for the link @JAndrassy).
With the behaviour now documented by Arduino, I'll code around the issue.
we were not able to have this working properly before, but now it works correctly (and as documented)
Documentation is good. 😉
FWIW, over in issue, https://github.com/espressif/arduino-esp32/issues/8796#issuecomment-2131305195 the same (now defunct) workaround is being used:
void setup() {
Serial.begin(115200);
#if ARDUINO_USB_CDC_ON_BOOT
Serial.setTxTimeoutMs(0);
#else
while (!Serial)
yield();
#endif
delay(100);
.
.
.
Board
seed studio XIAO S3
Device Description
None.
Hardware Configuration
None. Test sketch uses the built-in LED.
Version
other
IDE Name
Arduino IDE v2.3.2
Operating System
macOS 14.4.1 (Sonoma)
Flash frequency
240 MHz
PSRAM enabled
no
Upload speed
921600
Description
Cannot test for availability of the Serial port unless the serial port is connected and active. Trying to do so hangs the program.
Result is the device cannot be powered up by an external supply connected to the USB port.
Load the sketch below. When connected to the serial port of the computer, the sketch executes (LED blips). Leave the device connected to the computer. Close the serial port. Reset the board, sketch hangs (LED doesn't blip). Now connect the serial port and the sketch will run.
Disconnect the board from the computer, Connect the USB port of the board to an external 5V supply. Sketch hangs (LED does not blip.) There is no way to make the sketch run.
Replace the while clause in the sketch with a hard coded delay (750 ms seems to be the minimum required) and the sketch will work (LED blips) under all the conditions stated above.
As noted in the sketch, various uses of
Serial.setTxTimeoutMs( 0 );
does not change the result.While the sketch prints a number of lines, printing just one line is sufficient to produce the error.
Sketch
Debug Message
Other Steps to Reproduce
Tested using Arduino-esp32 core v2.0.17 Tested with Arduino-esp32 core v2.0.14 as well, same problem.
Replacing the
!Serial
test above with adelay()
works.Arduino IDE setup:
USB CDC On Boot: "Enabled" CPU Frequency: "240MHz (WiFi)" Core Debug Level: "Verbose" USB DFU On Boot: "Disabled" Erase All Flash Before Sketch Upload: "Disabled" Events Run On: "Core 1" Flash Mode: "QIO 80MHz" Flash Size: "8MB (64Mb)" JTAG Adapter: "Disabled" Arduino Runs On: "Core 1" USB Firmware MSC On Boot: "Disabled" Partition Scheme: "Default with spiffs (3MB APP/1.5MB SPIFFS)" PSRAM: "Disabled" Upload Mode: "UARTO / Hardware CDC" Upload Speed: "921600" USB Mode: "Hardware CDC and JTAG" Programmer: "Esptool"
I have checked existing issues, online documentation and the Troubleshooting Guide