Teensy Loader / PlatformIO Compatibility Issue

Aerokeith

Well-known member
I've been using the Teensy 4.0 for several years as part of an LED controller for outdoor art installations (like this one). I've had some challenges for sure, but all were eventually overcome, often with help from this community (thanks!).

For most of that time I've been using the VSCode + PlatformIO (PIO) development environment. PIO is complex and has some quirks, but it's generally been reliable. I rely on the PIO community forum to get past any issues that I can't figure out myself.

Now I find myself stuck on an issue that appears to be a compatibility issue between the Teensy Loader and PIO. It cropped up about 6 months ago. I posted about this on the PIO forum (most recent post, original post), but I haven't been able to get a resolution. It appears that the PIO folks fixed a related bug, but it had no impact on my situation. I haven't been able to get the developers to respond since the original post.

The problem is that the Teensy Loader sometimes (not always) "stalls" during code upload, and this appears to impact the startup of the PIO serial monitor. The stall duration is inconsistent, and can be up to 15-20 seconds. When the upload completes (and sometime it doesn't), the serial monitor sometimes (not always) start up, but if it does start, I've missed all of there messages that my code sends at a startup. This make debugging really difficult.

Here are the details of my environment: MacOS 11.7, PIO Core 6.1.7a3, PIO IDE 3.0.0, Teensy Loader 1.5.7

There was another post on the PJRC forum that referred to this problem, but it also mentioned some unrelated issue, so I thought it would be best to start a thread just on this issue.

Anyone else have similar problems, or know how to fix it? Thanks!
 
My first question for all PlatformIO issues is whether the same problem happens when using Arduino IDE.

Going to skip another PIO rant, but please understand PIO is not a consistent software install we can easily support. Over and over, we hear reports of things not working because all sorts of software and settings not meant for Teensy get used. With Arduino IDE, knowing the IDE version and Teensyduino version gives a very good idea of exactly what your setup really is.
 
Thanks for the quick response, Paul! I haven't used the Arduino IDE in a long time, but I fired it up and tried it with the Blink example sketch. (It would take a while to translate my multi-file program back to that environment). Interesting results: Every time I hit the compile/upload button, I got the "An error occurred while uploading the sketch" message. Regardless of the message, it did successfully upload and execute every time, but the amount of time to complete the upload (while the red upload LED was active) varied from about 3 seconds to 22 seconds. The average duration seems to increase the more times I tried. So something strange is definitely going on. I'll play around some more to see if I find more clues.

Over and over, we hear reports of things not working because all sorts of software and settings not meant for Teensy get used
Yeah, I'm aware of that, and I've run into that type of issue occasionally. I don't think that's what's going on here, especially since I see the same behavior for multiple programs that use different libraries.

I'm open to the idea of abandoning PIO, but I've really come to appreciate VSCode. Do you have any suggestions?
 
A little more info. After I rebooting my Mac, I no get the "An error occurred while uploading..." message. For the first ~8 uploads everything was very quick, but after that it started to bog down again. So basically the same as I reported before, just without the error message.
 
Very satisfied PlatformIO user here. Have used it without any problems for many years. Perhaps one of the reasons is that I *don't* use the native graphical teensy uploader. In my platformio.io for all my projects I specify
Code:
upload_protocol = teensy-cli

Environment: Linux x86_64
 
Code:
upload_protocol = teensy-cli
Many thanks, kind stranger! That worked like a charm! Uploaded a large-ish program 20 times, and it was blazing fast every time.
So it looks like there may be an issue with the "graphical" uploader with both PIO and the Arduino IDE.
 
I'm open to the idea of abandoning PIO, but I've really come to appreciate VSCode. Do you have any suggestions?
Use Visual Micro with Visual Studio (the grown up version of Visual Code).
Visual Micro piggy backs on the top of the Arduino IDE.
 
Use Visual Micro with Visual Studio (the grown up version of Visual Code).
Visual Micro piggy backs on the top of the Arduino IDE.

BriComp:
A while back I decided to try your suggestion on my Mac(OS Monterey 12.6.3). It would not even install, I got a whole lot of errors with no explanation as to what the errors meant.

Regards,
Ed
 
BriComp:
A while back I decided to try your suggestion on my Mac(OS Monterey 12.6.3). It would not even install, I got a whole lot of errors with no explanation as to what the errors meant.

Regards,
Ed

Was that errors with Visual Studio or Visual Micro?
 
BriComp:
This happened a couple of months ago, someone on this forum (It might have been you) provided a link to Visual Micro and I decided to try it out. (I have been using Visual Studio with PIO since EmbedXcode died) I clicked on the provided link which took me to the Visual Micro home page and selected the installer for the Mac and it blew up very quickly, so I just decided to continue to use PIO with Visual Studio and have not had any major problems with it since. (However I always kill the teensy loader as soon as it is finished loading, and I only use Coolterm for watching the output from the teensy)
If I don't kill Teensy loader the downloader fails every time, I have just become used to this small quirk in the use of PIO with Visual Studio.

Regards,
Ed
 
Did you install Visual Studio, before you tried to install Visual Micro?
Visual Micro is an add on for Visual Studio.
EDIT:
I should also say I work on a PC, not MAC.
 
Last edited:
Same here, nothing on the Visual Micro page matches with the Visual Studio I am able to download for Mac. I spent way too much time trying to get that running.

While I can totally understand, that Paul does not want to support multiple IDEs, I still cannot understand, why he limits himself and his community to the Arduino IDE. The Arduino IDE is the worse IDE I worked with for ages. Most modern Text-Editors are better. No Completion, no Code-Checks, no way to organize code and working with more files than fit into the tab bar is a nightmare. This might fit to 8bit AVRs back when Arduino started, but does not match what is possible with modern device like the Teensy.
 
Did you contact Visual Micro, I have found them to most helpful when I have needed help?
 
why he limits himself and his community to the Arduino IDE. The Arduino IDE is the worse IDE I worked with for ages. Most modern Text-Editors are better. No Completion, no Code-Checks, no way to organize code and working with more files than fit into the tab bar is a nightmare.

Maybe you haven't seen Arduino IDE 2.0 yet?

But to answer your original question (to the extent it's really a question), basically 3 reasons why Arduino IDE.

1: History - Most free Mac/Windows/Linux IDEs available today are fairly recent, they simply didn't exist over much of the 14 years of Teensy.

2: Inertia - Teensy development has tended to focus heavily hardware and optimized libraries and technical support, leaving little attention to the PC-side tooling.

3: Package Delivery - Software for Teensy is meant to be delivered as a set of libraries, toolchain, settings, utilities tested to work together.
 
Did you install Visual Studio, before you tried to install Visual Micro?
Visual Micro is an add on for Visual Studio.
EDIT:
I should also say I work on a PC, not MAC.

BriComp:
I already said I have been using Visual Studio since EmbedXcode died.
I have searched the add-on section for Visual Micro Arduino and it does not exist on my recently upgraded Visual Studio.
I guess it is only for Windows.

Regards,
Ed
 
I thought PIO only worked with Visual Studio Code.
EDIT:
Just did a search on Google and Visual Micro is only able to support Visual Studio on Windows.
Does Visual Micro work with Visual Studio for Mac? Sadly the Visual Studio for Mac is a different product which does not support the C++ programming environment required for Visual Micro.
 
No. In my over 30 years of using computers I learned, that if a software needs support during installation, I don’t have the time to use it. We use IDEs to make our life easier. to help us finish our project, to remove friction in what we are doing. I don’t need a piece that is working against me. On their website is a how to with pictures, that explains how to install the micros extension into Visual Studio. The images are wrong, they name menu items that don’t exists, and even after trying to find it myself, there is no Visual Micros Extension available, if you search for it in the Extension-Manager. So either this is all outdated, doesn’t match VS2022Community or they just ignored, that the Mac version might work differently. Whatever it is, the time I spend trying to install it, I can just work on what I am working on :)

Yes, PIO isn’t working flawless too, but in 99,9% of the times, it doesn’t get into my way, and I can use the same IDE for nearly any Microcontroller I work with.
 
Uija:
I agree.
In the 60+ years of designing, coding, and using various computer's I have used a lot of different environments. In the 80's working at Hughes Aircraft we had insanely (these systems cost more than a house in that era) expensive IDE's for the systems we were working on. It wasn't until I began using free Xcode(with a plugin for the 8-bit AVR's) in the 2005 era, that I really came to appreciate value of a great IDE. All the things you mentioned above, as well as the native MacOS integration made it a very fun experience coding. But you must realize that the Arduino system was originally designed for the use of children, ie blossoming coders of the very young. It is a toy and nothing else. I have seen this kind of use case for decades, were a very simple program is used by many for things it was not originally intended to be used for.
There is a very old lesson here, use the right tool for the right job. (for those of us old enough to remember "Primitive Pete Movies")

Regards,
Ed
 
I am totally with you there, and I can remember how awesome it was, to not have to mess around with that AVR stuff, when you didn't need every bit of memory etc. I don't want to rant about the Arduino project, but since the launch of the Arduino project nearly 18 years passed, and while the Arduino world continue to grow and get more and more diverse, for the user wanting to write code, nothing really happened over the years. I tried Arduino 2.0 a few weeks ago, and yes, it now has Autocompletion and the UI seems to be fluent, but I am still not able to decide, where my Project is located, need to add files to the tab, am not able to place them in folders etc. It looks as if they again wrote an IDE from scratch instead of using one of those hundreds of frameworks to put the Arduino stuff on top.

Don't get me wrong, I think Arduino is the most important step that made Microcontroller accessible to everyone and lets creators do incredible stuff, but with the power of the 32bit systems, more memory etc., people want more than let some LEDs in their Cosplay-Armor blink and play 2 sounds for their laser swords.
My Sequencer currently has around 200 .h and .cpp files with together nearly 16k lines of code. That does fit onto the device, but not really in the Arduino IDE.
 
Honestly if you do a lot of work with Teensy, you should buy a cheap Windows laptop to use Visual Micro. No, there isn't a Mac version, but it is hands-down the best coding environment.

You can still set up Microsoft Remote Desktop to access it from your Mac. It's latency-free and the resolution changes to match your Mac laptop, is Retina-display compatible and the ⌘-C ⌘-V etc. commands carry over. You can even cut-paste from your Mac to the PC. It's just as seamless as having it as a native program on your Mac, with the added bonus that you can now code over WiFi from anywhere while the PC laptop sits connected to your Teensy. It is really the ultimate setup.

After using it for a week I can attest that if you are attempting anything remotely complicated on a Teensy, there is no excuse to be using anything other than a professional coding environment like Visual Studio. Staying with Arduino IDE is shooting yourself in the foot with a bazooka.

As an added tip, I recommend disabling the "Use Mac shortcuts" option in Remote Desktop, and using PowerToys in Windows to swap the CMD and Ctrl keys instead.
 
Last edited:
Back
Top