Automating Programming Mode Entry for Teensy 4.0 Firmware Flashing

I attempted to flash firmware on a Teensy 4.0 via USB using the teensy_loader_cli command:
teensy_loader_cli --mcu=TEENSY40 -w -v {firmware_path}

Before flashing, I need to manually put the Teensy into programming mode by pressing the white push button on the Teensy 4.0 board.

As I want to automate the flashing process, is there a way to enter programming mode programmatically via software instead of manually pressing the button?
If possible, please provide any example code to implement this.
 
Add -s to the command.
Thank you for your answer! The solution you provided worked perfectly, and I am now able to flash the .hex file onto the Teensy without manually entering it into programming mode. I really appreciate your help.
To implement OTA using teensy_loader_cli, I used the teensy_loader_cli.exe, set its path in the environment variable, and was able to successfully flash the file.
Can I perform the flashing of Teensy using the teensy_loader_cli.c source code directly? If yes, could you please share the procedure to achieve this?
 
Back
Top