Can the Teensy 3.0 be programmed without pressing the button?

Status
Not open for further replies.

astroyam

Well-known member
I would like to encase a Teensy for a submersible application, but would like to be able to reprogram it. Since it will be encased, I can't press a button.
However I am wondering if that's what the Program button is for, or is there another button for that. Can I output a digital output high from the Teensy to itself somewhere to cause a reprogram? For example the code could be checking for a 'p' on the serial port, and then it would send a high to the correct port to have the Teensy reprogram, as if it was a button.
 
I reprogram my Teensy 3.0s all the time without pressing the reset button. Occasionally, I need to try several times or disconnect power, but that may be related to my 2007 MacBook Pro. No need for special wiring.
 
Like pictographer I can reprogram my Teensy 3.0 without hitting the button. I think it's really only needed for initial program; after that the Teensy loader application opens the USB serial port in a specific way and starts the upload.

On the other hand, you're submersing the board but it sounds like you'll have a cable from underwater up to a computer (USB? Power? both?) for reprogramming. Couldn't you add another pair of wires connecting to the same Mini54 pins as the on-board button?
 
If your program leaves interrupts disabled forever, or if it crashes by accessing memory than doesn't exist, then the board will not be able to hear the reboot request on the USB.

With "normal" Arduino programming, these are rarely problems. But if you write low-level code to directly access hardware, careful attention to detail is needed.

For uploading to a board without access to the button, a smart strategy would be to first test the code on another board where you can press the button. Then only upload to the real one after you're sure the code is good and unlikely to crash.
 
On the Teensy3, the PC loader software v1.15, with the Automatic mode disabled, greys-out the "program" menu option. If it were enabled, perhaps the PC side could invoke the re-download.

On the hardware side, I think you should be able to connect an I/O pin to the "Prog" board interface point- one of the 5 holes on the end of the board. Bottom of board has a "P" on that socket. Connect this to an I/O pin that isn't used by the system or your software- and because it "floats", and hopefully no software sets is to a LOW (logic 0), your program should run with this added jumper. Then, when your program decides (by whatever means), it needs to trigger a re-download, it can set that pin as an output and make it LOW. I haven't tried this. As was said, if the program running goes in some berserk modes, you'll still need the push button, or wire up that P pin and ground to a button located elsewhere, minding the possible introduction of noise).

Paul might know a way, but from the schematic, I didn't see a way for the ARM CPU to tell the MINI54TAN chip to commence a download. Hence, the above.
 
_reboot_Teensyduino_() - it works!!

But... if my code invokes the reboot/start download, and the Arduino console window is open and using USB virtual serial, the IDE gets confused. I have to close the console window then hit the T3's button.

Maybe I need to end the "Serial" USB before calling the reboot.

... I was using a special key on the PC keyboard to tell my code to force a reboot.
More thinking needed. Probably doesn't happen on a hardware UART port connection to the PC.
 
Last edited:
What am I missing?

For me here, the 'Program and Reboot software buttons are greyed out, unless I turn off automatic mode and press the hardware button. Is there a way to get them green without pressing the hardware button? Seems I am missing a basic something...
I am using RawHID mode, is this relevant? With Teensy Loader V1.07.
My code is attached just in case...


Like pictographer I can reprogram my Teensy 3.0 without hitting the button. I think it's really only needed for initial program; after that the Teensy loader application opens the USB serial port in a specific way and starts the upload.

On the other hand, you're submersing the board but it sounds like you'll have a cable from underwater up to a computer (USB? Power? both?) for reprogramming. Couldn't you add another pair of wires connecting to the same Mini54 pins as the on-board button?
 

Attachments

  • T3_Sample.ino
    2.1 KB · Views: 168
Hi Paul, right now the software buttons for uploading and rebooting get greyed out unless I turn off auto mode and press the physical button. Is there a way around that at all?
 
Teensy Loader only knows how to recognize and use Teensy when it's running the bootloader.

When Teensy runs your program, it's acting as a completely different type of device (usually Serial, HID Keyboard, MIDI, etc), so those buttons are disabled. There's no realistic way around that.

Teensy needs to reboot to the bootloader and appear to your PC as the right device type for Teensy Loader to be able to see it and enable those buttons. There's 2 ways to reboot... either press the button, or call the _reboot_Teensyduino_() function, which tries to emulate a reboot.
 
OK thanks.
Both the _reboot_Teensyduino_() and the teensy_reboot.exe in hardware/tools seem to do just what I want, ie load new code without touching the button.
I understand that if I put in flawed code it may not recover, but I'm not worried about that as I will test the code first on teensies with buttons accessible.
THanks.

Teensy Loader only knows how to recognize and use Teensy when it's running the bootloader.

When Teensy runs your program, it's acting as a completely different type of device (usually Serial, HID Keyboard, MIDI, etc), so those buttons are disabled. There's no realistic way around that.

Teensy needs to reboot to the bootloader and appear to your PC as the right device type for Teensy Loader to be able to see it and enable those buttons. There's 2 ways to reboot... either press the button, or call the _reboot_Teensyduino_() function, which tries to emulate a reboot.
 
On the Teensy3, the PC loader software v1.15, with the Automatic mode disabled, greys-out the "program" menu option. If it were enabled, perhaps the PC side could invoke the re-download.

On the hardware side, I think you should be able to connect an I/O pin to the "Prog" board interface point- one of the 5 holes on the end of the board. Bottom of board has a "P" on that socket. Connect this to an I/O pin that isn't used by the system or your software- and because it "floats", and hopefully no software sets is to a LOW (logic 0), your program should run with this added jumper. Then, when your program decides (by whatever means), it needs to trigger a re-download, it can set that pin as an output and make it LOW. I haven't tried this. As was said, if the program running goes in some berserk modes, you'll still need the push button, or wire up that P pin and ground to a button located elsewhere, minding the possible introduction of noise).

Paul might know a way, but from the schematic, I didn't see a way for the ARM CPU to tell the MINI54TAN chip to commence a download. Hence, the above.

A little follow up on this suggestion. Firstly it does not work simply by tieing the GPIO pin from K20 onto the program pin. The K20 only manages to assert LOW for 100uS. It is not long enough, this causes the RESET_B to be triggered and the running code stops. However the bootloader does not see this as a valid LOW signal and you end up with a dormant system. You need to manually press the program button to get the bootloader to do its thing.

Therefore a little interface circuit is needed. I used a 2N7002 n-channel FET, 1uF smd cap and a couple of resistors and a diiode. It sounds a lot, but actually I managed to squeeze the whole circuit between the GND and PROGRAM pads, tiny SMD components naturally.

Teensy3.2_Reprogram_Circuit.png

When GPIO goes high, the 1uF rapidly charges through the diode and 200ohm resistor (which is there to limit the current from the GPIO pin of the K20). This switches on the FET and shorts program to GND, starting the re-program sequence. But now when the RESET_B line triggers and the K20 GPIO pin drops low, the diode blocks and the cap now must discharge through the 390K resistor, ensuring that the FET remains on long enough for the re-program singnal to be seen correctly by the MKL02.

As a note, a simple capacitor does not work. The cap must charge when the Teensy is powered up and this confuses the bootloader and the Teensy never starts. Therefore the circuit above is needed and this does work.


Hope that helps.
Aidan
 
Last edited:
you could wire R and P to spare gpio pins, and send a command over serial to reboot/reprogram toggle it

oops just read above, im sure an additional part could help, like a cap as demonstrated for POR resets
 
Status
Not open for further replies.
Back
Top