Basic Teensy Operation with Raspberry Pi - won't connect

jmmocarro

Member
My setup:

Raspberry Pi 3B + Teensy 4.0 connected via USB.
Bottom line the Teensy will not connect to the Pi. Note I have not made any changes in the Pi to accommodate the Teensy. Note adding 00-teensy.rules to /etc/udev/rules.d does not change results.
Really don't know where to go from here so looking for clear direction as I'm probably missing something very basic.


Initial configuration of Teensy performed on Windows 10 laptop running Arduino IDE.

Detailed steps:

1. Enter and Upload the following basic program to the Teensy:

void setup() {

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.println("CONNECTED!!!");
}

void loop() {
Serial.println("Hello World");
delay(1000);
}​

2. Code produces expected output on both the Arduino Serial Monitor and also when I connect to the same laptop USB port with Putty (COM4).

CONNECTED!!!
Hello World
Hello World
Hello World
Hello World​


3. Unplug and reattach to Laptop - code restarts and produces same output.

4. Raspberry Pi has a Pi Keyboard/Mouse on one USB port.

pi@pi2:~ $ lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
|__ Port 3: Dev 4, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 1: Dev 5, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 2: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

pi@pi2:~ $ ls /dev/tty*
/dev/tty /dev/tty19 /dev/tty3 /dev/tty40 /dev/tty51 /dev/tty62
/dev/tty0 /dev/tty2 /dev/tty30 /dev/tty41 /dev/tty52 /dev/tty63
/dev/tty1 /dev/tty20 /dev/tty31 /dev/tty42 /dev/tty53 /dev/tty7
/dev/tty10 /dev/tty21 /dev/tty32 /dev/tty43 /dev/tty54 /dev/tty8
/dev/tty11 /dev/tty22 /dev/tty33 /dev/tty44 /dev/tty55 /dev/tty9
/dev/tty12 /dev/tty23 /dev/tty34 /dev/tty45 /dev/tty56 /dev/ttyAMA0
/dev/tty13 /dev/tty24 /dev/tty35 /dev/tty46 /dev/tty57 /dev/ttyprintk
/dev/tty14 /dev/tty25 /dev/tty36 /dev/tty47 /dev/tty58
/dev/tty15 /dev/tty26 /dev/tty37 /dev/tty48 /dev/tty59
/dev/tty16 /dev/tty27 /dev/tty38 /dev/tty49 /dev/tty6
/dev/tty17 /dev/tty28 /dev/tty39 /dev/tty5 /dev/tty60
/dev/tty18 /dev/tty29 /dev/tty4 /dev/tty50 /dev/tty61


pi@pi2:~ $ dmesg| grep usb
[ 0.133977] usbcore: registered new interface driver usbfs
[ 0.134059] usbcore: registered new interface driver hub
[ 0.134227] usbcore: registered new device driver usb
[ 1.548199] usbcore: registered new interface driver lan78xx
[ 1.548424] usbcore: registered new interface driver smsc95xx
[ 2.537758] dwc_otg 3f980000.usb: DWC OTG Controller
[ 2.544099] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[ 2.550529] dwc_otg 3f980000.usb: irq 56, io mem 0x00000000
[ 2.570122] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04
[ 2.576609] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.583031] usb usb1: Product: DWC OTG Controller
[ 2.589445] usb usb1: Manufacturer: Linux 5.4.79-v7+ dwc_otg_hcd
[ 2.595795] usb usb1: SerialNumber: 3f980000.usb
[ 2.616799] usbcore: registered new interface driver usb-storage
[ 2.689153] usbcore: registered new interface driver usbhid
[ 2.695532] usbhid: USB HID core driver
[ 3.036151] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 3.286522] usb 1-1: New USB device found, idVendor=0424, idProduct=9514, bcdDevice= 2.00
[ 3.293035] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.626175] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[ 3.756571] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00, bcdDevice= 2.00
[ 3.763060] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 3.870763] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:a9:1d:ce
[ 3.976162] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
[ 4.107824] usb 1-1.3: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice=32.98
[ 4.114728] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 4.121656] usb 1-1.3: Product: USB2.0 Hub
[ 4.466277] usb 1-1.3.1: new low-speed USB device number 5 using dwc_otg
[ 4.756802] usb 1-1.3.1: New USB device found, idVendor=04d9, idProduct=0006, bcdDevice= 1.40
[ 4.764261] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4.771759] usb 1-1.3.1: Product: RPI Wired Keyboard 4
[ 4.779111] usb 1-1.3.1: Manufacturer:
[ 4.856661] input: RPI Wired Keyboard 4 as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/0003:04D9:0006.0001/input/input0
[ 4.927047] hid-generic 0003:04D9:0006.0001: input,hidraw0: USB HID v1.11 Keyboard [ RPI Wired Keyboard 4] on usb-3f980000.usb-1.3.1/input0
[ 4.989723] input: RPI Wired Keyboard 4 as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.1/0003:04D9:0006.0002/input/input1
[ 5.066622] hid-generic 0003:04D9:0006.0002: input,hidraw1: USB HID v1.11 Device [ RPI Wired Keyboard 4] on usb-3f980000.usb-1.3.1/input1
[ 5.176181] usb 1-1.3.2: new low-speed USB device number 6 using dwc_otg
[ 5.322541] usb 1-1.3.2: New USB device found, idVendor=093a, idProduct=2510, bcdDevice= 1.00
[ 5.331238] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5.339941] usb 1-1.3.2: Product: USB Optical Mouse
[ 5.348637] usb 1-1.3.2: Manufacturer: PixArt
[ 5.362760] input: PixArt USB Optical Mouse as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.2/1-1.3.2:1.0/0003:093A:2510.0003/input/input2
[ 5.372552] hid-generic 0003:093A:2510.0003: input,hidraw2: USB HID v1.11 Mouse [PixArt USB Optical Mouse] on usb-3f980000.usb-1.3.2/input0
[ 8.450629] usbcore: registered new interface driver brcmfmac

