When we compile and upload, it works a few times (typically 3-5 successes, but random), then fails to upload. Once it fails, it won't work again until we quit Arduino and restart.
The specific symptom is that the code compiles, but then the upload gets stuck uploading for a long time, and finally fails.
A possibly related symptom: The Serial Monitor sometimes fails to show anything, even though the sketch compiles, uploads, and runs correctly. The Serial Monitor says there's no board connected, even though the USB status in the lower right corner say there is one, and the upload succeeds. (We know it's working because we can change the sketch and the changes are visible on the Teensy board.) Then, after a while, suddenly the Serial Monitor shows everything that it should have been showing, as though it were buffering and suddenly decided to dump the whole buffer.
You mention Serial Monitor as possibly related. Do you have Serial Monitor open in an Arduino IDE window at the time you have this problem? I don't know of any problems with Serial Monitor at this time, but there have been some problems in the past with Serial Monitor interfering with the upload process.
Which version of the Teensy boards platform do you have installed? You can see the installed version by finding the entry in Boards Manager. For example, here you can see I have version 1.57.0 installed:
Usually when I have run into something like this, it is because either someone else has control of the Serial port and/or it sometimes loses which IO port.
Example cases where I have it fail to upload is for example if I am running something like TyCommander to do Serial monitor stuff. OR sometimes I have another Arduino WIndow open that maybe has the Serial Monitor pane active.
I can usually clear it by first make sure I am not using TyCommander with Serial active. Or if I am, I will simply push the program button on the Teensy.
And sometimes I go and reselect the right Serial port.
In cases like this it might help to know what options you are building with. In particular which USB Type. Does the type include Serial or is it using the Serial Emualtion?
Yes, of course. That's kind of the point of the Serial Monitor.
I sometimes have two sketches open, and the Serial Monitor will be in both. It rarely works correctly -- the output from one sketch will appear in the Serial Monitor of the other. However, this problem happens even when only one sketch/monitor is open.
Tricks like that are helpful, thanks. But this is clearly a bug of some sort -- it never happened with earlier versions of Arduino (or Teensyduino). We used Arduino extensively with a different board and never had a single problem. We've had to resort to the quit-Arduino/restart frequently, which is frustrating and time consuming.
"The point" of Serial Monitor is irrelevant to this conversation. I am simply checking one of many possible causes of an upload failing.
Of course if the Arduino IDE Serial Monitor is interfering with uploads that would be a bug. The first step to fixing such a bug would be verifying its existence.
Does it still happen after you close Serial Monitor?
Please provide detailed instructions I can follow to reproduce this bug. I just gave it a try with two Teensy boards and was unable to reproduce the issue with either the Teensy port selected or the serial port.
Are you certain you have the right ports selected? Consider this hypothetical scenario:
Sketch A is open in Arduino IDE window 1
Sketch B is open in Arduino IDE window 2
You upload Sketch A from Arduino IDE window 1 to Teensy board X
You select the port of Teensy board Y in Arduino IDE window 2.
In this scenario, the expected and correct behavior would be for the output from Sketch A to be shown in the Serial Monitor of Arduino IDE window 2, regardless of the fact that a different sketch happens to be open in that window.
There was a report of a bug in the teensy-monitor tool that caused behavior similar to what you reported here:
However, that was reported as fixed before the 1.57.0 version.
I see now that @cjames53 created a dedicated topic for discussion of this bug. I think that is a good idea since it is distinct from the original subject here of the upload failures. Thanks!
We will use that topic for all further discussion of the bug of Serial Monitor displaying the wrong output:
For normal usage, the release versions are recommended.
However, when reporting bugs it is best practices to check whether the issue still occurs when using the nightly build. A lot of work has been done since the 2.0.0 release and we regularly receive reports of bugs that were fixed weeks ago:
And of course the latest nightly build should always be used by those who want to contribute to the project by beta testing.
Normally I'd agree, but we're using the nightly build because the production release didn't work for us. The nightly build is much more reliable and usable.