Can no longer upload to Teensy 4.1 via PlatformIO or Arduino IDE

Hey All,

I have been trying to figure out my problem for hours today and have come up with nothing.

I can no longer upload to my Teensy 4.1 from platform IO and can't open the serial monitor in the Arduino IDE. I can INTERMITTENTLY upload via the Arduino IDE, however.

The problem started after the Arduino IDE Serial Monitor froze and went black. I had to "end task" to close the IDE. Ever since I have had this issue.

I have reinstalled Teensyduino and the Arduino IDE. I have tried different USB cables and ports. I have tried uploading code that I know works. I have tried different Teensy 4.1s. It may be worth noting that the code does upload from my laptop (so the boards are fine), but I'm not about to fold and stop using my desktop.

- In PIO, I get stuck at "uploading .PIO\build\teensy41\firmware.hex" and then after several minutes it states "Teensy did not respond to a USB-based request to enter program mode."

- In the Arduino IDE, under "ports" it only ever says "COM7..." and doesn't change if I change ports. Previously this changed whenever changing the USB port the board was plugged into.

- In the Arduino IDE, it hangs at "uploading." IF the upload was successful and I try to open the Serial Monitor, it states "Board at usb:80000/1/0/6/2 is not available."

- In the Windows "device manager" it used to say "Teensy USB Serial (COM...)" and this is no longer present, it just says USB Serial Device (COM....).

Any help would be greatly appreciated! I've used up too much of my weekend trying to figure this out; I hoped to have made a lot of progress this weekend on my project... :/
 
Not seeing a clear resolution path given the info as it seems unique and odd.

USB Hub here occasioanlly goes offline on upload and all devices go away - have to unplug the USB to PC cable and all is well.

What OS and version and IDE version and TeensyDuino version are in use?

For Windows the download of TYQT/TyCommander is a great Serial Monitor replacement - and can do uploads to T_4.1 (when not the lockable and locked versions). To use that find the thread for it and download and for IDE 1.8.19 it can integrate to Arduino. Close the Teensy Loader and any IDE SerMon and the TyCommander should show the Teensy and if it works then great - if not then something is wrong and blocking the USB from working.
 
So I think I fixed it... Well, mostly. I did a fresh install of Windows 11 and I can upload and open the serial monitor from PlatformIO. The only thing is, I have to press the Teensy's button after clicking the "Upload" button, and once the terminal says "Uploading."

Also, I was getting an error stating "Teensy's SD library uses a custom modified copy of SdFat. Standard SdFat was mistakenly used. Arduino should print multiple libraries found for SdFat.h. To resolve this error, you will need to move or delete the copy Arduino is using, or otherwise take steps to cause Teensy's special copy of SdFat to be used."

I have uninstalled the Arduino IDE and reinstalled it. I have reinstalled Teensyduino. I have deleted the SD library in the Arduino folder. No luck.

Now I am getting "src\main.cpp:20:16: fatal error: SD.h: No such file or directory."

If I include "adafruit/SD" in the platformio.ini file, I get the following "BUILTIN_SDCARD' was not declared in this scope"
 
Last edited:
I've been having similar issues with PlatformIO for a few months. I posted about this twice on the PlatformIO forum (most recent post, original post), but haven't been able to get a resolution. My current workaround (which now only works ~80% of the time) is to kill the Teensy Uploader before hitting the PlatformIO compile/upload button. This causes the Uploader to be automatically restarted.

I was about to post about this issue here when I saw your post and decided to jump in. I'm starting to wonder if there's some compatibility issue between the Teensy Uploader and PlatformIO that has only surfaced in the most recent PIO updates. It's worked fine for a couple of years until recently.

Anyone have any ideas?

Edit: MacOS 11.7, PIO Core 6.1.7a3, PIO IDE 3.0.0, Teensy Loader 1.5.7
 
I have something similar on a Mac. Luckily it is just freezing the upload and I am able to set it back. What I have to do is to kill the teensy_reboot process (that sometimes is running several processes in parallel). I can reduce the amount of freezes of the uploading by the small teensy uploader app every time I used it.
It seems, that I happens more regularly with big sketches, while it never occurred with small ones. It is not continuous in a way, that sometimes I have this problem way more than 10 times per hour, some days there is not a single one the full day.
My resolution is to close the app every time I use it (and remember to do so) as well have a terminal open, where I can quickly recall that "killall -9 teensy_reboot"

I can say, that PlatformIO gets more and more annoying the bigger the project gets. The duration between the uploader shows 100% uploading and the Teensy restarting takes up to 20 seconds. The Serial monitory that I am used to start and reconnect automatically always runs into a timeout.
I don't know if this has to do with PlatformIO or the Teensy-Tools. I have not used Arduino IDE for such projects because I think it is not useable for projects having more than a hand full of files and I am at around 200...
 
Lots of people seem to have lots of problems using PlatformIO.
I looked at it but never got into it. I use VisualMicro with Code Studio.
It gives me all I want of a coding environment.
 
If I include "adafruit/SD" in the platformio.ini file, I get the following "BUILTIN_SDCARD' was not declared in this scope"

Of course it won't work if you use a SD library published by Adafruit.

These are the libraries Teensy uses:

https://github.com/PaulStoffregen/SD

https://github.com/PaulStoffregen/SdFat

Now here is the part where I rant a bit about PlatformIO. Over and over we get these support questions where pretty fundamentally basic things don't work on PlatformIO, because libraries and other stuff not meant to Teensy were used, or a different version of the compiler or even substantially different compiler options were used. Maybe all non-Arduino platforms are like this too, but PlatformIO is the one that regularly causes so much trouble.

With Arduino we also get this problem, but it's much less common. When it does happen Arduino almost always prints the warning about duplicate libraries found to clearly state which library it used and which it ignored. On Arduino, installing Teensyduino (Arduino 1.8.19 or earlier) or Teensy software from the Boards Manager (Arduino 2.0.0 or later) installs a complete set of the Teensy customized libraries. It also installs the gcc toolchain we use and sets up the build process to use the same consistent set of compiler options. The result is a pretty dependably consistent build process with the correct libraries.

Somehow PlatformIO regularly gets used with the wrong libraries, other gcc toolchains, and different compiler options than how all the software was developed and tested.
 
Yes that's another advantage of VisualMicro with Code Studio, it piggy backs on top of the Arduino IDE.

You don't have all the reported PlatformIO problems.
 
+1 for Visual Micro. I just got it up and running for the first time a few days ago and it is life-changing.
 
Yes, it seems like we're experiencing the same issue. I think I'll start a new thread about this, since the responses here are mostly about the SD library compatibility issue. I've been using PlatformIO for a few years, and the upload/serial monitor process has worked fine until a couple of months ago.
 
Back
Top