raspberrypi / linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
Other
11.14k stars 4.99k forks source link

AEOTEC USB Zwave module not creating /dev/ttyACM0 #3027

Closed ghost closed 5 years ago

ghost commented 5 years ago

When i connect one of these:

https://www.amazon.co.uk/Aeotec-Z-Stick-Z-Wave-create-gateway/dp/B00YETCNOE

I normally get this device:

/dev/ttyACM0

which is used for serial comms to zwave home automation via home assistant.

Connecting it to the Pi4 + Buster i see no such device, infact when i connect via lsusb i see no change before / after connecting.

Any ideas?

pelwell commented 5 years ago

Do you get the same lack of results in the USB2 and USB3 ports?

ghost commented 5 years ago

Yes. I tried both usb2 and usb3 and I'm using a genuine pi 4 for power supply.

pelwell commented 5 years ago

Are there any relevant messages in the kernel log? Unplug the device, sudo dmesg -C (to clear out the old messages), plug it in, wait a moment, then dmesg > usb.txt.

ghost commented 5 years ago

Hmm - i tried a fresh install of buster and got this:

[ 398.804524] usb 1-1.1: new full-speed USB device number 4 using xhci_hcd [ 398.941260] usb 1-1.1: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00 [ 398.941278] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 399.010369] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device [ 399.012948] usbcore: registered new interface driver cdc_acm [ 399.012958] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

and i see /dev/ttyACM0

something is odd about my original install, when i try it on that install i get nothing appearing.

Let me reinstall HA over the weekend and i'll report back.

Thanks!

pelwell commented 5 years ago

"HA"?

ghost commented 5 years ago

HA - Home Assistant. It uses zwave via the serial port /dev/ttyACM0

ghost commented 5 years ago

ok so.... i tried my "fresh" install and i can't recreate that message above. Seems very temperamental. I wonder if its power related.

pelwell commented 5 years ago

Hmm - it could be power related, but I would expect some kind of response to a device insertion, not nothing.

ghost commented 5 years ago

Hmm - I tried the MicroSD card which wouldnt work on the Pi4 on my Pi3B+ and works flawlessly, plugged in + out + in + out....

81.081896] usb 1-1.3: new full-speed USB device number 6 using dwc_otg [ 81.215187] usb 1-1.3: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00 [ 81.215205] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 81.289184] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device [ 81.290193] usbcore: registered new interface driver cdc_acm [ 81.290201] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters [ 95.383586] usb 1-1.3: USB disconnect, device number 6 [ 102.641555] usb 1-1.3: new full-speed USB device number 7 using dwc_otg [ 102.774812] usb 1-1.3: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00 [ 102.774830] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 102.775964] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device [ 110.231628] usb 1-1.3: USB disconnect, device number 7 [ 115.331396] usb 1-1.3: new full-speed USB device number 8 using dwc_otg [ 115.464944] usb 1-1.3: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00 [ 115.464962] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 115.466096] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device

ghost commented 5 years ago

I thought I would check with aeotec as to the certification of the pi4 am I mentioned to check if a module is loaded, they said:


​We have tested using RPi V3 in this case, but we have not yet tested RPi 4. One item to absolutely make sure is that the cdc acm module is installed from the Linux kernel which is required to actuate as a ttyACM0 device. I'll look into acquiring a RPi V4 to see if i can find any issues here.

Cheers, Chris Cheng Field Application Engineer Aeotec Inc. www.Aeotec.com

I'm going to test more over the weekend, any ideas about the module they mentioned?

pelwell commented 5 years ago

The module is in Raspbian images - see your kernel logs above.

Can you try connecting via a powered hub?

ghost commented 5 years ago

I currently only have the official raspberry pi 4 power supply, can you recommend a powered hub? I'll buy one. Thanks!

pelwell commented 5 years ago

I wasn't expecting you to buy one, especially since I don't know if power is the cause of the problem, but the general rule of thumb round here is that Amazon Basics cables and adapters are safe bets.

bieniu commented 5 years ago

I had exactly same issue on RPi 3B after upgrade kernel to version raspberrypi-kernel_1.20181112-1 (November 4). Downgrade kernel fixed the issue. I haven't updated the kernel since then.

ghost commented 5 years ago

