How to add a Teensyduino (beta) release to PlatformIO

shawn

Well-known member
The folks who make PlatformIO do a great job of incorporating new Teensyduino releases in a not unreasonable timeframe. However, the Teensyduino beta releases aren't usually added. This post serves as a guide to add a beta release to your PlatformIO build process.

A prerequisite is that you have Teensyduino installed, either v1.8.19 or via Arduino IDE v2.0.3 (the latest versions as of this writing).

Arduino IDE v2:
Arduino IDE v1.8.19:

There are three main parts:
  1. Core files,
  2. Toolchain, and
  3. Tools.

The first step is to create three directories in some well-known location:
  1. framework-arduinoteensy/
  2. toolchain-gccarmnoneeabi/
  3. tool-teensy/
These new directories will hold files for the above three parts. Note that you don't have to use these exact names; they can be different or have an appended version, etc. For example (I use a Mac), I put these in ~/pio/teensy_1.58-beta3/ for the latest beta release.

Note: My convention, when describing directories in text, is to append a '/'.

Next, copy the board and core files into your new framework-arduinoteensy/:
Arduino IDE v2: Everything under packages/teensy/hardware/avr/0.58.3/
Arduino IDE v1.8.19 (Mac): Everything under Contents/Java/hardware/teensy/avr/

Next, copy the toolchain into your new toolchain-gccarmnoneeabi/:
Arduino IDE v2: Everything under packages/teensy/tools/teensy-compile/11.3.1-beta2/arm/
Arduino IDE v1.8.19 (Mac): Everything under Contents/Java/hardware/tools/arm/

Next, copy the Teensy tools into your new tool-teensy/:
Arduino IDE v2: Everything under packages/teensy/tools/teensy-tools/0.58.3/
Arduino IDE v1.8.19 (Mac): Everything under Contents/Java/hardware/tools/ except for arm/ and avr/

Second-to-last, create a package.json file so that PlatformIO will recognize these new directories and their contents. To make it easy, just copy the ones from the 1.57 PlatformIO Teensy release and change the internal version numbers. For differentiating the package version, I used the beta release date, 17-Dec-2022 (221217).

framework-arduinoteensy/package.json (Mac): 1.157.220801 → 1.158.221217:
Code:
{
  "name": "framework-arduinoteensy",
  "version": "1.158.221217",
  "description": "Arduino Wiring-based Framework for Teensy boards",
  "keywords": [
    "framework",
    "arduino",
    "teensy"
  ],
  "homepage": "https://www.arduino.cc/reference/en",
  "repository": {
    "type": "git",
    "url": "https://github.com/PaulStoffregen/cores"
  }
}

toolchain-gccarmnoneeabi/package.json (Mac): 1.50401.190816 → 1.110301.221217:
Code:
{"name": "toolchain-gccarmnoneeabi", "version": "1.110301.221217", "description": "GNU toolchain for Arm Cortex-M and Cortex-R processors", "keywords": ["toolchain", "build tools", "compiler", "assembler", "linker", "preprocessor", "arm"], "homepage": "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm", "license": "GPL-2.0-or-later", "system": ["darwin_x86_64", "darwin_arm64"], "repository": {"type": "git", "url": "https://gcc.gnu.org/git/gcc.git"}}

tool-teensy/package.json (Mac): 1.157.0 → 1.158.221217:
Code:
{
  "description": "Upload tools for Teensy boards",
  "homepage": "https://www.pjrc.com/teensy/loader.html",
  "keywords": [
    "tools",
    "uploader",
    "teensy"
  ],
  "name": "tool-teensy",
  "system": [
    "darwin_x86_64",
    "darwin_arm64"
  ],
  "version": "1.158.221217"
}

Last, in your platformio.ini file, set the platform packages to point to those three new directories:
Code:
platform_packages =
  toolchain-gccarmnoneeabi@file:///Users/me/pio/teensy_1.58-beta3/toolchain-gccarmnoneeabi
  framework-arduinoteensy@file:///Users/me/pio/teensy_1.58-beta3/framework-arduinoteensy
  tool-teensy@file:///Users/me/pio/teensy_1.58-beta3/tool-teensy
The `file://`scheme is used to point to the absolute paths.
Note: These paths are just for illustration. It's likely you'll use different locations.

You can verify that the correct packages are used by looking at the build output. You should see something like this:
Code:
PACKAGES: 
 - framework-arduinoteensy @ 1.158.221217 (1.58) 
 - tool-teensy @ 1.158.221217 (1.58) 
 - toolchain-gccarmnoneeabi @ 1.110301.221217 (11.3.1)

