[Nut-upsuser] NUT 2.8.1-3 " Can't claim USB device [051d:0002]@0/0: Entity not found" using usbhid-ups
Jim Klimov
jimklimov+nut at gmail.com
Fri Nov 1 14:41:58 GMT 2024
Hello,
I was thinking about what could be going wrong here, and a few ideas pop
up:
1) If you installed NUT from packaging, there should have been no need to
add OS groups/users manually. There is a valid use-case for running
different daemons under different accounts, as long as they talk over
network and access same files or UNIX sockets at best by sharing a group
for that, but it does need some careful planning to pull off :)
In the worst case, if you also "chown"ed something to these new accounts,
and if no daemon actually runs as those, you've locked out the daemons from
some access.
2) Access to USB device filesystem nodes should be governed with udev on
that platform, check if you have a file like
/usr/lib/udev/rules.d/62-nut-usbups.rules and if it lists USB IDs of your
device 051d:0002
3) Driver options bus, device, busport can depend on topology and
enumeration of connected devices; it may be wise to comment them away.
Later NUT versions already do not default to offering them in `nut-scanner`
output, to minimize run-time surprises.
4) See if you already have a service instance
`nut-driver at apcupskelder.service` defined and running, since NUT v2.8.0
https://github.com/networkupstools/nut/wiki/nut%E2%80%90driver%E2%80%90enumerator-(NDE)
could have created it - but the older blogs/videos do not reflect this
facility. The "terminating other driver" seems to be a clue in that
direction. Maybe that other copy of the driver is what holds the USB port.
Also avoid `upsdrvctl` in that case.
Notably, if the driver already runs under that service, and `upsd
apcupskelder` returns data - maybe you don't have to do anything.
There might be some other loose threads to pull, but please check these
ones first as most likely :)
Jim
On Wed, Oct 30, 2024 at 11:58 AM Erik De Boeck via Nut-upsuser <
nut-upsuser at alioth-lists.debian.net> wrote:
> Hi all,
>
> Yesterday, I bought a UPS for the first time in my life, and was eager to
> dive into NUT. But not all is working as expected... I saw a similar thread
> started on 18 October, but it didn't help me. (I also spent a handful of
> hours searching the web for solutions, and of course read the manual and
> FAQ - "queequeg".)
>
> I tried shutting my UPS (APC "Back-UPS BX750MI FW:295202G -302202G") down
> with `sudo upsdrvctl shutdown`, but no response. Digging around, I found a
> few things that raised my suspicion, but I can't figure it out...
>
> I followed this fine gentleman's guide (but tweaked it a bit - I don't
> know why he uses `master` and `slave` for example?):
> https://www.youtube.com/watch?v=vyBP7wpN72c.
> I must add that I created a few users and user groups during installation
> and configuration, following the documentation. But in the end, I lost
> oversight, and everything didn't work. So it's entirely possible there's a
> permissions issue somewhere. But I don't have any idea where...
>
> Because of the trial-and-error approach, in the `.conf` files (shown
> below), a lot of stuff is commented out. I assume I can delete it, but I
> also assume the `#` should be adequate? Anyway, I keep it in the output
> below for clarity.
>
> I'll just paste various outputs here, I hope that's a reasonable approach?
>
> Thanks in advance for anyone's help!
>
> Kind regards,
>
> Erik
>
> PS. I also created a GitHub issue (
> https://github.com/networkupstools/nut/issues/2666). Maybe doing that AND
> mailing this, is not the correct procedure? In that case, I apologize.
>
>
> ```
> erik at MinipcLG2:/$ sudo upsdrvctl shutdown apcupskelder
> Network UPS Tools - UPS driver controller 2.8.1
> Network UPS Tools - Generic HID driver 0.52 (2.8.1)
> USB communication driver (libusb 1.0) 0.46
> select with socket: Invalid argument
> Can't claim USB device [051d:0002]@0/0: Entity not found
> upsnotify: failed to notify about state 4: no notification tech defined,
> will not spam more about it
> Driver failed to start (exit status=1)
> ```
>
> ```
> erik at MinipcLG2:/$ sudo nut-scanner -U
> Scanning USB bus.
> [nutdev1]
> driver = "usbhid-ups"
> port = "auto"
> vendorid = "051D"
> productid = "0002"
> product = "Back-UPS BX750MI FW:295202G -302202G"
> serial = "9B2416A22014"
> vendor = "American Power Conversion"
> bus = "001"
> device = "004"
> busport = "002"
> ###NOTMATCHED-YET###bcdDevice = "0106"
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo usbhid-ups -a apcupskelder
> sudo: usbhid-ups: opdracht niet gevonden
> ```
> This seems strange? But after some googling, I found the below alternative
> - although I would expect it to work without `/lib/nut/`):
> ````
> erik at MinipcLG2:/$ sudo /lib/nut/usbhid-ups -a apcupskelder
> Network UPS Tools - Generic HID driver 0.52 (2.8.1)
> USB communication driver (libusb 1.0) 0.46
> Duplicate driver instance detected (PID file
> /run/nut/usbhid-ups-apcupskelder.pid exists)! Terminating other driver!
>
> Bericht aan allen van root at MinipcLG2 (somewhere) (Wed Oct 30 10:27:32
> 2024):
>
> Communications with UPS apcupskelder at localhost lost
>
>
> Bericht aan allen van root at MinipcLG2 (somewhere) (Wed Oct 30 10:27:32
> 2024):
>
> Communications with UPS apcupskelder at localhost lost
>
> HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be
> incorrect; interpreting LogMax -1 as 255 in ReportID: 0x0c
> HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be
> incorrect; interpreting LogMax -1 as 255 in ReportID: 0x22
> HIDParse: LogMax is less than LogMin. Vendor HID report descriptor may be
> incorrect; interpreting LogMax -1 as 255 in ReportID: 0x40
> Using subdriver: APC HID 0.100
>
> Bericht aan allen van root at MinipcLG2 (somewhere) (Wed Oct 30 10:27:40
> 2024):
>
> Communications with UPS apcupskelder at localhost established
>
>
> Bericht aan allen van root at MinipcLG2 (somewhere) (Wed Oct 30 10:27:48
> 2024):
>
> Communications with UPS apcupskelder at localhost lost
>
>
> Bericht aan allen van root at MinipcLG2 (somewhere) (Wed Oct 30 10:27:56
> 2024):
>
> Communications with UPS apcupskelder at localhost established
> ```
>
> ```
> erik at MinipcLG2:/$ cat /etc/group | grep nut
> users:x:100:nutuser,nutmon
> nut:x:130:
> nutuser:x:1002:
> nutgroup:x:1003:nutuser
> nutmon:x:1004:
> nutmongroep:x:1005:nutmon
> ```
>
> ```
> erik at MinipcLG2:/$ lsusb
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 001 Device 003: ID 0403:6001 Future Technology Devices International,
> Ltd FT232 Serial (UART) IC
> Bus 001 Device 004: ID 051d:0002 American Power Conversion Uninterruptible
> Power Supply
> Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
> ```
>
> ```
> erik at MinipcLG2:/$ ls -l /dev/bus/usb/001/004
> crw-rw-r-- 1 root nut 189, 3 okt 30 10:31 /dev/bus/usb/001/004
> ```
>
> ```
> erik at MinipcLG2:/$ cat /etc/os-release
> NAME="Linux Mint"
> VERSION="22 (Wilma)"
> ID=linuxmint
> ID_LIKE="ubuntu debian"
> PRETTY_NAME="Linux Mint 22"
> VERSION_ID="22"
> HOME_URL="https://www.linuxmint.com/"
> SUPPORT_URL="https://forums.linuxmint.com/"
> BUG_REPORT_URL="
> http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
> PRIVACY_POLICY_URL="https://www.linuxmint.com/"
> VERSION_CODENAME=wilma
> UBUNTU_CODENAME=noble
> ```
>
> ```
> erik at MinipcLG2:/$ hostnamectl
> Static hostname: MinipcLG2
> Icon name: computer-desktop
> Chassis: desktop 🖥️
> Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxx
> Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxx
> Operating System: Linux Mint 22
> Kernel: Linux 6.8.0-47-generic
> Architecture: x86-64
> Hardware Vendor: HP
> Hardware Model: HP EliteDesk 800 G2 DM 65W
> Firmware Version: N21 Ver. 02.10
> Firmware Date: Sun 2016-01-24
> Firmware Age: 8y 9month 6d
> ```
>
> ```
> erik at MinipcLG2:/$ uname -r
> 6.8.0-47-generic
> ```
>
> ```
> erik at MinipcLG2:/$ sudo apt list nut*
> Bezig met oplijsten... Klaar
> nut-cgi/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
> nut-client/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
> nut-doc/noble 2.8.1-3.1ubuntu2 all
> nut-i2c/noble 2.8.1-3.1ubuntu2 amd64
> nut-ipmi/noble 2.8.1-3.1ubuntu2 amd64
> nut-modbus/noble 2.8.1-3.1ubuntu2 amd64
> nut-monitor/noble 2.8.1-3.1ubuntu2 all
> nut-powerman-pdu/noble 2.8.1-3.1ubuntu2 amd64
> nut-server/noble,now 2.8.1-3.1ubuntu2 amd64 [geïnstalleerd]
> nut-snmp/noble 2.8.1-3.1ubuntu2 amd64
> nut-xml/noble 2.8.1-3.1ubuntu2 amd64
> nut/noble,now 2.8.1-3.1ubuntu2 all [geïnstalleerd]
> nutcracker/noble 0.5.0+dfsg-2 amd64
> nutsqlite/noble 2.0.6-4 all
> nuttcp/noble 6.1.2-4build1 amd64
> ```
>
> ```
> erik at MinipcLG2:/$ sudo /lib/nut/usbhid-ups -DDD -a apcupskelder
> Network UPS Tools - Generic HID driver 0.52 (2.8.1)
> USB communication driver (libusb 1.0) 0.46
> 0.000000 [D3] do_global_args: var='pollinterval' val='1'
> 0.000024 [D1] testval_reloadable: setting 'pollinterval' exists and
> differs: new value '1' vs. '2'
> 0.000057 [D3] do_global_args: var='maxretry' val='3'
> 0.000083 [D3] main_arg: var='driver' val='usbhid-ups'
> 0.000108 [D3] main_arg: var='port' val='auto'
> 0.000136 [D3] main_arg: var='desc' val='Back-UPS BX750MI
> FW:295202G -302202G'
> 0.000152 [D3] main_arg: var='vendorid' val='051d'
> 0.000179 [D3] main_arg: var='productid' val='0002'
> 0.000203 [D3] main_arg: var='serial' val='9B2416A22014'
> 0.000248 [D1] Network UPS Tools version 2.8.1 (release/snapshot of
> 2.8.1) built with gcc (Ubuntu 13.2.0-23ubuntu2) 13.2.0 and configured with
> flags: --build=x86_64-linux-gnu --prefix=/usr
> --includedir=${prefix}/include --mandir=${prefix}/share/man
> --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var
> --disable-option-checking --disable-silent-rules
> --libdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run
> --disable-maintainer-mode --disable-dependency-tracking --prefix=
> --sysconfdir=/etc/nut --includedir=/usr/include --mandir=/usr/share/man
> --libdir=${prefix}/lib/x86_64-linux-gnu --libexecdir=/usr/libexec
> --with-ssl --with-nss --with-cgi --with-dev --enable-static
> --with-statepath=/run/nut --with-altpidpath=/run/nut
> --with-drvpath=/lib/nut --with-cgipath=/usr/lib/cgi-bin/nut
> --with-htmlpath=/usr/share/nut/www --with-pidpath=/run/nut
> --datadir=/usr/share/nut
> --with-pkgconfig-dir=/usr/lib/x86_64-linux-gnu/pkgconfig --with-user=nut
> --with-group=nut --with-udev-dir=/lib/udev
> --with-systemdsystemunitdir=/lib/systemd/system
> --with-systemdshutdowndir=/lib/systemd/system-shutdown
> --with-systemdtmpfilesdir=/usr/lib/tmpfiles.d --with-python=python3
> --with-python3=/usr/bin/python3 --with-doc=man,html-single,html-chunked,pdf
> 0.000352 [D1] debug level is '3'
> 0.002200 [D1] Succeeded to become_user(nut): now UID=121 GID=130
> 0.002266 [D1] upsdrv_initups (non-SHUT)...
> 0.002285 [D2] Initializing an USB-connected UPS with library
> libusb-1.0.27 (API: 0x100010a) (NUT subdriver name='USB communication
> driver (libusb 1.0)' ver='0.46')
> 0.008020 [D2] Checking device 1 of 4 (1D6B/0003)
> 0.008045 [D1] Failed to open device (1D6B/0003), skipping: Access
> denied (insufficient permissions)
> 0.008052 [D2] Checking device 2 of 4 (0403/6001)
> 0.008064 [D1] Failed to open device (0403/6001), skipping: Access
> denied (insufficient permissions)
> 0.008079 [D2] Checking device 3 of 4 (051D/0002)
> 0.010003 [D2] - VendorID: 051d
> 0.010014 [D2] - ProductID: 0002
> 0.010018 [D2] - Manufacturer: American Power Conversion
> 0.010022 [D2] - Product: Back-UPS BX750MI FW:295202G -302202G
> 0.010026 [D2] - Serial Number: 9B2416A22014
> 0.010030 [D2] - Bus: 001
> 0.010034 [D2] - Bus Port: 002
> 0.010038 [D2] - Device: 004
> 0.010042 [D2] - Device release number: 0106
> 0.010046 [D2] Trying to match device
> 0.010058 [D2] match_function_subdriver (non-SHUT mode): matching a
> device...
> 0.010068 [D3] match_function_regex: matching a device...
> 0.010145 [D2] Device matches
> 0.010155 [D2] Reading first configuration descriptor
> 0.010172 [D3] libusb_kernel_driver_active() returned 0: Success
> 0.010186 [D2] failed to claim USB device: Resource busy
> 0.010198 [D2] Kernel driver already detached
> 0.010210 [D2] failed to claim USB device: Resource busy
> 0.010225 [D2] Kernel driver already detached
> 0.010237 [D2] failed to claim USB device: Resource busy
> 0.010249 [D2] Kernel driver already detached
> 0.010263 [D2] failed to claim USB device: Resource busy
> 0.010275 [D2] Kernel driver already detached
> 0.010286 Can't claim USB device [051d:0002]@0/0: Entity not found
> 0.010300 upsnotify: failed to notify about state 4: no notification
> tech defined, will not spam more about it
> ```
>
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/hosts.conf
> MONITOR apcupskelder at localhost "APC-UPS kelder"
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/nut.conf
> MODE=netserver
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/ups.conf
> pollinterval = 1
> maxretry = 3
>
>
> [apcupskelder]
> driver = usbhid-ups
> port = auto
> desc = "Back-UPS BX750MI FW:295202G -302202G"
> vendorid = 051d
> productid = 0002
> serial = 9B2416A22014
> # vendor = "American Power Conversion"
> # bus = 001
> # device = 005
> # busport = 002
> ###NOTMATCHED-YET###bcdDevice = "0106"
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsd.conf
> LISTEN 0.0.0.0 3493
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsd.users
> #[bespieder]
> [monuser]
> password = indUStr*a
> # bekijker primary
> # admin master
> admin primary
> ```
>
> ```
> erik at MinipcLG2:/etc/nut$ sudo cat /etc/nut/upsmon.conf
> #RUN_AS_USER nutgebruiker
> RUN_AS_USER root
> #MONITOR apcupskelder at localhost 1 bekijker indUStr*a primary
> #MONITOR apcupskelder at localhost 1 admin indUStr*a master
> MONITOR apcupskelder at localhost 1 admin indUStr*a primary
>
>
> MINSUPPLIES 1
> SHUTDOWNCMD "/sbin/shutdown -h +0"
> NOTIFYCMD /usr/sbin/upssched
> POLLFREQ 2
> POLLFREQALERT 1
> HOSTSYNC 15
> DEADTIME 15
> POWERDOWNFLAG /etc/nut/killpower
>
> NOTIFYMSG ONLINE "UPS %s on line power"
> NOTIFYMSG ONBATT "UPS %s on battery"
> NOTIFYMSG LOWBATT "UPS %s battery is low"
> NOTIFYMSG FSD "UPS %s: forced shutdown in progress"
> NOTIFYMSG COMMOK "Communications with UPS %s established"
> NOTIFYMSG COMMBAD "Communications with UPS %s lost"
> NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding"
> NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
> NOTIFYMSG NOCOMM "UPS %s is unavailable"
> NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible"
>
> NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
> NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
> NOTIFYFLAG LOWBATT SYSLOG+WALL
> NOTIFYFLAG FSD SYSLOG+WALL+EXEC
> NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
> NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
> NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
> NOTIFYFLAG REPLBATT SYSLOG+WALL
> NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
> NOTIFYFLAG NOPARENT SYSLOG+WALL
>
> RBWARNTIME 43200
>
> NOCOMMWARNTIME 600
>
> FINALDELAY 5
> ```
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20241101/51a58faf/attachment-0001.htm>
More information about the Nut-upsuser
mailing list