I had exactly same issue on RPi 3B after upgrade kernel to version raspberrypi-kernel_1.20181112-1 (November 4). Downgrade kernel fixed the issue. I haven't updated the kernel since then.

interesting but but i am guessing i can't do that with the PI4?

bieniu commented 5 years ago

interesting but but i am guessing i can't do that with the PI4?

I think not.

ghost commented 5 years ago

so... I found something interesting. If i connect it to one of the USB 2 ports (i tried all four actually) i get nothing in the dmesg logs.

but then when i connect a four port hub (that could be powered - but isnt) i see these:

[ 1269.486927] usb 1-1.4: new high-speed USB device number 15 using xhci_hcd [ 1269.617433] usb 1-1.4: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11 [ 1269.617448] usb 1-1.4: New USB device strings: Mfr=0, Product=1, SerialNumber=0 [ 1269.617461] usb 1-1.4: Product: USB 2.0 Hub [ 1269.618998] hub 1-1.4:1.0: USB hub found [ 1269.619082] hub 1-1.4:1.0: 4 ports detected [ 1270.046942] usb 1-1.4.1: new high-speed USB device number 16 using xhci_hcd [ 1270.277312] usb 1-1.4.1: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11 [ 1270.277327] usb 1-1.4.1: New USB device strings: Mfr=0, Product=1, SerialNumber=0 [ 1270.277340] usb 1-1.4.1: Product: USB 2.0 Hub [ 1270.278633] hub 1-1.4.1:1.0: USB hub found [ 1270.278720] hub 1-1.4.1:1.0: 4 ports detected

then when i connect the Aeotec USB stick to one of the back two USB ports I then see:

[ 1329.418219] usb 1-1.4.1.1: new full-speed USB device number 17 using xhci_hcd [ 1329.654873] usb 1-1.4.1.1: New USB device found, idVendor=0658, idProduct=0200, bcdDevice= 0.00 [ 1329.654890] usb 1-1.4.1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 1329.657705] cdc_acm 1-1.4.1.1:1.0: ttyACM0: USB ACM device

It now works 100% of the time.

odd

So your suggestion of using a hub @pelwell you might be onto something.

pelwell commented 5 years ago

I think the Pi budget will stretch to one of these - I'll get one on order.

ghost commented 5 years ago

ok cool - I'm sure its something simple but from what i've read about this stick a few people have reported that updated BIOS on NUC PCs has fixed similar issues so maybe this is firmware related.

i remember seeing something similat with the pi2s back in the day and @ghollingworth i think helped fix it - some kind of timing issue with usb (I sent my hub in and they put it into some kind of usb tool.

anyway - i'm up and running with ZWave, Home Assistant and a super cool Pi4 now 💯 :)

ghost commented 5 years ago

By the way I happend to notice this article which talked about new firmware changes to the USB chip, could this issue be fixed as part of those changes?....

https://www.tomshardware.com/news/raspberry-pi-4-firmware-update-tested,39791.html

pelwell commented 5 years ago

I'm expecting the ZWave module to arrive any day now so I'll be able to try the new firmware, but I wouldn't expect it to fix this issue. Plus, the power saving features are causing problems with some devices. However, that mainly seems to affect high throughput to SSDs, etc., and it is possible to revert to the original version, so feel free to try for yourself: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=243500&p=1490467#p1490467

daaaaan commented 5 years ago

I can confirm the new firmware doesn't help the issue.

Mine exhibits the same behaviour as above, tho don't have a hub to test.

P33M commented 5 years ago

Looking at some USB analyzer traces, the zwave module doesn't even signal a USB attach event. On a VLI expansion card in a PC, I see an attach event but spurious SE1s (illegal bus states) which makes me think that there's some oddness in the way the device is pulling D+/D-. Will require probing with a scope to find out what is happening.

daaaaan commented 5 years ago

Not sure if its relevant but on the rpi3 my stick exhibits no issue.

ghost commented 5 years ago

This is the USB hub that when I connect it to the pi 4 and the zwave USB device everything works fine:

https://rover.ebay.com/rover/0/0/0?mpre=https%3A%2F%2Fwww.ebay.co.uk%2Fulk%2Fitm%2F283514195231

systemofapwne commented 5 years ago

~~I might have a similar problem with a "WiMOD iM871A-usb". Whenever I plug in the stick, a new device is created in /dev. That stick has been configured to receive W-MBUS data. On my PC, it shows me data popping in when I connect to it via putty. But on the pi4 with Raspbian Buster, if I do "cat" on that device, the output is quiet (while on stretch, it was outputting received data). I could reproduce a similar behaviour with a self-made "nano-cul" stick.~~ Error was on my end - Had to rebuild some node-js libraries.

pelwell commented 5 years ago

There is something peculiar electrically about the Zwave dongle. When you plug it into the Pi 4 (through a USB analyser) the Pi tries to talk USB3 to it, and gets no response because the device is only USB2-capable. This shouldn't happen. Repeating the same test with a PC USB3 port as host you see the same USB3 chatter to start with, then after a few hundred milliseconds it falls back to USB3.

This suggests that the dongle has the electrical signature of a USB3 device and the VIA USB3 host controller doesn't get past that to try USB2. (I'm not sure that behaviour is required by the USB3 spec but it seems sensible)

