Add pre-build script to patch core's pins_arduino.h with Launchpad X VID/PID
- pre_build.py patches framework-arduinoespressif32/variants/esp32s3_devkitc/pins_arduino.h - Replaces USB_VID 0x303a -> 0x1235, USB_PID 0x1001 -> 0x0103 - Adds USB_MANUFACTURER/PRODUCT
This commit is contained in:
+2
-1
@@ -16,9 +16,10 @@ build_flags =
|
||||
-DARDUINO_USB_MODE=0
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DUSE_TINYUSB=1
|
||||
-I${PROJECT_DIR}/variants/esp32s3
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
board_build.partitions = default_8MB.csv
|
||||
board_build.arduino.memory_type = qio_opi
|
||||
|
||||
extra_scripts = pre:pre_build.py
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import fileinput
|
||||
|
||||
def patch_usb_ids():
|
||||
# Find the core's pins_arduino.h for ESP32-S3 DevKitC-1
|
||||
core_variants = os.path.expanduser("~/.platformio/packages/framework-arduinoespressif32/variants")
|
||||
if not os.path.exists(core_variants):
|
||||
# Try PlatformIO default location
|
||||
core_variants = os.path.join(os.environ.get("PLATFORMIO_PACKAGES_DIR", ""), "framework-arduinoespressif32", "variants")
|
||||
|
||||
pins_file = os.path.join(core_variants, "esp32s3_devkitc", "pins_arduino.h")
|
||||
|
||||
if not os.path.exists(pins_file):
|
||||
# Try alternative variant name
|
||||
pins_file = os.path.join(core_variants, "esp32s3", "pins_arduino.h")
|
||||
|
||||
if os.path.exists(pins_file):
|
||||
print(f"Patching {pins_file} with Launchpad X VID/PID")
|
||||
|
||||
# Read and replace
|
||||
with open(pins_file, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace USB_VID and USB_PID
|
||||
content = content.replace(
|
||||
'#define USB_VID 0x303a',
|
||||
'#define USB_VID 0x1235'
|
||||
)
|
||||
content = content.replace(
|
||||
'#define USB_PID 0x1001',
|
||||
'#define USB_PID 0x0103'
|
||||
)
|
||||
# Add manufacturer/product if not present
|
||||
if 'USB_MANUFACTURER' not in content:
|
||||
content = content.replace(
|
||||
'#define USB_PID 0x0103',
|
||||
'#define USB_PID 0x0103\n#define USB_MANUFACTURER "Novation"\n#define USB_PRODUCT "Launchpad X"'
|
||||
)
|
||||
|
||||
with open(pins_file, 'w') as f:
|
||||
f.write(content)
|
||||
print("USB VID/PID patched successfully")
|
||||
else:
|
||||
print(f"WARNING: Could not find pins_arduino.h at {pins_file}")
|
||||
|
||||
patch_usb_ids()
|
||||
@@ -1,17 +0,0 @@
|
||||
// pins_arduino.h for ESP32-S3 DevKitC-1 with Launchpad X USB VID/PID
|
||||
|
||||
#ifndef _VARIANT_ESP32S3_DEVKITC_1_
|
||||
#define _VARIANT_ESP32S3_DEVKITC_1_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Override USB VID/PID to match Novation Launchpad X (0x1235/0x0103)
|
||||
// This must be before Arduino.h includes it
|
||||
#define USB_VID 0x1235
|
||||
#define USB_PID 0x0103
|
||||
#define USB_MANUFACTURER "Novation"
|
||||
#define USB_PRODUCT "Launchpad X"
|
||||
|
||||
#include "../../.pio/packages/framework-arduinoespressif32/variants/esp32s3_devkitc/pins_arduino.h"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user