add mandatory build flags for -S2 and -C3 (virtual USB)

I was wondering why sometimes the new MCUs still work better in Arduino IDE, so compared our build flags to what is used in Arduino IDE:

-S2 always has -DARDUINO_USB_MODE=0
-C3 always has -DARDUINO_USB_MODE=1
-S3 supports all possible modes
This commit is contained in:
Frank 2022-12-21 22:07:15 +01:00
parent 284a9999b3
commit d7b5719dfd
3 changed files with 15 additions and 1 deletions

View File

@ -214,6 +214,7 @@ build_flags = -g
-D CONFIG_ASYNC_TCP_USE_WDT=0
#use LITTLEFS library by lorol in ESP32 core 1.x.x instead of built-in in 2.x.x
-D LOROL_LITTLEFS
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; this flag is mandatory for "classic ESP32" when builing with arduino-esp32 >=2.0.3
default_partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
@ -230,6 +231,9 @@ build_flags = -g
-DCONFIG_IDF_TARGET_ESP32S2
-D CONFIG_ASYNC_TCP_USE_WDT=0
-DCO
-DARDUINO_USB_MODE=0 ;; this flag is mandatory for ESP32-S2 !
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
;; ARDUINO_USB_CDC_ON_BOOT, ARDUINO_USB_MSC_ON_BOOT, ARDUINO_USB_DFU_ON_BOOT
lib_deps =
${env.lib_deps}
@ -243,6 +247,9 @@ build_flags = -g
-DCONFIG_IDF_TARGET_ESP32C3
-D CONFIG_ASYNC_TCP_USE_WDT=0
-DCO
-DARDUINO_USB_MODE=1 ;; this flag is mandatory for ESP32-C3
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
;; ARDUINO_USB_CDC_ON_BOOT
lib_deps =
${env.lib_deps}
@ -258,6 +265,8 @@ build_flags = -g
-DCONFIG_IDF_TARGET_ESP32S3
-D CONFIG_ASYNC_TCP_USE_WDT=0
-DCO
;; please make sure that the following flags are properly set (to 0 or 1) by your board.json, or included in your custom platformio_override.ini entry:
;; ARDUINO_USB_MODE, ARDUINO_USB_CDC_ON_BOOT, ARDUINO_USB_MSC_ON_BOOT, ARDUINO_USB_DFU_ON_BOOT
lib_deps =
${env.lib_deps}
@ -387,6 +396,7 @@ board = esp32-c3-devkitm-1
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
build_flags = ${common.build_flags} ${esp32c3.build_flags} #-D WLED_RELEASE_NAME=ESP32-C3
-D WLED_WATCHDOG_TIMEOUT=0
; -DARDUINO_USB_CDC_ON_BOOT=1 ;; for virtual USB
upload_speed = 460800
build_unflags = ${common.build_unflags}
lib_deps = ${esp32c3.lib_deps}

View File

@ -268,7 +268,10 @@ void WLED::setup()
#endif
Serial.begin(115200);
Serial.setTimeout(50);
#if !ARDUINO_USB_CDC_ON_BOOT
Serial.setTimeout(50); // this causes troubles on new MCUs that have a "virtual" USB Serial (HWCDC)
#else
#endif
#if defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT)
delay(2500); // allow CDC USB serial to initialise
#endif

View File

@ -71,6 +71,7 @@
#include <user_interface.h>
}
#else // ESP32
#include <HardwareSerial.h> // ensure we have the correct "Serial" on new MCUs (depends on ARDUINO_USB_MODE and ARDUINO_USB_CDC_ON_BOOT)
#include <WiFi.h>
#include <ETH.h>
#include "esp_wifi.h"