5. Unplug Teensy from Laptop and plug into Raspberry USB port.

Activity observed on 'udevadm monitor'

No change recorded in ls /dev/tty* Output

No change recorded in lsusb -t Output

Incremental output from dmesg follows:
[ 712.946142] usb 1-1.2: new high-speed USB device number 7 using dwc_otg
[ 713.486143] usb 1-1.2: device not accepting address 7, error -71
[ 714.396371] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 714.396503] usb 1-1-port2: attempt power cycle
[ 715.676278] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 715.776121] usb 1-1.2: new high-speed USB device number 10 using dwc_otg
[ 716.216195] usb 1-1.2: device not accepting address 10, error -71
[ 716.216345] usb 1-1-port2: unable to enumerate USB device
[ 716.216558] usb 1-1.3-port1: cannot reset (err = -71)
[ 716.216790] usb 1-1.3-port1: cannot reset (err = -71)
[ 716.216826] usb 1-1.3: USB disconnect, device number 4
[ 716.216860] usb 1-1.3.1: USB disconnect, device number 5
[ 716.216941] usb 1-1.3-port1: cannot reset (err = -71)
[ 716.598782] usb 1-1.3.2: USB disconnect, device number 6
[ 717.056199] usb 1-1.3: new high-speed USB device number 11 using dwc_otg
[ 717.187678] usb 1-1.3: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice=32.98
[ 717.187692] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 717.187699] usb 1-1.3: Product: USB2.0 Hub
[ 717.486122] usb 1-1.2: new high-speed USB device number 12 using dwc_otg
[ 718.396348] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 718.496128] usb 1-1.2: new high-speed USB device number 14 using dwc_otg
[ 719.406287] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 719.406395] usb 1-1-port2: attempt power cycle
[ 719.436398] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.436533] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.436657] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.436782] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.436788] usb 1-1.3-port1: Cannot enable. Maybe the USB cable is bad?
[ 719.436922] usb 1-1.3-port1: cannot disable (err = -71)
[ 719.437072] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.437189] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.437314] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.437439] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.437562] usb 1-1.3-port1: cannot reset (err = -71)
[ 719.437568] usb 1-1.3-port1: Cannot enable. Maybe the USB cable is bad?
[ 719.437686] usb 1-1.3-port1: cannot disable (err = -71)
[ 719.437697] usb 1-1.3-port1: attempt power cycle
[ 720.656300] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 721.566408] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 721.566561] usb 1-1-port2: unable to enumerate USB device
[ 721.566859] usb 1-1.3-port1: cannot reset (err = -71)
[ 721.567023] usb 1-1.3-port1: cannot reset (err = -71)
[ 721.567085] usb 1-1.3: USB disconnect, device number 11
[ 721.567192] usb 1-1.3-port1: cannot reset (err = -71)
[ 721.886148] usb 1-1.3: new high-speed USB device number 20 using dwc_otg
[ 722.017910] usb 1-1.3: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice=32.98
[ 722.017926] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 722.017933] usb 1-1.3: Product: USB2.0 Hub
[ 722.336130] usb 1-1.3.1: new low-speed USB device number 21 using dwc_otg
[ 722.617385] usb 1-1.3.1: New USB device found, idVendor=04d9, idProduct=0006, bcdDevice= 1.40
[ 722.617408] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 722.617423] usb 1-1.3.1: Product: RPI Wired Keyboard 4
[ 722.617436] usb 1-1.3.1: Manufacturer:
[ 722.687046] input: RPI Wired Keyboard 4 as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/0003:04D9:0006.0004/input/input3
[ 722.757132] hid-generic 0003:04D9:0006.0004: input,hidraw0: USB HID v1.11 Keyboard [ RPI Wired Keyboard 4] on usb-3f980000.usb-1.3.1/input0
[ 722.810859] input: RPI Wired Keyboard 4 as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.1/0003:04D9:0006.0005/input/input4
[ 722.876544] hid-generic 0003:04D9:0006.0005: input,hidraw1: USB HID v1.11 Device [ RPI Wired Keyboard 4] on usb-3f980000.usb-1.3.1/input1
[ 722.976174] usb 1-1.3.2: new low-speed USB device number 22 using dwc_otg
[ 723.122664] usb 1-1.3.2: New USB device found, idVendor=093a, idProduct=2510, bcdDevice= 1.00
[ 723.122678] usb 1-1.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 723.122686] usb 1-1.3.2: Product: USB Optical Mouse
[ 723.122694] usb 1-1.3.2: Manufacturer: PixArt
[ 723.128062] input: PixArt USB Optical Mouse as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3.2/1-1.3.2:1.0/0003:093A:2510.0006/input/input5
[ 723.128469] hid-generic 0003:093A:2510.0006: input,hidraw2: USB HID v1.11 Mouse [PixArt USB Optical Mouse] on usb-3f980000.usb-1.3.2/input0​

