Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Bricked Teensy 4.0- not enough stack space?

  1. #1

    Bricked Teensy 4.0- not enough stack space?

    I've just bricked a teensy 4.0 which won't show up in USB anymore. It goes into program mode OK when if you press the program button (red light comes on) but teensy loader never sees it (1.53 Mac 10.14).

    I've tried pressing the program button before plugging in the USB but that doesn't help.

    The last program I tried to upload had very small amounts of stack space left over(< 3K) as static variables take up most of the memory. When uploaded, the program didn't work.

    I'm wondering if a program with too little stack space can brick a teensy. Does the program mode assume the stack pointers are valid from the running app? I'm thinking the USB interrupt code runs out of stack space and program mode doesn't force the stack pointers back to sensible defaults- does it assume the stack space from the program is valid?

    I may of course have damaged the USB interface in some way (the board is powered from a 9V supply regulated to 5V, and i forgot to chop the vin/vusb link).

    However, it's a very weird coincidence that it stopped working just as i tried to program a 'Stability problems may occur' image onto it.

    I'm reluctant to try another teensy in case i've discovered a way of reliably bricking it.

    Suggestions?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,619
    Have you tried the recovery process?
    Simply hold the program button down for something like 20 seconds, until the little red led near usb comes on and release. It should then stay on and reprogram the T4 back to the original simple blink program.
    This again may take something like 20 or so seconds. Hopefully then the program LED goes off and you are back to blink...

    If you run out of stack and hit something bad, the USB may fail to work, BUT again this should not keep you from being able to reprogram it again. Only rarely have I required to go back to the original program, usually holding in the program button when plugging in and then release, have simple blink program already done a verify and teensy program up, I can usually than just hit the program button and it programs or just try program command in Arduino IDE and it usually works.

  3. #3
    Thanks, the recovery process un--bricked it. I wasn't holding the program button down long enough.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,657
    Glad you got it back to working.


    Quote Originally Posted by dirkenstein View Post
    Does the program mode assume the stack pointers are valid from the running app? I'm thinking the USB interrupt code runs out of stack space and program mode doesn't force the stack pointers back to sensible defaults- does it assume the stack space from the program is valid?
    No, that's not how it works at all. Program mode fully resets the IMXRT processor, then takes control of it using its debug mode. In theory that should always work. But in practice things don't always work out as well as simple theories predict...

    Why this wasn't working involves either a tremendous effort using special equipment to troubleshoot, or guesswork, or both. Not only is the exact effect of a stack-heap-static memory collision hard to predict, but the outcome you can observe from your PC involves a lot of difficult to understand behavior of how your computer's USB host controller and its drivers handle errors and misbehaving devices. Often those details aren't even public knowledge. But judging from the sorts of issues I've seen on Arduino's issue tracker over the years, my guess is modern versions of MacOS are becoming less forgiving of USB devices which have certain types of erroneous behavior. Disabling a port or hub for a period of time is one possibility.

    I put the 15 sec restore into Teensy 4.x because of all the experience we've seen on earlier Teensy models, where a PC became a confusing and worthless tool for troubleshooting after things went wrong. Some of that was due to the USB driver bugs in Windows 7, but we still sometimes see reports of things going horribly wrong with Windows 10, then mysterious everything works a day later and after a full reboot. The restore process is meant to allow you to do everything entire on the Teensy side, even if you have only 5V and no USB cable at all, to get back to a clean known-good state.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •