Skip to content

Commit c144c77

Browse files
committed
S3: don't wait for serial to initialize
... allows to start effects a bit aerlier. Enabled by default on -S3. for your own builds, add `-DWLEDMM_NO_SERIAL_WAIT` to build_flags.
1 parent 8317c89 commit c144c77

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ build_flags = -g
500500
-DARDUINO_ARCH_ESP32S3
501501
-DCONFIG_IDF_TARGET_ESP32S3=1
502502
-DCONFIG_LITTLEFS_FOR_IDF_3_2 -DLFS_THREADSAFE ;; WLEDMM
503+
-DWLEDMM_NO_SERIAL_WAIT ;; WLEDMM don't wait for serial on -S3 (unless WLED_DEBUG is set)
503504
-D CONFIG_ASYNC_TCP_USE_WDT=0
504505
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
505506
-DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_DFU_ON_BOOT=0

wled00/wled.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,24 +452,32 @@ void WLED::setup()
452452
delay(WLED_BOOTUPDELAY); // delay to let voltage stabilize, helps with boot issues on some setups
453453
#endif
454454
Serial.begin(115200);
455+
456+
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
455457
if (!Serial) delay(1000); // WLEDMM make sure that Serial has initalized
458+
#else
459+
if (!Serial) delay(300); // just a tiny wait to avoid problems later when acessing serial
460+
#endif
456461

457462
#ifdef ARDUINO_ARCH_ESP32
458463
#if defined(WLED_DEBUG) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT)
459-
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise
464+
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise (WLED_DEBUG only)
460465
#endif
461466
#if ARDUINO_USB_CDC_ON_BOOT || ARDUINO_USB_MODE
462467
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
463468
// WLEDMM avoid "hung devices" when USB_CDC is enabled; see https://github.com/espressif/arduino-esp32/issues/9043
464469
Serial.setTxTimeoutMs(0); // potential side-effect: incomplete debug output, with missing characters whenever TX buffer is full.
465470
#endif
471+
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
466472
if (!Serial) delay(2500); // WLEDMM: always allow CDC USB serial to initialise
467473
if (Serial) Serial.println("wait 1"); // waiting a bit longer ensures that a debug messages are shown in serial monitor
468474
if (!Serial) delay(2500);
469475
if (Serial) Serial.println("wait 2");
470476
if (!Serial) delay(2500);
471477

472478
if (Serial) Serial.flush(); // WLEDMM
479+
#endif
480+
473481
//Serial.setTimeout(350); // WLEDMM: don't change timeout, as it causes crashes later
474482
// WLEDMM: redirect debug output to HWCDC
475483
#if ARDUINO_USB_CDC_ON_BOOT && (defined(WLED_DEBUG) || defined(SR_DEBUG))
@@ -521,6 +529,7 @@ void WLED::setup()
521529
USER_PRINT(F(", ")); USER_PRINT(ESP.getCpuFreqMHz()); USER_PRINTLN(F("MHz."));
522530

523531
// WLEDMM begin
532+
delay(20); USER_FLUSH(); // drain serial output buffers
524533
USER_PRINT(F("CPU "));
525534
esp_reset_reason_t resetReason = getRestartReason();
526535
USER_PRINT(restartCode2InfoLong(resetReason));

0 commit comments

Comments
 (0)