6. Restart Pi with Adruino connected produces a slightly different dmesg output:

[ 3.996200] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 4.976177] usb 1-1.2: device descriptor read/64, error -71
[ 6.006474] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 6.916460] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 6.916579] usb 1-1-port2: attempt power cycle
[ 8.176494] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 8.235245] usbcore: registered new interface driver brcmfmac
[ 9.088121] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?
[ 9.088275] usb 1-1-port2: unable to enumerate USB device







.
 
Sorry, I have not played much recently with RPI, so some simple questions might help to reproduce.


What are you running on RPI: Raspian (or they may have renamed this) Ubuntu...
Teensy 4 - which version of Arduino/Teensuduino are you building this with?
What USB options and the like.

I have a t4 plugged into rpi4 and it shows up... If I do a
lssub command.

It shows as one of the devices: 16c0:0483 Van o... which is the teensy.

if I look at the end of the dmesg:
Code:
[  629.529346] usb 1-1.1: new high-speed USB device number 8 using xhci_hcd
[  629.660297] usb 1-1.1: New USB device found, idVendor=16c0, idProduct=0483, bcdDevice= 2.79
[  629.660319] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  629.660338] usb 1-1.1: Product: USB Serial
[  629.660355] usb 1-1.1: Manufacturer: Teensyduino
[  629.660373] usb 1-1.1: SerialNumber: 6243450
[  629.669907] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
pi@raspberrypi:~ $
And the serial ports...
Code:
pi@raspberrypi:~ $ ls /dev/ttyA*
/dev/ttyACM0  /dev/ttyAMA0
pi@raspberrypi:~ $

So wonder a couple of things. Is the USB cable the same you are plugging into the PC and RPI the same? If not try the same one. Maybe defective, maybe charge only...

Power? I know some power supplies to RPI3 and earlier were pretty marginal. Sometimes when I was playing with them I ended using a powered usb hub.

Not sure what else yet.
 
Appreciate your very fast response....

Power: I read that may be a concern. Originally had other USB peripherals but removed them. Pi powered from USB hub. Even removed keyboard to try that.

Cable: Also considered that. Original was different, now using same cable as used on Windows to program.

USB Port on Pi: Tried all of them - same result.

RPI OS:
pi@pi2:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"​

Windows config:

Arduino 1.8.19
Teensyduino 1.56
Tools/USB Type set to Serial (also tried dual/triple Serial and Raw HID all with similar results)
COM4​

Note I do have other software loaded on the Pi (NGINX, JANUS, GStreamer). Pi is running Desktop and VNC. It also has an Ethernet cable and Pi Camera connected.

Do you know what the error 71 is from dmesg?
device not accepting address 7, error -71
 
