Teensy 3.2 no longer able to upload code via Arduino IDE

Status
Not open for further replies.
I'm worried that using the Snooze library's timers may have somehow fudged my Teensy 3.2. I'm no longer able to upload code through the Arduino IDE (using Arduino 1.8.3 and the Teensy Loader 1.37 program on windows 7). When I hit compile, the Teensy Loader shows lots of this:

Code:
15:07:29.538: remote cmd: "status"
15:07:29.538: status data sent
15:07:29.638: remote cmd: "status"
15:07:29.638: status data sent
15:07:29.748: remote connection closed

With the remote cmd status being received many, many times before closing the connection. I hit the program button on the Teensy 3.2 during this period and after but it doesn't do anything. My hardware does not respond to new code being uploaded, it does not reset itself, and I can only get it to reset if I unplug and plug back in the USB serial cable.

The code is huge but the relevant parts are the calls to:
Snooze.deepSleep( config_teensy32);

and:
timer.setTimer(15000);

which determine wakeup time. Using the Snooze library breaks the serial connection to the PC after it first goes to sleep. I tried using the SnoozeUSBSerial class to re-enable it but no luck, it just causes the Arduino IDE to start reporting errors about unable to make a serial connection while running.

Q: What would cause the Teensy 3.2 to not accept uploads any more? Is it sleeping or being interrupted too quickly while powered? It's only every 15s so I don't know why the uploader can't "catch" it at a good time.


Code:
(see post below for better example)
 
Last edited:
The bootloader chip tries to detect when you've put the MK20 into a deep sleep mode. It automatically shuts itself down too. It's normal mode of monitoring whether you want to upload code consumes about 100 to 150 uA, which isn't much in the context of the 45 mA the MK20 draw when running full power at 96 MHz. But if you're using deep sleep modes, the assumption is you want the lowest possible power usage.

Unfortunately, the bootloader chip can't wake up without a button press. I really should be responding when you press the button. Perhaps there's some sort of issue where it's going back into shutdown mode? I'd really like to investigate. I see you've posted a program, but it uses lots of libs that aren't provided by Teensyduino or Arduino by default, so at the very least I would need to figure out exactly which ones you've used.

But even if this button responsiveness issue gets solved, please be aware the bootloader chip does intentionally shut down when it sees the MK20 enter deep sleep modes. Once it's shut itself down, you can't upload again by only clicking the button in Arduino. It can only wake up by a physical signal. Pressing the button on Teensy is supposed to do that, so when you're having to physically plug the cable is a mystery... and one I'd like to look into. Can you help me by giving me details about exactly which sources / versions of those libs you have? Also, if "pictures.h" is yours, that's obviously also needed to compile so I can test on a board here. Or if you could whittle this down to a smaller program without so many other libs, that'd *really* make investigating the problem easier.
 
The bootloader chip tries to detect when you've put the MK20 into a deep sleep mode. It automatically shuts itself down too. It's normal mode of monitoring whether you want to upload code consumes about 100 to 150 uA, which isn't much in the context of the 45 mA the MK20 draw when running full power at 96 MHz. But if you're using deep sleep modes, the assumption is you want the lowest possible power usage.

Unfortunately, the bootloader chip can't wake up without a button press. I really should be responding when you press the button. Perhaps there's some sort of issue where it's going back into shutdown mode? I'd really like to investigate. I see you've posted a program, but it uses lots of libs that aren't provided by Teensyduino or Arduino by default, so at the very least I would need to figure out exactly which ones you've used.

But even if this button responsiveness issue gets solved, please be aware the bootloader chip does intentionally shut down when it sees the MK20 enter deep sleep modes. Once it's shut itself down, you can't upload again by only clicking the button in Arduino. It can only wake up by a physical signal. Pressing the button on Teensy is supposed to do that, so when you're having to physically plug the cable is a mystery... and one I'd like to look into. Can you help me by giving me details about exactly which sources / versions of those libs you have? Also, if "pictures.h" is yours, that's obviously also needed to compile so I can test on a board here. Or if you could whittle this down to a smaller program without so many other libs, that'd *really* make investigating the problem easier.

Thanks for your response. Here's a small program demonstrating the functionality I'm trying to get out of version 6.2.8 of the Snooze library. I'm not able to upload this program though, I think the Teensy is still running the previous program. I push the button the moment the Teensy Loader brings itself to the foreground but no luck. The serial monitor window for COM18 where the Teensy 3.2 is connected says "Closed" while the Arduino IDE is compiling, then it says "Offline". However the Arduino IDE seems to think it's connected to COM18, otherwise it'd complain about no device being found.

Do I need to try and upload it right at the moment when the Teensy is not in sleep mode? I've got about a 4s window every 15s...

Code:
#include <Snooze.h>

// Load snooze drivers
SnoozeCompare compare;
SnoozeTimer timer;
SnoozeDigital digital;
SnoozeAlarm  alarm;

SnoozeBlock config_teensy32(digital, timer, compare, alarm);


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  setupAlarms();
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Time to sleep...");
  Snooze.deepSleep( config_teensy32 );
  Serial.println("I woke up!");
}

void setupAlarms(){
  
  /********************************************************
  Set Low Power Timer wake up in milliseconds.
  ********************************************************/
  timer.setTimer(15000);// milliseconds
 
}
 
