usb-reset icon indicating copy to clipboard operation
usb-reset copied to clipboard

Libusb cant initialize?

Open bphermansson opened this issue 7 years ago • 16 comments

Cant get the program to run on Peppermint OS:

sudo usb-reset -a
Unable to initialise libusb, exiting.

And then nothing more.

bphermansson avatar Sep 25 '18 10:09 bphermansson

That's a puzzler, it's about the first thing that is done. I've just pushed a change to this repository that attempts to print out the error from libusb, are you able to give it a try?

ralight avatar Sep 25 '18 11:09 ralight

Well it didn't compile:

gcc -c -Wall -O2 -ggdb -I/usr/include/libusb-1.0 -DVERSION="\"0.3\"" -o usb-reset.o usb-reset.c
usb-reset.c:24:10: fatal error: libusb.h: No such file or directory
 #include <libusb.h>
          ^~~~~~~~~~
compilation terminated.
Makefile:15: recipe for target 'usb-reset.o' failed
make: *** [usb-reset.o] Error 1

I took a shoot and installed libusb-dev and then it compiles and works. The version I first ran was a Snap, it still fails even though I installed the dev-lib.

bphermansson avatar Sep 25 '18 11:09 bphermansson

Ok... I wonder if there is a permission that isn't set on the snap that is required (or possibly Peppermint is doing something unusual).

If you're willing to do some more debugging, would you run the following commands to scan the snap security log for any issues related to usb-reset?

sudo snap install snappy-debug
sudo /snap/bin/snappy-debug.security scanlog usb-reset

The commands are from the bottom of this page: https://docs.snapcraft.io/build-snaps/debugging

ralight avatar Sep 25 '18 12:09 ralight

Ok, I tested that:

sudo /snap/bin/snappy-debug.security scanlog usb-reset
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0

Then it just sits there.

bphermansson avatar Sep 25 '18 14:09 bphermansson

Hmm, ok. I thought that it scanned the old log messages but it might not - could you run the scanlog command, then try to run the usb-reset snap?

ralight avatar Sep 25 '18 14:09 ralight

Ok, I ran "sudo /snap/bin/snappy-debug.security scanlog" in one terminal, "sudo usb-reset -a" in another. The scanlog then says:

 sudo /snap/bin/snappy-debug.security scanlog
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0
= Seccomp =
Time: Sep 26 17:36:47
Log: auid=4294967295 uid=0 gid=0 ses=4294967295 pid=11810 comm="usb-reset" exe="/snap/usb-reset/7/usr/local/bin/usb-reset" sig=0 arch=c000003e 41(socket) compat=0 ip=0x7faf36b385a7 code=0x50000
Syscall: socket
Suggestions:
* add account-control (if using NETLINK_AUDIT)
* add bluetooth-control (if using AF_{ALG,BLUETOOTH})
* add firewall-control (if using NETLINK_{FIREWALL,IP6_FW,NETFILTER,NF_LOG,ROUTE})
* add hardware-observe (if using NETLINK_{GENERIC,KOBJECT_UEVENT})
* add netlink-audit (if using NETLINK_AUDIT)
* add netlink-connector (if using NETLINK_CONNECTOR)
* add network (if using AF_INET{,6}, NETLINK_ROUTE)
* add network-bind (if using AF_INET{,6}, NETLINK_ROUTE)
* add network-control (if using AF_{APPLETALK,BRIDGE,INET,INET6,IPX,PACKET,PPPOX,SNA}, NETLINK_{DNRTMSG,FIB_LOOKUP,GENERIC,INET_DIAG,ISCSI,KOBJECT_UEVENT,RDMA,ROUTE,XFRM})
* add network-observe (if using SOCK_RAW, AF_INET{,6}), NETLINK_{GENERIC,INET_DIAG,KOBJECT_UEVENT,ROUTE})
* add unity7 (if using NETLINK_KOBJECT_UEVENT)
* add x11 (if using NETLINK_KOBJECT_UEVENT)

bphermansson avatar Sep 26 '18 15:09 bphermansson

Ok, we're making progress! In the suggestions list it says "add network" - this should already be the case, so let's check if it has worked. Could you run:

snap interfaces usb-reset

This should give you an output like this:

Slot      Plug
:network  chromium,telegram-desktop,usb-reset
-         usb-reset:raw-usb

The important point here is that the network line exists, and that usb-reset is present. If it isn't present, then I don't know what has happened, it should be automatic.

ralight avatar Sep 26 '18 19:09 ralight

To fix:

sudo snap connect usb-reset:network core:network

ralight avatar Sep 26 '18 19:09 ralight

Well it's there:

snap interfaces usb-reset
Slot      Plug
:network  spotify,usb-reset
-         usb-reset:raw-usb

bphermansson avatar Sep 27 '18 08:09 bphermansson

Thanks for your help, I've got to the bottom of the problem - a change in recent versions of snapd of what interface is needed for observing hardware.

If you run "snap refresh" you should get the updated version that works.

ralight avatar Sep 27 '18 11:09 ralight

$snap refresh
All snaps up to date.
$sudo usb-reset -a
[sudo] password for patrik: 
Unable to initialise libusb, exiting.
usb-reset is installed as a snap. To allow it to function correctly you may need to run:
	sudo snap connect usb-reset:hardware-observe core:hardware-observe
	sudo snap connect usb-reset:raw-usb core:raw-usb

$sudo snap connect usb-reset:hardware-observe core:hardware-observe
$sudo snap connect usb-reset:raw-usb core:raw-usb
$sudo usb-reset -a
Unable to open device 10c4:ea60, are you root?
usb-reset is installed as a snap. To allow it to function correctly you may need to run:
	sudo snap connect usb-reset:hardware-observe core:hardware-observe
	sudo snap connect usb-reset:raw-usb core:raw-usb

bphermansson avatar Oct 02 '18 05:10 bphermansson

This problem still exists, I can't use the software.

bphermansson avatar Oct 23 '18 11:10 bphermansson

Could you retry the steps in https://github.com/ralight/usb-reset/issues/2#issuecomment-424763311 please?

ralight avatar Oct 23 '18 12:10 ralight

Like this?

sudo /snap/bin/snappy-debug.security scanlog
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0
^C
kernel.printk_ratelimit = 5

patrik@PeppermintAthlon ~/Downloads $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
= AppArmor =
Time: okt 25 13:10:30
Log: apparmor="DENIED" operation="capable" profile="snap.snappy-debug.security" pid=28980 comm="python3" capability=2  capname="dac_read_search"

bphermansson avatar Oct 25 '18 11:10 bphermansson

Nearly :)

In one terminal run:

sudo /snap/bin/snappy-debug.security scanlog

In another terminal run:

sudo usb-reset -a

Then report back the output from the first terminal.

ralight avatar Oct 25 '18 12:10 ralight

Ok

sudo /snap/bin/snappy-debug.security scanlog
[sudo] password for patrik: 
INFO: following '/var/log/syslog'. If have dropped messages, use:
INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug.security scanlog
kernel.printk_ratelimit = 0


bphermansson avatar Oct 29 '18 19:10 bphermansson