systemofapwne commented 5 years ago

~~This is what I get with my stick: [ 6951.473076] usb 1-1.4: new high-speed USB device number 8 using xhci_hcd [ 6951.625698] usb 1-1.4: New USB device found, idVendor=05e3, idProduct=0610, bcdDevice= 6.54 [ 6951.625712] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 6951.625723] usb 1-1.4: Product: USB2.1 Hub [ 6951.625732] usb 1-1.4: Manufacturer: GenesysLogic [ 6951.634230] hub 1-1.4:1.0: USB hub found [ 6951.634533] hub 1-1.4:1.0: 4 ports detected [ 6951.973078] usb 1-1.4.4: new full-speed USB device number 9 using xhci_hcd [ 6952.130569] usb 1-1.4.4: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00 [ 6952.130579] usb 1-1.4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 6952.130587] usb 1-1.4.4: Product: WiMOD iM871A-usb [ 6952.130594] usb 1-1.4.4: Manufacturer: Silicon Labs [ 6952.130601] usb 1-1.4.4: SerialNumber: 00B93F17 [ 6952.146717] cp210x 1-1.4.4:1.0: cp210x converter detected [ 6952.152214] usb 1-1.4.4: cp210x converter now attached to ttyUSB1~~

For this test, I connected it to a hub this time. Yet, it fails to work, even though it gets added to /dev: There is no serial throughput whatsoever. Error was on my end - Had to rebuild some node-js libraries.

systemofapwne commented 5 years ago

~~Just to make sure, that I did not mess anything up when I upgraded from stretch to buster: I just flashed buster (lite) from iso (on a RPi4), made an apt-get update/upgrade/dist-upgrade and tried it again: "sudo cat /dev/ttyUSB1" does not print anything, while this stick definitely receives data and is supposed to print it here. There is definitly something messed up.~~ Error was on my end - Had to rebuild some node-js libraries.

fribse commented 5 years ago