I modified code
Code:
#include <Snooze.h>

// Load snooze drivers
SnoozeCompare compare;
SnoozeTimer timer;
SnoozeDigital digital;
SnoozeAlarm  alarm;

SnoozeBlock config_teensy32(digital, timer, compare, alarm);


void setup() {
  // put your setup code here, to run once:
  while(!Serial);
  setupAlarms();
  pinMode(13,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Time to sleep...");
  Snooze.deepSleep( config_teensy32 );
  Serial.println("I woke up!");
  digitalWriteFast(13,HIGH);
  delay(2000);
  digitalWriteFast(13,LOW);
}

void setupAlarms(){
  
  /********************************************************
  Set Low Power Timer wake up in milliseconds.
  ********************************************************/
  timer.setTimer(15000);// milliseconds
 
}

it blinks every 15 seconds for two seconds
meaning program is running
as in other parallel thread indicated, Teensy (Serial) Monitor does not bridge snooze or reset operation

Edit: uploading works automatically while light is on, but requires button press otherwise (No USB is running when in snooze condition)

Edit: the parallel thread is https://forum.pjrc.com/threads/45542-Serial-Monitor-does-not-open-after-Reset
 
Last edited:
I came upon that issue that the serial monitor got killed during snooze and didn't get restored. It sounds like you're only able to upload a new program during that 2 second window when the device is awake, right? I can't upload with or without a button press. So if I've got a very narrow duty cycle when the chip is awake, I'm out of luck unless I can hit it just right. ;-(

Paul what do you recommend for using a deepSleep mode and avoiding this problem? Wiring up a button that forces the chip to wake up and stay awake to allow a programming window? Only using lighter sleep or hibernate modes?
 
I came upon that issue that the serial monitor got killed during snooze and didn't get restored. It sounds like you're only able to upload a new program during that 2 second window when the device is awake, right? I can't upload with or without a button press. So if I've got a very narrow duty cycle when the chip is awake, I'm out of luck unless I can hit it just right. ;-(

I compiled program and once finished I pressed the button and voila, the program uploaded also when snoozing.
Button press put teensy into program mode, independent of program (running, snoozing or crashed).
 
I was able to upload your demo using TyQt (TyCommander). No button press required. Thanks for your help, my Teensy is now un-bricked.

The Arduino IDE console (after integrating with TyCommander) gave this output when I tried to upload my big main program:

Code:
Waiting for user selection
       upload@3112000-Teensy  Uploading to board '3112000-Teensy' (Teensy 3.2)
       upload@3112000-Teensy  Triggering board reboot
       upload@3112000-Teensy  Reboot didn't work, press button manually
       upload@3112000-Teensy  Firmware: SolarPoweredMonitor.ino.TEENSY31.hex
       upload@3112000-Teensy  Flash usage: 64 kiB (24.8%)
       upload@3112000-Teensy  Uploading...
       upload@3112000-Teensy  Sending reset command

I had to push the button as it says. I'm not sure what causes that difference between the two sketches.

Edit: several hours later, now it's not working again. :( The serial port is not showing up anywhere- not in the Arduino IDE, not in Device Manager (on Win7). TyCommander doesn't see the board anymore. Not sure what changed, I did not alter the snooze code. Tried restarting the computer but no luck. Tried re-installing the PJRC Teensy Loader, and in the Verbose Information it can see activity happening when I hit upload:

Code:
15:01:20.421: remote connection opened
15:01:20.423: remote cmd: "comment: Teensyduino 1.37 - WINDOWS (teensy_post_compile)"
15:01:20.426: remote cmd: "status"
15:01:20.428: status data sent
15:01:20.431: remote cmd: "dir:C:\Users\MYNAME\AppData\Local\Temp\arduino_build_940665\"
15:01:20.433: remote cmd: "file:sleep_test.ino.hex"
15:01:20.439: File "sleep_test.ino.hex". 22864 bytes, 9% used
15:01:20.444: remote cmd: "status"
15:01:20.446: status data sent
15:01:20.456: remote connection closed
15:01:20.743: remote connection opened
15:01:20.753: remote cmd: "comment: Teensyduino 1.37 - WINDOWS (teensy_post_compile)"
15:01:20.753: remote cmd: "status"
15:01:20.763: status data sent
15:01:20.763: remote cmd: "dir:C:\Users\MYNAME\AppData\Local\Temp\arduino_build_940665\"
15:01:20.763: remote cmd: "file:sleep_test.ino.hex"
15:01:20.773: File "sleep_test.ino.hex". 22864 bytes, 9% used
15:01:20.773: remote cmd: "status"
15:01:20.783: status data sent
15:01:20.793: remote connection closed
15:01:20.843: remote connection opened
15:01:20.843: remote cmd: "comment: Teensyduino 1.37 - WINDOWS (teensy_reboot)"
15:01:20.853: remote cmd: "status"
15:01:20.853: status data sent
15:01:20.853: remote cmd: "status"
15:01:20.863: status data sent
(cut)
15:01:25.899: remote cmd: "status"
15:01:25.919: status data sent
15:01:26.029: remote connection closed
 
Last edited:
Status
Not open for further replies.
Back
Top