Repository navigation
Description
Describe the bug
I have a Powercom SPD-850U UPS. I try to connect this UPS with my Raspberry PI 3B + via NUT,
I came to the conclusion - all works nice with Raspbian (2018-03-13), the first one that supports 3B +, but does not work with the latest version of Raspbian (2019-04-08). I think, the algorithm for working with the USB bus has changed in the latest versions of the kernel. And this is bad, because it breaks down the work of previously debugged programs.
To reproduce
I use the following NUT driver settings.
This works on both the Debian desktop and Raspbian(2018-03-13) with this UPS.But does not work on Raspbian (2019-04-08)
sudo nano /etc/nut/ups.conf
[spider]
driver = usbhid-ups
port = auto
desc = "Poaercom SPD-850U"
Expected behaviour
The NUT driver start command must start the NUT driver
$ sudo upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Using subdriver: PowerCOM HID 0.5
Actual behaviour
Attempt to launch NUT driver
sudo upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
No matching HID UPS found
Driver failed to start (exit status=1)
System
Raspberry PI3B+
$ cat /etc/rpi-issue
Raspberry Pi reference 2019-04-08
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, e910bf55ac92e27c6e77043e8995bcb5e0a2d742, stage5
$ vcgencmd version
Mar 27 2019 15:45:53
Copyright (c) 2012 Broadcom
version 2e98b31d18547962e564bdf88e57b3df7085c29b (clean) (release) (start)
$ uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux
Logs
$ dmesg
[ 937.439522] usb 1-1.1.2: new low-speed USB device number 6 using dwc_otg
[ 937.600259] usb 1-1.1.2: New USB device found, idVendor=0d9f, idProduct=0004
[ 937.600275] usb 1-1.1.2: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[ 937.600284] usb 1-1.1.2: Product: HID UPS Battery
[ 937.600292] usb 1-1.1.2: Manufacturer: POWERCOM Co.,LTD
[ 937.600301] usb 1-1.1.2: SerialNumber: 004-0D9F-000
[ 937.808194] hid-generic 0003:0D9F:0004.0002: hiddev96,hidraw0: USB HID v1.00 Device [POWERCOM Co.,LTD HID UPS Battery] on usb-3f980000.usb-1.1.2/input0
$ sudo /lib/nut/usbhid-ups -DD -a spider
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
0.000000 debug level is '2'
0.002877 upsdrv_initups...
0.004120 Checking device (0D9F/0004) (001/006)
0.006031 - VendorID: 0d9f
0.006103 - ProductID: 0004
0.006176 - Manufacturer: unknown
0.006273 - Product: unknown
0.006366 - Serial Number: unknown
0.006461 - Bus: 001
0.006557 - Device release number: 0002
0.006650 Trying to match device
0.006765 Device matches
0.007697 Unable to get HID descriptor (error sending control message: Broken pipe)
0.007879 HID descriptor length 996
0.008555 Unable to get Report descriptor: Broken pipe
Activity
Zaitchikk commentedon Jun 25, 2019
Hey anyone! Can I hope that the problem will ever be fixed?
Zaitchikk commentedon Jun 25, 2019
If in the earlier version of Linux for Raspberry, the program worked normally with USB ports, and after updating this operating system, the program stops working, most likely, there have been some changes in the kernel of the operating system. And if we also take into account that the program works fine on Linux for X86 / 64 platforms, we can conclude that the Linux kernel for Raspberry does not work with USB ports in a standard way.
6by9 commentedon Jul 1, 2019
It's difficult to debug without the hardware.
The suspicion would be that it is something that has changed between the 4.9 and 4.14 kernels. It'd be interesting to know if it worked against something like Ubuntu 18.10 or 19.04 on an x86 PC which will be using a similar kernel (actually 4.18 and 5.0 respectively IIRC)
You can use rpi-update to download particular releases using hashes from https://github.com/Hexxeh/rpi-firmware/commits/master
sudo rpi-update 5c80565should get the last 4.9 release.PLEASE DO NOT DO THIS ON A CRITICAL SYSTEM.
sudo apt install --reinstall raspberrypi-kernel raspberrypi-bootloadershould get you back to apt's version of the kernel and firmware.Zaitchikk commentedon Jul 18, 2019
You can check on any other UPS that is supported by the driver "usbhid-ups".
I tested this UPS on the "Raspberry Pi Desktop". The system worked under "VMware® Workstation 15 Player 15.1.0 build-13591040" Everything works.
Here is the version of that system.
Zaitchikk commentedon Jul 18, 2019
Now I tested on Debian 10 under the same Workstation 15 Player. Everything works great.
clepple commentedon Aug 7, 2019
Hi, one of the NUT developers here. @Zaitchikk can confirm, but the base version of NUT in the two versions of Raspbian and Debian 10 is the same (2.7.4). As I understand it, the other differences between the working version and the non-working version of Raspbian are the kernel version, and potentially libusb-0.1, which NUT 2.7.4 uses to talk to this particular UPS. What about the versions of libusb? (
dpkg -l libusb-0.1\*) If not libusb, it is likely a kernel regression.pelwell commentedon Aug 8, 2019
Hi, @clepple - good to have you here. From the usbhid-ups debug output above it seems like the tool is failing quite early. Could you (or anybody) run it under strace on working and non-working systems so we can see the system calls that lead to the error?
Feel free to change any of the usbhid-ups parameters as you see fit, as long as they are the same in both cases.
Zaitchikk commentedon Aug 8, 2019
libusb-0.1-4:a 2:0.1.12-30 armhf userspace USB programming library
Zaitchikk commentedon Aug 8, 2019
strace_bad.txt
I cannot quickly send debug output for the working system (Raspbian (2018-03-13)), because I will have to install it. But I will do it now, and will send a little later.
pelwell commentedon Aug 8, 2019
Thanks. There are a lot of EACCESS and EPERM errors in the trace - can you just confirm that you ran it with sudo?
Zaitchikk commentedon Aug 8, 2019
Yes
By the way, I can quickly send debug output to the working desktop Debian 10 (under VMware® Workstation 15 Player). I do not know if this is necessary.
pelwell commentedon Aug 8, 2019
Yes please - the two systems ought to look about the same at this level.
Zaitchikk commentedon Aug 8, 2019
Here for the desktop Debian10
strace_good.txt
pelwell commentedon Aug 8, 2019
Thanks again - the output is very different, but I can see that the syscalls that return EPIPE on the broken system:
are succeeding on the Debian 10 system:
Did you try downgrading to a 4.9 kernel as @6by9 suggested:
8 remaining items
P33M commentedon Aug 21, 2019
That's irritating. The breakage corresponds to a kernel major version update and not anything to do with a dwc_otg driver change.
Using the dwc_otg driver, can you try capturing the USB "traffic" in both cases using with usbmon/wireshark, then upload the traces somewhere?
https://discussions.flightaware.com/t/monitoring-usb-utilization-on-raspberry-pi/16421
Instead of filtering on address/endpoint, just dump the whole output from usbmon1 until after the transmission breaks (or starts normally on 4.9). Note: don't enter any passwords via keyboard when wireshark is capturing as these will appear in the packets. You may also want to disconnect the network cable while capture is ongoing to reduce the amount of spam created.
Zaitchikk commentedon Aug 21, 2019
I cannot repeat this instruction.
It seems to me this line of script is not working.
At least I don't see any of the instructions in the wireshark window
P33M commentedon Aug 21, 2019
It appears that debugfs is already mounted so you can skip that step.
You may need to run wireshark as root (from a terminal on the desktop) in order to see the usbmon interfaces.
Zaitchikk commentedon Aug 21, 2019
Yes, it did.
Now explain in more detail what conditions should be.
You want me to start debugging in the current configuration (Raspbian 2019-07-10 with the native dwc_otg driver), at the time the NUT driver starts.
Did I understand correctly?
P33M commentedon Aug 21, 2019
Yes, capture with the default driver configuration. Ideally, start the capture with the device unplugged, then plug the device in, then start NUT. You can stop the capture after the communication breaks in the newer version of kernel (4.14.26) and after communication starts successfully in the older version of kernel (4.9.80).
Zaitchikk commentedon Aug 22, 2019
Here is the first attempt. I rebooted Raspberry with the UPS turned off, then did as you wrote. The file contains the result. If you got what you need, let me know. I will repeat the process on 4.14.26
4.9.80_successful_start.pcapng.zip
Zaitchikk commentedon Aug 22, 2019
I tried to install an older system, designated as "firmware: Rebuild from correct tree" dated March 10, 2018. Its version:
And the NUT driver did not start either. Could there be a problem in "rebuild ... ing"?
Here is the wireshark debug output:
4.14.24_Failed_start.pcapng.zip
Zaitchikk commentedon Sep 30, 2019
As I said, NUT start with the dwc2 driver does not work stably.
I was have a little dance with a tambourine around the fire, and I found one new and very strange circumstance. Perhaps it will prompt developers to solve this annoying problem.
I was able to run NUT with the default driver (dwc_otg) with my Powercom SPD-850U UPS.
The sequence is as follows:
After this procedure, all checks show that the NUT driver did not start, and cannot be started manually.
If you want to connect it to the same USB port, you must wait more than 10 seconds, (But this does not always work.)
sudo upsdrvctl startAfter that NUT works, but I'm not sure which is stable.
The following sequence is also possible:
Source here
https://github.com/codazoda/hub-ctrl.c
https://github.com/codazoda/hub-ctrl.c/wiki/Raspberry-Pi
5. After that, the NUT driver is started manually by the command
sudo upsdrvctl startAfter that NUT works, but I'm not sure which is stable.
After these procedures, the NUT can be reconnected to any port. The driver picks it up automatically ... BUT only until the next restart of Ruspberry.
Kernel version
P33M commentedon Jan 14, 2020
Whoops, forgot about this one - what with Pi4 release and all.
The traces you've provided are mostly identical up until the point the host requests a string descriptor for index 0x0. In the working case, a 6-byte string descriptor is returned (two LANGIDs), in the broken case you get -EPIPE (protocol error). All subsequent transfers are broken in the same manner.
Can you try with latest rpi-update firmware? It bumps kernel to 4.19 and also has a few dwc_otg fixes for small transfers such as these.
JamesH65 commentedon Feb 13, 2020
@Zaitchikk Did you have chance to try with the latest firmware? I suspect that apt update apt full-upgrade would be sufficient, rather than using rpi-update.
Zaitchikk commentedon Feb 13, 2020
I tried "apt full-upgrade" now. No effect. Only those magic dances with a tambourine, about which I wrote above, allow me to launch NUT.
hugazo commentedon Jul 9, 2021
Sorry the late bump, but i'm having exactly this issue and since i have a raspberry pi 4, i don't know if the kernel reversal solution could work for me.