I’ve done a lot for years with Teensy 3.2 and Teensy 4.0. I recently started playing with Teensy 4.1, and I get a strange behaviour on upload. As the title suggests, it fails specifically every second time. When it fails, it looks like this:
Building in release mode
Linking .pio/build/teensy41/firmware.elf
Checking size .pio/build/teensy41/firmware.elf
Building .pio/build/teensy41/firmware.hex
Configuring upload protocol...
AVAILABLE: jlink, teensy-cli, teensy-gui
CURRENT: upload_protocol = teensy-cli
Rebooting...
Uploading .pio/build/teensy41/firmware.hex
Teensy Loader, Command Line, Version 2.2
Read ".pio/build/teensy41/firmware.hex": 333820 bytes, 16.4% usage
Error opening USB device: Operation timed out
Waiting for Teensy device...
(hint: press the reset button)
Found HalfKay Bootloader
Read ".pio/build/teensy41/firmware.hex": 333820 bytes, 16.4% usage
error writing to Teensy
*** [upload] Error 1
Programming...========================== [FAILED] Took 4.35 seconds ==========================
If I switch to the teensy-gui uploader, it uploads every time, but the serial monitor doesn’t resume:
Error: [Errno 2] could not open port /dev/cu.usbmodem117574901: [Errno 2] No such file or directory: ‘/dev/cu.usbmodem117574901’
But I just press up and enter and it’s fine. It seems in either case it could be a timeout waiting for the socket to become available.
Everything is up to date. I made a blink sketch, that worked fine every time. Then I added NativeEthernet, still worked every time… then I added NativeEthernetUdp - that did it. Failed every other time, same as before. Here’s my code if you want to try and replicate it (obviously must be on a Teensy 4.1 with ethernet):
I had to update the Arduino IDE as it’s been a good five years since I’ve used it, but then it appears to just use Teensy Loader anyway. Uploads every time.
I just tried a clean Atom & PlatformIO install on a spare Mac Mini, running the latest macOS. Exactly the same problem presents.