Ah got it thanks! Here is the platformio.ini config (note i am using a micromod so set your board accordingly):
Code:
[platformio]
default_envs = release
[env]
platform = teensy@4.17.0
board = teensymm
board_build.mcu = imxrt1062
board_build.f_cpu = 600000000L
upload_protocol = teensy-gui
framework = arduino
monitor_speed = 115200
extra_scripts = pre:patch/apply.py
build_flags =
-std=c++0x
-Wl,--print-memory-usage
-g
-D USB_MIDI_AUDIO_SERIAL
lib_deps = <your deps here>
[env:release]
build_flags =
${env.build_flags}
And patch/apply.py:
Code:
from os.path import join, isfile
import shutil
Import("env")
print("PATCHING...", end =" ")
FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoteensy")
patchflag = ".patched"
patchflag_path = join("patch", patchflag)
# patch files only if the patchflag is not present
if not isfile(patchflag_path):
original_file = join(FRAMEWORK_DIR, "cores", "teensy4", "usb_audio.h")
patched_file = join("patch", "usb_audio.h")
assert isfile(original_file) and isfile(patched_file)
shutil.copyfile(patched_file, original_file)
original_file = join(FRAMEWORK_DIR, "cores", "teensy4", "usb_audio.cpp")
patched_file = join("patch", "usb_audio.cpp")
assert isfile(original_file) and isfile(patched_file)
shutil.copyfile(patched_file, original_file)
original_file = join(FRAMEWORK_DIR, "cores", "teensy4", "usb_desc.h")
patched_file = join("patch", "usb_desc.h")
assert isfile(original_file) and isfile(patched_file)
shutil.copyfile(patched_file, original_file)
original_file = join(FRAMEWORK_DIR, "cores", "teensy4", "usb_desc.c")
patched_file = join("patch", "usb_desc.c")
assert isfile(original_file) and isfile(patched_file)
shutil.copyfile(patched_file, original_file)
with open(patchflag_path, "w") as fp:
fp.write("")
print("complete!")
else:
print("skipped")
Which pulls in files local to the /patch directory if the /patch/.patched flag is not present. There is a bit of overhead remembering to copy changes over from teensy core files that you are modifying, but overall this works well. Once the changes are more or less done, I am going to remove the .patched flag and just have it copy happen with every compile so I can just forget about it.