Hello,

I'd like to share an issue that I've been dealing with and what fixed it.

My system:
Asus K501UX
Linux Mint 19.3
Kernel 5.3.0-40
Arduino 1.8.11
Teensyduino 1.50
Teensy 3.2

Example code

Code:
#define BLINK_PERIOD 500
uint32_t next_blink = 0;
uint32_t counter = 0;

void setup() {
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}


void loop() {
  uint32_t now = millis();
  Serial.print(counter++);
  Serial.print("\t");
  Serial.print("this is a ");
  Serial.print("test");
  Serial.println();

  if(now >= next_blink){
    next_blink += (BLINK_PERIOD/2);
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  }
  
  delay(5);
}
After uploading with Arduino IDE (or Platformio) and opening the Arduino serial monitor (or Putty), the output would contain a single line with counter between 35 and 40 or be completely blank. Nothing more appeared on the serial monitor, but the Teensy continued to run as indicated by the flashing LED. Sometimes, though rarely, the serial monitor would repeatedly print the full "### this is a test" line with the counter increasing. In this case, I could close and reopen the serial monitor, and it would continue to work. When it did work, however, the counter would start at 4.

I tried programming the Teensy in Linux and then booting into Windows. Using either putty or the Arduino serial monitor, I would continue to receive the expected output. This narrowed it down to a Linux issue...

I tried a different kernel version (4.15.0-88) which did not make a difference.

At this point, after doing some Googling, I was pretty convinced some other program was stealing the device file.
I uninstalled ModemManager, which unfortunately did not make a difference.
I installed the latest udev rules which did not make a difference.

Here, I noticed something interesting. If I increased the delay, or decreased the amount of stuff being printed, the connection would work more often. Still not sure if this is relevant or how this plays into it...

I tried compiling with MIDI USB type instead of serial as suggested by Paul somewhere. This, in fact, worked! I could consistently get a serial connection. I probably would have stopped here, but Putty couldn't open it as it wasn't a tty.

Finally, I figured it out. Adding "while(!Serial)" to the beginning of my setup() worked! I now consistently get a repeating output. Paul suggests this here: https://forum.pjrc.com/threads/56818...l-print-lockup in #4. Though he said it's only been reported to solve issues on Raspberry Pis, here's a case where it worked on a different system.

Anyways, I figured I'd share this here in hope that anyone else who deals with this does not have to spend as many hours on it...

Any speculation on the factors at play is welcome. I'm interested in learning more about what's going on with USB here.