Teensy Loader CLI specify upload port

jrkb

New member
Hallo,

I have a remote Linux machine with multiple teensy 4.0 attached via USB (no physical access).

One of them needs to get the code updated, but when I try to upload, Teensy Loader automatically selects the other one (of course, it's always the other one :) ).

I used platformio for this, but there seems to be a bug with specifying the port for Teensy Loader.
The command from me was (`pio run -e teensy40 --upload-port /dev/ttyACM1 -t upload`). It seems that the defined upload port is ignored...
This just as background information, I naturally do not expect to get platformio support in this forum.

My question is:
Can I use Teensy Loader CLI directly to upload the compiled hex file on a specific port?
There does not seem to be a parameter for it in my teensy_loader_cli

HTML:
$ teensy_loader_cli --help
Usage: teensy_loader_cli --mcu=<MCU> [-w] [-h] [-n] [-b] [-v] <file.hex>
	-w : Wait for device to appear
	-r : Use hard reboot if device not online
	-s : Use soft reboot if device not online (Teensy3.x only)
	-n : No reboot after programming
	-b : Boot only, do not program
	-v : Verbose output

Use `teensy_loader_cli --list-mcus` to list supported MCUs.

For more information, please visit:
http://www.pjrc.com/teensy/loader_cli.html

I am very sorry if this is covered by a readme, forum post or tutorial. Somehow I was not able to find it.
 
If it is not possible to define the port... I was considering detaching the usb port of the other one with something like:

usb_modeswitch -v 0x8086 -p 0x0ad3 -b $bus -g $port -d

and afterwards reboot to get both teensies back.

but I don't have physical access to the machine, and really really want to avoid losing access to a usb port... would this be risky?
 
after a bit more research this seems not possible with out of the box teensy_loader_cli.

I'll now try out this branch: https://github.com/hmaarrfk/teensy_loader_cli/tree/serial_number
where I can (hopefully) use the serial number to upload, which is even better.
let's see if that works.

so I would do with a freshly compiled teensy_loader_cli_serial from above repository:
Code:
$ teensy_loader_cli_serial --mcu=TEENSY40 --serial-number=11086920 <path_to_project>/.pio/build/teensy40/firmware.hex

[update] After looking over the code in the above mentioned branch, I saw too many question marks and wouldn't want to risk running it and bricking something ... The only safe solution I can think of right now is to rent a car, drive to the other side of the country, reprogram the teensy and drive back. ;) so i'll do that... any recommendations for technical podcasts I can listen to while driving?

Should this feature be added (upload to a port or serial number), I would be super excited. If there is another safe solution for a situation like this, I'd be also glad to hear about it (for next time then).
 
Last edited:
It may be a non-starter in your case but you can bring the PROGRAM pin low when you use the -w flag (wait) with teensy_loader_cli. I have a remote Pi Zero W uploading to my Teensy4.0 and can confirm that this works, although since I only have one Teensy going straight over USB works as well. I can give more detail later if you'd like. Heading out right now.
 
I have not tried it recently, but if you set the baud rate of the comport of the teensy in question to 134 baud, then Teensy should go into program mode.
Idea is that loader detects first teensy in program mode to download hex file
this can be tested with any terminal program.
 
Back
Top