From 6fb8e430ff17fb25aae34a989e93983e4b6b928b Mon Sep 17 00:00:00 2001 From: mikecarper Date: Tue, 22 Sep 2026 07:49:40 -0700 Subject: [PATCH] fix(usb): preserve platform startup ordering --- examples/companion_radio/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index d7ecbc2af..d36488152 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -2706,13 +2706,21 @@ bool handleCompanionWirelessCommand(const char* command, char* reply, size_t siz } void setup() { +#if MESH_ESP32_HWCDC_SESSION_GUARD + // HWCDC's TX ring is resized before Serial.begin() creates its mutex and + // enables the USB ISR. This is deliberately before the nRF52 ordering below: + // prepareUsbLoggingPort() is otherwise a no-op outside ESP32 HWCDC. + mesh::prepareUsbLoggingPort(); +#endif // On nRF52 TinyUSB, bring the primary CDC transport up before any board or // wireless preparation. Bluefruit preserves USB power state while it // enables the SoftDevice; a late first Serial.begin() can leave that enable // path in an invalid state on native-USB boards such as the T1000-E. Serial.begin(115200); mesh::wireless::control().begin(companion_wireless); +#if !MESH_ESP32_HWCDC_SESSION_GUARD mesh::prepareUsbLoggingPort(); +#endif #if MESH_PACKET_LOGGING mesh::serialLogBegin(); #endif