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

Thread: Uploading sketches problem - Teensy 4.0

  1. #1

    Uploading sketches problem - Teensy 4.0

    Hi all,

    Lately I've been having a lot of odd issues with simply uploading sketches. The programmer will say there is no Teensy plugged in, or to press the Teensy button. Or the program will compile, but then the Teensy loader will show the programming progress start, and then abruptly abort halfway through with no error message. Happens over and over now.

    The sketch is not too big to fit, and I've been having no problems for a year literally. I thought maybe something was up with the Teensy I was using, so I swapped it out for a fresh one, but no joy.

    I tried cleaning the USB ports on my computer. I tried using a different USB port. I have the Teensy plugged directly into the computer, a Mac, and not into a hub. I tried a different USB cable, brand new.

    If I reboot the whole system, sometimes it works fine for awhile, but then I get into this cycle where it simply will not upload sketches without me resetting the Teensy to the blink program, or pressing the button, or simply trying again and again about 4 - 5 times.

    It's killing my productivity and I don't know what could be wrong here.

    Has anyone else experienced anything like this and what is the answer?

    Thanks,

    Mike

  2. #2
    Here's one of many error messages I get:

    Memory Usage on Teensy 4.0:
    FLASH: code:333948, data:1427004, headers:9156 free for files:261508
    RAM1: variables:50176, code:332144, padding:28304 free for local variables:113664
    RAM2: variables:21120 free for malloc/new:503168
    An error occurred while uploading the sketch
    Teensy Loader is currently busy with another operation (p). Please try again in a few seconds, or restart Teensy Loader.
    quit

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    In the small Teensy Loader window, click Help > Verbose Info.

    You can use the Log menu to save it all to a file. Then here on the forum, click "Go Advanced" to get the full editor which lets you attach a file to your message. Or just copy & paste it all here, maybe between code tags.

  4. #4

    Log file attached

    Thank-you so much. Log file attached.

    Just prior to this, I did a complete reset of my mac's PRAM and SMC, as well as ran a long cleaner program to delete system junk etc. But the sketch still didn't load - it got about 90% loaded in the Teensy loader and then abruptly aborted.

    Thanks kindly for any insights. It's shocking to have such amazing support from the creator himself. Thank-you Paul.

    Mike
    Attached Files Attached Files

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Sorry about the delay, just today got time to look at this log file.

    Please keep in mind it's always harder to answer "why" than "what".

    In the first part of the log file, I can see Teensy is detected in bootloader mode several times over about 30 seconds.

    Code:
    08:50:11.593 (ports 6): USB device add callback
    08:50:20.509 (ports 6): USB device remove callback
    
    08:50:20.511 (ports 6): USB device add callback
    08:50:26.062 (ports 6): USB device remove callback
    
    08:50:26.064 (ports 6): USB device add callback
    08:50:30.643 (ports 6): USB device remove callback
    
    08:50:30.645 (ports 6): USB device add callback
    08:50:34.321 (ports 6): USB device remove callback
    
    08:50:34.323 (ports 6): USB device add callback
    08:50:39.022 (ports 6): USB device remove callback
    
    08:50:39.025 (ports 6): USB device add callback
    08:50:40.769 (ports 6): USB device remove callback
    
    08:50:40.771 (ports 6): USB device add callback
    The interesting info is the timing. MacOS detects Teensy has disconnected, and then only 2-3 milliseconds later reports it has reconnected.

    That's the "what" part. Getting to "why" involves guesswork...

    I'm pretty sure Teensy isn't losing power. The hardware can't start up that fast and even if it could, USB enumeration can't possibly happen so quickly. The hardware is never supposed to power up into bootloader mode either, so I'm pretty sure Teensy is remaining powered up and running with USB working.

    How this timing between MacOS remove callbacks and then add callbacks can happen is a mystery to me. It's like the hardware is detecting loss of communication, then very quickly recovering.

    Do you have a long USB cable or chain of dongles/adaptors or unpowered hubs between Teensy and your Mac's USB port? Or anything creating strong electrical interference?

  6. #6
    Many kind thanks Paul for your time.

    The Teensy is connected directly to the Mac via a 2m long USB-A to USB-Micro B cable.

    The saga has continued. I've discovered if I work with the Teensy loader, I can usually just re-upload and then reboot the Teensy, although sometimes it takes 5-6 tries on even this (and sometimes I have to quit Teensyduino, and occasionally even reboot the whole machine). Other times, it gets into a kind of loop where no matter what I do, I cannot upload anything, and that's usually after I've been coding for several hours (could the Teensy get hot and have an issue? - although it's been VERY COLD here!). Upon return hours later it's usually back to previous behavior.

    I will try to experiment with a shorter cable.

    There is no other interference I can think of, except Peaches the cat who likes to paw at and bite whatever cables are on the desk. But so far she has not managed to cause any damage. By the way she's a very good coder. She likes your Teensyduino interface.

    Thanks again, and I'll try the shorter cable and report back. At least now with working with the Teensy loader directly I can get some things done, albeit still much more slowly than I'd like.

    Mike

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Quick followup, to check if a shorter or different USB cable fully solved this problem?

  8. #8
    Tried a brand new USB cable; no joy. I don't have a shorter one ATM but when I get one I will test. I only have 2m long cables so maybe this is the factor.

    I have found I can work with the Teensy Loader program in a way I didn't realize before - basically after compiling, I can upload manually and if it fails, upload again, until it loads. Usually this works after 3-4 rounds; sometimes more, sometimes less. Then a manual reboot through the loader. At least I don't have to keep recompiling which is what I was doing before.

    Of course you programmed it this way so thanks Paul; I just didn't realize I could work with the Loader that way.

    This has largely mitigated the issue. Although why there's the issue remains the rub.

    Thanks,

    Mike

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,366
    Maybe try adding a powered hub between your computer and Teensy.

Posting Permissions

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