Makes me believe that I have something wrong with the configuration of my Teensy although I'm quickly running out of ideas as to what it might be. Remember I'm new to Teensy so it could be something very basic!
 
Sorry, again I am not a linux/rpi expert although did play with them for some time, before I went more with Odroid and UP and ...

The first thing I would expect is when you plug the teensy it, it would show up in the system log...

Where if you then do dmesg you should find something like:
Code:
629.529346] usb 1-1.1: new high-speed USB device number 8 using xhci_hcd
[  629.660297] usb 1-1.1: New USB device found, idVendor=16c0, idProduct=0483, bcdDevice= 2.79
Where all teensy should have vendor id of 16c0.

Now if it did not show up on PC, I would wonder if you built sketch with no usb as USB option...

I am assuming that cdc-acm support is built in. Don't remember if there was some settings to disable it... But again I would expect that it would at least show it sees the device.
It might end up saying something like, could not find driver... If something was missing or disabled.

Maybe other linux expert might have other ideas
 
Based on what dmesg is saying (original post) the Pi is seeing the Teensy but is not establishing the connection.

[ 713.486143] usb 1-1.2: device not accepting address 7, error -71
[ 714.396371] usb 1-1-port2: Cannot enable. Maybe the USB cable is bad?

The dmesg info varies depending on whether the device is plugged in at boot time or not and probably other things. On one of my many iterations it did identify the correct vendor ID and name the Teensy but did not create ttyACM0.

All of this and the fact that the Arduino connects while running the same code suggests some configuration issue on my part with the Teensy.

So some questions.
1. What settings should/can be selected in the Arduino IDE that will impact how the Arduino establishes a USB connection?
2. Does the basic code example in the original post make sense ? I assume it does since it works on Arduino.
3. Is 00-teensy.rules required on the Pi to establish the USB connection and if so what is the correct version of this file?
4. Are there any other configuration requirements that you know of on the Pi that would be different than the Arduino?

Note: the 'device not accepting address -error 71' that is reported by dmesg (sometimes) produces many results when googled. Most common suggestion is power issues but believe I definitely ruled that out as I now have all 4 USB ports occupied (2 cams, keyboard/mouse, Arduino) plus Pi Cam.

Would really like to get this working on Teensy as the small footprint is ideal for my application. If I can't get USB to work I guess I could pursue a separate hardware serial connection but I don't give up easily :)
 
Note: I am doing a fresh install of raspian on sd card to try on one of my RPI3... boards...
To see if anything different, my Pi4 had a version from early last year so this one will be the latest with raspberry pi imager. may take awhile

1) Most any should work, the simplest is the default Serial Which is simple CDC-ACM device, which should creat a new /dev/ttyAMAn device note on Ubuntu (pc at least) /dev/ttyACMn That is always the one I would first try
2) yes.... Often times I put a timeout on waiting for serial...
Code:
void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial && millis() < 5000) {  // waits up to 5 seconds...
        ; // wait for serial port to connect.
    }
    Serial.println("CONNECTED!!!");
}

void loop() {
    Serial.println("Hello World");
    delay(1000);
}

3) Yes and no. That is the system should see the device.
Most recent one. I am assuming the one that the teensyduino installer program checks for and if mismatch it puts on in your temp folder is probably the most recent... At least most recent at time of when the teensyduino app was made.
You should also be able to get it from the main installer page: https://www.pjrc.com/teensy/td_download.html

4) lots of differences... between pc and pi, but I believe most of the simple things needed should have been installed.

I know you said you tried different cables. I assume you tried plug the teensy into different USB port connections. i.e. there are 4 usb a connectors, I assume you tried more than 1... Also again I would try with as few other things on rpi plugged in...

Will see if generic install works.
 
I finished the fresh install on rpi3, arduino 19 latest td...

Mostly works:
2022-01-20-131133_1920x1080_scrot.jpg
Upload has problem, but pushing program button worked
 
Kurt
Thanks.
on previous question 4. You responded re differences between Pi and PC. I was asking about differences between Arduino and Teensy since I can get the Arduino to connect to the Pi but not the teensy (Both running the same code - post 5).
In latest post looks like you installed IDE on Pi. I have the IDE installed on Windows not the Pi.
And yes I tried all USB ports on Pi with and without other stuff connected.
 
Update: I got my hands on a Teensy LC. Plugged it in to Pi with same code. Detected by Pi as /dev/ttyAMA0 and everything works.
Based on the fact that the LC works as does the Arduino, I have to assume that the Teensy 4.0 was defective in some way. That was an awful lot of troubleshooting for nothing!!
 
Back
Top