Merge pull request #330 from troyhacks/mdev
Always allow proper serial console on S3/C3/C6/etc under ALL conditions
This commit is contained in:
@@ -26,31 +26,37 @@
|
|||||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
#error please fix your build environment. ESP32 and ESP8266 are both defined.
|
#error please fix your build environment. ESP32 and ESP8266 are both defined.
|
||||||
#endif
|
#endif
|
||||||
// only one of ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32C3 allowed
|
// only one of ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32C3, ARDUINO_ARCH_ESP32C6 allowed
|
||||||
#if defined(ARDUINO_ARCH_ESP32S3) && ( defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3) )
|
#if defined(ARDUINO_ARCH_ESP32S3) && ( defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32C6) )
|
||||||
#error please fix your build environment. only one of ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32C3 may be defined
|
#error please fix your build environment. only one of ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32C3, ARDUINO_ARCH_ESP32C6 may be defined
|
||||||
#endif
|
#endif
|
||||||
#if defined(ARDUINO_ARCH_ESP32S2) && ( defined(ARDUINO_ARCH_ESP32S3) || defined(ARDUINO_ARCH_ESP32C3) )
|
#if defined(ARDUINO_ARCH_ESP32S2) && ( defined(ARDUINO_ARCH_ESP32S3) || defined(ARDUINO_ARCH_ESP32C3) || defined(ARDUINO_ARCH_ESP32C6) )
|
||||||
#error please fix your build environment. only one of ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32C3 may be defined
|
#error please fix your build environment. only one of ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32C3, ARDUINO_ARCH_ESP32C6 may be defined
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32) && ( defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3))
|
#if defined(ARDUINO_ARCH_ESP32C6) && ( defined(ARDUINO_ARCH_ESP32S3) || defined(ARDUINO_ARCH_ESP32S2) || defined(ARDUINO_ARCH_ESP32C3) )
|
||||||
|
#error please fix your build environment. only one of ARDUINO_ARCH_ESP32S3, ARDUINO_ARCH_ESP32S2, ARDUINO_ARCH_ESP32C3, ARDUINO_ARCH_ESP32C6 may be defined
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_IDF_TARGET_ESP32) && ( defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
|
||||||
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
||||||
#endif
|
#endif
|
||||||
// make sure we have a supported CONFIG_IDF_TARGET_
|
// make sure we have a supported CONFIG_IDF_TARGET_
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
#error please fix your build environment. No supported CONFIG_IDF_TARGET was defined
|
#error please fix your build environment. No supported CONFIG_IDF_TARGET was defined
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32_SOLO || CONFIG_IDF_TARGET_ESP32SOLO
|
#if CONFIG_IDF_TARGET_ESP32_SOLO || CONFIG_IDF_TARGET_ESP32SOLO
|
||||||
#warning ESP32 SOLO (single core) is not supported.
|
#warning ESP32 SOLO (single core) is not supported.
|
||||||
#endif
|
#endif
|
||||||
// only one of CONFIG_IDF_TARGET_ESP32, CONFIG_IDF_TARGET_ESP32S2, CONFIG_IDF_TARGET_ESP32S3, CONFIG_IDF_TARGET_ESP32C3 is allowed
|
// only one of CONFIG_IDF_TARGET_ESP32, CONFIG_IDF_TARGET_ESP32S2, CONFIG_IDF_TARGET_ESP32S3, CONFIG_IDF_TARGET_ESP32C3, CONFIG_IDF_TARGET_ESP32C6 is allowed
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32) && ( defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3))
|
#if defined(CONFIG_IDF_TARGET_ESP32) && ( defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
|
||||||
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32S3) && ( defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3))
|
#if defined(CONFIG_IDF_TARGET_ESP32S3) && ( defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
|
||||||
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) && ( defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2))
|
#if defined(CONFIG_IDF_TARGET_ESP32C3) && ( defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C6))
|
||||||
|
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_IDF_TARGET_ESP32C6) && ( defined(CONFIG_IDF_TARGET_ESP32) || defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3))
|
||||||
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
#error please fix your build environment. only one CONFIG_IDF_TARGET may be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -466,13 +472,19 @@ void WLED::setup()
|
|||||||
#ifdef WLED_BOOTUPDELAY
|
#ifdef WLED_BOOTUPDELAY
|
||||||
delay(WLED_BOOTUPDELAY); // delay to let voltage stabilize, helps with boot issues on some setups
|
delay(WLED_BOOTUPDELAY); // delay to let voltage stabilize, helps with boot issues on some setups
|
||||||
#endif
|
#endif
|
||||||
Serial.begin(115200);
|
|
||||||
|
|
||||||
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
|
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32P4))
|
||||||
|
Serial.begin(115200); // WLEDMM avoid "hung devices" when USB_CDC is enabled; see https://github.com/espressif/arduino-esp32/issues/9043
|
||||||
|
Serial.setTxTimeoutMs(0); // potential side-effect: incomplete debug output, with missing characters whenever TX buffer is full.
|
||||||
|
#else
|
||||||
|
Serial.begin(115200);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
|
||||||
if (!Serial) delay(1000); // WLEDMM make sure that Serial has initalized
|
if (!Serial) delay(1000); // WLEDMM make sure that Serial has initalized
|
||||||
#else
|
#else
|
||||||
if (!Serial) delay(300); // just a tiny wait to avoid problems later when acessing serial
|
if (!Serial) delay(300); // just a tiny wait to avoid problems later when acessing serial
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_math(); // WLEDMM: pre-calculate some lookup tables
|
init_math(); // WLEDMM: pre-calculate some lookup tables
|
||||||
|
|
||||||
@@ -495,9 +507,9 @@ void WLED::setup()
|
|||||||
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise (WLED_DEBUG only)
|
if (!Serial) delay(2500); // WLEDMM allow CDC USB serial to initialise (WLED_DEBUG only)
|
||||||
#endif
|
#endif
|
||||||
#if ARDUINO_USB_CDC_ON_BOOT || ARDUINO_USB_MODE
|
#if ARDUINO_USB_CDC_ON_BOOT || ARDUINO_USB_MODE
|
||||||
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6))
|
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32P4))
|
||||||
// WLEDMM avoid "hung devices" when USB_CDC is enabled; see https://github.com/espressif/arduino-esp32/issues/9043
|
// WLEDMM avoid "hung devices" when USB_CDC is enabled; see https://github.com/espressif/arduino-esp32/issues/9043
|
||||||
Serial.setTxTimeoutMs(0); // potential side-effect: incomplete debug output, with missing characters whenever TX buffer is full.
|
Serial.setTxTimeoutMs(0);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
|
#if !defined(WLEDMM_NO_SERIAL_WAIT) || defined(WLED_DEBUG)
|
||||||
if (!Serial) delay(2500); // WLEDMM: always allow CDC USB serial to initialise
|
if (!Serial) delay(2500); // WLEDMM: always allow CDC USB serial to initialise
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ void sendBytes(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool canUseSerial(void) { // WLEDMM returns true if Serial can be used for debug output (i.e. not configured for other purpose)
|
bool canUseSerial(void) { // WLEDMM returns true if Serial can be used for debug output (i.e. not configured for other purpose)
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) && ARDUINO_USB_CDC_ON_BOOT && !defined(WLED_DEBUG_HOST)
|
#if ARDUINO_USB_CDC_ON_BOOT && (defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32P4)) && !defined(WLED_DEBUG_HOST)
|
||||||
// on -C3, USB CDC blocks if disconnected! so check if Serial is active before printing to it.
|
// on S3/C3/C6/P4, USB CDC blocks if disconnected! so check if Serial is active before printing to it.
|
||||||
if (!Serial) return false;
|
if (!Serial) return false;
|
||||||
#endif
|
#endif
|
||||||
if (pinManager.isPinAllocated(hardwareTX) && (pinManager.getPinOwner(hardwareTX) != PinOwner::DebugOut))
|
if (pinManager.isPinAllocated(hardwareTX) && (pinManager.getPinOwner(hardwareTX) != PinOwner::DebugOut))
|
||||||
|
|||||||
Reference in New Issue
Block a user