There is something peculiar electrically about the Zwave dongle. When you plug it into the Pi 4 (through a USB analyser) the Pi tries to talk USB3 to it, and gets no response because the device is only USB2-capable. This shouldn't happen. Repeating the same test with a PC USB3 port as host you see the same USB3 chatter to start with, then after a few hundred milliseconds it falls back to USB3. This suggests that the dongle has the electrical signature of a USB3 device and the VIA USB3 host controller doesn't get past that to try USB2. (I'm not sure that behaviour is required by the USB3 spec but it seems sensible)

Wouldn't that fit with those that have used a hub in between, if it's a USB2 hub, that it will not get confused, and just go to USB2?

pelwell commented 5 years ago

Yes, it does fit the hypothesis.

TerrorSource commented 5 years ago

Question remains, who is causing this and how to solve this? The Pi4 or the Aeotec stick?

pelwell commented 5 years ago

There is clearly room for improvement on both sides, but the ZWave dongle appears to be non-compliant. I haven't seen a requirement for USB3 controllers and hubs to revert to USB2 after a while, but other controllers must do it otherwise nobody would be able to use the Aeotec device.

We have a number of things to work through with the manufacturer of the Pi4 USB3 device, and the question of USB3 to USB2 fallback is one of them but far from the top priority.

TerrorSource commented 5 years ago

Just a quick update. Using a USB 2.0 hub is a good workaround

Bought the cheapest USB 2.0 hub i could find ( https://www.action.com/nl-nl/p/usb-poort-/ ) Connect the USB 2.0 hub, saw the extra device via dmesg Connected Aeotec Z-wave stick in the USB 2.0 hub. Is now visible also and gets ttyACM0 port assigned.

Mastiffen commented 5 years ago

Are there any official word on this? I have tried connectign a powered USB 3.0 Hub without using the power to the USB 2.0 ports, and that works halfway. It creates the device, and it connects, but only partly. The messages that come in are not correct.

Edit: It started working as it should after a few boots and now have been working correctly for some days.

P33M commented 5 years ago

The device is non-compliant and causes issues with certain USB3.0 ports. See: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=245031#p1502030

The recommended workaround is to connect a USB2.0 hub between the Pi and the device.

ghost commented 5 years ago

UPDATE: The ticket i opened with AEOTEC about this issue mentioned:

The Z-Stick Gen5 does support USB3.0, while we believe that USB 3.0 port of the RPi4 has poor USB current drive capability. Try using a high power adapter to power the RPi4 (5VDC, 3.5A, 17.5W). ​The only other alternative is to try an external USB hub between RPi 4 and Z-Stick Gen5.

Mastiffen commented 5 years ago

That does not explain why it works when I use the USB 3.0 hub without the power, but doesn't work when I plug in the power on the same hub.

JamesH65 commented 5 years ago

They are talking rubbish. I've seen the traces on a scope - their device is almost certainly non-compliant, and to implicate the Pi4 current capacity is passing the buck.

ghost commented 5 years ago

I have updated my case with AEOTEC and asked them to comment on this guthub issue with their comments.

P33M commented 5 years ago

I dismantled the device to find out why it's broken. There is a discrete pull-up resistor connected between D+ and Vbus directly.

@Mastiffen I suspect that with the USB3.0 hub in a bus-powered configuration, the downstream Vbus level is low enough to stop tripping the protection facility of the hub's ports.

Mastiffen commented 5 years ago

@P33M Is it some kind of a "soft" short circuit? If it's a short circuit then there's no enough power without power to the hub to actually make the hub understand that it's being short circuited. Is that about right?

alucryd commented 5 years ago

FWIW my test results are a bit contradictory to what I read here. A 2.0 hub I had lying around didn't help at all, instead I ended up plugging the zwave stick into my desktop monitor hub. Both 2.0 and 3.0 ports on the hub are working fine, and I can connect the hub to either 2.0 or 3.0 ports on the rpi without issue.

pelwell commented 5 years ago

Out of interest, does the Aeotec dongle work in the USB 2 hub when it's connected to some other Pi or PC?

alucryd commented 5 years ago

Yes, the dongle was correctly discovered when I plugged the hub into my laptop.

roberttuttle commented 5 years ago

My current results on this issue:

I have a pure old-school USB 2.0 hub (wall and bus power options) arriving from Amazon tomorrow to try which based on reports above should do the trick for just $5 (USB 3.0 hub with power is overkill) https://www.amazon.com/gp/product/B07F8SVY35/ref=ppx_yo_dt_b_asin_title_o00_s00

roberttuttle commented 5 years ago

UPDATE: USB 2.0 hub (see above) did not work (neither wall nor bus powered). Ordered a 4-port USB 3.0 hub with adapter power options to try out. https://www.amazon.com/gp/product/B00TPMEOYM/ref=ppx_yo_dt_b_asin_title_o00_s00

This one worked ... plugged into the USB 3.0 port on the RPi. It is interesting that it works with both wall power ... 0.5A adapter ... and bus power from the RPi).

So, the "just plug in a USB 2.0 adapter in between the Aeotec stick and the RPi" is not necessarily a 100% workaround.

fribse commented 5 years ago

Hey Robert. How about on reboot, does it get auro mounted? I would consider this Hub just for that.

roberttuttle commented 5 years ago

Hey Robert. How about on reboot, does it get auro mounted? I would consider this Hub just for that.

Yes ... rebooted dozens of times now and /dev/ttyACM0 gets discovered/activated 100% each time. For me ... YMMV. (Raspbian Buster, RPi 4).

Mastiffen commented 5 years ago

The Plexgear Desktop 500 works 100 % on the Pi 4 (of course with Buster, since that's the only version of Rasbian that works on the 4) when it's not powered. Not at all when it's powered.