From 66592dc33e315be952a0bfe301b45532fdeb09bd Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Tue, 23 Jun 2026 23:33:51 +0000 Subject: [PATCH] Delete Adafruit's generic dcd_dwc2.c so ESP32 core's patched DCD is used --- extra_script.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extra_script.py b/extra_script.py index fda0754..648dcc5 100644 --- a/extra_script.py +++ b/extra_script.py @@ -1,3 +1,21 @@ Import("env") +import os, sys +# Keep allow-multiple-definition for core TinyUSB symbol overlaps env.Append(LINKFLAGS=["-Wl,--allow-multiple-definition"]) + +# Delete the Adafruit library's generic DCD so we use the ESP32-specific +# one from libarduino_tinyusb.a (which has correct hardware init patches) +lib_path = os.path.join( + env.subst("$PROJECT_DIR"), + ".pio", "libdeps", env.subst("$PIOENV"), + "Adafruit TinyUSB Library", "src" +) + +dcd_path = os.path.join(lib_path, "portable", "synopsys", "dwc2", "dcd_dwc2.c") + +if os.path.exists(dcd_path): + os.remove(dcd_path) + print("[extra_script] Removed generic dcd_dwc2.c (using ESP32 core's patched version)") +else: + print("[extra_script] dcd_dwc2.c not found at:", dcd_path)