Xubuntu USB Serial Problems

Status
Not open for further replies.

AidanRTaylor

Active member
Hello, I recently switched over from Ubuntu 17.04 to Xubuntu 18.04 on a laptop - I have an odd problem with USB serial that I'm not sure existed before. It seems it is very easy to crash the Serial Monitor when printing too frequently. The problem is that this threshold is extremely poor - I can't even print to serial 10 times a second.

As an example, I have a Teensy with the Prop Shield attached, and I can't open the Serial Monitor with the Orientation example loaded. I get about 6 readings, then the Serial Monitor and Arduino are frozen.

I also often get a failure error when uploading a sketch, though Teensy Loader opens and the upload does actually complete without any problem.

I have USB 3.0 and 2.0 ports on my laptop but the problem occurs on any of them.

I don't really know what steps to take to further diagnose or resolve this - I will see if the same problem occurs in a terminal emulator but my guess is it will. Any advice would be very appreciated as always!
 
Which version of Arduino and Teensyduino are you using? To check, click Help > About in Arduino.

If you're not using the latest beta, please give it a try. Almost all the USB communication has recently been redesigned. If there's still problems (which are in the software, rather than something wrong with your system), fixes will be made to the new version so there's not much point to testing with anything older.

Sometimes when things are going badly, the Linux kernel will send messages to syslog. On older Ubuntu you could see it with"tail -f /var/log/syslog".
 
Hi Paul, thanks for the swift reply - I'm on Arduino 1.8.5 and Teensyduino 1.41

I can try the beta no problem.

Before I do though, tail -f /var/log/syslog does work and I can see live updates - any idea what I should be looking for though? This is the output unplugging and plugging in the Teensy via USB:

Code:
May 22 21:44:28 aidan-Lite kernel: [ 6868.913692] usb 1-1: USB disconnect, device number 25
May 22 21:44:28 aidan-Lite upowerd[1324]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.1
May 22 21:44:28 aidan-Lite upowerd[1324]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0
May 22 21:44:28 aidan-Lite upowerd[1324]: unhandled action 'unbind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1
May 22 21:44:36 aidan-Lite kernel: [ 6877.748911] xhci_hcd 0000:00:15.0: Root hub is not suspended
May 22 21:44:37 aidan-Lite kernel: [ 6877.984046] usb 1-1: new full-speed USB device number 26 using xhci_hcd
May 22 21:44:37 aidan-Lite kernel: [ 6878.133096] usb 1-1: New USB device found, idVendor=16c0, idProduct=0483
May 22 21:44:37 aidan-Lite kernel: [ 6878.133104] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 22 21:44:37 aidan-Lite kernel: [ 6878.133109] usb 1-1: Product: USB Serial
May 22 21:44:37 aidan-Lite kernel: [ 6878.133113] usb 1-1: Manufacturer: Teensyduino
May 22 21:44:37 aidan-Lite kernel: [ 6878.133117] usb 1-1: SerialNumber: 4090200
May 22 21:44:37 aidan-Lite kernel: [ 6878.135263] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
May 22 21:44:37 aidan-Lite upowerd[1324]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.1
May 22 21:44:37 aidan-Lite upowerd[1324]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0
May 22 21:44:37 aidan-Lite upowerd[1324]: unhandled action 'bind' on /sys/devices/pci0000:00/0000:00:15.0/usb1/1-1
 
I have found a work around for now, adding while(!Serial); seems to completely solve the problem:

Code:
int counter;

void setup() {
  Serial.begin(115200);

  while(!Serial);

}

void loop() {
  counter++;
  Serial.println(counter);
  delay(10);
}

I couldn't even use delay(100) previously - weird, some kind of clock problem? I have no idea!
 
I just have one more update, I'm heading to bed now - but I tested with an Arduino Uno and it behaves as expected so unfortunately it does seem to be specific to serial on Teensy. I did update to the Teensyduino 1.42 beta.

It totally could be a Xubuntu problem, I'm pretty sure I had no issue with Ubuntu 17.04 but I don't have any way to test that right now.
 
The Arduino Uno is ways slower than the Teensy and thus it is normal to hang up the serial communication when a much quicker Teensy starts sending data before the computer‘s serial port is ready.
 
The Arduino Uno is ways slower than the Teensy and thus it is normal to hang up the serial communication when a much quicker Teensy starts sending data before the computer‘s serial port is ready.

So how do I alleviate that? The serial port is behaving very poorly in this case.

The only thing I can think of at the moment is doing something like using a jumper wire to enable serial - or adding lots of if(Serial) into a sketch. I wonder if there is a driver issue that can be fixed here, but it is a Ubuntu/Xubuntu or maybe even Kernel problem
 
Normally waiting once in setup until serial is ready on the Ubuntu side should solve the problem. Afterwards, the port should work at full speed. If it still doesn‘t, though, there is for sure a problem in Ubuntu‘s handling of the virtual serial port over USB, since on other OSs, you might use even higher baud rates.
 
There are 2 very different approaches used on these boards, which could be called native USB and serial converter USB.

On Arduino Uno, there is a dedicated chip for the USB. When you Uno reboots, the USB connection remains the same. The USB chip doesn't reboot, only the main processor.

On Teensy and other native USB boards, the USB is built into the main chip. Rebooting means the USB disconnects and reconnects. To your PC it's as if the USB cable was unplugged and plugged back in. Linux has to do the USB enumeration process all over again, load drivers, let udev set up the user space stuff for the port, and so on.

Teensy isn't the only Arduino compatible board with native USB (before 2012 it was... but not in these modern times). Arduino Leonardo, Micro, MKR1000 and others are native USB. Some like Arduino Due & Zero have 2 ports, one native and one with a converter chip. If you have access to any of those boards, it'd be really helpful to know whether the issue you're seeing happens on their native USB ports.
 
There are 2 very different approaches used on these boards, which could be called native USB and serial converter USB.

On Arduino Uno, there is a dedicated chip for the USB. When you Uno reboots, the USB connection remains the same. The USB chip doesn't reboot, only the main processor.

On Teensy and other native USB boards, the USB is built into the main chip. Rebooting means the USB disconnects and reconnects. To your PC it's as if the USB cable was unplugged and plugged back in. Linux has to do the USB enumeration process all over again, load drivers, let udev set up the user space stuff for the port, and so on.

Teensy isn't the only Arduino compatible board with native USB (before 2012 it was... but not in these modern times). Arduino Leonardo, Micro, MKR1000 and others are native USB. Some like Arduino Due & Zero have 2 ports, one native and one with a converter chip. If you have access to any of those boards, it'd be really helpful to know whether the issue you're seeing happens on their native USB ports.

I see, is it basically where you either have a seperate chip for USB comms (serial converter), or it is handled onboard the MCU (native)?

I do indeed have a MKR1000 and a Due - I will test it out
 
Hi Paul, I can't find the MKR1000 - it is probably knocking around at work somewhere. But the Due is working fine on both the Programming Port and the Native Port - I'm just running this (the equivalent doesn't work on Teensy for me):

Code:
int counter;

void setup() {
  SerialUSB.begin(115200);
}

void loop() {
  counter++;
  SerialUSB.println(counter);
  delay(1);
}

I can even comment out the delay without any problems
 
I just tried 1.8.5 with Teensyduino 1.42 Beta #5 on 64-bit linux Ubuntu 16.04.4 LTS and ran simple sketch with println and delay in loop(). it seemed to print every other line and then froze after 7 or 8 lines. teensy loader window disappeared. reload eventually worked and i haven't been able to reproduce the problem ... ?
 
D'oh, thought I fixed this in beta5. Guess not. :(

ran simple sketch with println and delay in loop(). it seemed to print every other line and then froze after 7 or 8 lines.

I'm pretty sure this is a matter Unix default line discipline settings. In beta5 I added code to (supposedly) put the port into raw mode. But maybe it's not working?
 
Thanks @manitou - that's basically what happens to me everytime

Paul, I'm happy to test anything you or anyone else can throw at me - I'm afraid that's as much as I can help with my ability level, I'm definitely towards the end user end of the dev spectrum!
 
Status
Not open for further replies.
Back
Top