Collected links:

A request: It would be lovely if someone could fill in the details for Windows and Linux systems.

Side note: It's likely these instructions will be obsoleted by newer releases of either the Arduino IDE or Teensyduino if any of the structures or locations change.

Corrections, notes, and updates are welcome.
 
Shawn:
Thanks, I followed your directions and it was successful!!!
You would think the folks at PIO would make this less painful.

Regards,
Ed
 
I’m glad it worked for you! Mac?

I think I’d describe the above steps as the steps the PIO folks need to do in order to make it less painful. :)
 
Followed the guide but somehow it fails to find arm-none-eabi-g++:

'arm-none-eabi-g++' is not recognized as an internal or external command,
operable program or batch file.


PIO version: version 6.1.5

Also seems that everytime I compile it reinstalls the packages.

I checked .vscode/c_cpp_properties.json and it seems that it doesn't set the complete path:

Code:
"compilerPath": "arm-none-eabi-gcc",
 
Last edited:
@shawn Seems that the "toolchain-gccarmnoneeabi" package is now called "toolchain-gccarmnoneeabi-teensy". The guide should be updated.
 
Agreed. I have no update powers, so I'll just hope people scroll down. [If the instructions were to be updated directly by those with the power, my preference would be to add an "Update" paragraph instead of changing because I think it's important to keep the original text.]
 
I successfully added Beta 0.59.3 to PIO.
The build succeeds, but i get a red lined error message:

/Users/me/.platformio/packages/toolchain-gccarmnoneeabi_0_59_3/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /Users/me/.platformio/packages/toolchain-gccarmnoneeabi_0_59_3/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: DWARF error: section .debug_info is larger than 10x its filesize! (0x0 vs 0x0)

This is my platformio.ini:


Code:
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
build_type = release

platform_packages =
  toolchain-gccarmnoneeabi@file:///Users/me/.platformio/packages/toolchain-gccarmnoneeabi_0_59_3
  framework-arduinoteensy@file:///Users/me/.platformio/packages/framework-arduinoteensy_0_59_3
  tool-teensy@file:///Users/me/.platformio/packages/tool-teensy_0_59_3

build_flags =
    -D TEENSY_OPT_FASTER
    -ffast-math
    -D __IMXRT1062__
    -I lib/WDT_T4
    -I src
    -I lib/teensy4_i2c/src

; *** BETA 1.59.3 ***
build_unflags =
    -std=gnu++14
 
What happens if you change toolchain-gccarmnoneeabi@ to toolchain-gccarmnoneeabi-teensy@?

Also, I don’t think any of those build flags are needed here because they’re the defaults (maybe with the exception of "-ffast-math"). In addition, the include paths should be discovered automatically.

Update: I'm curious why "-ffast-math" is needed?
 
Last edited:
Another tip: if you wanted to, you could dispense with putting WDT_t4 and teensy4_i2c inside your lib/ folder and instead use lib_deps, as follows. That is, unless you really want to use specific local copies. Note that when you build, the lib_deps libraries are cached locally in the .pio/libdeps/ directory.

INI:
lib_deps =
  https://github.com/tonton81/WDT_T4.git
  https://github.com/Richard-Gemmell/teensy4_i2c.git

Note that you can use a specific tag or version of the library if you like. For a specific tag, for example, "hello", simply append "#hello" to the URL. There's also a syntax for specifying a specific version number, version number range, or commit hash.
See also here: https://docs.platformio.org/en/late...d_install.html#cmd-pkg-install-specifications
 
Last edited:
Using toolchain-gccarmnoneeabi-teensy@ did not change anything.

And thank you for the hints! I did not know the "#" option. But in general, i only work with local copies of libs as this is production code. I do have the WDT_T4 and teensy4_i2c libraries as local copies in my /lib directory, but i need the include flags in order for my code to compile. For some reason, without the include flags, the compiler won't find these libs at compile time or maybe not in the right order.
My application is a DSP intensive audio unit where i need to use every bit of speed i can get. With -ffast-math i could measure some improvement.
 
Do library.json (preferred) or library.properties files exist in the root of those libraries under lib/?
 
Yes they have both .json and .properties files. I checked with the git repos and I am using the latest WDT_T4 (v0.1) and almost the latest teensy4_i2c (v2.0.0-beta.1) without any changes so far.
 
If you’d like, I can try to build it here and see what I can find. Something’s amiss with your setup.
 
That is very kind, thank you! But as this is a commercial project, i can not give out the code. And as i said, it does compile. I will post an update here as soon as i find the cause for my error messages.
 
Back
Top