How to 'remote upload' to Teensy4?

Hi.
This are my first steps (fresh installed environment) with PlatformIO and i run into problems to upload my code to Teensy4 by remote agent.

If i click PlatformIO => PROJECT TASKS => “Remote Upload”, the following is the first output-line:

Executing task in folder smallTestProject: platformio remote run --target upload

To get more output i executed “platformio remote run --target upload -v”, this is the output (of the upload):

Uploading firmware remotely
Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)

([“upload”], [“.pio/build/teensy40/firmware.hex”])
AVAILABLE: jlink, teensy-cli, teensy-gui
CURRENT: upload_protocol = teensy-cli
teensy_reboot -s
teensy_loader_cli -mmcu=imxrt1062 -w -s -v .pio/build/teensy40/firmware.hex
Unknown MCU type “imxrt1062”
Supported MCUs are:

  • at90usb162
  • atmega32u4
  • at90usb646
  • at90usb1286
  • mkl26z64
  • mk20dx128
  • mk20dx256
  • mk66fx1m0
  • mk64fx512
  • TEENSY2
  • TEENSY2PP
  • TEENSYLC
  • TEENSY30
  • TEENSY31
  • TEENSY35
  • TEENSY36
    *** [upload] Error 1
    ========================== [FAILED] Took 1.89 seconds ==========================

Why i got the message “Unknown MCU type “imxrt1062”” ???
If i switch to the remote (raspberry), and cwd into ~/.platformio/remote/projects/smallTestProject-65256b697b56d59d708bf4158b50512f275f4d6c
and execute the cmd as written in the above output (teensy_loader_cli -mmcu=imxrt1062 -w -s -v .pio/build/teensy40/firmware.hex) the programming of the teensy is done.

So whats my problem?
Is something installed in a incorrect way?
Something configured wrong?

Also tested with a ArduinoDue (same setup) which just worked as expected (no problems during remote upload).

Setup remote
Raspberry (latest raspbian)
platformio-core installed (pio --version = version 4.2.1)
teensy_loader_cli cloned from github and compiled (to be sure it’s in the path, i link in /usr/bin was also created).
udev-rules installed

Setup Development
Debian 10 as Virtualbox-Guestsystem
VSCodium and PlatformIO installed

Project:
New created via ‘PlatformIO Home’->“New Project” and Teensy4 selected.

platformio.ini:

[env:teensy40]
platform = teensy
board = teensy40
framework = arduino

This is correct - the documentation for teensy_loader_cli says to use --mcu=imxrt1062 for the Teensy 4.0. If it doesn’t work, it is most likely the teensy platform on your desktop needs updating. The fact that the Teensy4 isn’t at the end of that list also suggests the teensy_loader_cli is an old version. Either use PIO Home to check if your teensy platform version needs updating, or alternately, you ran open a PIO Terminal and run pio update -c to check for updates, or pio update to update any out of date packages/platforms.

Thanks for your reply.
But i can’t see why you suggest to update anything.
As i have written in my first post, the whole setup (starting from the OS-Level) was installed the day i have written the post.
In detail:

It does work if i execute “teensy_loader_cli -mmcu=imxrt1062 -w -s -v .pio/build/teensy40/firmware.hex” on the remote system (the one where the teensy is connected to) directly in the terminal.
But why you are saying i have to update the teensy platform on my desktop?
teensy_loader_cli is NOT installed on my desktop, as there is no teensy connected to my desktop.
teensy_loader_cli is only installed at the remote-system (raspberry) where the teensy is connected to.
Is there any reason to install teensy_loader_cli also on the desktop (on which the teensy is NEVER connected to)???

It’s the latest version directly from github, cloned the day i have written the first post and compiled from the source-code.
And as mentioned, it does work as expected if i upload the firmware.hex by executing teensy_loader_cli from the commandline.

As expected (as it’s a fresh install), everything is reported as ‘Up-to-date’.

Output of pio update -c on the remote (raspberry):

markus@rasp-pio:~ $ pio update -c
Checking contrib-pysite @ 2.37.191017 [Up-to-date]
Checking tool-pioplus @ 2.6.2 [Up-to-date]
Checking tool-scons @ 3.30102.0 [Up-to-date]

Platform Manager

Platform Atmel SAM

Checking atmelsam @ 4.1.0 [Up-to-date]
Checking framework-arduino-sam @ 1.6.12 [Up-to-date]
Checking framework-cmsis @ 1.40500.0 [Up-to-date]
Checking framework-cmsis-atmel @ 1.2.0 [Up-to-date]
Checking tool-bossac @ 1.10700.190624 [Up-to-date]

Platform Teensy

Checking teensy @ 4.7.1 [Up-to-date]
Checking framework-arduinoteensy @ 1.149.0 [Up-to-date]
Checking tool-teensy @ 1.21.1 [Up-to-date]

