From: Richard <rk...@us...> - 2009-04-02 12:32:18
|
Hello, I have a LFS 6.2 system with many BLFS additions, with kernel 2.6.16.27. I think I have enabled all the necessary usb stuff in the kernel. Recently I had been using libusb-0.1.12, which worked however it was slow so I wanted to try upgrading to libusb-1.0.0. I used the following commands to build libusb-1.0.0: ----------------------------------------- ./configure --prefix=/usr make pushd doc make docs popd make install install -v -d -m755 /usr/share/doc/libusb-1.0.0/apidocs install -v -m644 doc/html/* \ /usr/share/doc/libusb-1.0.0/apidocs ------------------------------------------- The build appeared to go smoothly with no errors reported. I did not try to un-install libusb-0.1.12 before installing libusb-1.0.0, so both exist concurrently on my machine. According to the libusb-1.0 website, this should not be a problem. To compile my program that uses libusb-1.0.0, I did the following (is this correct? It is the only way I could get it to compile, and I could not find any instructions how to compile with libusb-1.0): ---------------------------------------------------- gcc -lm -g -o myprog myprog.c \ `pkg-config --cflags --libs libusb-1.0` -lcurses ---------------------------------------------------- Here are some relevant lines from myprog.c that pertain to libusb-1.0.0: ----------------------------------------------------- #include <libusb-1.0/libusb.h> libusb_device **usb_list; ssize_t usb_cnt; int usb_r; usb_r=libusb_init(NULL); /* (usb_r is returned 0, indicating success) */ usb_cnt = libusb_get_device_list(NULL, &usb_list); ----------------------------------------------------- The problem is that I can't get anywhere with libusb-1.0 because it always returns -1 for usb_cnt, which I think means that libusb-1.0 can't find any usb devices. I have a previous version of myprog_prev.c that uses libusb-0.1.12, which is able to find usb devices using the following: ----------------------------------------------------- usb_init(); usb_find_busses(); usb_find_devices(); ----------------------------------------------------- I compiled the libusb-0.1.12 program as follows: -------------------------------------------------------- gcc -lusb -lncurses -lm -g -o myprog_prev myprog_prev.c -------------------------------------------------------- I did some searching in the archives of the libusb mailing list, and I remember seeing one thread where there was a similar problem, i.e. libusb_get_device_list() always returned -1. It didn't seem to me that there was a resolution of this problem, only speculation that it might be related to a udev problem. However in my case since libusb-0.1.12 can find the usb devices, it seems that they must be set up correctly. Am I missing something? Any advice on what I need to do to get libusb-1.0.0 to find usb devices? I am kind of stuck at this point. Thanks very much, Richard |
From: Richard <rk...@us...> - 2009-04-05 23:46:45
|
Since no one has responded, I will attempt to answer my own question. I think I found the reason why libusb-1.0 was not able to find any usb devices on my system. I don't really understand why this happens or what is the best solution, however I have found at least a temporary workaround. Apparently libusb-1.0 is looking for devices in /dev/bus/usb/001, /dev/bus/usb/002, etc. On my system these files appear to be located in /proc/bus/usb/001, proc/bus/usb/002, etc. I was able to get libusb-1.0 to find usb devices by creating the following links (I have 4 usb devices on my system): -------------------------------------------- ln -s /proc/bus/usb/001 /dev/bus/usb/001 ln -s /proc/bus/usb/002 /dev/bus/usb/002 ln -s /proc/bus/usb/003 /dev/bus/usb/003 ln -s /proc/bus/usb/004 /dev/bus/usb/004 -------------------------------------------- Why it is that libusb-1.0 can't find these files on its own, whereas libusb-0.1.12 is able to find them, I don't know. Richard Richard wrote: > Hello, > > I have a LFS 6.2 system with many BLFS > additions, with kernel 2.6.16.27. I > think I have enabled all the necessary > usb stuff in the kernel. > > Recently I had been using libusb-0.1.12, > which worked however it was slow so I > wanted to try upgrading to libusb-1.0.0. > > I used the following commands to build > libusb-1.0.0: > > ----------------------------------------- > ./configure --prefix=/usr > make > pushd doc > make docs > popd > make install > install -v -d -m755 /usr/share/doc/libusb-1.0.0/apidocs > install -v -m644 doc/html/* \ > /usr/share/doc/libusb-1.0.0/apidocs > ------------------------------------------- > > The build appeared to go smoothly with no errors > reported. > > I did not try to un-install libusb-0.1.12 before > installing libusb-1.0.0, so both exist concurrently > on my machine. According to the libusb-1.0 website, > this should not be a problem. > > To compile my program that uses libusb-1.0.0, > I did the following (is this correct? It is > the only way I could get it to compile, and > I could not find any instructions how to > compile with libusb-1.0): > > ---------------------------------------------------- > gcc -lm -g -o myprog myprog.c \ > `pkg-config --cflags --libs libusb-1.0` -lcurses > ---------------------------------------------------- > > Here are some relevant lines from myprog.c that > pertain to libusb-1.0.0: > > ----------------------------------------------------- > #include <libusb-1.0/libusb.h> > > libusb_device **usb_list; > ssize_t usb_cnt; > int usb_r; > > usb_r=libusb_init(NULL); > /* (usb_r is returned 0, indicating success) */ > usb_cnt = libusb_get_device_list(NULL, &usb_list); > ----------------------------------------------------- > > The problem is that I can't get anywhere with libusb-1.0 > because it always returns -1 for usb_cnt, which I think > means that libusb-1.0 can't find any usb devices. I have > a previous version of myprog_prev.c that uses libusb-0.1.12, > which is able to find usb devices using the following: > > ----------------------------------------------------- > usb_init(); > > usb_find_busses(); > usb_find_devices(); > ----------------------------------------------------- > > I compiled the libusb-0.1.12 program as follows: > > -------------------------------------------------------- > gcc -lusb -lncurses -lm -g -o myprog_prev myprog_prev.c > -------------------------------------------------------- > > I did some searching in the archives of the libusb > mailing list, and I remember seeing one thread where > there was a similar problem, i.e. libusb_get_device_list() > always returned -1. It didn't seem to me that there was > a resolution of this problem, only speculation that it > might be related to a udev problem. However in my case > since libusb-0.1.12 can find the usb devices, it seems > that they must be set up correctly. > > Am I missing something? Any advice on what I need to do > to get libusb-1.0.0 to find usb devices? I am kind of > stuck at this point. > > Thanks very much, > > Richard > > > ------------------------------------------------------------------------------ > _______________________________________________ > Libusb-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libusb-devel > > . > |
From: Peter S. <pe...@st...> - 2009-04-06 00:16:06
|
Richard wrote: > Why it is that libusb-1.0 can't find these > files on its own, whereas libusb-0.1.12 is > able to find them, I don't know. The default mount point (and name) for usbfs has changed over time. A compiled in default is no fun, I'd like libusb to just grab the mount point at run time, and as a bonus it can then error out when usbfs is required but not mounted at all. //Peter |
From: Alan S. <st...@ro...> - 2009-04-06 14:13:51
|
On Mon, 6 Apr 2009, Peter Stuge wrote: > Richard wrote: > > Why it is that libusb-1.0 can't find these > > files on its own, whereas libusb-0.1.12 is > > able to find them, I don't know. > > The default mount point (and name) for usbfs has changed over time. This is not true. The default mount point has always been /proc/bus/usb. Some distributions may choose to mount a usbfs filesystem somewhere else; that's their business. If they do then they should make the corresponding changes to the version of libusb they distribute. The name change part _is_ true -- usbfs used to be called usbdevfs. But that was a long time ago. Alan Stern |
From: Peter S. <pe...@st...> - 2009-04-06 16:08:01
|
Hi, Alan Stern wrote: > > > Why it is that libusb-1.0 can't find these files > > > > The default mount point (and name) for usbfs has changed over time. > > This is not true. The default mount point has always been > /proc/bus/usb. Some distributions may choose to mount a usbfs > filesystem somewhere else; that's their business. If they do then > they should make the corresponding changes to the version of libusb > they distribute. Yep. I was thinking about how the device nodes are created in /dev/bus/usb/ by udev these days, and confused that with usbfs. Thanks for clearing it up. (The major difference is that usbfs has a devices file with info about all devices, and /dev/bus/usb does not.) > The name change part _is_ true -- usbfs used to be called > usbdevfs. But that was a long time ago. Aye. //Peter |
From: Alan S. <st...@ro...> - 2009-04-06 17:57:13
|
On Mon, 6 Apr 2009, Peter Stuge wrote: > Hi, > > Alan Stern wrote: > > > > Why it is that libusb-1.0 can't find these files > > > > > > The default mount point (and name) for usbfs has changed over time. > > > > This is not true. The default mount point has always been > > /proc/bus/usb. Some distributions may choose to mount a usbfs > > filesystem somewhere else; that's their business. If they do then > > they should make the corresponding changes to the version of libusb > > they distribute. > > Yep. I was thinking about how the device nodes are created in > /dev/bus/usb/ by udev these days, and confused that with usbfs. > Thanks for clearing it up. (The major difference is that usbfs has a > devices file with info about all devices, and /dev/bus/usb does not.) That's exactly right. To add to the confusion, the kernel's implementation of those device nodes uses a lot of the same code as its implementation of the usbfs device files (as you would expect, since the nodes and the files do essentially the same things). So to a kernel programmer, it all looks like just plain usbfs! :-) Alan Stern |
From: Xiaofan C. <xia...@gm...> - 2009-04-06 01:57:01
|
On Mon, Apr 6, 2009 at 7:46 AM, Richard <rk...@us...> wrote: > Apparently libusb-1.0 is looking for devices > in /dev/bus/usb/001, /dev/bus/usb/002, etc. > On my system these files appear to be located > in /proc/bus/usb/001, proc/bus/usb/002, etc. > > Why it is that libusb-1.0 can't find these > files on its own, whereas libusb-0.1.12 is > able to find them, I don't know. > Supposedly libusb-1.0 will try /dev/bus/usb (sysfs) first, it that fails, it will try /proc/bus/usb (usbfs). So there might be a bug in the code. Maybe you can enable debug and send out the log and hopefully the developer can find the hidden bug. Xiaofan |
From: Richard <rk...@us...> - 2009-04-07 10:49:00
|
Xiaofan Chen wrote: > > Supposedly libusb-1.0 will try /dev/bus/usb (sysfs) > first, it that fails, it will try /proc/bus/usb (usbfs). > So there might be a bug in the code. Maybe you > can enable debug and send out the log and hopefully > the developer can find the hidden bug. > > Xiaofan > > . > Are there some instructions available how to do this? Thanks, Richard |
From: Xiaofan C. <xia...@gm...> - 2009-04-07 14:07:56
|
On Tue, Apr 7, 2009 at 6:47 PM, Richard <rk...@us...> wrote: >> Supposedly libusb-1.0 will try /dev/bus/usb (sysfs) >> first, it that fails, it will try /proc/bus/usb (usbfs). >> So there might be a bug in the code. Maybe you >> can enable debug and send out the log and hopefully >> the developer can find the hidden bug. > > Are there some instructions available how to do this? > Thanks, > You can try call libusb_set_debug() after libusb_init() but it does not seem to work right now (need to check further). Or you can build libusb with the following. ./configure --enable-debug-log --prefix=/usr make sudo make install This is the example output from the example lsusb.c output. [mcuee@acerpc examples]$ ./lsusb libusb:debug [libusb_init] libusb:debug [find_usbfs_path] found usbfs at /dev/bus/usb libusb:debug [op_init] found usb devices in sysfs libusb:debug [usbi_add_pollfd] add fd 3 events 1 libusb:debug [libusb_init] created default context libusb:debug [libusb_get_device_list] libusb:debug [sysfs_scan_device] scan usb1 libusb:debug [sysfs_scan_device] sysfs descriptors available libusb:debug [sysfs_scan_device] bus=1 dev=1 libusb:debug [enumerate_device] busnum 1 devaddr 1 session_id 257 libusb:debug [enumerate_device] allocating new device for 1/1 (session 257) libusb:debug [sysfs_scan_device] scan usb2 libusb:debug [sysfs_scan_device] bus=2 dev=1 libusb:debug [enumerate_device] busnum 2 devaddr 1 session_id 513 libusb:debug [enumerate_device] allocating new device for 2/1 (session 513) libusb:debug [sysfs_scan_device] scan 2-1 libusb:debug [sysfs_scan_device] bus=2 dev=2 libusb:debug [enumerate_device] busnum 2 devaddr 2 session_id 514 libusb:debug [enumerate_device] allocating new device for 2/2 (session 514) libusb:debug [sysfs_scan_device] scan 2-3 libusb:debug [sysfs_scan_device] bus=2 dev=3 libusb:debug [enumerate_device] busnum 2 devaddr 3 session_id 515 libusb:debug [enumerate_device] allocating new device for 2/3 (session 515) libusb:debug [sysfs_scan_device] scan 2-7 libusb:debug [sysfs_scan_device] bus=2 dev=4 libusb:debug [enumerate_device] busnum 2 devaddr 4 session_id 516 libusb:debug [enumerate_device] allocating new device for 2/4 (session 516) libusb:debug [sysfs_scan_device] scan 2-8 libusb:debug [sysfs_scan_device] bus=2 dev=5 libusb:debug [enumerate_device] busnum 2 devaddr 5 session_id 517 libusb:debug [enumerate_device] allocating new device for 2/5 (session 517) libusb:debug [libusb_get_device_descriptor] 1d6b:0002 (bus 1, device 1) libusb:debug [libusb_get_device_descriptor] 1d6b:0001 (bus 2, device 1) libusb:debug [libusb_get_device_descriptor] 058f:9360 (bus 2, device 2) libusb:debug [libusb_get_device_descriptor] 046d:c054 (bus 2, device 3) libusb:debug [libusb_get_device_descriptor] 04d8:0033 (bus 2, device 4) libusb:debug [libusb_get_device_descriptor] 04d8:8001 (bus 2, device 5) libusb:debug [libusb_unref_device] destroy device 1.1 libusb:debug [libusb_unref_device] destroy device 2.1 libusb:debug [libusb_unref_device] destroy device 2.2 libusb:debug [libusb_unref_device] destroy device 2.3 libusb:debug [libusb_unref_device] destroy device 2.4 libusb:debug [libusb_unref_device] destroy device 2.5 libusb:debug [libusb_exit] libusb:debug [usbi_remove_pollfd] remove fd 3 libusb:debug [libusb_exit] freeing default context The relevant code in linux_usbfs.c static const char *find_usbfs_path(void) { const char *path = "/dev/bus/usb"; const char *ret = NULL; if (check_usb_vfs(path)) { ret = path; } else { path = "/proc/bus/usb"; if (check_usb_vfs(path)) ret = path; } usbi_dbg("found usbfs at %s", ret); return ret; } static int op_init(struct libusb_context *ctx) { struct stat statbuf; int r; usbfs_path = find_usbfs_path(); if (!usbfs_path) { usbi_err(ctx, "could not find usbfs"); return LIBUSB_ERROR_OTHER; } r = stat(SYSFS_DEVICE_PATH, &statbuf); if (r == 0 && S_ISDIR(statbuf.st_mode)) { usbi_dbg("found usb devices in sysfs"); } else { usbi_dbg("sysfs usb info not available"); sysfs_has_descriptors = 0; sysfs_can_relate_devices = 0; } return 0; } Regards, Xiaofan |