Teensy 3.6 jumping into bootloader while running code

Status
Not open for further replies.

Jopj

Member
Hi,

I have a problem where a Teensy 3.6 occasionally jumps into bootloader mode while running code. I'm using one to control a onewhee-like balancing scooter, which is good motivation for me to love the issue. After it happens, the Teensy stops running the code and shows up as (Bootloader) in the port list.

The Teensy is located pretty close to a BLDC motor controller, so my first thought was interference doing something to the program pin, but this happens even with the motor controller off. Before running into the problem, I already had glued the actual program button to prevent it from doing anything if shaked, and this happens also while just sitting there on the desk. According to the schematic, the Teensy 3.6 does not have pullups or capacitors for the program and reset pins, would adding these be a reasonable solution or just an attempt at masking the problem?

The Teensy is powered off a 5V source from the motor controller capable of 1.5 A, and has a 600uF electrolytic capacitor and a few ceramic ones across that right next to it. The 5V source does not brown out atleast according to logs from the motor controller. As this is a very transient issue, I don't yet have much data about it. Reading the reset status registers in my code isn't too useful, as after a power toggle to get it out of bootloader mode, it'll show that and not whatever happened before.

I'm not doing anything with the USB except some Serial prints on startup. Any ideas what could cause it to jump to the bootloader?
 
Always hard to say.

Hardware:
There are some obvious possibilities. Something is pushing the Program button on the teensy Or something is pulling the Program signal pin down low.

Software:
And if it is truly setup in program mode, potentially the code is doing what is the Arduino IDE does to reset the teensy to be in program mode, or randomly causing that code to be run.

This can be caused by doing something to trash memory, like overrun array, or not passing enough arguments to functions or... In all cases like this, I would make sure I had turned on all compilation warnings... (go into Arduino preferences). And then check and fix all the compiler warnings.

Also if it turns out that it is not in program mode, but USB now responding... Sometimes this can be caused by total processor hangs. Example an interrupt is setup and triggered and the ISR does not do what is necessary to clear that condition, you end up in an endless calls to ISR and USB and everything else will be totally hung.

Again can only throw darts here.
 
Does Teensyduino mark it with (bootloader) in cases where the USB is not responding? In that case, it could be anything that freezes it :( I do use some pin interrupts with "AttachInterrupt", but that should clear the right flag I assume.
 
Noise coupling to the Program pin is the most like cause. If you are not pressing the button, try soldering a wire directly from Program to 3.3V. Or use a 100 ohm resistor if you wish to still press the button.

To answer this specific question:

Does Teensyduino mark it with (bootloader) in cases where the USB is not responding?

No. If the USB isn't responding, after ~1.5 seconds it will simply disappear from the Tools > Ports menu. You can see this if you simply unplug the USB cable.

It only shows as "Bootloader" in the Ports menu if Teensy has actually gone into programming mode.
 
Noise coupling to the Program pin is the most like cause. If you are not pressing the button, try soldering a wire directly from Program to 3.3V. Or use a 100 ohm resistor if you wish to still press the button.

To answer this specific question:



No. If the USB isn't responding, after ~1.5 seconds it will simply disappear from the Tools > Ports menu. You can see this if you simply unplug the USB cable.

It only shows as "Bootloader" in the Ports menu if Teensy has actually gone into programming mode.

Thanks, Ill try that! I would have thought if there's enough noise to do that with just the Teensy powered, running ~1kW through a BLDC controller switching away 5 cm off it would do that pretty much immediately. EMC can be arcane. I guess I'll add a pullup and cap for the Reset pin just in case as well.
P_20200404_214053_vHDR_On.jpg
Hope I can get it fixed so I can continue riding with confidence :)
 
Last edited:
Is there a reasonable ballpark, is 1uF too much? Gotta remember to test it before replacing the legion of nylocks holding the casing together.
 
Yes, 1uF is far too much. Something in the 1nF to 10nF range is probably as high as you should go.

Focus on a low value pullup resistor, like 1K or even 330 ohms.
 
I went with a jumper to 3.3v for the program pin, 470 pullup and 10nF cap to ground for the reset pin. Also removed the button completely just in case so nothing can press it. Bootloader still works, we'll see if this takes care of the problem.
 
Status
Not open for further replies.
Back
Top