Teensy 3.1 won't boot unless connected to host computer over USB

iambrentiam

Active member
Hi -

I am having a problem with one of my teensy boards that I have not seen before. Unfortunately, I am not sure how it got into this state. The problem is that the teensy will not boot unless it is connected to the host computer's USB port. It will be working just fine connected. I then unplug the usb it and it still works fine (it has its own power). I press the reset button or do a hard power cycle and it gets stuck, my application does not start. After I plug the USB back in I see the Windows Teensy Boot Loader come to the foreground, the programming progress bar appears and finishes, then my program starts loading just fine.

Could I have accidentally put it in a mode that stalls the boot sequence until it is connected to USB? If so how do I reset it so that it will boot normally without the USB connected?

A little more context: I have the problem teensy connected to another teensy over a CAN bus and the second teensy works as expected. I have been debugging the problem teensy over the CAN bus to see when it boots.

Thanks!!
Brent
 
There is possible a while (!Serial) - forever loop in setup, requiring active USB - add something like this that waits a decent time , then exits. If you never need USB - then just remove the wait on it:

while (!Serial && (millis() <= 4000)) ;

Note: If this doesn't do it then - forum rule says to show your code - here I'm just guessing
 
There is possible a while (!Serial) - forever loop in setup, requiring active USB - add something like this that waits a decent time , then exits. If you never need USB - then just remove the wait on it:

while (!Serial && (millis() <= 4000)) ;

Note: If this doesn't do it then - forum rule says to show your code - here I'm just guessing

Thanks for the response! I did a search on that and it looked like it was being used a lot in the examples but not the core initialization code... This is part of a relatively large project so the code base is pretty complicated... If this problem rings a bell with anyone I would love to hear about it but I can debug it further and try to repro with a simpler code base.
 
Without other info anything is just a guess . . . my only other one is put "delay(2000);" at top of setup. When powered from USB and doing it that way any attached devices have a warm boot head start on the fast starting teensy. Without the USB and advance power applied during upload Teensy starts and runs in milliseconds and might be trying to init cold devices that are not yet ready.
 
Without other info anything is just a guess . . . my only other one is put "delay(2000);" at top of setup. When powered from USB and doing it that way any attached devices have a warm boot head start on the fast starting teensy. Without the USB and advance power applied during upload Teensy starts and runs in milliseconds and might be trying to init cold devices that are not yet ready.

I have some updates:
1) I believe that I was confusing the program mode button with a reset button. So when I was seeing the teensy halt until I plugged in the USB after hitting the button, this is the correct behavior?
2) I am still having a problem where the teensy won't load my application on cold boot most of the time. It seems that about 1 in 5 cold boots does work (with or without the usb plugged in). On the cold boots that dont work after I hit the program button with the usb connected it starts working just fine.

I thought this was maybe a power issue but I have another teensy on the same power bus that works fine. My power supply is pretty beefy and I switch on the power to the devices directly (ie I switch on the power supply and then I switch on the 5v power).

I will try the suggestion above and if that does not work I am going to try swapping out the teensy with another one...
 
Re #1 that button takes the teensy offline to program mode, does not do a reset, took me time to learn that

Do you have usb in the upload from tools? If so you need to debug that with usb output. Something not right.
 
Do you have usb in the upload from tools? If so you need to debug that with usb output. Something not right.

Thanks for the help! I am not sure what you are asking? I am not doing anything special with usb just the usual serial output from the teensy and downloading the program to the teensy.

(Also, I should clarify that both teensy devices are running the same program)
 
Teensy does run your program. Really, it does. If you don't believe this, please first load File > Examples > 01.Basics > Blink.

This question comes up regularly. It's always something in the program that works when Teensy is connected to the PC and has already been turned on, but fails when the PC isn't there, or when powered up cold (eg, trying to initialize other chips before they're ready).

You didn't post code to demonstrate the problem (see the "Forum Rule"), probably because you genuinely believe this is a flaw with Teensy. It's not Teensy. First, if you don't believe me, run the Blink example. Or add similar code to your program, to blink the LED several times *before* you do anything else. You'll see Teensy is indeed running your program.
 
Teensy does run your program. Really, it does. If you don't believe this, please first load File > Examples > 01.Basics > Blink.

This question comes up regularly. It's always something in the program that works when Teensy is connected to the PC and has already been turned on, but fails when the PC isn't there, or when powered up cold (eg, trying to initialize other chips before they're ready).

You didn't post code to demonstrate the problem (see the "Forum Rule"), probably because you genuinely believe this is a flaw with Teensy. It's not Teensy. First, if you don't believe me, run the Blink example. Or add similar code to your program, to blink the LED several times *before* you do anything else. You'll see Teensy is indeed running your program.

Hi Paul - Thanks for the response. Sorry, I did not mean to impugn teensy. Teensy is awesome and what you have done is amazing! :) I didn't post code because its big and complicated and requires a tedious setup but for what it's worth the git hub is https://github.com/beehoppop/TrainControl. Also, I am using every pin so I desoldered the LED (kind of regretting that now...). Originally I thought I accidentally put it in a weird mode which is why I posted but I don't believe that is the case anymore, it must be a bug in my program.

Thanks guys!
 
Well, I added an LED back to pin 13 and loaded up blinky and I am seeing the same behavior so its not my program after all. So now I am back to thinking it could be a power issue so I am going to look into that. But I do have another teensy on the same power rails that boots fine. Maybe I damaged the teensy while soldering my leads onto it?... I have a lead on every io pin....
 
OK. I have discovered something interesting. I have reproduced this on two teensy's now. The problem seems to be related to attaching an input to a motor driver on pin 33 (The line is relatively long, about 10-12 feet). When connected I see this problem, when it is not connected I do not see the problem. This happens on the blink program so my code is not involved.

I found this which may be related: https://forum.pjrc.com/threads/24823-Teensy-3-1-Tying-Pin-33-(pta4)-low-freezes-teensy.

However, I am not able to set pin 33 as an output since my program does not run at all... Should I just not use this pin?

Thanks!
 
Just wanted to leave the solution for my case: Comment out all Serial.xxx lines. My teensy stops (often) if no serial is available.

The more you know!

richard
 
Check if you have a while(!Serial); this waits for a serial connection... of course there is none if it is not connected to a PC...
 
Back
Top