Oh right I forgot about that. The teensy tools (and thus also PlatformIO) can reboot the teensy automatically into bootloader mode if the firmware exposes the standard USB serial. But for that an extra teensy program called teensy_reboot
must be used. Once the teensy.exe
GUI is open and says “press reset button”, you can just execute the teensy_reboot
program and then teensy.exe
will see the device, no reboot button pressing needed. This has already outlined in arduino ide - Use command line to upload program through hex file to Teensy-LC - Arduino Stack Exchange.
Note that these tools are for some reason not available for a precompiled download from the Teensy website, only when one would install the full Teensyduino Arduino IDE extension. However, you can grab the files (that is, actually all teensy related tools) from PlatformIO. The API request https://api.registry.platformio.org/v3/packages/platformio/tool/tool-teensy shows the available OSes and download links, e.g.
- Windows 32 and 64-bit: https://dl.registry.platformio.org/download/platformio/tool/tool-teensy/1.154.0/tool-teensy-windows-1.154.0.tar.gz
- Linux 64 bit: https://dl.registry.platformio.org/download/platformio/tool/tool-teensy/1.154.0/tool-teensy-linux_x86_64-1.154.0.tar.gz
- Mac ARM and 64-bit: https://dl.registry.platformio.org/download/platformio/tool/tool-teensy/1.154.0/tool-teensy-darwin_x86_64-1.154.0.tar.gz
(needs e.g. 7zip to extract the .tar.gz
)
There’s also a more automated way of doing it with all these tools available. One can just put the two tools teensy_reboot.exe
and teensy_loader_cli.exe
in the same folder as the firmware.hex
and the following simple upload.bat
script (this is Windows specific of course)
@echo off
echo Rebooting device
teensy_reboot.exe -s
echo Flashing firmware
teensy_loader_cli.exe -w -s -mmcu=TEENSY41 -v firmware.hex
pause
So, simply double-clicking on upload.bat
will do a reboot & flash & reboot to firmware, then ask to press a key to close the window.
The script can be trivially written for Unix-like OSes (aka, Linux & Mac) too. They will need the appropriate version of the tools for their OS too, of course.
And finally, if your users are themselves developers who already have PlatformIO, you can just compile locally once, then clear the .pio\build\<env>\
folder while not deleting the needed firmware.hex
. Users can then do a upload without compile (taking the existing firmware.hex
) with pio run -t nobuild -t upload
as explained in Upload Latest build without a Compile/Link - #4 by ivankravets. Then PlatformIO would also automatically take care of downloading the correct version of the tools since it draws those from the PlatformIO registry. This would need a whole PlatformIO installation of course, and the distribution package above there is more compact.