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 https://arduino.stackexchange.com/a/19845/30175.
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.
(needs e.g. 7zip to extract the
There’s also a more automated way of doing it with all these tools available. One can just put the two tools
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 Rebooting device
echo Flashing firmware
teensy_loader_cli.exe -w -s -mmcu=TEENSY41 -v firmware.hex
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
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.