View previous topic :: View next topic |
Author |
Message |
statikregimen Apprentice
Joined: 16 Jul 2011 Posts: 173 Location: USA/Michigan
|
Posted: Tue Aug 01, 2017 12:33 am Post subject: Identifying which driver for given device |
|
|
Greetings,
I've been at this for days and posting this because every time I do, I find the answer on my own shortly after. It's a curse.
Anyway, it seems like there has to be a way to identify what specifically one needs to enable in the kernel configuration based on the output of lspci and others (I mean somehow the kernel obviously works out which driver and/or module for each device). Yet, and endless barrage of googling has turned up no such method.
I've more or less gotten lucky so far on this machine but now have an elusive webcam and touchscreen that still need drivers. I know they are supported as I ran Debian Jessie on this machine.and they are also detected and modules loaded by Sabayon live image.
Using Sabayon live image, I've checked the output of lspci -k, lsusb, and usb-devices (both the camera and touchscreen are usb in this case), also lsmod. That is all great, but it only gives me some loose guidance. Some devices are apparently not so straight forward.
I swear I've done this a few times before, but it's lost to me now
I'm intentionally not posting any additional details about my hardware because I am asking how to find out for myself - not asking for someone to tell me!
Thanks in advance!
p.s. yes, i've looked at all the related wiki and doc articles I can find... from here and everywhere. And yes, I am aware that I'm overlooking something horribly obvious so go easy on me!
Last edited by statikregimen on Tue Aug 01, 2017 4:14 am; edited 1 time in total |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Tue Aug 01, 2017 12:47 am Post subject: |
|
|
This is out of date but still helps 99% of the time.
If you boot from a livecd, `make localyesconfig` in the kernel tree enables all currently loaded drivers.
You can also run e.g. `udevadm info /sys/bus/pci/devices/$foo` (no trailing slash) to get some info (it works on other things besides PCI), and the MODALIAS=* line it prints out can be passed directly to modinfo/modprobe to see what driver it thinks it should load.
99% of webcams are either GSPCA or UVC. Touchscreens are a bit more difficult but sometimes usbhid works fine. If it has a kernel driver loaded but doesn't work otherwise, try libinput. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21635
|
Posted: Tue Aug 01, 2017 1:32 am Post subject: |
|
|
OP: you mentioned lsmod -k; did you mean lspci -k? The latter tells you which kernel driver is bound to a device. That is usually the hard part. Once you know what kernel driver serves the device, you need to find what Kconfig symbol will build that driver in the kernel of your choice. If you are lucky, the Kconfig symbol will have the driver's name as a substring, so you can find it using / to search in menuconfig. If you are not lucky, you may need to explore the kernel Makefiles to work backward from the source that implements the driver to the rule that causes that source to be built. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Tue Aug 01, 2017 1:48 am Post subject: Re: Identifying which driver for given device |
|
|
statikregimen wrote: | I've been at this for days and posting this because every time I do, I find the answer on my own shortly after. It's a curse. |
lol perhaps you shouldn't wait for so many days, but post your problem right away.. after you find the answer on your own shortly after, don't forget to mark it solved. that would also help everyone else with similar problems
statikregimen wrote: | I've more or less gotten lucky so far on this machine but now have an elusive webcam and touchscreen that still need drivers. I know they are supported as I ran Debian Jessie on this machine.and they are also detected and modules loaded by Sabayon live image. |
load your Jessie and/or Sabayon and then look for kernel driver/modules in the output of
_________________ "Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey |
|
Back to top |
|
|
statikregimen Apprentice
Joined: 16 Jul 2011 Posts: 173 Location: USA/Michigan
|
Posted: Tue Aug 01, 2017 1:55 am Post subject: |
|
|
Ant P. wrote: | This is out of date but still helps 99% of the time.
If you boot from a livecd, `make localyesconfig` in the kernel tree enables all currently loaded drivers.
You can also run e.g. `udevadm info /sys/bus/pci/devices/$foo` (no trailing slash) to get some info (it works on other things besides PCI), and the MODALIAS=* line it prints out can be passed directly to modinfo/modprobe to see what driver it thinks it should load.
99% of webcams are either GSPCA or UVC. Touchscreens are a bit more difficult but sometimes usbhid works fine. If it has a kernel driver loaded but doesn't work otherwise, try libinput. |
Thanks I will try these. Especially the first sounds enticing. Do I just do that from a chroot into my installed system?
Sabayon appears to load UVC and V4L2 modules according to lsmod, so I enabled both of those but apparently still missing more.
Jaglover wrote: | You can grep kernel sources for USB ID, or search http://cateee.net
Even plain net search can help, my webcam as an example. |
Thanks. I admittedly found something about using grep once, but couldn't find it again (forgot to bookmark). 'grep -nr' is enough? Also, it never occurred to me to search google like that - derp. |
|
Back to top |
|
|
statikregimen Apprentice
Joined: 16 Jul 2011 Posts: 173 Location: USA/Michigan
|
Posted: Tue Aug 01, 2017 1:59 am Post subject: Re: Identifying which driver for given device |
|
|
josephg wrote: |
lol perhaps you shouldn't wait for so many days, but post your problem right away.. after you find the answer on your own shortly after, don't forget to mark it solved. that would also help everyone else with similar problems
load your Jessie and/or Sabayon and then look for kernel driver/modules in the output of
|
haha! Thanks...good advice but usually I am self sufficient. I have to get pretty desperate before I reach out!
I will also try lspci with those options,because again: i'm looking for general strategy and approach than just purely how to set up one specific device. However, in this specific case they are apparently USB devices (this is on a laptop so bus type isn't usually immediately obvious).
EDIT: Wow..yea that helps a lot - the knnvvv options! Thank you! |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Tue Aug 01, 2017 2:53 am Post subject: |
|
|
For me, the best i have found to get drivers name from a running system is
Code: | find /sys -name driver* -exec readlink '{}' \; |
as it is not limited to pci devices. |
|
Back to top |
|
|
statikregimen Apprentice
Joined: 16 Jul 2011 Posts: 173 Location: USA/Michigan
|
Posted: Tue Aug 01, 2017 4:13 am Post subject: |
|
|
Hu wrote: | OP: you mentioned lsmod -k; did you mean lspci -k? |
sorry - typo... I meant lspci -k
krinn wrote: | For me, the best i have found to get drivers name from a running system is
Code: | find /sys -name driver* -exec readlink '{}' \; |
as it is not limited to pci devices. |
This looks like it very well could be the magic potion....I'm looking over the output now (or rather, will be when I'm done typing this).
I haven't been able to find any of these strategies with just searching, so again, thank you all! I feel like it's got to be a redundant topic, but I'll be dipped if I can find any of it.
EDIT: btw - here is what I'm working on to satisfy any curiosity: https://wiki.gentoo.org/wiki/Lenovo_Yoga_2_11-inch |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21635
|
Posted: Wed Aug 02, 2017 2:18 am Post subject: |
|
|
krinn wrote: | For me, the best i have found to get drivers name from a running system is
Code: | find /sys -name driver* -exec readlink '{}' \; |
as it is not limited to pci devices. | There's a chance that won't do what you want, and even if it does, there's a simpler way to do it. Since you didn't quote the glob, you're relying on (1) there being no matching files in the current directory and (2) the shell passing the glob through unchanged on failure (with the right options, failed globs are a hard failure and prevent running the command at all). As for the simpler way, you could use -printf '%l\n' to print the link target instead of running readlink. |
|
Back to top |
|
|
statikregimen Apprentice
Joined: 16 Jul 2011 Posts: 173 Location: USA/Michigan
|
Posted: Wed Aug 02, 2017 3:21 am Post subject: |
|
|
Thanks, Hu.... I'll try your suggestion! The original suggestion seemed to work ok, but I don't fully understand your explanation. Mainly what is a glob?
In the mean time, I broke down and installed sys-kernel/kergen which comes with a couple useful tools. Plus, I happen to be quite proficient in Python so should be able to glean more knowledge from the source as well. It will also be a good stopgap until I master this subject.
I am getting there, though! |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21635
|
Posted: Thu Aug 03, 2017 1:46 am Post subject: |
|
|
Read man 7 glob for a better background than I could readily enter here. (Ask if you still have questions after reading it. Always feel free to ask for elaborations on manual page references.)
Yes, the original will work fine (although perhaps less efficiently (although immeasurably so in most cases)), provided you have no files in the current directory with driver as an initial substring of the filename. If you do, the shell will expand driver* to that list instead of running find with a literal driver*. If you don't have such files, but you do have failglob (Bash name; other shells may name it otherwise, if they have it at all), then the command simply fails. Consider: Code: | $ (shopt -s failglob; ls -l /foo?)
-bash: no match: /foo?
$ (shopt -u failglob; ls -l /foo?)
ls: cannot access '/foo?': No such file or directory
$ (shopt -s failglob; echo /foo?)
-bash: no match: /foo?
$ (shopt -u failglob; echo /foo?)
/foo? |
|
|
Back to top |
|
|
|