Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 13 of 13

Thread: PlatformIO, how to compile for Teensy 4.0 with beta core

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    8

    PlatformIO, how to compile for Teensy 4.0 with beta core

    Hi, I'm trying to compile a MIDI-USB project in PlatformIO and I get errors because the stable release of the Teensy 4.0 core used by PlatformIO has no support for USB modes other than Serial.
    I successfully compile that project in Arduino and I imagine that it is due to the fact that I installed the Teensyduino 1.49 Beta #3, which has support for all the USB types, including MIDI-USB.
    I downloaded the up-to-date Teensy 4.0 core from GIT, but I don't know where to put it in PlatformIO in order to let the IDE use it for compiling my Teensy 4.0 projects.
    Any help will be appreciated.

  2. #2
    Senior Member blackketter's Avatar
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    283
    What I did on my Mac (probably the same for Linux, not sure about Windows) was to move aside the installed cores directory:

    Code:
    mv ~/.platformio/packages/framework-arduinoteensy/cores ~/.platformio/packages/framework-arduinoteensy/cores.original
    then created a symlink from the cores directory I checked out from git

    Code:
    ln -s ~/src/cores ~/.platformio/packages/framework-arduinoteensy/cores
    This worked for now!

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Posts
    8
    Quote Originally Posted by blackketter View Post
    What I did on my Mac (probably the same for Linux, not sure about Windows) was to move aside the installed cores directory:

    Code:
    mv ~/.platformio/packages/framework-arduinoteensy/cores ~/.platformio/packages/framework-arduinoteensy/cores.original
    then created a symlink from the cores directory I checked out from git

    Code:
    ln -s ~/src/cores ~/.platformio/packages/framework-arduinoteensy/cores
    This worked for now!

    Thanks a lot blackketter. It also works on Linux.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,142
    It should work fine on Windows as well, although commands will be different:

    Note: on Windows 10 at times I also use links in a similar way. Note: I don't use platformio, but I use it for Arduino where I have many github projects that I keep on a different drive and then when I am working with them, I link them into my Arduino/libraries folder. When a new release comes out or when I need/want to compare versus released, I might then remove that link...

    So in my case, I might do something like:
    Code:
    mklink /D C:\Users\kurte\Documents\Arduino\libraries\ili9341_t3 d:\github\ili9341_t3
    Note: I would typically not type this whole thing in, but would instead have: C:\Users\kurte\Documents\Arduino\libraries as my working directory and type:
    Code:
    mklink /D ili9341_t3 d:\github\ili9341_t3
    To later remove it, I always want to be careful on which command I use. I believe the correct one is rmdir:
    Code:
    rmdir ili9341_t3
    You don't want to use del command as it will delete everything at the target...

  5. #5
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Quote Originally Posted by lastshaman View Post
    Hi, I'm trying to compile a MIDI-USB project in PlatformIO and I get errors because the stable release of the Teensy 4.0 core used by PlatformIO has no support for USB modes other than Serial.
    I successfully compile that project in Arduino and I imagine that it is due to the fact that I installed the Teensyduino 1.49 Beta #3, which has support for all the USB types, including MIDI-USB.
    I downloaded the up-to-date Teensy 4.0 core from GIT, but I don't know where to put it in PlatformIO in order to let the IDE use it for compiling my Teensy 4.0 projects.
    Any help will be appreciated.
    Apologies in advance if I've overlooked something obvious, but I'm currently trying to port a PlatformIO MIDI-USB project from Teensy 3.2 to 4.0, and I'm running into compilation errors, I imagine for the same reason. I've done a bunch of googling but I can't figure out which "core" and git repo you're referring to. If someone could hand me an URL I'd really appreciate it. I've got a Teensy 4.0 sitting here on my bench but until I can compile my project it's just going to sit there feeling neglected.

    Thanks--
    --Adam

  6. #6
    Senior Member blackketter's Avatar
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    283
    Quote Originally Posted by schabtach View Post
    Apologies in advance if I've overlooked something obvious, but I'm currently trying to port a PlatformIO MIDI-USB project from Teensy 3.2 to 4.0, and I'm running into compilation errors, I imagine for the same reason. I've done a bunch of googling but I can't figure out which "core" and git repo you're referring to. If someone could hand me an URL I'd really appreciate it. I've got a Teensy 4.0 sitting here on my bench but until I can compile my project it's just going to sit there feeling neglected.
    Ha, sorry, that's important information. Here's the repo for the cores: https://github.com/PaulStoffregen/cores

  7. #7
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Ah, thanks so much. I'd actually found that repo but the magic string "framework-arduinoteensy" doesn't seem to be associated with it, so I thought I was looking in the wrong place. I appreciate it!

  8. #8
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Another detail: It seems that MIDIUSB.h is missing from cores/teensy4/. It's present in cores/teensy3/ and doesn't appear to have any board-specific code, but MIDI-USB code won't compile for Teensy 4 unless I place a copy of MIDIUSB.h in cores/teensy4/.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,285
    Try copying that header from the teensy3 folder to the teensy4 folder. It's just a compatibility file for Arduino's API.

    Or you could use Teensy's USB MIDI functions, which match the MIDI.h library and are probably much more familiar for anyone using MIDI than Arduino's way.

    https://www.pjrc.com/teensy/td_midi.html

  10. #10
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Thanks, Paul! I did get it to compile by copying that .h file, but then I figured out that, while I was already using the Teensy USB MIDI functions, I had some superfluous #include statements left over from an earlier, Arduino-based version of the project. All sorted now. My homebrew Teensy-based MIDI-CV converter has been successfully upgraded with a Teensy 4.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,285
    I've added this file for Teensy 4.0, so if anyone else hits this issue in the future everything should "just work".

    https://github.com/PaulStoffregen/co...903b70b48c0103

  12. #12
    I've just started down the PlatformIO road myself. I have found that you can define the link to the cores files in the platformio.ini file within the project.

    • Download/clone the cores repo https://github.com/PaulStoffregen/cores
    • Put the unzipped repo in your favorite spot. I keep mine in <home>/Developer
    • Add the following to your project's platformio.ini file:

    For Windows
    Code:
    [platformio]
    boards_dir = %HOMEPATH%\Developer\cores-master
    For Mac / Linux
    Code:
    [platformio]
    boards_dir = ~/Developer/cores-master
    Don't forget to add the USB_MIDI build flag

    Code:
    [env:teensy40]
    platform = teensy
    board = teensy40
    framework = arduino
    build_flags = -D USB_MIDI
    lib_deps =
    ; Add additional libraries
    I've only tested this on Windows 10 but it compiles successfully and finds the usbMIDI libraries correctly. Good luck!

  13. #13
    Junior Member
    Join Date
    May 2020
    Posts
    5
    Hey, thanks to both of you guys for the two posts--I appreciate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •