Teensy4.1: USB reset by third party program removes device on Ubuntu 18.04

mdb

Member
* Linux 4.18.0-25-generic #26~18.04.1-Ubuntu x86_64
* 18.04.3 LTS (Bionic Beaver)
* Teensy 4.1

On reboot, I can see /dev/ttyACM0 (Teensy), /dev/ttyACM1 (other device)

When I run a third party application (based on FLIR Spinnaker SDK), I can no longer see /dev/ttyACM0.

In the kernel logs (relevant snippets below), I see

[ 1.232364] hub 2-0:1.0: USB hub found
[ 2.012066] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 2.172730] usb 1-1: New USB device found, idVendor=16c0, idProduct=0483, bcdDevice= 2.80
[ 2.172731] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2.172732] usb 1-1: Product: USB Serial
[ 2.172734] usb 1-1: Manufacturer: Teensyduino
[ 2.172735] usb 1-1: SerialNumber: 12487990
...
[ 5.503703] usbcore: registered new interface driver usbhid
[ 5.503705] usbhid: USB HID core driver
[ 5.580862] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
[ 5.581849] cdc_acm 1-2:1.0: ttyACM1: USB ACM device
[ 5.582030] usbcore: registered new interface driver cdc_acm
[ 5.582031] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
... I can see the Teensy (ttyACM0)
... Running sample spinview program, example /opt/spinnaker/bin/Acquisition
[ 168.456654] usb 2-4: reset SuperSpeed Gen 1 USB device number 3 using xhci_hcd
[ 168.668449] usb 1-1: reset high-speed USB device number 2 using xhci_hcd
[ 168.818768] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
... I can not longer see the Teensy in my devices. I can still see /dev/ttyACM1 (other device, not associated with Teensy or third party library)

I have to use this third party SDK, and this reset occurs on the obligatory "Init" call. I would really appreciate new ideas.

These are the third party udev rules (.txt so I could attach). I also have the latest 00-teensy.rules file installed.
View attachment 40-flir.rules.txt
View attachment 40-flir-spinnaker.rules.txt
 
Seems there are some testable 'usb_Active' info bits?
Wonder if polling those would allow restoration with 'usbInit' to reconnect?
 
The only solution we have found so far was to change the udev rules to

#ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"
#ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789a]*", ENV{MTP_NO_PROBE}="1"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666", RUN:="/bin/stty -F /dev/%k raw -echo"
#KERNEL=="hidraw*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
#SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04*", MODE:="0666"
#KERNEL=="hidraw*", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"
#SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="013*", MODE:="0666"

and to run the FLIR Spinnaker SDK as user (ie. non-root). This has been a humbling experience in terms of using sudo as a development crutch; it was fun fixing everything else that was dependent on it.

For completeness, here are the udev rules for the FLIR device

SUBSYSTEM=="usb", ATTRS{idVendor}=="1e10", GROUP="flirimaging"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1724", GROUP="flirimaging"

I still do not have a complete understanding as to how this works. My guess is that IF the FLIR Spinnaker SDK is able to modify the Teensy USB nodes (ie. MODE:=0666), it performs some form of reconfiguration to said USB nodes that prevents the Teensy from enumerating (ie. no /dev/ttyACMx when it power cycles).
 
Back
Top