Errors using PlatformIO/PIOArduino support for teensy

honey_the_codewitch

Well-known member
I'm trying to build for a Teensy 4.1. This used to work. Now I get all kinds of crazy errors. (Both for PIOArduino and PlatformIO)

I love your devkit, i do not love the Arduino IDE, so if your kit forces me to use Arduino IDE, I am done with your kit.

I am hoping there is a solution to this.
1750874409936.png
 
Honey:
Please show us your platform.ini file, and the complete output from the build.

Regards,
Ed
 
Code:
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
build_flags = -DHTCW_GFX_NO_SWAP
lib_deps = codewitch-honey-crisis/htcw_uix

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy41.html
PLATFORM: Teensy (5.0.0) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
- framework-arduinoteensy @ 1.159.0 (1.59)
- tool-teensy @ 1.159.0 (1.59)
- toolchain-gccarmnoneeabi-teensy @ 1.110301.0 (11.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 99 compatible libraries
Scanning dependencies...
Dependency Graph
|-- htcw_uix @ 1.6.7
|-- htcw_gfx @ 2.2.2
|-- SSD1351_t3 @ 1.0.0
Building in release mode
p.o
Compiling .pio\build\teensy41\lib50f\htcw_gfx\source\gfx_math.cpp.o
In file included from C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/WProgram.h:69,
from C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/Arduino.h:6,
from .pio\libdeps\teensy41\htcw_io\src/io_stream.hpp:5,
from .pio\libdeps\teensy41\htcw_io\src\source\io_stream.cpp:2:
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h: In member function 'uint32_t IntervalTimer::cyclesFromPeriod(period_t)':
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:36: error: 'is_arithmetic_v' is not a member of 'std'; did you mean 'is_arithmetic'?
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^~~~~~~~~~~~~~~
| is_arithmetic
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:60: error: expected primary-expression before '>' token
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:61: error: expected primary-expression before ',' token
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:20: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^~~~~~~~~
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:36: error: 'is_integral_v' is not a member of 'std'; did you mean 'is_integral'?
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^~~~~~~~~~~~~
| is_integral
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:58: error: expected primary-expression before '>' token
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:59: error: expected primary-expression before ')' token
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:20: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^~~~~~~~~
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:36: error: 'is_floating_point_v' is not a member of 'std'; did you mean 'is_floating_point'?
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^~~~~~~~~~~~~~~~~~~
| is_floating_point
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:64: error: expected primary-expression before '>' token
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:65: error: expected primary-expression before ')' token
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^
In file included from C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/WProgram.h:69,
from C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/Arduino.h:6,
from .pio\libdeps\teensy41\htcw_ml\src/ml_reader_fa.hpp:4,
from .pio\libdeps\teensy41\htcw_ml\src\source\ml_reader_fa.cpp:1:
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h: In member function 'uint32_t IntervalTimer::cyclesFromPeriod(period_t)':
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:36: error: 'is_arithmetic_v' is not a member of 'std'; did you mean 'is_arithmetic'?
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^~~~~~~~~~~~~~~
| is_arithmetic
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:60: error: expected primary-expression before '>' token
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:114:61: error: expected primary-expression before ',' token
114 | static_assert(std::is_arithmetic_v<period_t>, "Period must be arithmetic");
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:20: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^~~~~~~~~
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:36: error: 'is_integral_v' is not a member of 'std'; did you mean 'is_integral'?
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^~~~~~~~~~~~~
| is_integral
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:58: error: expected primary-expression before '>' token
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:118:59: error: expected primary-expression before ')' token
118 | if constexpr (std::is_integral_v<period_t>) // handles all integral types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:20: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^~~~~~~~~
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:36: error: 'is_floating_point_v' is not a member of 'std'; did you mean 'is_floating_point'?
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^~~~~~~~~~~~~~~~~~~
| is_floating_point
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:64: error: expected primary-expression before '>' token
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^
C:\Users\gazto\.platformio\packages\framework-arduinoteensy\cores\teensy4/IntervalTimer.h:120:65: error: expected primary-expression before ')' token
120 | if constexpr (std::is_floating_point_v<period_t>) // handles all float types
| ^
Compiling .pio\build\teensy41\lib50f\htcw_gfx\source\gfx_palette.cpp.o
*** [.pio\build\teensy41\lib885\htcw_io\source\io_stream.cpp.o] Error 1
*** [.pio\build\teensy41\lib4d4\htcw_ml\source\ml_reader_fa.cpp.o] Error 1
 
Perhaps you’re using an old version of PlatformIO’s Teensy platform? Have you tried updating lately? It looks like the code is being compiled with C++14; the default changed to C++17 in recent versions, which allows the things the compiler is complaining about.
 
Hey thanks. I was originally doing -std=gnu++11 in my build_unflags, but that wasn't working. You tipped me off to a fix. When I switched it to 14 from 11 it worked

Code:
build_unflags = -std=gnu++14
build_flags = -std=gnu++17
    -DHTCW_GFX_NO_SWAP

I am on the latest PlatformIO package for teensy, so it probably is out of date.
 
Hmm. It still doesn’t sound like you have the latest version of PlatformIO’s Teensy platform. When you build, what version does it say it’s using? Should be near the top of the build output.
 
The default C++ version for that compiler version is C++17. I’m confused why it’s defaulting to C++14 for you. But in any case, your build_unflags and build_flags look correct.
 
What I do in these situations, because I fiddle with libraries and cores and compiler versions, is delete everything teensy-related under the PlatformIO packages directory and then re-build; it will automatically re-download. On the Mac, the directory is at ~/.platformio/packages. Example of what I would do:

Bash:
rm -r ~/.platformio/packages/toolchain-gccarmnoneeabi*
rm -r ~/.platformio/packages/tool-teensy
rm -r ~/.platformio/packages/framework-arduinoteensy*

When I do this if things aren't working as expected, the system usually starts working again. I bet you have more than one version of the first (the toolchain). (Note the '*' at the end of two of the commands, because there might be more than one directory with the same prefix.)

I'm not certain where the Windows folders are, and it's likely the Linux folders are similar.
 
I know where the windows folders are. I'll give that a shot, but I'm not confident based on the fact that I was seeing the latest package versions during the build. Either way, I appreciate it.
 
PlatformIO sometimes gets confused with the toolchain directory, in my experience, if there have been more than one version. Let me know if deleting those folders and then simply rebuilding the project (which will force a re-download of the packages if they’re missing) works for you. I’m really curious.
 
hey, i did have two versions of gccarmoneeabi - one with -teensy as a suffix. I deleted both, in addition to the other folders.
I removed the build_unflags/build_flags settings from PIO, reverting them to the default configuration, and rebuilt.
I got the same errors, so i went one further and deleted PIO's .cache directory, just in case, and rebuilt.
I get the same error.

Curiously. if I simply add build_unflags = -std=gnu++14 everything works.

This leads me to suspect that the package has not removed the old flag, even if it added the new one.
 
Those errors from msg #3 look like C++17 features used in the core library code aren't supported by the toolchain+params you're using.

We're definitely making use of C++17 stuff like "if constexpr" and "is_integral_v".

I hear you love PlatformIO and don't want to use Arduino IDE. A lot of people feel that way. You do get a lot of powerful features and configurable options with PlatformIO. But you also get a lot of opportunity for your setup to be quite different from the compiler we used to develop all those libraries. From a technical support perspective, this is the thing I like about Arduino IDE - it's a "known quantity". Because the toolchain and command line params aren't easily changed (unless you deep dive into config files not normally edited) you always get exactly the same toolchain and settings that were used to develop the libraries.

If you're completely stuck, maybe hold your nose and run Arduino IDE just long enough to enable verbose output during compile in File > Prefs, click Verify to compile any simple program, and copy some of the compiler commands to a text file. You can get in and out of Arduino IDE in probably less than 1 minute. Main idea is to get the full compiler command line Arduino IDE is actually using. Then you can compare to the params and command line you have configured in PlatformIO.

These libraries definitely do compile and work when you build with the same toolchain and command line params. Tricky part is figuring out what's changed in your setup relative to the "known quantity" of Arduino IDE.
 
Those errors from msg #3 look like C++17 features used in the core library code aren't supported by the toolchain+params you're using.

We're definitely making use of C++17 stuff like "if constexpr" and "is_integral_v".

I hear you love PlatformIO and don't want to use Arduino IDE. A lot of people feel that way. You do get a lot of powerful features and configurable options with PlatformIO. But you also get a lot of opportunity for your setup to be quite different from the compiler we used to develop all those libraries. From a technical support perspective, this is the thing I like about Arduino IDE - it's a "known quantity". Because the toolchain and command line params aren't easily changed (unless you deep dive into config files not normally edited) you always get exactly the same toolchain and settings that were used to develop the libraries.

If you're completely stuck, maybe hold your nose and run Arduino IDE just long enough to enable verbose output during compile in File > Prefs, click Verify to compile any simple program, and copy some of the compiler commands to a text file. You can get in and out of Arduino IDE in probably less than 1 minute. Main idea is to get the full compiler command line Arduino IDE is actually using. Then you can compare to the params and command line you have configured in PlatformIO.

These libraries definitely do compile and work when you build with the same toolchain and command line params. Tricky part is figuring out what's changed in your setup relative to the "known quantity" of Arduino IDE.

Thanks for the advice. Arduino IDE 2.x flickers painfully on both my machines, rendering it nearly unusable.

STM32CubeMX had a similar issue, - it had to do with them not testing on high end video cards -but I was able to work around it. No such luck with Arduino IDE.
 
Thanks for the advice. Arduino IDE 2.x flickers painfully on both my machines, rendering it nearly unusable.

STM32CubeMX had a similar issue, - it had to do with them not testing on high end video cards -but I was able to work around it. No such luck with Arduino IDE.
Have a look at VisualMicro. It sits between the Arduino IDE and Visual Studio giving you the best of both worlds. It can be used with Arduino v1 and v2. It also has built in debugging capabilities.
 
Back
Top