Library Manager

Library Storage: /home/markus/.platformio/lib

Output of pio update -c on the development-system (desktop):

markus@markusarduino:~/Documents/PlatformIO/Projects/smallTestProject$ pio update -c
Checking contrib-piohome @ 3.1.1 [Up-to-date]
Checking contrib-pysite @ 2.37.191017 [Up-to-date]
Checking tool-pioplus @ 2.6.2 [Up-to-date]
Checking tool-unity @ 1.20500.0 [Up-to-date]
Checking tool-scons @ 3.30102.0 [Up-to-date]
Checking tool-cppcheck @ 1.189.0 [Up-to-date]

Platform Manager

Platform Atmel SAM

Checking atmelsam @ 4.1.0 [Up-to-date]
Checking toolchain-gccarmnoneeabi @ 1.70201.0 [Up-to-date]
Checking framework-arduino-sam @ 1.6.12 [Up-to-date]
Checking framework-cmsis @ 1.40500.0 [Up-to-date]
Checking framework-cmsis-atmel @ 1.2.0 [Up-to-date]
Checking tool-openocd @ 2.1000.190707 [Up-to-date]

Platform Teensy

Checking teensy @ 4.7.1 [Up-to-date]
Checking toolchain-atmelavr @ 1.50400.190710 [Up-to-date]
Checking toolchain-gccarmnoneeabi @ 1.50401.190816 [Up-to-date]
Checking framework-arduinoteensy @ 1.149.0 [Up-to-date]
Checking tool-teensy @ 1.149.200123 [Up-to-date]

Library Manager

Library Storage: /home/markus/.platformio/lib

So why is platformio not able to update the teensy?
Why platformio does report the board is not supported, but teensy_loader_cli does support the board and uploading by calling teensy_loader_cli from terminal will do the job?
Does platformIO use some kind of internal teensy_loader_cli which isn’t up-to-date?
If yes, is there any possibility to tell platformIO to use the actual and installed teensy_loader_cli on the remote?

1 Like

My apologies, I missed that you were working with a remote agent. :man_facepalming:

I said to update because it is quite clear from the output of teensy_loader_cli -mmcu=imxrt1062 -w -s -v .pio/build/teensy40/firmware.hex on your remote device it is not a version of teensy_loader_cli that supports the teensy4. Perhaps the PlatformIO teensy toolchain for the rPi has not been updated recently? Unfortunately Paul is a bit slack in updating the version number in teensy_loader_cli and it’s been version 2.1 for the last three years, so there is no point checking that. :laughing:

Since you’ve cloned and compiled the teensy_loader_cli binary (thus have the latest version for your architecture handy), try replacing the copy in ~/.platformio/packages/tool-teensy and see if that fixes it, as PlatformIO should only look for it’s own copy. If that is indeed the problem, you could also open an issue at in the platformio teensy repo and link your working binary, so Ivan can update the package.

Edit: PlatformIO by design will only use it’s own toolchains… that’s part of the whole goal - no need to install stuff yourself. But occasionally stuff slips through, or there’s just not enough people using the different combinations. I’m not sure how you would go about over-riding to use a system-installed copy of the loader… if I were me I’d just replace the binary, or perhaps just link to the copy you’ve put in /usr/bin.

thanks to pointing me to the internal version of teensy_loader_cli of platformIO.
after replacing ~/.platformio/packages/tool-teensy/teensy_loader_cli with a link to the compiled (from teensy_loader_cli github-repo) teensy_loader_cli i am now able to compile and upload remote to the teensy4.

In case someone else also plans to use teensy4 remote:
Another problem is that i always have to press the ‘reboot’-button on the teensy during uploading, which does of cause not work for me as it’s planned to program the teensy remotely.
After some searching i found the following post:

It seems platformIO execute a script called “teensy_reboot” just infront of calling teensy_loader_cli (and this teensy_reboot is empty right now), i just added the following code to the teensy_reboot script (taken from the mentioned post):

SERIAL_TEENSY_DEVICE=find /dev/serial/by-id/ -name "usb-Teensyduino*";
echo “-> Performing soft resset (baud = 134 hack). $SERIAL_TEENSY_DEVICE”;
lsusb | grep Teensy;
stty -F $SERIAL_TEENSY_DEVICE 9600
sleep 1;
stty -F $SERIAL_TEENSY_DEVICE 134
sleep 1;
lsusb | grep Teensy;
echo “-> Should be ready to program…”;

But beware: This of course only works if the Teensy has the serial interface activated. For the HID modes you need to send some magic bytes to the feature report of one of the interfaces. (teensy_loader_cli and Teensy 4.0? | Teensy Forum)

With this two changes it’s now possible to upload to teensy4 remotely.

And as suggested, i also opend an issue: Update teensy_loader_cli · Issue #60 · platformio/platform-teensy · GitHub

2 Likes