Teensy with custom usb_desc.h

Hey guys,

What is the best way to handle this case. I am using a teensy 3.2, and I need to modify the usb_desc.h. Do I need to create a new platform or board?

See Redirecting...

Yes, you can create new development platform and specify custom Arduino/teensy packages. Howerver, do you want to maintain it?
I think that easy way in this situation is extra scripting. You can control build process of ALL files not only final firmware.
If you don’t want to play with it, you can

  1. Create usb_desc.h in project’s src folder
  2. Add to platformio.ini, build_flags = $PROJECTSRC_DIR
  3. Create extra_script.py and env.AddPreAction("$BUILD_DIR/firmware.elf", delete_origin_usb_desc), where need to declare this callback and remove original file.

P.S: The source code of framework could be retrivied using FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoteensy")

This looks promising, I will give this route a go. Can I do this for any of the framework files?

Of course. We need that extra scripting to avoid issue when Teensy development platform will be updated. In this case, this file be restored again. However, this script will remove it again and the header from src folder will be used.

; PlatformIO Project Configuration File
;   Build options: build flags, source filter, extra scripting
;   Upload options: custom port, speed and extra flags
;   Library options: dependencies, extra library storages
; Please visit documentation for the other options and examples
; http://docs.platformio.org/en/stable/projectconf.html

platform = teensy
board = teensy31
framework = arduino
build_flags = $PROJECTSRC_DIR

extra_script = extra_script.py
platform = teensy

print "HERE"
print env.Dump()

The extra_script in in the root of the project. I am getting this error:

[Tue Dec 13 19:03:43 2016] Processing pre_and_post_hooks (extra_script: extra_script.py, platform: teensy)
Verbose mode can be enabled via `-v, --verbose` option
Collected 0 compatible libraries
Looking for dependencies...
Project does not have dependencies
AttributeError: 'SConsEnvironment' object has no attribute 'ElfToHex':
File "/usr/local/lib/python2.7/site-packages/platformio/builder/main.py", line 142:
File "/Users/vbabiy/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "/Users/vbabiy/.platformio/packages/tool-scons/script/../engine/SCons/Script/SConscript.py", line 250:
exec _file_ in call_stack[-1].globals
File "/Users/vbabiy/.platformio/platforms/teensy/builder/main.py", line 211:
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)

Also do you have an example of the call back, I am not I understand what is required to make that work.

Please specify framework and board here.