date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,415,303,231,000 |
I've been following these instrctions to install the guest packages for arch linux.
Unfortunatelly modprobe returns:
[snooc@archfire ~]$ modprobe -a vboxguest vboxsf vboxvideo
modprobe: WARNING: Module vboxguest not found.
modprobe: WARNING: Module vboxsf not found.
modprobe: WARNING: Module vboxvideo not found.
pacman -Ss virtualbox is showing:
[snooc@archfire ~]$ pacman -Ss virtualbox
...
community/virtualbox-guest-modules 4.3.12-1 [installed]
Guest kernel modules for VirtualBox
...
community/virtualbox-guest-utils 4.3.12-1 [installed]
VirtualBox Guest userspace utilities
...
How can I fix this? I have no idea where to begin.
Arch Linux is guest on VirtualBox which runs under Win7.
|
I had the exact same problem when i was trying to install arch on virtualbox earlier today.
The solution is to run depmod
$ depmod 3.14.4-1-ARCH
After running modprobe again, it should work.
You can use uname -r to find your kernel version string.
Source
| VirtualBox: modprobe can't find vboxguest, vboxsf, vboxvideo |
1,415,303,231,000 |
I'm debugging a closed-source software installer that seems to have some pre-conceived notions about my distribution. The installation aborts after not finding apt-get. The command it attempts to run is:
apt-get -y -q install linux-headers-3.7.5-1-ARCH
I suppose the "package name" comes from /usr/src, where the sole entry is linux-3.7.5-1-ARCH. Does anyone have any educated guess as to which package I should install with pacman?
The headers are probably going to be used to compile drivers for custom hardware.
Here is some relevant text from the install log:
NOTE: Linux drivers must be built against the kernel sources for the kernel
that your Linux OS is currently running. This script automates this task
for you.
NOTE: You must have the Linux OS kernel header source files installed.
If you plan on running the Jungo Debug Monitor, then you may also
need to install "compat-libstdc++" and "libpng3".
Your Linux is currently running the following kernel version:
3.7.5-1-ARCH
|
You're running Arch linux. According to pacman -Q -i linux-headers, the package "linux-headers" contains "Header files and scripts for building modules for linux kernel". When the linux kernel gets built, various constants, which might be numbers or strings or what have you, get defined. Some loadable modules need to know those numbers or strings. The files in "linux-headers" should contain all the build-specific numbers, strings etc for the kernel, in your case kernel version 3.7.5-1 .
You can see what files package "linux-headers" owns: pacman -Q -l linux-headers
You can install package "linux-headers" as root: pacman -S linux-headers
The "apt-get" part of the script seems to assume you're running Debian or a derivative. Install linux-headers with pacman and see how it goes.
| What package could "linux-headers-3.7.5-1-ARCH" mean? |
1,415,303,231,000 |
I've built a new computer with a AMD Ryzen 5700G and to my surprise, no sensor information is picked up whatsoever. I thought perhaps the new AMD chips would not yet be recognized by Linux, but the docs say otherwise.
Here's sudo sensors-detect:
# sensors-detect version 3.6.0+git
# System: Gigabyte Technology Co., Ltd. B550I AORUS PRO AX [Default string]
# Kernel: 5.14.6-arch1-1 x86_64
# Processor: AMD Ryzen 7 5700G with Radeon Graphics (25/80/0)
This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.
Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no):
Silicon Integrated Systems SIS5595... No
VIA VT82C686 Integrated Sensors... No
VIA VT8231 Integrated Sensors... No
AMD K8 thermal sensors... No
AMD Family 10h thermal sensors... No
AMD Family 11h thermal sensors... No
AMD Family 12h and 14h thermal sensors... No
AMD Family 15h thermal sensors... No
AMD Family 16h thermal sensors... No
AMD Family 17h thermal sensors... No
AMD Family 15h power sensors... No
AMD Family 16h power sensors... No
Hygon Family 18h thermal sensors... No
AMD Family 19h thermal sensors... No
Intel digital thermal sensor... No
Intel AMB FB-DIMM thermal sensor... No
Intel 5500/5520/X58 thermal sensor... No
VIA C7 thermal sensor... No
VIA Nano thermal sensor... No
The kernel version should be new enough, and the 5700G should be detected as 'AMD Family 19h', but clearly it isn't.
I've tried manually loading the k10temp module to no effect. I've also tried reinstalling lm_sensors, updating the system and installing the 3rd party utility 'Zenpower', but still sensors looks quite pathetic:
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1: N/A
acpitz-acpi-0
Adapter: ACPI interface
temp1: +16.8°C (crit = +20.8°C)
nvme-pci-0400
Adapter: PCI adapter
Composite: +43.9°C
Is it perhaps the Zen 3 APU's that can't be detected? Or is there some other module or setting I'm missing?
|
The driver in Linux 5.14 doesn't support these APUs yet, it will be available in 5.15 but you can grab it now and compile in 5.14 (must be safe).
| No temperature reading on Ryzen 5700G? |
1,415,303,231,000 |
I have this embedded Linux devices. I would like to add kernel-level functionality to it, but would highly prefer not to compile my own kernel to do so. (If the kernel doesn't load and get to user space the device is bricked; I can't access the bootloader to recover it. The current kernel doesn't have kexec support so I couldn't use that to test a kernel image of my own.)
The device's kernel has support for modules, but I do not have a copy of the corresponding Module.symvers file.
My question: if I do not have the Module.symvers file for a Linux kernel but do have the kernel image and a module compiled for it, can I compile more modules that can be inserted into that kernel, maybe by generating the missing Module.symvers file?
The device is running Linux kernel version 3.10.
Kernel image (in its uImage container): https://www.olio.watch/olio-firmware-1.10.220/olio-firmware/uImage
Configuration (extracted from above image thanks to CONFIG_IKCONFIG): https://www.olio.watch/3.10.0-g2ae2f33-config
The one kernel module I have that matches that kernel: https://www.olio.watch/olio-firmware-1.10.220/olio-firmware/drv2605.ko
|
First, in order to answer your question "can I compile Linux kernel module without Module.symvers", we need to understand what is the purpose of Module.symvers:
Module.symvers serves two main purposes:
1) It lists all exported symbols from vmlinux and all modules.
2) It lists the CRC if CONFIG_MODVERSIONS is enabled. Without CONFIG_MODVERSIONS enabled, the CRC would read 0x00000000.
Module.symvers will be generated during a kernel build, it contains all exported symbols from the kernel and compiled modules. For each symbol, the corresponding CRC value is also stored. The syntax of the Module.symvers file is:
<CRC> <Symbol> <module>
For example:
0x2d036834 scsi_remove_host drivers/scsi/scsi_mod
Having said that, if we have Module.symvers then we can build any module because it contain all the necessary symbols.
If Module.symvers is not available, we still able to build an external module either by building this file or by borrowing it from another module.
Usually, when building an external module, the build system needs access to the symbols from the kernel to check if all external symbols are defined. This is done in a build step called MODPOST. This step obtains the symbols by reading Module.symvers from the kernel source tree.
If a Module.symvers file is present in the directory where the external module is being built, this file will be read too. During the MODPOST step, a new Module.symvers file will be written containing all exported symbols that were not defined in the kernel.
if Module.symvers file is not present, then an external module might be using an exported symbols from another external module, kbuild needs to have full knowledge of all symbols to avoid spitting out warnings about undefined symbols.
For this situation, there are three solutions:
1) Use a top-level kbuild file: If you have two modules, foo.ko and bar.ko, where foo.ko needs symbols from bar.ko, you can use a common top-level kbuild file so both modules are compiled in the same build. Consider the following directory layout:
./foo/ <= contains foo.ko
./bar/ <= contains bar.ko
The top-level kbuild file would then look like:
#./Kbuild (or ./Makefile):
obj-y := foo/ bar/
And executing
$ make -C $KDIR M=$PWD
will then do the expected and compile both modules with
full knowledge of symbols from either module.
2) Use an extra Module.symvers file: When an external module is built, a Module.symvers file is generated containing all exported symbols which are not defined in the kernel. To get access to symbols from bar.ko, copy the Module.symvers file from the compilation of bar.ko to the directory where foo.ko is built. During the module build, kbuild will read the Module.symvers file in the directory of the external module, and when the build is finished, a new Module.symvers file is created containing the sum of all symbols defined and not part of the kernel.
3) Use "make" variable KBUILD_EXTRA_SYMBOLS: If it is impractical to copy Module.symvers from another module, you can assign a space separated list of files to KBUILD_EXTRA_SYMBOLS in your build file. These files will be loaded by modpost during the initialization of its symbol tables.
More details 1
| Compile Linux kernel module without Module.symvers |
1,415,303,231,000 |
Let's take a scenario where a Linux system has booted and is running correctly. A user comes along and hotplugs a USB memory device.
The sequence of events that happen are illustrated on the diagram below:
Where does modprobe load its driver into ?
Is the driver for the requested device found in /sys/bus/drivers after modprobe loads it or before ?
What I'm trying to establish here is the relationship between entries in /sys/ and the events that happen on the graph above.
|
The uevent message contains information about the device (example). This information contains registered vendor and model identification for devices connected to buses such as PCI and USB. Udev parses these events and constructs a fixed-form module name which it passes to modprobe. modprobe looks under /lib/modules/VERSION for a file called depmod.alias which is generated when the kernel is installed and that maps the fixed-form module names to actual driver module file names. See Are driver modules loaded and unloaded automatically? for more details about the process — that answer describes the earlier days when the kernel called modprobe directly, but the way modprobe and module aliases work hasn't changed.
See also Michael Opdenacker's presentation “Hotplugging with udev” which has more examples and describes other aspects of device management with udev, and the Linux from scratch guide which has a section on how the fixed-form module names are defined.
modprobe loads a module by calling the init_module system call. It doesn't interact with sysfs in any way. When the module is loaded, the kernel creates an entry for it in /sys/module. Any entry that appears elsewhere in sysfs is up to the code in the module (e.g. a module with a driver for a type of USB devices will call some generic USB support code that adds an entry under /sys/bus/usb/drivers).
| Where does modprobe load a driver that udev requests? |
1,415,303,231,000 |
I've recently applied a one-line patch to drivers/bluetooth/btusb.c in order to enable compatibility with my Bluetooth device. However, whenever I get a kernel upgrade, the patch will be lost until someone backports it (which isn't likely). Is there a way for me to run a script and patch each new kernel upgrade automatically?
DKMS seems like a good solution, but I'm not sure how to set things up. I don't want to recompile the entire Linux kernel every time I get an update, but I'd like to apply that patch to the btusb module, recompile it, and insert it into my kernel on every update. How can I do this using the source obtained from apt-get source linux-source-3.2.0? What files do I need to copy over? The critical make call is make M=drivers/bluetooth modules, but this depends on other kernel utilities to be built first. How can I assemble a DKMS module for this?
Details on how to apply the patch can be found here on Ask Ubuntu.
|
Yes, you should package up your changes as a DKMS module. Building modules for several installed kernels or automatically rebuilding them on an updated kernel is the main feature of DKMS.
Ubuntu community documention has a nice article on this topic here.
| Automatically apply module patch and compile kernel when updated? |
1,415,303,231,000 |
I just compiled a new kernel and asked myself: What decides during the compilation process which kernel modules are built in the kernel statically?
I then deleted /lib/modules, rebooted and found that my system works fine, so it appears all essential modules are statically built in the kernel.
Without /lib/modules, the kernel loads 22. With the directory present, it loads 67 modules.
|
You do this as part of the configuration process, usually when you run make config, make menuconfig or similar. You can set the module as built-in (marked as *), or modularised (marked as M).
You can see examples of this in a screenshot of make menuconfig, from here:
| What decides which kernel modules are built in the kernel statically during compilation? |
1,415,303,231,000 |
I am studying Linux device drivers, my main focus is on wifi drivers.
I want to know how the code flows when I plugin my device.
Maybe, I can do something like add a printk line in every function.
The device I have is supported by ath9k_htc driver.
I want to make some changes in the driver code for learning purposes.
What is the correct or general approach for understanding the code flow of driver modules in linux?
|
When I want to do this, I use the ftrace framework. Start by mounting the special file system:
mount -t tracefs nodev /sys/kernel/tracing
(as root; you should become root for all this, you’ll be doing everything as root anyway, and it’s easier to have a root shell than to use sudo).
Then change to that directory:
cd /sys/kernel/tracing
It contains a basic README which provides a short summary. To explore function calls, I use the function graph tracer, function_graph in available_tracers. Identify the functions you’re interested in, for example ath9k_htc_tx, and set them up
echo ath9k_htc_tx > set_graph_function
You can append other functions, make sure to use >> after the first function. You can see the configured functions with
cat set_graph_function
When you write to set_graph_function, the function is checked against the running kernel; if the function can’t be found, the write will fail, so you’ll know straight away if you’ll end up not tracing anything.
Once the functions are set up, enable the tracer:
echo function_graph > current_tracer
then watch the trace file. To disable the tracer again,
echo nop > current_tracer
or flip tracing_on by writing 0 or 1 to it (0 to disable tracing, 1 to re-enable it).
| How to know the code flow of a driver module? |
1,415,303,231,000 |
I have been provided with a vendor supplied minimal linux installation. From an answer to a previous question I discovered that it is possible to build a kernel with or without module support. I have a CANBUS device that I need to attach which comes with drivers in the form of .ko files. I would like to be able to install these with the provided install scripts, but firstly I need to know if my kernel was built with module support - is it possible for me to detect this from the command line??
When I run lsmod it returns nothing so I know that there are no .ko files there at the moment - but doest this mean that the kernel won't allow me to install a .ko file ?
|
If you have a /proc filesystem, the file /proc/modules exists if and only if the kernel if compiled with module support. If the file exists but is empty, your kernel supports modules but none are loaded at the moment. If the file doesn't exist, your kernel cannot load any module.
It's technically possible to have loadable module support without /proc. You can check for the presence of the init_module and delete_module system calls in the kernel binary. This may not be easy if you only have a compressed binary (e.g. vmlinuz or uImage). See How do I uncompress vmlinuz to vmlinux? for vmlinuz. Once you've managed to decompress the bulk of the kernel, search for the string sys_init_module.
Note that if modules are supported, you'll need additional files to compile your own modules anyway: kernel headers. These are C header files (*.h), some of which are generated when the kernel is compiled (so you can't just take them from the kernel source). See What does a kernel source tree contain? Is this related to Linux kernel headers?
| Can I detect if my custom made kernel was built with module support? |
1,415,303,231,000 |
I am trying to understand the disadvantages of using Linux kernel modules. I understand the benefits of using them: the ability to dynamically insert code into a running system without having to recompile and reboot the base system. Given this strong advantage, I was guessing most of kernel code should then be in kernel modules instead as part of base kernel, but that does not seem to be the case -- a good number of core subsystems (like memory management) still go into the base kernel.
One reason I can think of is that kernel modules are loaded very late in the boot process and hence core functionality has to go in the base kernel. Another reason I read was about fragmentation.
I didn't really understand why kernel modules cause memory fragmentation, can someone please explain? Are there any other downsides of using kernel modules?
|
Yes, the reason that essential components (such as mm) cannot be loadable modules is because they are essential -- the kernel will not work without them.
I can't find any references claiming the effects of memory fragmentation with regard to loadable modules is significant, but this part of the LLKM how-to might be interesting reading for you.
I think the question is really part and parcel of the issue of memory fragmentation generally, which happens on two levels: the fragmentation of real memory, which the kernel mm subsystem manages, and the fragmentation of virtual address space which may occur with very large applications (which I'd presume is mostly the result of how they are designed and compiled).
With regard to the fragmentation of real memory, I do not think this is possible at finer than page size (4 KB) granularity. So if you were reading 1 MB of virtually contiguous space that is actually 100% fragmented into 1024 pages, there may be 1000 extra minor operations involved. In that bit of the how-to we read:
The base kernel contains within its prized contiguous domain a large
expanse of reusable memory -- the kmalloc pool. In some versions of
Linux, the module loader tries first to get contiguous memory from
that pool into which to load an LKM and only if a large enough space
was not available, go to the vmalloc space. Andi Kleen submitted code
to do that in Linux 2.5 in October 2002. He claims the difference is
in the several per cent range.
Here the vmalloc space, which is where userspace applications reside, would be that which is potentially prone to fragment into pages. This is simply the reality of contemporary operating systems (they all manage memory via virtual addressing). We might infer from this that virtual addressing could represent a performance penalty of "several percent" in userland as well, but in so far as virtual addressing is necessary and inescapable in userland, it is only in relation to something completely theoretical.
There is the possibility for further compounding fragmentation by the fragmentation of a process's virtual address space (as opposed to the real memory behind it), but this would never apply to kernel modules (whereas the last paragraph apparently could).
If you want my opinion, it is not worth much contemplation. Keep in mind that even with a highly modular kernel, the most used components (fs, networking, etc) will tend to be loaded very early and remain loaded, hence they will certainly be in a contiguous region of real memory, for what it is worth (which might be a reason to not pointlessly load and unload modules).
| Disadvantages of linux kernel module? |
1,415,303,231,000 |
I have Kubuntu 14.10 development workstation and recently I have bought a QinHeng Electronics HL-340 USB-Serial adapter. HL-340 is USB<---->Serial adapter and it is recognised by my kernel:
user@comp001:~$ lsusb
Bus 007 Device 010: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
[..]
I am trying to initiate communication via this adapter with Raspberry Pi B+ board, but I am constantly failing.
Whatever text I send to the Raspberry Pi B+ via minicom, the traffic on the line is dead, I've checked with scope. I've double checked the Raspberry Pi B+ setup, the wirings (triple checked with multimeter), the scope wirings and the serial communication is dead. The port on Raspberry Pi B+ is working, because I've hooked up scope on transmit pin of serial port (on Raspberry Pi B+ side) and if I send text from Raspberry Pi B+ (via minicom under ssh tunnel), I get activity on the scope.
I cannot get data from PC via USB serial dongle. How do I test if the dongle works?
|
Is the adapter loading the right kernel module? I've heard that your device may be CH341 compatible:
sudo modprobe ch341
| Testing QinHeng Electronics HL-340 USB-Serial adapter |
1,415,303,231,000 |
I want to build my Linux kernel on my host and use it in my VWware virtual machine. They both use the same Ubuntu kernel now.
On my Host, I do make and make configure. Then, what files should I copy to the target machine, before I do make modules_install and make install?
What other things do I need to do?
|
The 'best' way to do this, is building it as a package. You can then distribute and install it to any Ubuntu machine running the same (major) version.
For building vanilla kernels from source, there's a tool make-kpkg which can build the kernel as packages. Other major advantages: easy reverting by just removing the package, automatic triggers by the package management such as rebuilding DKMS, etc.
The Ubuntu community wiki on Kernel/Compile Alternate Build Method provides a few steps on how to do that.
Basically, it's just the same as building the kernel from upstream documentation, but instead of having make blindly installing it on your system, have it build in a 'fake root' environment and make a package out of it, using
fakeroot make-kpkg --initrd --append-to-version=-some-string-here \
kernel-image kernel-headers
This should produce binary .deb files which you will be able to transfer to other machines and install it using
dpkg -i mykernelfile-image.deb mykernelfile-headers.deb ...
| Build kernel in one machine, install in another |
1,415,303,231,000 |
I've encountered a relatively common problem with ASIX AX88179 USB 3.0 Gigabit Ethernet adapter, where it was not working at all, or was working sporadically, and dmesg was showing errors like
[23552.344134] ax88179_178a 2-1:2.1 eth1: Failed to read reg index 0x0000: -32
Searching on-line, I've found reports of this or similar problems without satisfactory solutions or explanation.
After some debugging, it turned out that the problem is solved if cdc_mbim module is loaded before ax88179_178a. The following solves the problem until the next reboot:
# rmmod ax88179_178a
# modprobe cdc_mbim
# modprobe ax88179_178a # optional
I've checked that cdc_mbim is not declared a dependency of ax88179_178a, neither directly, nor indirectly.
How can I make ax88179_178a depend on cdc_mbim, so that cdc_mbim be always loaded automatically before ax88179_178a?
Update.
My question seems to be a duplicate of Create Linux module dependency for autoloading module.
|
A similar, but slightly cleaner strategy also involving a file in modprobe.d/ is to use the softdep feature to tell modprobe to load cdc_mbim before ax88179_178a. In /etc/modprobe.d/ax88179.conf:
softdep ax88179_178a pre: cdc_mbim
| How to fix an apparenlty missing kernel module dependency declaration? |
1,415,303,231,000 |
I have been trying to get a FreeBSD box (running FreeNAS) to control its fans. It wants to just run them at high speed even though the system temperatures are quite low.
The lm-sensors package can do this on Linux, but it's not available on FreeBSD.
I found this similar question here, but there has been no response.
Is there a kernel module I can load to do this on FreeBSD?
|
ACPI
Yes. If your hardware supports Advanced Configuration and Power Interface (ACPI) then there are loadable modules for ACPI support.
Unfortunately most (if not all) modules are targetting laptops.
You can see if you have any settings related to fans using sysctl:
# sysctl hw.acpi
But rather than manually tweaking the fan speed it should autoadjust according to temperature and load. In FreeBSD this is handled by powerd which is disabled by default.
So even if the fans are not directly exposed then you might be able to adjust them but adjusting the CPU frequency. Some BIOSes then adjust the fan speed accordingly (if within reasonable temperature range as well).
Example setting in /etc/rc.conf
powerd_enable="YES"
powerd_flags="-a adaptive"
performance_cx_lowest="C2" # Online CPU idle state
performance_cpu_freq="1399" # Online CPU frequency
economy_cx_lowest="C3" # Offline CPU idle state
economy_cpu_freq="NONE" # Offline CPU frequency
The sysctl hw.acpi will also show if any of the above settings can take effect.
IPMI
If you have no luck going the ACPI route then maybe the Intelligent Platform Management Interface (IPMI) can be helpful to you. This is however normally only available on serverclass motherboards with a BMC.
When the server boots up the fans runs at BIOS default speeds until the OS takes over. If the OS does not take over (ie. using ACPI) then the CPU and fans often runs at full throttle. Even though the thresholds are not directly available in the BIOS configuration screen in several cases this can then be set using IPMI.
FreeBSD does have an IPMI driver and you can install sysutils/ipmitool to play with the settings.
The following snippet from servethehome.com should work for some SuperMicro boards (X9/X10/X11):
#set fan mode to "full"
ipmitool raw 0x30 0x45 0x01 0x01
#set fans in "system" zone to 37.5%
ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x24
#set fans in "peripheral" zone to 25%
ipmitool raw 0x30 0x70 0x66 0x01 0x01 0x16
NOTE: The fan mode is set to full at first as the BMC does not seem to change the fan speed if not.
The link above states:
but the magic numbers are the same
Please do note that the magic numbers are the same for a SuperMicro board no matter the IPMI tool used. They might be different for Tyan. The hard part is the figuring that out. It seems SuperMicro uses 0x30 but IBM might use 0x3a.
If you have setup username/password then supply them as well:
ipmitool -H HOST_IP -U USERNAME -P PASSWORD raw 0x3a 0x07 0x01 0x50 0x01
You might not have made a bad choice. Some really like Tyan. But beware that their implementation might be a little wonky. This is really important if you try to guess the magic numbers. This experience from 2020 might be better with an updates BIOS:
Definitely the Tyan board has some rough spots around the IPMI since it's not as well used and polished as the SM implementation. I'm seeing things like the KVM connection will drop even though timeout is 1800 seconds. I have to reload the IPMI webpage, log back in and start KVM again. Once, the IPMI completely rejected my root logon even though I am sure of my password. I just pulled power to the server, plugged it back in and waited for IPMI and I was in again. My conclusion is the IPMI lost itself.
Maybe you instead could set the duty cycle in BIOS. That seems to be available on some Tyan board but not obvious in the settings.
it can be set to one of two values - MANUAL and FULL SPEED. That's it. Right now all the temps you see above were with the fan duty cycle set to the default of 30%. I am going to create a support ticket and ask Tyan how to get the fan to vary with CPU or SYS temps
UPDATE: thanks to @jpmomo pointing out that the fan control works - in a fashion - I set the duty cycle to 15 and load tested the motherboard. The winner here is clearly the Supermicro SNK-P0064AP4 heatsink. At the default 30% duty cycle, it does 1600RPM and is super quiet. The heatsink also ensures that the CPU doesn't cross 68C under load. That is an amazing result. Pushing the duty cycle down to 15% makes the CPU fan spin at 1300RPM but it will spin up - once the CPU crosses 75C. I can't believe how good this heatsink is. Of course the 7302P is "only" a 180W processor so there's that
Hardware
If everything else fails then get a cheap hardware fan controller :-).
Or if you do not mind tinkering a little yourself then try 7VDC for fan
You would need a 4 pin molex connector to 3 pin fan connector and if more than one fan, more Y harnesses. Take the black wire and move it to the far end of the connector. This would end up moving the ground wire to the +5VDC line and you would have basically 7VDC (12VDC minus 5VDC equals 7VDC). It's safe providing you do it right and the fans would run at a slower speed. If they still spin too fast for you, you could only move the yellow (may be red on your adapter) to the opposite side. This would make it +5VDC but some fans will not work because that may not be enough voltage to start the fan turning.
| FreeBSD kernel module to control fan speed |
1,415,303,231,000 |
I am learning how to create kernel modules and it was all working fine: I compiled, inserted the .ko with sudo insmod cheat.ko, and the printk messages inside the init function (set by module_init) appeared correctly in /etc/log/syslog. Then I made changes to the module, removed it with sudo rmmod cheat.ko, reinserted, and printk messages were good again.
Then, when I tried a new feature the screen became like a tty, error messages all over, I did ctrl-alt-f2 ctrl-alt-f7 (I'm on ubuntu), and I got back to the X server.
I undid the most recent modifications to the source file, recompiled, but the problem now is that I am unable to reinsert the module to test things out again, unless I reboot, which is too annoying for testing.
How can I reinsert the modified module without rebooting?
What I tried and info I got:
cat /etc/log/syslog: The only relevant information to me was:
BUG: unable to handle kernel NULL pointer dereference at 00000003
so it seems that was the cause of the problem, and then I got an oops:
Oops: 0002 [#1] SMP
Horrid debug information follows that, but nothing that seems to help me on how to reinsert the module.
sudo insmod cheat.ko: command just hangs, outputs nothing, and the only way I can get on using that terminal emulator is killing it with c-c
sudo rmmod cheat:
Error: Module cheat is not currently loaded
sudo modprobe -r cheat.ko
FATAL: Module cheat.ko not found.
lsmod | grep cheat:
cheat 19009 -2
which has a very suspicious -2 usage count...
cat /proc/modules | grep cheat
cheat 19009 1 - Loading 0x00000000 (OF+)
interesting, so the module is still loading...
Edit
As others have said, use a VM. And I strongly recommend you to use Vagrant to manage it.
Edit 2
Nah, Vagrant is for newbs, use QEMU + Buildroot instead: https://github.com/cirosantilli/linux-kernel-module-cheat
|
The Linux kernel is only willing to unload modules if their module_exit function returns successfully. If some function from the module crashes, the kernel may be able to recover, but the module is locked in memory. It may be possible to rummage through the kernel data structures and forcibly mark the module as unloadable (try patching the module_exit function to do nothing), but that's risky. Your best bet is to reboot.
The normal way to test a kernel module is in a virtual machine. Don't test the module on your development machine. A VM has the advantage over a physical machine that you can save the VM state in a ready-for-testing configuration and restore it as many times as you like, which saves the startup time between tests.
| Cannot remove or reinsert kernel module after error while inserting it without rebooting |
1,415,303,231,000 |
I would like to load a custom kernel module upon startup on my system (Debian 9). The vermagic string of this module does not exactly match my kernel version, but I can load it using modprobe -f module_name or insmod -f /path/to/module and it seems to work fine.
If I just add the name of the module to /etc/modules-load.d/modules.conf it does not work, systemctl shows that systemd-modules-load.service gets an error upon trying to load the module.
Can I tell systemd to force load the module?
|
You should be able to override the install behaviour using a configuration file in /etc/modprobe.d, for example /etc/modprobe.d/module_name.conf:
install module_name /sbin/modprobe -i -f module_name
This instructs the module loading code to run /sbin/modprobe -i -f module_name when a request is made to install module_name. -i tells modprobe to ignore install directives when processing the command (otherwise we’d end up with a loop).
| How to force load kernel module (modprobe -f) on startup? |
1,415,303,231,000 |
I want to try my hand at writing a linux driver. I am trying to set up my environment. My current kernel:
$ uname -r
4.10.0-37-generic
I then download the source code:
$ apt-get source linux-image-$(uname -r)
Reading package lists... Done
Picking 'linux' as source package instead of 'linux-image-4.10.0-37-generic'
...
I go to compile and modprobe my driver, it fails. Looking in dmesg, it shows:
version magic '4.10.17 SMP mod_unload ' should be '4.10.0-37-generic SMP mod_unload '
At this point, I'm confused. I go back to the source tree I downloaded, and when I run
$ make kernelversion
4.10.17
Ok, try two.
Download kernel 4.10.17 and install it.
$ uname -r
4.10.17-041017-generic
Still error:
version magic '4.10.17 SMP mod_unload ' should be '4.10.17-041017-generic SMP mod_unload
So maybe someone can help: what is the best and correct way for me to get a working kernel and matching source on ubuntu (well, xubuntu, but I don't think it should matter)? Do I need to get the code from kernel.org and build it from scratch? I kinda want to match the shipping Ubuntu kernel.
|
There are a number of approaches...
If you’re trying to build an external module (including one you’re developing), you only need the kernel headers:
apt install linux-header-$(uname -r)
This will provide the necessary files so that the /lib/modules/$(uname -r)/{build,source} symlinks point to something meaningful. Then you can build a module in another directory by running
make -C /lib/modules/$(uname -r)/build SUBDIRS="/path/to/your/module" modules
This will ensure that the module is built for the kernel you’re running.
If you want to base your development on the Ubuntu kernel, use the appropriate linux-source package; for your release of Ubuntu, that’s currently linux-source-4.10.0:
apt install linux-source-4.10.0
cd /usr/src
tar xf linux-source-4.10.0.tar.bz2
This will include the Ubuntu kernel patches, allowing you to build a kernel with the same features as your current kernel. Note however the caveat from the package description:
This package is mainly meant for other packages to use, in order to build
custom flavours.
If you wish to use this package to create a custom Linux kernel, then it
is suggested that you investigate the package kernel-package, which has
been designed to ease the task of creating kernel image packages.
If you are simply trying to build third-party modules for your kernel,
you do not want this package. Install the appropriate linux-headers
package instead.
If you want to base your development on the upstream kernel (which is what I’d recommend), you should clone Linus’ tree and work there. To test your module, you’ll need to either build a full upstream kernel, or build your module using the approach given in point 1 above.
In any case it’s not a good idea to use the linux source package itself (as obtained using apt-get source), since that’s really designed for building all the kernels used in Ubuntu. If you blindly debuild using that source package, you’ll wait for many hours before the build finishes... (There are circumstances where this is appropriate, and the Ubuntu kernel documentation will explain what to do; but this is very likely not one of them.)
| Getting kernel source code (ubuntu) |
1,415,303,231,000 |
TL;DR:
when I was trying to compile a driver for USB DAQ device I have reconfigured the kernel. The driver refused to compile under the default distro's kernel but everything works with my tweaked kernel.
The driver consists of 2 kernel modules. I know which options I changed but I want to know which particular configuration option enabled my driver. Is there any way how to figure it out without trying (configuring and compiling kernel) every possible combination of the options?
Longer story:
I have an Advantech USB-4702 DAQ device which comes with a driver for various distros, e.g. openSUSE 11.4. It has to be compiled from source and it compiles well on supported distributions (I tried openSUSE 11.4 32bit with kernel 2.6.37.6-24-desktop).
When I was trying to get it work under SLES 11 SP 3 (64bit, kernel 3.0.76-0.11-default) I got compile errors. One of them was caused by this snippet in the source:
#ifndef CONFIG_USB
# error "This driver needs to have USB support."
#endif
So I took a look at the configuration options of the running kernel (from /proc/config.gz) and found CONFIG_USB to be enabled (I guess I would not be able to use my USB keyboard and mouse if it was disabled). Then I started to play with the kernel configuration and enabled (some as modules) some of them. I compiled the kernel, installed it, rebooted. Then the driver compiled without any errors or warnings and I am able to use the device now.
The question is, how can I find out which particular option "enabled" compilation of the driver? I know which options were changed, but I don't want to enable anything that is not necessary for the driver. And I don't want to go through configuring and compiling the kernel with every possible combination of the options.
|
After some further experimenting I can confirm my claim made in one of my comments: the CONFIG_USB option has to have value Y; m is "not enough". Incidentally, the kernel in openSUSE 11.4 has it Y by default and the kernel in SLES11SP3 has m.
It's a pity that the error message does not state it clearly.
An easy way of setting it up is via make menuonfig, then selecting Y for the option Support for host-side USB under Device Drivers -> USB Support.
| How do I know which kernel configuration option enabled my driver? |
1,415,303,231,000 |
On a "Linux debian 2.6.32-5-amd64 #1 SMP" installation where loading a kernel module (mpt2sas) is desired to be delayed to be loaded after starting sshd and users can remotely login, the mpt2sas module was disabled from loading in single user boot, by:
$ echo 'blacklist mpt2sas' >> /etc/modprobe.d/mpt2sas.conf; depmod -aeF /boot/System.map-2.6.32-5-amd64; update-initramfs -u -k $(uname -r)
Later on a modeprobe -v mpt2sas will be run in /etc/rc.local.
After installing a newer mpt2sas driver, using dpkg -i mpt2sas-15.00.00.00-3_Debian6.0.5.amd64.deb the result is that the old driver is renamed from /lib/modules/2.6.32-5-amd64/kernel/drivers/scsi/mpt2sas/mpt2sas.ko to /lib/modules/2.6.32-5-amd64/kernel/drivers/scsi/mpt2sas/mpt2sas.ko.orig and the new driver is installed at /lib/modules/2.6.32-5-amd64/weak-updates/mpt2sas/mpt2sas.ko.
The side effect is that the line blacklist mpt2sas in /etc/modprobe.d/mpt2sas.conf no longer has any effect, when modules are loaded in the single user boot process, mpt2sas is loaded as first kernel module.
Regression:
I know that /etc/modprobe.d/mpt2sas.conf is still being loaded, because when entering a faulty line in this file, a warning is display at console during boot (4 times).
Running depmod -aeF /boot/System.map-2.6.32-5-amd64; update-initramfs -u -k -t $(uname -r); reboot doesn't improve.
Adding kernel boot parameter modprobe.blacklist=mpt2sas doesn't improve.
How can I block loading the new mpt2sas kernel module during the single user boot phase? (I still want to load mpt2sas using modprobe in /etc/rc.local).
|
Check that your module is not listed in file /etc/modules. This file lists the modules that must be loaded at boot time according to http://www.debian.org/doc/manuals/debian-faq/ch-kernel.en.html#s-modules
When the module name - mpt2sas in this case - is listed in file /etc/modules:
Remove that mpt2sas line or comment it by prepending a hash. Line "mpt2sas" becomes "#mpt2sas".
Update the initramfs image file: depmod -aeF /boot/System.map-$(uname -r) && update-initramfs -u -k $(uname -r) -t
And reboot
| How to block loading kernel module only in single user boot when blacklist fails? |
1,415,303,231,000 |
Lets suppose I have a module named "mptsas". How can I find out, what kernel configuration menu entry (make menuconfig inside /usr/src/linux) corresponds to that module?
By 'corresponds' I mean what menu entry compiles the appropriate module into the kernel.
//edit: it works very nicely:
|
There is no recorded association. You need to explore the makefiles in the kernel source. You'll find lines like
obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o
This means that:
If CONFIG_FUSION_SAS is y, then the drivers mptbase, mptscsih and mptsas are compiled into the kernel.
If CONFIG_FUSION_SAS is m, then the drivers mptbase, mptscsih and mptsas are compiled as modules.
If CONFIG_FUSION_SAS is n, then the drivers mptbase, mptscsih and mptsas are not compiled.
The command grep -R --include=Makefile '\bNAME\.o\b' from the top of the kernel source tree will return the relevant makefile line in most cases.
| Binding lsmod module name with kernel configuration menu entry |
1,415,303,231,000 |
Directly related: Prevent claiming of novelty usb device by usbhid so I can control it with libusb?
I want to access an RFID reader (works as HID device) from a program that uses libusb-0.1. In the code, the kernel driver is correctly detached with usb_detach_kernel_driver_np (no errors), but is seems that whenever my program tries to access the USB device, the usbhid module reclaims it. The following error always appears in dmesg:
usb 1-1.3: usbfs: interface 0 claimed by usbhid while 'MyProgram' sets config #1
I've added the following udev rule, restarted udevd and replugged the device, but without effect. It is supposed to blacklist the device from being used by usbhid.
# I anonymized the vendor/product IDs here
ATTRS{idVendor}=="dead", ATTRS{idProduct}=="beef", OPTIONS=="ignore_device"
Apart from dmesg output, I can see in /sys/bus/usb/drivers/usbhid/ that the device 1-1.3:1.0 is recreated every time, so the blacklisting doesn't seem to work.
Anything else I could try? The operating system is Raspbian (on a Raspberry Pi) with kernel 3.2.27.
|
I've solved this part of the problem:
OPTIONS=="ignore_device" was removed from the kernel (commit)
blacklist usbhid didn't do anything, not even blocked my keyboard
A configuration file in /etc/modprobe.d with options usbhid quirks=0xdead:0xbeef:0x0004 did not work because usbhid was not compiled as module
So, I added usbhid.quirks=0xdead:0xbeef:0x4 to the boot command line (on Raspbian, that's in /boot/cmdline.txt) and usbhid does not bind the device anymore.
My original problem, however, still remains. I always get a read/timeout error when accessing the RFID reader the first time.
| Prevent usbhid from claiming USB device |
1,415,303,231,000 |
I get following errors in my logs:
kernel: snd_hda_intel 0000:00:1b.0: IRQ timing workaround is
activated for card #0. Suggest a bigger bdl_pos_adj
Google found some old posts here and here which deal with the same problem. The offered solution suggests to change the value for the kernel module:
options snd-hda-intel enable_msi=1 bdl_pos_adj=1,48
Howeveer, nowhere is there explained what the numbers mean. Moreover, the current (default) value that I have now has multiple numbers:
# cat /sys/module/snd_hda_intel/parameters/bdl_pos_adj
-1,1,-1,-1,-1,-1,-1,-1
Can somebody please explain what all these numbers mean, and how to change them to get rid of the errors ?
|
The kernel documentation describes bdl_pos_adj as follows (see the ALSA driver configuration guide and More Notes on HD-Audio Driver):
bdl_pos_adj - Specifies the DMA IRQ timing delay in samples.
Passing -1 will make the driver to choose the appropriate
value based on the controller chip.
(sic). On Intel controllers, the default is 1 (which is what you can see in your own /sys/module/snd_hda_intel/parameters/bdl_pos_adj). The multiple numbers are there because the module supports multiple HDA devices (eight by default, it's SNDRV_CARDS in the kernel source). I'm not sure off-hand what the correspondence is; I'd have hoped it would match the card number, but you're getting the error for card #0 while your bdl_pos_adj suggests it's taking its value in second position...
As far as fixing the problem, there isn't much documentation and the code doesn't say much either. The only suggestion I have is to follow the instructions, and try increasing the value until you get something that works:
options snd-hda-intel enable_msi=1 bdl_pos_adj=2,2
(I'm using 2,2 here because I'm not sure which of the first two will be used for your device.)
| bdl_pos_adj: set IRQ timing workaround for hda-intel |
1,415,303,231,000 |
Is it possible to boot linux without a initrd.img ? I am planning to add default drivers as a part-of-kernel itself and avoid initrd completely.
What are the modules that should be made part-of-the-kernel instead of loadable modules ?
|
It is, unless your root volume is on an LVM, on a dmcrypt partition, or otherwise requires commands to be run before it can be accessed.
I haven't used an initrd on my server in years. You need at a minimum these modules built in:
the drivers of whatever controller where your root volume disk lives
the drivers necessary to "get to" that like PCI, PCIe support, USB support, etc.
the modules that run the filesystem mounted on it
It's also a very good idea to build in your network card drivers as well.
I've found that lspci/lsmod can help you here from your currently running kernel, look at what's there and use the make menuconfig search option before compiling to find where to enable the modules.
| Booting without initrd |
1,415,303,231,000 |
I have recently been playing around with creating kernel modules using some crosstools for an embedded setup.
It would be helpful to me in future to have the ability to identify the version of the kernel that these modules have been built against. I can find no information online about this so I am starting to think that perhaps it is not possible.
So my question is are there any command line utilities that can ascertain the kernel version headers that a *.ko file was compiled against?
|
Execute the command modinfo <kernel_module_name> and look for vermagic
shw@shw:/tmp # modinfo btrfs
filename: /lib/modules/3.13.0-36-generic/kernel/fs/btrfs/btrfs.ko
license: GPL
alias: devname:btrfs-control
alias: char-major-10-234
alias: fs-btrfs
srcversion: EA2C07F0B841AE2A6D8F91F
depends: libcrc32c,raid6_pq,xor
intree: Y
vermagic: 3.13.0-36-generic SMP mod_unload modversions 686 <==
signer: Magrathea: Glacier signing key
sig_key: FF:9A:DA:11:B8:55:51:6A:72:98:65:9D:4E:3F:BB:76:C5:4A:D3:30
sig_hashalgo: sha512
| Is there a way to determine what kernel version a kernel module was compiled against? |
1,415,303,231,000 |
I want to build kernel modules in Alpine; I know how to do it in Ubuntu.
In Ubuntu, I used to install kernel headers by running:
apt install -y build-essential linux-headers-$(uname -r)
What is the equivalent in Alpine?
I searched on the web and Github user progrium wrote a comment that the equivalent for build-essential is build-base, but what about the linux-headers-$(uname -r) ?
|
build-base is indeed the equivalent to build-essential.
The package providing the headers and scripts needed to build kernel modules is the -dev package matching your kernel package, e.g. linux-lts-dev.
| What is the equivalent packages build-essential and linux-headers-<xxxx> in alpine? |
1,415,303,231,000 |
I don't want to load the kernel module nouveau on my debian box at startup, so I put the following in /etc/modprobe.d/blacklist.conf:
blacklist ttm
blacklist drm
blacklist nouveau
I even did a update-initramfs -u but nonetheless those three modules get loaded each time I boot.
Does anyone know why and how to fix this.
|
You can find the answer in the wiki: the idea is that one does not use /etc/modprobe.d/blacklist.conf.
Instead, say you want to blacklist pcspkr. You create a pcspkr.conf file in /etc/modprobe.d and put blacklist pcspkr inside. Then run
depmod -ae && update-initramfs -u
| Excluding kernel modules through /etc/modprobe.d/blacklist.conf does not work |
1,415,303,231,000 |
So i am on a debian buster 10 system and i installed virtualbox and i encountered an error which tells me to load some kernel modules manually.
sudo ./vboxconfig
[sudo] password for user:
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: You must sign these kernel modules before using VirtualBox:
vboxdrv vboxnetflt vboxnetadp
See the documenatation for your Linux distribution..
vboxdrv.sh: Building VirtualBox kernel modules
So i just need some help to load the vboxdrv, vboxnetflt and vboxnetadp kernel modules to complete my virtual box installation and i am not too sure how this is done. I am using a UEFI system which has secure boot enabled.
|
There are three steps involved in signing modules:
create a Machine Owner Key
enroll it
sign kernel modules with it
The first two steps only need to be done once, the last will need to be redone every time the modules are built.
To create a MOK:
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -days 36500 -subj "/CN=My Name/" -nodes
replacing My Name with something appropriate. (The following instructions assume you run this as root, in root’s home directory, /root.)
To enroll it:
mokutil --import MOK.der
This will prompt for a password, which is a temporary password used on the next boot only. Reboot your system, and you will enter the UEFI MOK management tool; see this handy guide with screenshots and follow the instructions to enroll your key.
This will reboot again, and you will then be able to check that your key is loaded:
dmesg | grep cert
To sign modules with your key, go to the directory containing the modules, and run
/usr/lib/linux-kbuild-4.19/scripts/sign-file sha256 /root/MOK.priv /root/MOK.der vboxdrv.ko
replacing “4.19” and vboxdrv.ko as appropriate.
| Sign Kernel Modules |
1,415,303,231,000 |
I would like to use LZMA-compressed kernel modules on my system. Unfortunately Canoncial leaves that feature disabled both in kernel and user-space tools. Here's what I did so far:
Compile and install the current 14.04.05-LTS kernel (v4.4.19) with:
CONFIG_MODULE_COMPRESS=y
CONFIG_MODULE_COMPRESS_XZ=y
After installation I can now see a bunch of .ko.xz files in /lib/modules/4.4.19-37.56+/kernel/.
Backport the kmod_22 package from Xenial (16.04) to Trusty (14.04) configured with the --with-xz option. This seems to work too.
Run update-initrams -u -k 4.4.19-37.56+.
What works so far:
arbitrary operations on uncompressed modules (like those built by DKMS):
$ modinfo nvidia_370
filename: /lib/modules/4.4.19-37.56+/updates/dkms/nvidia_370.ko
[…]
showing compressed modules by their full path:
modinfo /lib/modules/4.4.19-37.56+/kernel/fs/jfs/jfs.ko.xz
loading compressed modules without (missing) dependencies by their full path:
insmod /lib/modules/4.4.19-37.56+/kernel/fs/jfs/jfs.ko.xz
unloading such modules:
rmmod jfs
What doesn't work:
Unloading with modprobe -r.
Any other operation with just a package name but no path, e. g.:
# insmod jfs
insmod: ERROR: could not load module jfs: No such file or directory
# modprobe jfs
modprobe: FATAL: Module jfs not found in directory /lib/modules/4.4.19-37.56+
So, for modules without dependencies like jfs there's a work-around where I can just specify the full module file path to insmod, but this is both annoying and doesn't perform dependency resolution like modprobe.
I suppose that the kernel module directory somehow doesn't pick up compressed module files. How can I load compressed kernel modules by their name with modprobe?
|
You need to run depmod.
depmod (by default) reads the modules under /lib/modules/$(uname -r), finds which symbols they export and also what they need themselves, then using these info creates the symbol (module) dependencies between modules, and saves it in the file /lib/modules/$(uname -r)/modules.dep and also creates a binary hash /lib/modules/$(uname -r)/modules.dep.bin.
It also creates two other files:
/lib/modules/$(uname -r)/modules.symbols (and it's binary hash /lib/modules/$(uname -r)/modules.dep.bin): contains the symbols each module exports
/lib/modules/$(uname -r)/modules.devname: contains the /dev entry that needs to be created for necessary modules, contains the module name, name of the /dev entry and the major, minor numbers
Just to note, you can also run depmod for a specific kernel version or on a specific module, check man depmod.
| How to load compressed kernel modules in Ubuntu? |
1,481,569,316,000 |
In order to troubleshoot an issue I'm looking in my kernel configuration settings for: CONFIG_SECCOMP, CONFIG_HAVE_ARCH_SECCOMP_FILTER and CONFIG_SECCOMP_FILTER.
The first one is present in the kernel's config file as: CONFIG_SECCOMP=y but the other two are simply not present. This leaves me wondering how to interpret that..
Should settings missing in a kernel's config be interpreted as <setting>=n or are defaults used?
|
For boolean or tristate yes/no/module settings, missing and n are equivalent.
Boolean settings correspond to a C preprocessor macro which is either defined or not. Source files check whether the macro is defined with #ifdef. If the setting is n, the macro is not defined, which is equivalent to the default state.
Yes/no/module tristate settings are expanded in makefiles. Options set to y cause a source file to be compiled and the resulting object file to be linked into the main kernel image. Options set to m cause a source file to be compiled and the resulting object file to be linked as a separate module. Options set to n don't cause anything to be built.
Some configuration options don't have a direct impact on the file, but only cause configuration interfaces to prompt you for a category of settings.
If you have a .config file in the kernel source tree, you can run make oldconfig to regenerate the file with unknown options removed and options not present in the file added with their default setting. Some options are skipped from the resulting file if their category is skipped by setting the category prompt option to n.
| Should settings missing in a kernel's config be interpreted as `<setting>=n` or are `defaults` used? |
1,481,569,316,000 |
I have allocated /dev/ram0:
dd if=/dev/zero of=/dev/ram0 bs=1M count=1024
Now I have 1Gb sitting in memory. How do I free up the allocated space?
|
I believe, you can use blockdev command, which is available from util-linux package (in Debian)
blockdev --flushbufs /dev/ram0
Source
| How to deallocate /dev/ram0 |
1,481,569,316,000 |
When installing kernel modules, I have the option to strip out debugging symbols using INSTALL_MOD_STRIP=1. This saves significant disk space.
Does it also save memory? Why should one keep the debugging symbols in the kernel modules?
|
Debugging symbols just add extra information to an executable that helps when running a debugger such as GDB. It lets the debugger recreate the source code from the executable to show you where things such as segfaults occur during runtime.
If you are testing / hacking / making something inter-operate with the module then you need them. During normal operation they just take up space and can pose a security risk on a production machine. For example if someone breaks into your system with user privileges they can use a debugger to look for weaknesses in the current running modules to gain root access.
It will save a small amount of space to remove them as well.
| When should I keep debugging symbols in kernel modules? |
1,481,569,316,000 |
I'm currently having to recompile my wireless driver from source every time I get a new kernel release. Thinking it would be awesomely hackerish to automate this process, I symlinked my Bash build script to /etc/kernel/postinst.d. I've verified that it does, in fact, run when the latest kernel update is installed, but one thing is left as a problem: the driver compiles for the existing running version of the kernel.
For example, if I'm running 3.0.0-14-generic and apt-get dist-upgrade to kernel 3.0.0-15-generic, then it compiles for kernel 3.0.0-14-generic, which doesn't really help me at all.
Is there a way to tell from my kernel postinst script which version of the kernel has been installed so I can pass it to my make call so it can be compiled for the newly installed kernel?
|
This is no actual answer to your question, just a pointer to a tool that might be related and helpful:
Do you have dkms installed? (Some information here, the alioth page seems down at the moment.) It's supposed to do just that, if I'm not misled. It requires the appropriate linux-headers package and the module/firmware/something-like-that package to be installed; and it works for all installed linux-image packages. (I can't say anything about a generic module, but it worked fine when I used it with the non-free nvidia module.)
(There're more links here, like the manpage and this linuxjournal.com article which provides a non-Debian-ecosystem-centric explanation of the program.)
| Running a script every time a new kernel is installed |
1,481,569,316,000 |
I am interested in Linux and been digging it for a while. I just learnt to compile a Linux kernel from source and boot it with Grub which lands you with the shell of the kernel.
Now as soon as the kernel is loaded into memory it searches for the init to load it. My agenda is to bring up a shell (which a normal user can use - like bash).
So, How can I bring it in?
Do I need to configure init to load the bash shell or is there something I could do?
I am building my own distro and I just need the distro to have a shell (bash) and nothing else.
|
Hmm. This should not be complicated to achieve, but it's also very complex :)
You can simply do what Alexander suggested (init=/bin/bash), and you'll do fine.
The init process is what the kernel calls, and it kicks off all of your userland. Login terminal included. If your init just spawns that bash terminal, you're fine. But if that terminal crashes, or exits, init is supposed to clean up. If some of the processes you launch from terminal die, you need to clean up. If they die, then their children need a new parrent process, it'll be your init.
I highly recommend dedicating 10 minutes to read this, it's very friendly overview of what init does:
http://tilde.town/~elly/userland.txt
Then you'll get closer to understand what it entails to run your own init.
A relevant part of that link says:
There is only one thing we
need to do: provide an initial binary to launch at any of these paths: /sbin/init, /etc/init, /bin/init, or /bin/sh. This process (init) is run as pid 1.
The init process needs to do two things:
Never exit (if init exits, the kernel panics)
Reap zombie processes
The rest of the text then implements a simple init.
| How can I make a shell to show up in my own distro (linux)? [closed] |
1,481,569,316,000 |
I'm wondering if I can use the directory listing of /sys/module instead of lsmod to get a list of currently loaded modules.
Is that the list of loaded modules only? Or maybe that combined with /sys/module/*/initstate?
|
Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.
lsmod gets the list of loaded modules from /proc/modules.
I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.
¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.
| Are Modules listed under /sys/module all the Loaded Modules? |
1,481,569,316,000 |
I am trying to build the CP210x driver for the 3.x.x kernel on ChrUbuntu.
Build instructions: Ubuntu:
make ( your cp210x driver )
cp cp210x.ko /lib/modules/<kernel-version>/kernel/drivers/usb/serial
insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko
insmod cp210x.ko
I started with apt-get install build-essential then:
root@ChrUbuntu:~/Documents/# make
make -C /lib/modules/3.4.0/build M=/home/me/Documents/Linux_3.x.x_VCP_Driver_Source modules
make: *** /lib/modules/3.4.0/build: No such file or directory. Stop.
make: *** [all] Error 2
But I am confused by the error because the location apparently exists:
root@ChrUbuntu:/lib/modules/3.4.0# ls -la
total 820
lrwxrwxrwx 1 root root 105 Feb 8 17:01 build -> /build/x86-mario/tmp/portage/sys-kernel/chromeos-kernel-3.4-r996/work/chromeos-kernel-3.4/build/x86-mario
How can I resolve this?
|
Figured out the steps to compile this kernel module. The version on the website, silabs.com is apparently too old to be used with newer kernels (3.4+).
I was able to compile a newer version of the file, cp210x.c, that I found over on kernel.org for my particular version of the kernel, using the Makefile provided in the VCP Driver Source.
Building cp210x for your kernel version
baseline your kernel
First make note of your major & minor numbers for your kernel you have (i.e. 3.4, 3.5, etc.).
$ uname -r
3.5.0-19-generic
Incidentally I'm on Ubuntu 12.10:
$ lsb_release -r
Release: 12.10
Install the kernel headers & build tools for your kernel version:
sudo apt-get install linux-headers-$(uname -r) build-essential
Get the VCP bundle from silabs.com
Now make yourself a little work area for all this:
mkdir -p $HOME/cp210x && cd $HOME/cp210x
Download the VCP Driver Source:
wget http://www.silabs.com/Support%20Documents/Software/Linux_3.x.x_VCP_Driver_Source.zip
unzip Linux_3.x.x_VCP_Driver_Source.zip
cd Linux_3.x.x_VCP_Driver_Source
mv cp210x.c cp210x.c_orig
Get kernel.org cp210x.c
Now download the appropriate version of cp210x.c for your kernel:
$ wget https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/drivers/usb/serial/cp210x.c?h=linux-3.5.y -O cp210x.c
NOTE: You can browse the different versions of the kernel here.
Compile
Now we compile using make:
$ make
make -C /lib/modules/3.5.0-19-generic/build M=/home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-19-generic'
CC [M] /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.mod.o
LD [M] /home/manny/cp210x/Linux_3.x.x_VCP_Driver_Source/cp210x.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic'
Deploy
Now move any pre-existing cp210x.ko kernel out of the way:
sudo mv /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko.orig
Now copy the newly built kernel module, cp210x.ko in it's place:
sudo cp cp210x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/cp210x.ko
Load
Now make sure the previous cp210x.ko kernel module wasn't loaded:
$ lsmod | grep cp210x
$
If it is, unload it:
sudo rmmod cp210x
Now let's load our new cp210x.ko module:
sudo modprobe cp210x
Test
Confirm that it loaded correctly:
$ lsmod |grep cp210x
cp210x 21822 0
usbserial 42355 1 cp210x
Also check dmesg for any issues:
$ dmesg | tail
...
...
[979772.614394] usbcore: registered new interface driver usbserial
[979772.614410] usbcore: registered new interface driver usbserial_generic
[979772.614456] USB Serial support registered for generic
[979772.614461] usbserial: USB Serial Driver core
[979772.614810] usbcore: registered new interface driver cp210x
[979772.614822] USB Serial support registered for cp210x
Compiling usbserial kernel module
The OP asked about how to accomplish compiling the usbserial.ko module as well, given it's needed by the applications in order to make use of the cp210x kernel module. Here are those instructions.
First make note of which kernel version you're using:
uname -r
3.5.0-19-generic
So we're using 3.5.0, next install the kernel source:
sudo apt-get install linux-source-3.5.0
Now let's make ourselves a work area:
mkdir -p $HOME/src && cd $HOME/src
Unpack the kernel source into our work area:
tar jxvf /usr/src/linux-source-3.5.0.tar.bz2
Now let's compile usbserial.ko:
$ cd linux-source-3.5.0/drivers/usb/serial
$ make -C /usr/src/linux-headers-`uname -r` M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-3.5.0-19-generic'
CC [M] /root/src/linux-source-3.5.0/drivers/usb/serial/usb-serial.o
...
...
LD [M] /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.o
...
...
CC /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.mod.o
LD [M] /root/src/linux-source-3.5.0/drivers/usb/serial/usbserial.ko
...
...
make: Leaving directory `/usr/src/linux-headers-3.5.0-19-generic'
Check that usbserial.ko was built:
ls -l |grep usbserial
-rw-r--r-- 1 root root 74822 May 15 09:20 usbserial.ko
-rw-r--r-- 1 root root 4120 May 15 09:20 usbserial.mod.c
-rw-r--r-- 1 root root 8840 May 15 09:20 usbserial.mod.o
-rw-r--r-- 1 root root 74724 May 15 09:20 usbserial.o
Now let's install it, load it, and test it:
# move old driver out of the way
$ mv /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/usbserial.ko.orig
# copy newly built one in
$ cp usbserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial/.
# confirm `usbserial.ko` isn't loaded
$ lsmod | grep usbserial
$
# load it
$ modprobe usbserial
# confirm
$ lsmod |grep usbserial
usbserial 42355 0
# check dmesg log
$ dmesg | tail -4
[1195955.210920] usbcore: registered new interface driver usbserial
[1195955.210970] usbcore: registered new interface driver usbserial_generic
[1195955.211002] USB Serial support registered for generic
[1195955.211069] usbserial: USB Serial Driver core
References
USB Driver Compilation Error
KernelCustomBuild - Ubuntu wiki
| Ubuntu make fails with No such file or directory /lib/modules/3.4.0/build |
1,481,569,316,000 |
I wonder why there are so many entries in modules.dep when I don't have that many drivers? I have a plain vanilla Dell Latitude E7450 running Ubuntu 16.04 and my modules.dep lists hundreds of dependencies. Are really that many necessary? All thos can't be drivers so what is it more that is implemented as a module and listed by modules.dep?
|
modules.dep lists the dependencies of every single module available on your system, not just those which are in use on your system. It also lists modules which have no dependencies, which adds to its length. Distribution kernel packages typically have thousands of modules nowadays, so it’s perfectly normal for modules.dep to have thousands of lines (one per available module).
Kernel modules provide a variety of services: they can contain hardware drivers, common code shared by a number of drivers, file systems...
| Why are there so many entries in modules.dep? |
1,481,569,316,000 |
I'm seeing a lot of posts reference lar_disable like this one for instance. I'm wondering what it does. modinfo iwlwifi just says,
parm: lar_disable:disable LAR functionality (default: N) (bool)
What is "LAR functionality"?
|
LAR means Location Aware Regulatory
I searched LAR in the source code of Linux wireless driver, only Intel use the LAR term in their code.
In their code comment [1, 2, 3] mention the full form of LAR
| What is iwlwifi's "lar_disable"? |
1,481,569,316,000 |
I would like to blacklist the amdgpu driver. I opened /etc/modprobe.d/blacklist.conf and added the following line:
blacklist amdgpu
Then I rebooted and ran lsmod | grep amdgpu:
$ lsmod | grep amdgpu
amdgpu 1564672 23
i2c_algo_bit 16384 1 amdgpu
ttm 98304 1 amdgpu
drm_kms_helper 151552 1 amdgpu
drm 352256 11 amdgpu,ttm,drm_kms_helper
Why is the module still loading?
My desktop is running Kubuntu 17.04 and I have a Radeon R9 270X.
|
Many modules are loaded from the initramfs, before the root filesystem is mounted. That means the initramfs contains its own copy of the modprobe configuration, so after editing, you need to update the initramfs:
sudo update-initramfs -u
will do that. Note that only updates the one for the current kernel—you can specify additional arguments to update others (e.g., old kernels) as well.
| How to blacklist amdgpu? |
1,481,569,316,000 |
I read in a book written by Robert Love that:
Linux supports the dynamic loading of kernel modules.
He said this is the difference between Linux and Unix, but I seem to recall there is also KLD in FreeBSD? So can KLD also be seen as dynamic loading of kernel modules?
|
KLD is indeed dynamic kernel modules. In fact, many old school Unixen also have loadable kernel modules nowadays. Your book must be quite old :)
| "Linux supports the dynamic loading of kernel modules. " |
1,481,569,316,000 |
In this post there is some explanation about why does lsmod show -2 in 'used by' column. The idea is that the kernel config option CONFIG_MODULE_UNLOAD was not set.
But what if lsmod shows -1 only for one specific module while CONFIG_MODULE_UNLOAD is set in my current kernel? How to debug this muddle?
|
A module reference count of -1, visible both in /sys/module/<module>/refcnt and in lsmod’s output, means that the module is currently unloading.
If a module’s reference count stays at -1, that indicates a problem — dmesg should tell you more.
| lsmod 'used by' shows -1 while CONFIG_MODULE_UNLOAD=y |
1,481,569,316,000 |
I'd like to add an alias to a kernel module, e.g. make nvidia-343 available as nvidia on Ubuntu 14.10 with Linux 3.18.1, so that it can be loaded under the alias name and so that the alias appear in the list of aliases in modinfo.
The current level of explanation of what a kernel module alias is in the manpages of modprobe, modinfo, modinfo, etc. is rather ridiculous because it is zero (see https://bugs.launchpad.net/ubuntu/+source/kmod/+bug/1405669 as well).
Adding a line in the form of alias <name> <alias> to /etc/modprobe.conf as described at http://www.tldp.org/LDP/lkmpg/2.6/html/x44.html doesn't work (alias not listed in modinfo output) (I guess(!) these are the docs for 2.6.x anyway).
|
I think you know all you need to know about module aliases. Adding that line in /etc/modprobe.conf does define an alias: doesn't it work when you run modprobe <name>? It doesn't work with modinfo because that program doesn't support aliases: they're a concept of the modprobe program, not of the lower-level tools like insmod and modinfo.
| How to add an alias to a kernel module? |
1,481,569,316,000 |
Today I changed my workstation to Debian. As Ubuntu is not nearly stable. Now I installed VMware player. I started it and got a message "Before you can run VMware, several modules must be compiled and and loaded into the running kernel. Kernel headers for version2.6.32-5-amd64 were not found" , below a field were I can give a file location. What should I do now? I never faced such a situation.
|
In order to compile kernel modules for your running kernel, you need install the kernel headers. The following command should work:
apt-get install linux-headers-$(uname -r) build-essential
| VMwarePlayer on debian. Missing kernel modules |
1,481,569,316,000 |
I'm currently trying to rebuild the kernel for a proprietary device. In order to do this I will need to produce a kernel config for the device. While I could likely do this through trial and error, it would be better to see if I can extract the config from the running host.
That being said the running kernel was not compiled with CONFIG_IKCONFIG (and thus not CONFIG_IKCONFIG_PROC either). This means that there is no /proc/config.gz to extract.
In addition, they didn't bother to package the config in /boot either. Thus, the two common places where a kernel config is generally stored are out of luck.
Most everything was compiled statically into this kernel:
# cat /proc/modules
linux_user_bde 12327 0 - Live 0xf8536000 (PO)
linux_kernel_bde 29225 1 linux_user_bde, Live 0xf8524000 (PO)
pciDrv 1448 0 - Live 0xf8510000 (O)
iTCO_wdt 4456 0 - Live 0xf83fb000
iTCO_vendor_support 2003 1 iTCO_wdt, Live 0xf83f7000
i2c_dev 5443 0 - Live 0xf83f2000
i2c_i801 9421 0 - Live 0xf83eb000
i2c_core 20859 3 i2cscan,i2c_dev,i2c_i801, Live 0xf83e0000
igb 148294 0 - Live 0xf83ae000 (O)
dca 4665 0 - Live 0xf804c000
# ls -l /proc/conf*
ls: /proc/conf*: No such file or directory
# find /boot/ -name "conf*"
# modprobe configs
modprobe: module 'configs' not found
#
|
One, arguably silly, idea that comes to mind is to see if you can pull the kernel's symbol table from the image or from /proc/kallsyms or somewhere, and reverse engineer at least the included drivers based on that. Though with something like 35000 symbols shown by kallsyms on a stock distribution kernel, that would require some scripting.
| What are methods for recovering a Linux Kernel config? |
1,481,569,316,000 |
I have a USB Linux Kernel module that compiles and builds. Running insmod loads my module and dmseg and tail -f /var/log/debug shows me it works as expected.
Running depmod -a then modprobe from the terminal loads the module and modprobe -r unloads and I see - tail -f /var/log/debug output as expected.
When I plug in my USB keyboard though it does not trigger and load on-demand as expected.
I have investigated /etc/udev/rules.d with no success. Any workarounds or guidance is most welcome. Am running Ubuntu 12.04.4 LTS with a Custom Linux Kernel 3.14.0
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
#include <linux/hid.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Aruna Hewapathirane");
MODULE_DESCRIPTION("A USB Keyboard Driver Kernel Module");
static struct usb_device_id usb_kbd_id_table[] = {
{ USB_INTERFACE_INFO(
USB_INTERFACE_CLASS_HID,
USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_KEYBOARD) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usb_kbd_id_table);
static int __init kbd_init(void)
{
printk(KERN_DEBUG "USB Keyboard Plugged In.. \n");
return 0;
}
static void __exit kbd_exit(void)
{
printk(KERN_DEBUG "USB Keyboard Removed.. \n");
return ;
}
module_init(kbd_init);
module_exit(kbd_exit);
|
You are missing with usb_register and probe functions
Here is updated device driver with usb_register and probe functions
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
#include <linux/hid.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Aruna Hewapathirane");
MODULE_DESCRIPTION("A USB Keyboard Driver Kernel Module");
static struct usb_device_id usb_kbd_id_table[] = {
{ USB_INTERFACE_INFO(
USB_INTERFACE_CLASS_HID,
USB_INTERFACE_SUBCLASS_BOOT,
USB_INTERFACE_PROTOCOL_KEYBOARD) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usb_kbd_id_table);
static int kbd_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
pr_info("USB keyboard probe function called\n");
return 0;
}
static void kbd_disconnect(struct usb_interface *interface)
{
pr_info("USB keyboard disconnect function called\n");
}
static struct usb_driver kbd_driver = {
.name = "usbkbd",
.probe = kbd_probe,
.disconnect = kbd_disconnect,
.id_table = usb_kbd_id_table,
};
static int __init kbd_init(void)
{
int res = 0;
res = usb_register(&kbd_driver);
if (res)
pr_err("usb_register failed with error %d", res);
return res;
}
static void __exit kbd_exit(void)
{
pr_debug("USB Keyboard Removed..\n");
usb_deregister(&kbd_driver);
return;
}
module_init(kbd_init);
module_exit(kbd_exit);
Please refer previous SO question for probe function's use.
| usb kernel module does not load on demand but works fine with insmod and modprobe from the shell |
1,481,569,316,000 |
I would like to debug a loaded kernel module I don't have the source code to; I suspect it's a virus. Is there a way to feed it into GDB for analysis?
|
From a debugging perspective, the kernel is a special "process", distinct from the user space processes, which communicate with the kernel via a sort of rpc mechanism (syscalls) or mapped memory..
I don't think you can see the kernel's data structure simply by inspecting some random user process.
Another problem is, that every user space process (including the debugger) needs the kernel to run and to communicate with the users; I don't think you can just stop the kernel and believe that the debugger will continue to run.
So you need to run GDB on a second machine, and that is what is called Kernel debugging.
Please refer to (http://kgdb.linsyssoft.com/, Documentation/sh/kgdb) for more details.
| How to debug an inserted kernel module? |
1,481,569,316,000 |
I just tried to extract EDID file data with read-edid util; The thing is the output shows :
$sudo get-edid | decode-edid
...
Manufacturer: AUO Model 20ec Serial Number 0
Made week 0 of 2013
EDID version: 1.4
Digital display
6 bits per primary color channel
Digital interface is not defined
Maximum image size: 34 cm x 19 cm
Gamma: 2.20
Supported color formats: RGB 4:4:4
First detailed timing is preferred timing
Established timings supported:
Standard timings supported:
Detailed mode: Clock 77.000 MHz, 344 mm x 193 mm
1366 1382 1398 1628 hborder 0
768 771 785 788 vborder 0
-hsync -vsync
Manufacturer-specified data, tag 15
ASCII string: AUO
ASCII string: ***
...
I checked the xrandr and it outputs :
$xrandr
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
eDP1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
1366x768 60.02*+
1024x768 60.00
800x600 60.32 56.25
640x480 59.94
...
And it shows I have 60.02 refresh rate or similar which is not correct?...
As a test, according to the EDID I created /etc/X11/xorg.conf.d/90-monitor.conf file with content as :
Section "Monitor"
Identifier "<default monitor>"
DisplaySize 344 193
EndSection
...as you can see, the xrandr outputs as enabled the 344x193 display size but still I am not sure is the 344x193 are correct values? Should it be 344x193 or 340x190 according to "Maximum image size: 34 cm x 19 cm" values?
Moreover, the EDID shows my notebook has 77.000MHz refresh rate (supposed to be) but the xrandr outputs (see above) I have 60.000MHz, as I can get it; So that makes me confused which values really should be used for xorg? And should I have (in linux .config) PWM as y or m if I need un-standard refresh rate be running?
So my question is... how to use proper DPI and refresh values from EDID to set them into /etc/X11/xorg.conf.d/90-monitor.conf file and have them valid?
p.s.
kernel 3.16.7
os Linux Arch x64
video card : Intel HD Graphics (Sandy Bridge - Bay Trail)
|
77MHz is the pixel clock, not the vertical refresh rate. The vertical refresh rate is measured in Hz, not MHz.
Take a look at the mode:
Clock 77.000 MHz, 344 mm x 193 mm
1366 1382 1398 1628 hborder 0
768 771 785 788 vborder 0
1366 is the number of "active" pixels per line, and 768 is the number of "active" lines. These are pixels you see. There are also "blanking" pixels and lines and "border" pixels and lines that are inserted to even out the clock.
See the one metric that says 1628x788? This is the one that includes all active, blanking, and border pixels. If you divide 77MHz (or 77,000,000Hz) by (1628 * 788), you'll see that you get roughly 60.02 Hz.
| EDID - detect proper DPI and refresh rate values |
1,481,569,316,000 |
Suppose I called kmalloc and didn't free that memory before rmmod was called on the module, what happens to that memory? Is it a memory leak and it is completely unusable until restart, or does the kernel free that memory automatically?
thanks
|
It won't be freed until explicitly done. Memory allocated with kmalloc() needs to be freed using kfree(). That piece of memory stays till the system is on.
[...] didn't free that memory before rmmod was called on the module [...]
When you do rmmod, module_exit() will be executed where you can free the memory incase when memory has to freed when module is unloaded. for example.
x() {
z = kmalloc(...)
}
y() {
kfree(z)
}
module_init(x)
module_exit(y)
| What happens to memory that wasn't freed in a kernel module after unloading? |
1,481,569,316,000 |
I installed Ubuntu 14.04 on my new Lenovo G50-70. The wifi works perfectly in windows, however it behaves strangely on Ubuntu. It is slow, doesn't load heavier sites at all, and after a while, completely drops.
After some research I discovered: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1320070
sudo rmmod rtl8723be && sudo modprobe rtl8723be does not change anything, the wifi remains gone.
The first thing I tried was sudo make install the driver from this repo: https://github.com/lwfinger/rtlwifi_new. Unfortunately nothing changed.
Next I tried to disable the sleep feature:
echo "options rtl8723be fwlps=0" | sudo tee /etc/modprobe.d/rtl8723be.conf, without any luck.
I then tried:
sudo rmmod -v ideapad_laptop
But removing that module did not help either.
Here is some environment info:
uname -a
Linux zirconcode 3.13.0-40-generic #69-Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
lsusb | grep Rea
Bus 002 Device 006: ID 0bda:b728 Realtek Semiconductor Corp.
Bus 002 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
lsmod | grep rtl
rtl8723be 139336 0
btcoexist 183378 1 rtl8723be
rtl_pci 39740 1 rtl8723be
rtlwifi 121008 3 btcoexist,rtl_pci,rtl8723be
mac80211 626557 3 rtl_pci,rtlwifi,rtl8723be
cfg80211 484040 2 mac80211,rtlwifi
I am stuck as none of the solutions seem to work. Any ideas would be much appreciated.
|
Upgrading my kernel from 3.13 to 3.16 (http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.16-utopic/) and reinstalling the new driver from https://github.com/lwfinger/rtlwifi_new seems to have solved my problems. Don't forget to reboot.
Note: Upgrading the kernel in itself did not help.
| rtl8723be Realtek Wifi-Card driver not working on Ubuntu 14.04 |
1,481,569,316,000 |
I was making (my first) kernel module to play with the gpio pins of my pandaboard and interrupts.
Already "built-in", I noticed you can do (briefly)
cd /sys/class/gpio
echo 138 > export # a file gpio138 appears
echo out > gpio138/direction
echo 1 > gpio138/value
to turn some voltage high or low on connector pins.
Similarly on a kernel module you have module parameters and you can do echo 3 > /sys/module/my_module/parameters/delay_seconds for instance
My questions :
What handles /sys/class/gpio ? A kernel module ? a driver ?
Whatever 1. is, is it possible to have more complicated module parameters in a kernel module, with some directory structure ? Like a 'delays' directory containing the params for delays, ... /sys/module/my_module/parameters/delays/delay_led1_seconds
Can you have the parameters somewhere else than in the path /sys/module/my_module/parameters/... ? (/sys/class/a_name/... for instance)
How does the gpio thing creates new/deletes files in /sys/class/gpio when you write to [un]export ?
|
1) What handles /sys/class/gpio ? A kernel module ? a driver ?
It's a kernel interface similar to the /proc directory.
2) is it possible to have more complicated module parameters in a kernel module, with some directory structure ? Like a 'delays' directory containing the params for delays
Yes; some things in /proc and /sys do use directory hierarchies. If you want to modify or expand them, though, you have to modify the kernel.
#3 has a similar answer -- to make changes you need to change the relevant kernel code.
4) How does the gpio thing creates new/deletes files in /sys/class/gpio when you write to [un]export ?
These are not files on disk, they're just system interfaces.1 When you go to read data from a procfs or sysfs file, what you are really doing is making a request for information from the kernel. The data is then formatted and returned. It probably isn't stored anywhere in the form you see it, although parts of it may be stored in the kernel.
When you write to such a file -- not all of them allow this -- you're sending a request to the kernel to do something specific. This can include, e.g., activating or expanding the GPIO interface.
1. read and write calls are always system calls anyway, since normal files are normally on disk, and the kernel is needed to access hardware. Hence using a filesystem style API here is natural; even if they are not "real files", accessing whatever resource they represent must involve system calls.
| Kernel module parameters vs /sys/class/... explanation |
1,481,569,316,000 |
Background
I occasionally have firewall rules that I need to use for maintenance windows, but don't want active (and therefore consuming CPU cycles or slowing the network interface) the rest of the time. I add the rules when I need them, and then want to wipe the slate clean and stop iptables from counting packets and bytes flowing through the filter chains.
Problem: Filter Table Keeps Counting Anyway
The first time I check iptables in verbose mode, packet and byte counts are
always zero. For example:
$ sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
However, once the filter table has been initialized, flushing the table or resetting the counters doesn't stop the table from continuing to count packets and bytes. For example:
$ sudo iptables -F; sleep 5; sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 395 packets, 577K bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 199 packets, 11135 bytes)
pkts bytes target prot opt in out source destination
Current Solution
While I suspect that the actual CPU usage isn't all that high for an empty table, it seems wasteful to have the kernel inspect packets or count bytes that I don't care about. In order to prevent the filter table from consuming CPU cycles when there are no active rules, I've been doing the following:
$ sudo iptables -F; sudo iptables -X; sudo modprobe -r iptable_filter
This removes the rules and the filter table, allowing the iptables filter module to be removed from the running kernel. Once I do that, then counters remain zeroed until I once again initialize the table.
The Actual Question
My two-part question is:
Whether the counters for empty chains even have a measurable impact on performance. Intuitively, it seems like they would on a busy network interface, but I have no idea how to measure whether the impact exists.
Assuming there is an impact, whether there's a more elegant way to stop iptables from counting bytes/packets on empty chains than unloading the related kernel modules.
|
You can't unless you patch the kernel. And you have better things to do.
The counters are incremented __nf_ct_refresh_acct if the parameter do_acct is nonzero. This function is called through two wrappers: nf_ct_refresh_acct, which increments the counters, and nf_ct_refresh, which doesn't. The choice of wrapper is made according to the protocol type: protocols that can track do, the ones that can't don't.
The amount of computation is tiny. It's just two synchronized additions. Modern processors have very deep instruction pipelines, which makes conditional instructions expensive: the processor tries to predict which branch will be taken to start executing the next few instructions before it's determined the result of the test, and if the prediction is wrong, a lot of work needs to be discarded. The additions do require synchronization between the CPUs, because all CPUs have to be updating the same counter; on typical multicore architecture, this means that the core has to lock the cache line containing the counters. If the feature was optional, the CPU would have to read the configuration value, which doesn't require exclusive access so is a little less expensive. Still it would be an extremely tiny gain, to be balanced by the slightly less tiny loss for the majority of users who want the counters. It's just not worth having an option to disable this feature.
| How can I prevent iptables from counting bytes and packets on empty chains? |
1,481,569,316,000 |
I write a kernel module which has initialize and end function. I want one more function and want to call it from the user space process at any time i want.
Is it applicable ? If so, how ?
I am working on CentOS 5.2 and custom kernel, patched from linux 2.6.18.
EDIT:
To make clear, I want to write a function into kernel module and call this function from the regular source.c file.
|
Doing a kernel module that can use the /proc filesystem sounds like it might work for you. IBM developerWorks has an article on that topic. I worked through the code a few years ago, and it worked back then. The article is dated 2006, and seems to apply to Linux 2.6 kernels.
The problem I can foresee with using "files" in the /proc filesystem to get your module to do its work is that an open/read/close style API probably doesn't match what you want to do. You might have to use an open() on a /proc file to mean "execute WBINVD" or something unobvious like that.
| kernel module function call |
1,481,569,316,000 |
I'd like to load some additional modules at boot.
This works fine from the command line:
modprobe -a i2c-dev
modprobe -a snd-soc-pcm512x
modprobe -a snd-soc-wm8804
But I want this done at boot. I've tried creating /etc/modules, /etc/modprobe.conf and /etc/modprobe.d/i2c-dev.conf, etc. with the module name in there, but no luck.
I'm using a buildroot-2017-08, which I believes uses kmod, with a BusyBox init.
I can just create an init.d script, but I think there's a specific location that should contain the list of modules to load.
|
Couldn't find many polished and ready scripts. Turns out that Linux From Scratch (LFS) had some scripts that look good and are easy to use.
My solution to loading modules for a plain BusyBox init:
/etc/init.d/S02modules
#!/bin/sh
########################################################################
#
# Description : Module auto-loading script
#
# Authors : Zack Winkles
#
# Version : 00.00
#
# Notes :
#
########################################################################
. /etc/sysconfig/functions
# Assure that the kernel has module support.
[ -e /proc/ksyms -o -e /proc/modules ] || exit 0
case "${1}" in
start)
# Exit if there's no modules file or there are no
# valid entries
[ -r /etc/sysconfig/modules ] &&
egrep -qv '^($|#)' /etc/sysconfig/modules ||
exit 0
boot_mesg -n "Loading modules:" ${INFO}
# Only try to load modules if the user has actually given us
# some modules to load.
while read module args; do
# Ignore comments and blank lines.
case "$module" in
""|"#"*) continue ;;
esac
# Attempt to load the module, making
# sure to pass any arguments provided.
modprobe ${module} ${args} >/dev/null
# Print the module name if successful,
# otherwise take note.
if [ $? -eq 0 ]; then
boot_mesg -n " ${module}" ${NORMAL}
else
failedmod="${failedmod} ${module}"
fi
done < /etc/sysconfig/modules
boot_mesg "" ${NORMAL}
# Print a message about successfully loaded
# modules on the correct line.
echo_ok
# Print a failure message with a list of any
# modules that may have failed to load.
if [ -n "${failedmod}" ]; then
boot_mesg "Failed to load modules:${failedmod}" ${FAILURE}
echo_failure
fi
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
Based on this LFS script:
http://www.linuxfromscratch.org/lfs/view/6.5/scripts/apds05.html
/etc/sysconfig/functions
#!/bin/sh
#######################################################################
#
# Description : Run Level Control Functions
#
# Authors : Gerard Beekmans - [email protected]
#
# Version : 00.00
#
# Notes : With code based on Matthias Benkmann's simpleinit-msb
# http://winterdrache.de/linux/newboot/index.html
#
########################################################################
## Environmental setup
# Setup default values for environment
umask 022
export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
# Signal sent to running processes to refresh their configuration
RELOADSIG="HUP"
# Number of seconds between STOPSIG and FALLBACK when stopping processes
KILLDELAY="3"
## Screen Dimensions
# Find current screen size
if [ -z "${COLUMNS}" ]; then
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
fi
# When using remote connections, such as a serial port, stty size returns 0
if [ "${COLUMNS}" = "0" ]; then
COLUMNS=80
fi
## Measurements for positioning result messages
COL=$((${COLUMNS} - 8))
WCOL=$((${COL} - 2))
## Provide an echo that supports -e and -n
# If formatting is needed, $ECHO should be used
case "`echo -e -n test`" in
-[en]*)
ECHO=/bin/echo
;;
*)
ECHO=echo
;;
esac
## Set Cursor Position Commands, used via $ECHO
SET_COL="\\033[${COL}G" # at the $COL char
SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char
## Set color commands, used via $ECHO
# Please consult `man console_codes for more information
# under the "ECMA-48 Set Graphics Rendition" section
#
# Warning: when switching from a 8bit to a 9bit font,
# the linux console will reinterpret the bold (1;) to
# the top 256 glyphs of the 9bit font. This does
# not affect framebuffer consoles
NORMAL="\\033[0;39m" # Standard console grey
SUCCESS="\\033[1;32m" # Success is green
WARNING="\\033[1;33m" # Warnings are yellow
FAILURE="\\033[1;31m" # Failures are red
INFO="\\033[1;36m" # Information is light cyan
BRACKET="\\033[1;34m" # Brackets are blue
STRING_LENGTH="0" # the length of the current message
#*******************************************************************************
# Function - boot_mesg()
#
# Purpose: Sending information from bootup scripts to the console
#
# Inputs: $1 is the message
# $2 is the colorcode for the console
#
# Outputs: Standard Output
#
# Dependencies: - sed for parsing strings.
# - grep for counting string length.
#
# Todo:
#*******************************************************************************
boot_mesg()
{
local ECHOPARM=""
while true
do
case "${1}" in
-n)
ECHOPARM=" -n "
shift 1
;;
-*)
echo "Unknown Option: ${1}"
return 1
;;
*)
break
;;
esac
done
## Figure out the length of what is to be printed to be used
## for warning messages.
STRING_LENGTH=$((${#1} + 1))
# Print the message to the screen
${ECHO} ${ECHOPARM} -e "${2}${1}"
}
boot_mesg_flush()
{
# Reset STRING_LENGTH for next message
STRING_LENGTH="0"
}
echo_ok()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
}
echo_failure()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
}
echo_warning()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
}
Based on this LFS script:
http://www.linuxfromscratch.org/lfs/view/6.5/scripts/apds02.html
/etc/sysconfig/modules
i2c-dev
snd-soc-pcm512x
snd-soc-wm8804
snd-soc-hifiberry_dac
(or any module you want to load, obviously)
If there are any problems or issues with loading modules this way in a BusyBox init, I'm sure they'll end up in the comments below ;-).
| (Buildroot) How to load modules automatically |
1,481,569,316,000 |
I'm trying to enable the kernel persistent storage (pstore) in order to help debug a module which malfunctions and freezes my laptop on suspend, but I'm having difficulties doing so.
My kernel (4.1.20) config with related parameters is
# gunzip -c /proc/config.gz | grep PSTORE
CONFIG_CHROMEOS_PSTORE=m
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
# CONFIG_PSTORE_PMSG is not set
# CONFIG_PSTORE_FTRACE is not set
CONFIG_PSTORE_RAM=m
I have also tried loading the ramoops module, but when I do
# cat /sys/module/pstore/parameters/backend
(null)
it doesn't seem to have enabled anything. /sys/fs/pstore is empty as well, altough mount says that it is mounted. I have tried to panic my kernel using this but nothing showed up.
What am I doing wrong? Is it even supposed to work on a normal laptop, or am I completely in the dark? I could not find very much while looking for this feature.
|
You need to determine a piece of memory that survives a reboot. Then it's probably the easiest approach to pass that via kernel parameters, see
the ramoops Documentation in the kernel tree.
| How to enable kernel pstore? |
1,481,569,316,000 |
On a running linux system, what is a portable (among linux distributions) way to find out what filesystems the current kernel has compiled-in (not through modules) support for?
Consider for example my current Ubuntu x86_64 kernel: 3.11.0-24-generic #41-Ubuntu. It has for instance no /proc/config.gz, which would be my first thought otherwise.
The reason I'm interested is that I'd like to (programmatically) build a rescue environment with the current kernel and an initial ramdisk that the kernel will be able to load/mount.
Is is as simple as comparing /proc/filesystems with lsmod?
If so: Do the modules always have the exact same name (first column from lsmod output) as the filesystem name (last column in /proc/filesystems)?
Is there perhaps a more modern way such as /sys instead of /proc to look for info?
My current approach is as follows. Can someone confirm that it is correct, or advise how to do it instead?:
for fscand in $(awk '{print $NF}' /proc/filesystems)
do
if test $(lsmod | grep -c -e '^'${fscand}'[^a-z0-9_-]') -eq 0
then
candlist="${fscand} ${candlist}"
fi
done
for fscand in $candlist
do
echo $fscand is compiled-in
done
|
Is is as simple as comparing /proc/filesystems with lsmod?
No:
$ comm -31 <(lsmod | awk 'NR!=1 {print $1}' |sort) \
<(</proc/filesystems awk '{print $NF}' |sort) | fmt
anon_inodefs autofs bdev cgroup cpuset debugfs devpts devtmpfs ext2 ext3
fuseblk fusectl hugetlbfs mqueue nfs4 pipefs proc pstore ramfs rootfs
rpc_pipefs securityfs sockfs sysfs tmpfs
Many of these are not built into the kernel on that system. autofs is provided by a modules called autofs4 while nfs4 is provided by a module called nfs. The ext4 module provides ext2 and ext3 as well as ext4; fuse provides both fuseblk and fusectl. rpc_pipefs (not to be confused with pipefs) is provided by sunrpc.
Yet your system is able to load a module for a filesystem on demand: when you run mount -t foo …, if foo isn't a supported filesystem type, Linux attempts to load a module that provides this filesystem. The way this works is that the kernel detects that foo isn't a supported filesystem, and it calls modprobe to load a module called fs-foo. The mechanism is similar to pci:… aliases to load the driver for a PCI hardware peripheral by its PCI ID and usb:… which is similar to USB — see How to assign USB driver to device and Debian does not detect serial PCI card after reboot for more explanations. The fs-… module aliases are recorded in /lib/$(uname -r)/modules.alias. This file is generated when you build the kernel.
Under normal conditions, you can use this to determine which filesystems are provided by modules. By elimintation, the filesystems that are not provided by modules are built into the kernel. There are rare edge cases where this approach wouldn't work, for example if you've modified or erased your modules.alias file, or if a filesystem is provided both by a module and in a compiled-in form. I don't know of a way to cope with these cases short of writing some kernel code and loading it as a module.
for fs in $(</proc/filesystems awk '{print "fs-" $NF}' |sort); do
/sbin/modprobe -n $fs 2>/dev/null || echo "$fs is built in"
done
| How do I find out what filesystem drivers are compiled-in into the linux kernel? |
1,597,753,776,000 |
Why isn't the Linux module API backward compatible? I'm frustrated to find updated drivers after updating the Linux kernel.
I have a wireless adapter that needs a proprietary driver, but the manufacturer has discontinued this device about 7 years ago. As the code is very old and was written for Linux 2.6.0.0, it doesn't compile with the latest Linux kernels. I have used many Linux distributions but the same problem is everywhere. Although there is an open-source driver distributed with Linux kernel, it doesn't work. Some people are trying to modify the old proprietary code to make it compatible with the latest Linux kernels, but when a new Linux kernel is released, it takes months to make code compatible with that. Within that time, another new version is released. For this reason, I can't upgrade to a new Linux kernel; sometimes I can't even upgrade my distribution.
|
Greg Kroah-Hartman has written on this topic here: https://www.kernel.org/doc/html/v4.10/process/stable-api-nonsense.html
Besides some technical details regarding compiling C code he draws out a couple of basic software engineering issues that make their decision.
Linux Kernel is always a work in progress. This happens for many reasons:
New requirements come along. People want their software to do more, that's why most of us upgrade, we want the latest and greatest features. These can require rework to the existing software.
Bugs are found which need fixing, sometimes bugs are with the design itself and cannot be fixed without significant rework
New ideas and idioms in the software world happen and people find much easier / elegant / efficient ways to do things.
This is true of most software, and any software that is not maintained will die a slow and painful death. What you are asking is why doesn't that old unmaintained code still work?
Why aren't old interfaces maintained?
To ensure backward compatibility would require that old (often "broken" and insecure) interfaces are maintained. Of course it's theoretically possible to do this except it does carry significant cost.
Greg Kroah-Hartman writes
If Linux had to ensure that it will preserve a stable source interface, a new interface would have been created, and the older, broken one would have had to be maintained over time, leading to extra work for the [developers]. Since all Linux [developers] do their work on their own time, asking programmers to do extra work for no gain, for free, is not a possibility.
Even though Linux is open source, there is still only limited developer time to maintain it. So manpower can still be discussed in terms of "cost". The developers have to chose how they spend their time:
Spend a lot of time maintaining old / broken / slow / insecure interfaces. This can sometimes be double to triple the time it took to write the interface in the fist instance.
Thow away the old interfaces and expect other software maintainers to [do their job and] maintain their own software.
On balance, binning interfaces is really cost-effective (for the kernel developers). If you want to know why developers don't spend months and years of their life saving others from paying $10 for a new wifi adaptor... that's the reason. Remember that's time/cost effective for the kernel developers, not necessarily cost-effective for you or manufacturers.
| Why Linux module API isn't backward compatible? |
1,597,753,776,000 |
I read the post here and I tried to make do with what I understood from the post but here are some questions:
Where is the /lib/firmware located in for example /usr/src/linux/lib/firmware or /usr/lib/firmware or elsewhere?
Could I use a pre-build EDID in that address the post gave and tweak it with an editor like Gvim and pass it to kernel using the info below? The resolution I am trying to set is 1600x900@60:
1: [H PIXELS RND] : 1600.000000
2: [V LINES RND] : 450.000000
3: [V FIELD RATE RQD] : 120.000000
4: [TOP MARGIN (LINES)] : 8.000000
5: [BOT MARGIN (LINES)] : 8.000000
6: [INTERLACE] : 0.500000
7: [H PERIOD EST] : 16.648841
8: [V SYNC+BP] : 33.000000
9: [V BACK PORCH] : 30.000000
10: [TOTAL V LINES] : 500.500000
11: [V FIELD RATE EST] : 120.008471
12: [H PERIOD] : 16.650017
13: [V FIELD RATE] : 120.000000
14: [V FRAME RATE] : 60.000000
15: [LEFT MARGIN (PIXELS)] : 32.000000
16: [RIGHT MARGIN (PIXELS)] : 32.000000
17: [TOTAL ACTIVE PIXELS] : 1664.000000
18: [IDEAL DUTY CYCLE] : 25.004995
19: [H BLANK (PIXELS)] : 560.000000
20: [TOTAL PIXELS] : 2224.000000
21: [PIXEL FREQ] : 133.573440
22: [H FREQ] : 60.060000
17: [H SYNC (PIXELS)] : 176.000000
18: [H FRONT PORCH (PIXELS)] : 104.000000
36: [V ODD FRONT PORCH(LINES)] : 1.500000
If yes where could I get an edid.bin file?
Or should I build an EDID file from scratch; if yes how could I make an EDID file?
|
Where is /lib/firmware?
The final resting place for your EDID mode firmware should be under /lib/firmware/edid. However, many linux distributions place the example EDID mode-setting firmware source and the Makefile under the directory for the linux kernel documentation. For Fedora, this is provided by the kernel-doc package and resides under /usr/share/doc/kernel-doc-3.11.4/Documentation/EDID. After you compile the firmware for your monitor, you can place the edid binary anywhere that is accessable to grub upon boot, but the convention is /lib/firmware/edid/.
Can I tweak an existing edid.bin file to match my monitor's resolution?
The edid.bin files are in binary format so the correct way to tweak it would not be intuitive.
How can I make an EDID file from scratch?
The post you provided links to the official kernel documentation for building your custom edid file. The same instructions are also provided in the HOWTO.txt file in the kernel documentation directory referenced above. Essentially you edit one of the example firmware files, say 1024x768.S, providing the parameters for your monitor. Then compile it with the provided Makefile and configure grub to use the new firmware.
For me, there were two tricky bits to accomplishing this. The first one is where to find the edid source file that needs to be compiled. This was answered for Fedora above.
The second tricky bit is finding the correct values to place in 1024x768.S for your monitor. This is achieved by running cvt to generate your desired modeline and then doing a little arithmetic. For a resolution of 1600x900 with 60 Hz refresh rate and reduced blanking (recommended for LCDs), you would have:
[user@host ~]$ cvt 1600 900 60 -r
# 1600x900 59.82 Hz (CVT 1.44M9-R) hsync: 55.40 kHz; pclk: 97.50 MHz
Modeline "1600x900R" 97.50 1600 1648 1680 1760 900 903 908 926 +hsync -vsync
You can match the last line of this output to the instructions in HOWTO.txt:
Please note that the EDID data structure expects the timing
values in a different way as compared to the standard X11 format.
X11:
HTimings: hdisp hsyncstart hsyncend htotal
VTimings: vdisp vsyncstart vsyncend vtotal
EDID:
#define XPIX hdisp
#define XBLANK htotal-hdisp
#define XOFFSET hsyncstart-hdisp
#define XPULSE hsyncend-hsyncstart
#define YPIX vdisp
#define YBLANK vtotal-vdisp
#define YOFFSET (63+(vsyncstart-vdisp))
#define YPULSE (63+(vsyncend-vsyncstart))
The 2nd - 5th numbers in the last line of the cvt output (1600 1648 1680 1760) are the four "HTimings" parameters (hdisp hsyncstart hsyncend htotal) and the 6th - 9th numbers (900 903 908 926) are the four "VTimings" parameters (vdisp vsyncstart vsyncend vtotal).
Lastly, you'll need to compile the firmware a second time in order to set the correct CRC value in the last line (see the HOWTO.txt for details).
| How to make EDID |
1,597,753,776,000 |
I installed VirtualBox, in the first run i got this warning:
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (3.10.0-327.4.4.el7.x86_64) or it failed to
load. Please recompile the kernel module and install it by
sudo /sbin/rcvboxdrv setup
After launching this command, I got:
sudo /sbin/rcvboxdrv
setup Bad argument setup
I tried another way which is the following commands:
/etc/init.d/vboxdrv setup
bash: /etc/init.d/vboxdrv: No such file or directory
Last way that I tried:
/usr/lib/virtualbox/boxdrv.sh setup
Stopping VirtualBox kernel modules [ OK ]
Uninstalling old VirtualBox DKMS kernel modules [ OK ]
Removing old VirtualBox pci kernel module [ OK ]
Removing old VirtualBox netadp kernel module [ OK ]
Removing old VirtualBox netflt kernel module [ OK ]
Removing old VirtualBox kernel module [ OK ]
Trying to register the VirtualBox kernel modules using DKMSdepmod:
... Some Warnings ... [ OK ]
Starting VirtualBox kernel modules [FAILED]
What can i try?
|
I hit the same issue today after upgrading to 5.0.14 (I am on Ubuntu 15.10, using the official Virtualbox apt repo)
I fixed it with:
sudo /usr/lib/virtualbox/vboxdrv.sh setup
| VirtualBox Kernel Module Installing Issue |
1,597,753,776,000 |
I have installed a PCI card with two serial and one parallel port on it. the chipset is MCS9865. I downloaded the latest driver(V1.0.12) from here. I ran make and make install. now the two serial ports are /dev/ttyD0 and /dev/ttyD1. I have tested them with picocom and it is working perfectly. the problem is that when I reboot the system there is no /dev/ttyD0 and /dev/ttyD1. I need to do another make install. Is there any solution?
output of lspci -v shows this:
03:01.0 Serial controller: NetMos Technology PCI 9865 Multi-I/O Controller (prog-if 02 [16550])
Subsystem: Device a000:1000
Flags: bus master, medium devsel, latency 32, IRQ 19
I/O ports at df00 [size=8]
Memory at fbeff000 (32-bit, non-prefetchable) [size=4K]
Memory at fbefe000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [48] Power Management version 2
Kernel driver in use: mcs9865-serial
03:01.1 Serial controller: NetMos Technology PCI 9865 Multi-I/O Controller (prog-if 02 [16550])
Subsystem: Device a000:1000
Flags: bus master, medium devsel, latency 32, IRQ 18
I/O ports at de00 [size=8]
Memory at fbefd000 (32-bit, non-prefetchable) [size=4K]
Memory at fbefc000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [48] Power Management version 2
Kernel driver in use: mcs9865-serial
03:01.2 Parallel controller: NetMos Technology PCI 9865 Multi-I/O Controller (prog-if 03 [IEEE1284])
Subsystem: Device a000:2000
Flags: bus master, medium devsel, latency 32, IRQ 7
I/O ports at dd00 [size=8]
I/O ports at dc00 [size=8]
Memory at fbefb000 (32-bit, non-prefetchable) [size=4K]
Memory at fbefa000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [48] Power Management version 2
make install shows this:
cp mcs9865.ko mcs9865-isa.ko /lib/modules/2.6.32-5-amd64/kernel/drivers/serial/
depmod -A
chmod +x mcs9865
cp mcs9865 /etc/init.d/
ln -s /etc/init.d/mcs9865 /etc/rcS.d/S99mcs9865 || true
ln: creating symbolic link `/etc/rcS.d/S99mcs9865': File exists
modprobe mcs9865
modprobe mcs9865-isa
I'm running debian 6.0.5 with most updated packages.
|
The way this normally works is:
The module source code contains calls to the MODULE_DEVICE_TABLE macro to declare a table of device identifiers that this module supports.
In the compiled module, the aliases are stored as values of symbols called __mod_alias_NNN where the NNN are integers. The value encodes the bus identification for the device, e.g. pci:v00009710d00009865sv*sd*bc*sc*i* for the PCI device identified as vendor 0x9710, device 0x9865.
They are also stored under the name __mod_pci_device_table for PCI devices, __mod_usb_device_table for USB devices, etc.
The depmod program creates an alias table mapping __mod_alias_NNN values to the module name. This table is stored in the file modules.alias at the root of the kernel modules directory, e.g. /lib/modules/2.6.32-5-amd64/modules.alias.
It also creates files like modules.pcimap, modules.usbmap, …, which are used by the obsolete hotplug infrastructure which has been subsumed back into modprobe.
When the kernel detects a device for which no driver is present, it tries to load a module by calling the program indicated by the kernel.modprobe sysctl, which is /sbin/modprobe by default. The kernel passes an argument to modprobe that indicates what driver is requested. For a PCI device, this is a name like pci:v00009710d00009865sv*sd*bc*sc*i*.
modprobe searches for a module with the given name. If it finds a module with the requested name (after following the alias defined in its configuration files, which include /etc/modprobe.d/*.conf and /lib/modules/$(uname -r)/modules.alias), it loads that module.
modprobe will not load a module that has been blacklisted by a blacklist directive in its configuration files.
Run lspci -n to see the PCI ids of your device, and check the chain above to see where something went wrong.
Sometimes a driver works for a device that is very similar to the device it is intended for, but has a different PCI id. In that case, it's possible that the driver will work, but won't be loaded automatically because it doesn't declare the PCI id for your device. You can add the alias manually in /etc/modprobe/my_aliases.conf.
You can force a module to be loaded automatically at boot time by adding its name to /etc/modules.
| Debian does not detect serial PCI card after reboot |
1,597,753,776,000 |
I just started learning about netfilter and I was trying to make a simple netfilter module, all the tutorials and HOW TOs register a hook function with nf_register_hook(), but I could not find one in linux kernels above 4.13-rc1.
As far as I understand, the nf_register_hook() function used to call the _nf_register_hook() function which further called nf_register_net_hook() function, iterating over each member of the net linked list, but then it gets a bit difficult for me to understand.
With, the nf_register_hook() function gone, I am in a fix as to how to register a hook.
The nf_register_net_hook() function is still there but, I am not really sure how that works.
So my question boils down to,
How to register a netfilter hook in kernels above 4.13-rc1?
|
Use the following code:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
nf_register_net_hook(&init_net, reg)
#else
nf_register_hook(reg)
#endif
Reference: init_net
| nf_register_hook not found in linux kernel 4.13-rc2 and later |
1,597,753,776,000 |
So I had this problem with my new Lenovo ThinkPad 13 where it did not resume from suspension and hibernation. After 2 days of troubleshooting I found out that apparently a module called intel_lpss_pci is causing the problem. When I disable it, everything works fine. I'm not exactly sure what it is used for too, as everything seems to be working just fine without it.
Now to my question. How can I disable this module for good?
I tried the kernel parameter modprobe.blacklist=intel_lpss_pci which didn't seem to do the trick and also adding it to /etc/modprobe.d/blacklist did not seem to work.
Any ideas on how to proceed?
|
The proper file is:
/etc/modprobe.d/blacklist.conf
(notice the extension .conf). And at the end of this file put a line:
blacklist intel_lpss_pci
| How do I disable a kernel module persistently? |
1,597,753,776,000 |
I'm trying to read DDR4 RAM SPD data with the new ee1004 driver. I thought that after modprobe ee1004 I would be able to read data from /sys/bus/i2c/drivers/ee1004, however thats not the case (no devices appeared there). Am I missing something?
I'm running Ubuntu 19.04 with Kernel 5.0.0-13. Contents of ee1004 directory in sysfs is:
user@ryzen:/sys/bus/i2c/drivers/ee1004$ ls -l
celkom 0
--w------- 1 root root 4096 apr 28 21:33 bind
lrwxrwxrwx 1 root root 0 apr 28 21:33 module -> ../../../../module/ee1004
--w------- 1 root root 4096 apr 28 21:33 uevent
--w------- 1 root root 4096 apr 28 21:33 unbind
|
I was able to find solution thanks to RafDouglas.
The trick is to manually set i2c addresses to ee1004 driver. Follow these instructions https://www.spinics.net/lists/linux-i2c/msg32331.html (start at "First you must find out the i2c bus number of your motherboard's SMBus ...")
| How to read DDR4 SPD with ee1004 driver? |
1,597,753,776,000 |
When I run lsmod or sudo lsmod, I get an error that says:
libkmod: ERROR ../libkmod/libkmod-module.c:1655 kmod_module_new_from_loaded: could not open /proc/modules: No such file or directory
Error: could not get list of modules: No such file or directory
I searched on a lot of forums but am unable to find a solution for this. I'm running Debian on Windows Subsystem for Linux.
I was recently also trying to edit the sysctl.conf file for the purpose of disabling ipv6. I had added the following lines:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
And when I tried sudo sysctl -p, it returned this error:
sysctl: cannot stat /proc/sys/net/ipv6/conf/all/disable_ipv6: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/default/disable_ipv6: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv6/conf/lo/disable_ipv6: No such file or directory
I'm not sure if the above 2 errors are connected. I was trying to run Linux shell on Windows. Any solution to the problem?
|
In both cases, you’re trying to interact with the kernel. Any Linux environment running on WSL isn’t running a Linux kernel, it’s running on the Windows kernel; so anything tied to the Linux kernel (including modules and system controls) won’t work.
In the IPv6 case, you need to configure the network using Windows’ tools.
| lsmod gives error: "could not get list of modules" on Debian running on WSL |
1,597,753,776,000 |
I downloaded the sources for my kernel, applied a patch and rebuilt it and now I have a kernel module that, when I try to insmod, complains "Unknown symbol in module" with dmesg giving the error "disagrees about the version of symbol ...".
Without having to hunt down the source for this module and rebuild it against my kernel is it possible to somehow force the kernel to accept this module?
I realise this would be dangerous but I'll to take the risk if its possible.
|
insmod isn't the best tool to load modules - use modprobe instead, it's smarter. In modprobe's man page, you'll find that it has a --force option which might load a module with conflicting version information.
As you said, this is dangerous and should essentially never be used. You pick up the pieces if your system blows up.
| possible to load kernel module that "disagrees about version of symbol" |
1,597,753,776,000 |
This is on the Linux OS.
I see that on some machines the net.bridge.bridge-nf-call-iptables variable doesn't exist until I modprobe the br_netfilter filter. I also see that there are some machines where the bridge module is loaded and that itself brings in this variable.
Is there a way to know which module I should load in order to get a particular variable ?
|
There's no automatic database relating sysctl variables to modules. You can search the module binary and hope that the variable name isn't found in other strings (this one isn't). Search for the last part, i.e. bridge-nf-call-iptables — the full string isn't present in the binary, it's constructed dynamically.
grep -rl bridge-nf-call-iptables /lib/modules/`uname -r`
Alternatively, you can check the documentation — but it doesn't always tell you, and in this case it doesn't say. So you're left with the source code. First look for the string (again, only the last part); in recent kernels it's in net/bridge/br_netfilter_hooks.c. Now check the makefile in the same directory to see how this source file is built. The relevant line is
br_netfilter-y := br_netfilter_hooks.o
which means that if the br_netfilter module is built then it contains the code from br_netfilter_hooks.c, thus the br_netfilter module is the one you need.
| Kernel module for net.bridge.bridge-nf-call-iptables |
1,597,753,776,000 |
Is there a neat way of stripping the Linux kernel to only support the devices that are currently in use. After NVIDIA complaining about GCC version mismatch, I decided to recompile the kernel with the current version of GCC. Now, since it is known which modules the current kernel actually uses, can I automatically generate a .config file which is customized for this machine. That would booth save some space and time. Something like
lsmod [options] | sed [a good regexp] > .config
|
That's what make localmodconfig is for.
Excerpt from /usr/src/linux/README:
"make localmodconfig" Create a config based on current config and
loaded modules (lsmod). Disables any module
option that is not needed for the loaded modules.
| Recompile kernel without modules that are not currently in use |
1,597,753,776,000 |
I have put a vendor supplied embedded Linux installation (called X-Linux) onto a hardware device. I ran lsmod to see what modules are loaded and nothing at all is shown. Also there is no /proc/modules directory on the system. What does this mean? Does it mean that no drivers are loaded to communicate with the rest of the devices on the board (ethernet, serial etc?). I don't see how this can be as I have been able to configure the static IP of the board and am able to successfull ftpget files from my desktop development machine. I really am unsure about what is going on and about the stability of the system. Is this is a problem or is it expected behaviour?
|
This just means that the drivers are compiled directly into the kernel and that the kernel does not have module support. If you know exactly your target system and the purpose you don't necessarily need module support.
| lsmod returns nothing on my embedded device |
1,597,753,776,000 |
I'm working on building a kernel module for an input device, and I noticed that in the module source, there's a couple calls to input_get_keycode(data->input_dev, scancode, &keycode); When I was compiling I was getting errors that there's no function with that prototype.
Looking into the input/input.c source code, this is the definition of input_get_keycode:
int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
I tried to look online, and I found a couple obscure references to changing the kernel to be able to deal with large keymaps better, and apparently this function was changed to better handle that. Looking at an older source from input/input.c, the input_get_keycode function was defined as
int input_get_keycode(struct input_dev *dev, unsigned int scancode, unsigned int *keycode)
My question is, when was this changed. Is there notes on the change? I'm building the ubuntu natty kernel from git which is from my understanding from the 2.6.37-rc3 branch.
Is this a ubuntu specific change? Or is this a change in the mainline kernel. I also have the maverick source from git which has the old style (3 input) function.
|
If you are working on a kernel module, I very much recommend that you get a git tree. Obviously Linus's tree is mandatory - I also get the stable trees. Since you are working on Ubuntu, I'd check to see if they have a tree with their changes you can pull from.
Using the git tree, I was able to checkout master and run git blame drivers/input/input.c to see that the function signature for input_get_keycode was last changed in commit 8613e4c2.
Running git show 8613e4c2 gives me the commit message for that change (the notes that you wanted) as well as the patch that implements the change. I can see that the change was made on 2010-09-09.
Starting up gitk (a graphical git viewer) and telling it to go to that commit I can see that the commit precedes v2.6.37-rc1, telling me it was merged into that release. Following the branch up to when Linus merged it, I can see it was merged on 2010-10-26 in commit 3a99c631.
This is all mainline without looking at Ubuntu patches, so it looks like the change has nothing to do with Ubuntu.
| Changes to input_get_keycode function in linux kernel (input/input.c) |
1,597,753,776,000 |
I have very little experience with kernel module development. Despite this I have been tasked with maintaining an old driver for a Sensoray 626 DAQ card. I am using a very simple dkms setup to build and install the driver which has been working well for a long time. The driver has been working in Ubuntu 22.04 until recently I ran into the error below during the kernel module build and I'm unable to find a solution. Any help is appreciated. If additional information is needed, simply ask and I will update the question with the requested information.
Note: I am aware that Comedi has a driver for the Sensoray 626. I do not want to use the Comedi driver.
DKMS build log:
DKMS make.log for s626-1.0.5 for kernel 6.5.0-14-generic (x86_64)
Fri Jan 12 01:17:52 PM PST 2024
make -C /lib/modules/6.5.0-14-generic/build M=/var/lib/dkms/s626/1.0.5/build SUBDIRS=/var/lib/dkms/s626/1.0.5/build
make[1]: Entering directory '/usr/src/linux-headers-6.5.0-14-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
CC [M] /var/lib/dkms/s626/1.0.5/build/s626drv.o
gcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[3]: *** [scripts/Makefile.build:251: /var/lib/dkms/s626/1.0.5/build/s626drv.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /var/lib/dkms/s626/1.0.5/build] Error 2
make[1]: *** [Makefile:234: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-14-generic'
make: *** [Makefile:29: all] Error 2
Distribution: Ubuntu 22.04.3 LTS
Linux kernel version: 6.5.0-14-generic
Output of apt list --installed | grep gcc
gcc-11-base/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]
gcc-11/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]
gcc-12-base/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
gcc-12/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
gcc/jammy,now 4:11.2.0-1ubuntu1 amd64 [installed,automatic]
libgcc-11-dev/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]
libgcc-12-dev/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
libgcc-s1/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
Makefile (note this makefile has recipes for things other than the kernel module and the CC variable is not used for building the kernel module):
###############################################################################
# for kernel modeule level driver:
# Kernel directory
KDIR := /lib/modules/$(shell uname -r)/build
# Module directory
MODDIR := /lib/modules/$(shell uname -r)/kernel/drivers/sensoray
# System values
PWD := $(shell pwd)
KERNEL_24 := $(if $(wildcard $(KDIR)/Rules.make),1,0)
# Target file
obj-m := s626.o
# Source files
ifeq ($(KERNEL_24),0) # > 2.4
s626-objs := s626drv.o
else # <= 2.4
s626-objs := s626drv.o
endif
.PHONY: all clean modules_install
ifeq ($(KERNEL_24),0) # > 2.4
ifeq ($(KERNELRELEASE),)
all:
$(MAKE) -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD)
clean modules_install:
$(MAKE) -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD) $@
endif # KERNELRELEASE
else # <= 2.4
ifneq ($(KERNELRELEASE),)
include $(KDIR)/Rules.make
s626.o: $(s626-objs)
$(Q)$(LD) $(LD_RFLAG) -r -o $@ $(s626-objs)
else
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -f *.ko *.o .*.cmd .*.o.flags *.mod.c
endif # KERNELRELEASE
endif # KERNEL_24
ifeq ($(KERNEL_24),1) # <= 2.4
install: s626.o
@if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/ ];\
then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/s626.*;\
fi
@if [ -d /lib/modules/$(shell uname -r)/extra/ ];\
then rm -f /lib/modules/$(shell uname -r)/extra/s626.*;\
fi
su -c "set -x;./MAKEDEV;mkdir -p $(MODDIR);cp -v s626.o $(MODDIR);depmod -a"
else
install: s626.ko
@if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/ ];\
then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/s626.*; \
fi
@if [ -d /lib/modules/$(shell uname -r)/extra/ ];\
then rm -f /lib/modules/$(shell uname -r)/extra/s626.*;\
fi
@if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/staging/comedi/drivers ];\
then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/staging/comedi/drivers/s626.*;\
fi
su -c "set -x;./MAKEDEV;mkdir -p $(MODDIR);cp -v s626.ko $(MODDIR);install -m 444 s626.ko $(MODDIR);depmod -a"
endif # KERNEL > 2.4
###############################################################################
# for library and application level:
SRC= # module source tree
CC= # compiler
AR= # library manager
# source path
ifeq ($(strip $(SRC)),)
SRC=.
endif
# the compiler
ifeq ($(strip $(CC)),)
CC=gcc
endif
# the library manager
ifeq ($(strip $(AR)),)
AR=ar
endif
# build the distribution's library
lib: libs626.a
libs626.a: s626core.o s626mod.o
$(AR) cr libs626.a $(SRC)/s626core.o $(SRC)/s626mod.o
# compile the 626 universal core
core: s626core.o
s626core.o: $(SRC)/s626core.c $(SRC)/s626core.h $(SRC)/s626mod.h
$(CC) $(CFLAGS) -c $(SRC)/s626core.c
# build the 626 OS-dependent module
mod: s626mod.o
s626mod.o: $(SRC)/s626mod.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626.h $(SRC)/s626api.h
$(CC) $(CFLAGS) -c $(SRC)/s626mod.c
# build the distribution's library (you may need to install gcc-multilib package)
lib32: libs626-32.a
libs626-32.a: s626core-32.o s626mod-32.o
$(AR) cr libs626-32.a $(SRC)/s626core-32.o $(SRC)/s626mod-32.o
# compile the 626 universal core
s626core-32.o: $(SRC)/s626core.c $(SRC)/s626core.h $(SRC)/s626mod.h
$(CC) $(CFLAGS) -m32 -c $(SRC)/s626core.c -o $@
# build the 626 OS-dependent module
s626mod-32.o: $(SRC)/s626mod.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626.h $(SRC)/s626api.h
$(CC) $(CFLAGS) -m32 -c $(SRC)/s626mod.c -o $@
#----------------------------------------------------------------
# Demonstration programs
# type "make demo" to compile, link, and create demo application
demo: libs626.a s626demo.o s626dm2b.o
$(CC) -o s626demo s626demo.o -L$(SRC) -ls626 -lpthread
$(CC) -o s626dm2b s626dm2b.o -L$(SRC) -ls626 -lpthread
s626demo.o: $(SRC)/s626demo.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h
$(CC) $(CFLAGS) -c $(SRC)/s626demo.c
s626dm2b.o: $(SRC)/s626dm2b.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h
$(CC) $(CFLAGS) -c $(SRC)/s626dm2b.c
demo32: libs626-32.a s626demo-32.o s626dm2b-32.o
$(CC) -m32 -o s626demo-32 s626demo-32.o -L$(SRC) -ls626-32 -lpthread
$(CC) -m32 -o s626dm2b-32 s626dm2b-32.o -L$(SRC) -ls626-32 -lpthread
s626demo-32.o: $(SRC)/s626demo.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h
$(CC) $(CFLAGS) -m32 -c $(SRC)/s626demo.c -o $@
s626dm2b-32.o: $(SRC)/s626dm2b.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h
$(CC) $(CFLAGS) -m32 -c $(SRC)/s626dm2b.c -o $@
# for debugging:
# gcc -g -o s626demo s626core.c s626mod.c s626demo.c -lpthread
# gcc -g -o s626dm2b s626core.c s626mod.c s626dm2b.c -lpthread
clnall:
rm -f *.ko *.o .*.cmd .*.o.flags *.mod.c libs626*.a s626demo s626dm2b *.tar.gz s626*-32 Module.symvers modules.order
###############################################################################
# for internal develoment only
#----------------------------------------------------------------
# select files for the distribution tarball
T = $(SRC)/README
T += $(SRC)/COPYING
T += $(SRC)/MAKEDEV
T += $(SRC)/Modules.conf
T += $(SRC)/Makefile
T += $(SRC)/s626drv.h
T += $(SRC)/s626drv.c
T += $(SRC)/s626.h
T += $(SRC)/s626mod.h
T += $(SRC)/s626mod.c
T += $(SRC)/s626core.h
T += $(SRC)/s626core.c
T += $(SRC)/s626api.h
T += $(SRC)/App626.h
T += $(SRC)/libs626.a
T += $(SRC)/s626demo.c
T += $(SRC)/s626dm2b.c
#----------------------------------------------------------------
# build distribution tarball (only for development)
tar:
# tar -Pzcf s626-0.3.tar.gz $(T)
tar -czvf s626-1.0.tar.gz $(T)
DKMS configuration file:
MAKE="'make' KDIR=/lib/modules/${kernelver}/build"
CLEAN="'make' clean"
BUILT_MODULE_NAME=s626
BUILT_MODULE_LOCATION=./
DEST_MODULE_LOCATION=/kernel/drivers/sensoray/
PACKAGE_NAME=s626
PACKAGE_VERSION=1.0.5
AUTOINSTALL=yes
REMAKE_INITRD=yes
|
It appears that the problem is that the Makefile (which was written by the original developers) sets the CC make variable, thus preventing DKMS from properly overriding the compiler using a CC environment variable. This potential problem is described by this bug report.
Since in my case the Makefile only uses the CC make variable for building a user-level API library (i.e. it is not used in the portion of the Makefile used for building the module), the best solution was to install (into /usr/src/) a copy of the Makefile that only contains that portion dealing with the kernel module instead of installing the full Makefile.
| Unrecognized command-line option ‘-ftrivial-auto-var-init=zero’ when building kernel module |
1,597,753,776,000 |
It might be a incoherent question about kernel headers as I don't have clear understanding about it and where and how it is used. I think it might get flagged down. My question has 3 parts:
I think Kernel headers provide a interface so that other part of the kernel, like modules, can use them. That's my bookish knowledge. I haven't seen or found any code that used kernel headers (I would appreciate if someone can point me to it). Can it be used in userspace too? Any code example would be appreciated.
I found out that using make headers_install kernel headers are exposed for by userspace, but at the same time it is discouraged to use kernel headers in userspace. If it is discouraged then what is the use of exposing it to userspace?
As per this and this, kernel header files (.h files) should be at 3 places:
a. /usr/include/linux/kernel.h which is intended for user space
b. /lib/modules/$(uname -r)/build/include/linux/sched.h which is external modules
c. /usr/src/... which is used for kernel modules
Does it mean header files in different directories have different purpose or different interface or signature? In other words, does #include <linux/xyz.h> in a userspace code has different meaning than #include <linux/xyz.h> in kernel module? Also is external module same as kernel module?
Thanks.
|
Welcome to Unix & Linux StackExchange!
Yes, the kernel headers provide an interface for other parts of the kernel - in this you're entirely correct. They also include definitions for the interface between the kernel and the userspace - but usually the "raw" kernel interface is not used directly, but through the C library (often glibc).
The userspace-kernel interface may include multiple versions of a particular system call, for backwards compatibility reasons. By making the system call through the C library, all the applications get the same version of the actual system call, and thus a guarantee of consistent behavior. Also, when the relevant part of the kernel interface gets updated, you'll only need to update the C library to take advantage of new features.
(For example, when time_t gets extended to 64-bit in 32-bit architectures to avoid the Y2K38 problem, the C library may move to always use the 64-bit version of the kernel interface, but have an userspace-configurable mapping for applications that still use the 32-bit version. At that point, the functions using 32-bit time_t can be obsoleted and removed from the kernel, and the C library can provide better workarounds for legacy applications that still use the 32-bit type.)
So, unless you're compiling your own versions od the C library also, you should generally prefer the development headers of the C library instead of using the kernel headers directly.
The headers in /usr/include/linux/ generally come with the development header package of the C library, and describe the version of the kernel theC limrary was compiled for. This is what an userspace application developer normally needs.
/lib/modules/$(uname -r)/build is often a symbolic link to /usr/src/... where the headers or full source code of the actual running kernel version is stored. It is used when compiling external (aka third-party) kernel modules, i.e kernel modules from sources that are not integrated to the main kernel source code. These headers include the necessary kernel API version signatures so that the modules can use version-specific kernel-internal APIs.
| What is kernel headers that can be used in userspace? Do their signature or interface differ than the headers in different directories? |
1,597,753,776,000 |
I am writing a small simple driver module for a LED badge. I followed a couple of tutorials and references to do the job. All of them seem to imply that the module will be automatically loaded when the device is plugged in. However, when I run usb-devices the corresponding device has driver Driver=usbfs.
I have another terminal doing a follow on dmesg and it is at no point spitting out any of my debug messages. When I try to connect and disconnect this is what shows up:
[36078.726962] usb 1-2: USB disconnect, device number 24
[36080.925619] usb 1-2: new full-speed USB device number 25 using xhci_hcd
[36081.067062] usb 1-2: New USB device found, idVendor=0483, idProduct=5750
[36081.067067] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[36081.067071] usb 1-2: Product: CHW20160112 HID
[36081.067075] usb 1-2: Manufacturer: Chuanghongweitech1
[36081.068695] input: Chuanghongweitech1 CHW20160112 HID as /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/0003:0483:5750.0018/input/input40
[36081.069072] hid-generic 0003:0483:5750.0018: input,hidraw2: USB HID v1.10 Device [Chuanghongweitech1 CHW20160112 HID] on usb-0000:00:14.0-2/input0
My module does unload/load if I issue a sudo insmod ledbadge_drv.ko (rmmod for unload) with this output to the log:
[36216.554620] ledbadge:, Unloading module. Handler: ledbadge_exit
[36216.554620] ledbadge:, Attempting to deregister USB device.
[36216.554621] usbcore: deregistering interface driver ledbadge
[36216.554647] ledbadge:, Leaving module!
[36217.632615] ledbadge:, Loading module. Handler: ledbadge_init
[36217.632616] ledbadge:, Attempting to register USB device.
[36217.632636] usbcore: registered new interface driver ledbadge
The module's code is as follows:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/usb.h>
#define LEDBADGE_VENDOR_ID 0x0483
#define LEDBADGE_PRODUCT_ID 0x5750
#define LEDBADGE_MOD_NAME "ledbadge"
#define LEDBADGE_DRV_NAME "ledbadge"
/************* usb operations *************/
/*
ledbadge_probe
called when plugging the USB device */
static int ledbadge_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk(KERN_NOTICE "Led Badge driver (%04X: %04X) plugged \n", id->idVendor, id->idProduct);
return 0;
}
/*
ledbadge_disconnect
called when unplugging the USB device */
static void ledbadge_disconnect(struct usb_interface *interface)
{
printk(KERN_NOTICE "%s:, ledbage USB device removed", LEDBADGE_DRV_NAME);
}
/************* usb driver *************/
// information required to recognize the device
static struct usb_device_id ledbadge_table [] = {
{USB_DEVICE(LEDBADGE_VENDOR_ID, LEDBADGE_PRODUCT_ID)},
{ }, // terminating entry
};
MODULE_DEVICE_TABLE(usb, ledbadge_table);
static struct usb_driver ledbadge_driver = {
.name = LEDBADGE_DRV_NAME,
.id_table = ledbadge_table,
.probe = ledbadge_probe,
.disconnect = ledbadge_disconnect,
};
/************** module definition **************/
/* ledbadge_init
caled on module loading */
static int __init ledbadge_init(void)
{
int ret = -1;
printk(KERN_NOTICE "%s:, Loading module. Handler: %s",
LEDBADGE_MOD_NAME, __FUNCTION__);
printk(KERN_NOTICE "%s:, Attempting to register USB device.", LEDBADGE_MOD_NAME);
// attempt to register usb device
ret = usb_register(&ledbadge_driver);
// log dmesg of status
if(ret == 0) printk(KERN_NOTICE "%s:, Device registered!", LEDBADGE_MOD_NAME);
else printk(KERN_ERR "%s:, Device registration failed > %d", LEDBADGE_MOD_NAME, ret);
return ret;
}
/* ledbadge_exit
caled on module unloading */
static void __exit ledbadge_exit(void)
{
printk(KERN_NOTICE "%s:, Unloading module. Handler: %s",
LEDBADGE_MOD_NAME, __FUNCTION__);
printk(KERN_NOTICE "%s:, Attempting to deregister USB device.", LEDBADGE_MOD_NAME);
// attempt to deregister usb device
usb_deregister(&ledbadge_driver);
// log dmesg of status
printk(KERN_NOTICE "%s:, Leaving module!", LEDBADGE_MOD_NAME);
}
module_init(ledbadge_init);
module_exit(ledbadge_exit);
MODULE_LICENSE("GPL");
|
Have you placed your module in the /lib/modules/<your kernel version> directory tree and run depmod after that?
If so, then in the /lib/modules/<your kernel version>/modules.alias file should be a line like this:
alias usb:v0483p5750d*dc*dsc*dp*ic*isc*ip*in* ledbadge
When the kernel sees a new USB device, it reads its vendor and product IDs and a number of other attributes, and uses those as components for a systematically-created module alias name like above. Then the kernel causes the modprobe command to be executed (actual mechanism for that has varied somewhat in the history of Linux 2.6 and above) with that alias name. If modprobe finds an alias definition that matches it, then the module listed in that alias definition gets loaded.
I think the matching happens in such a way that the most specific match will win. Currently it looks like the hid-generic module might be winning over your module (assuming that you've run depmod after installing your module), so your ledbadge device might be a USB HID class device. So you might need to also/instead declare a USB HID device alias. Something like this:
static const struct hid_device_id ledbadge_hid_table[] = {
{HID_USB_DEVICE(LEDBADGE_VENDOR_ID,LEDBADGE_PRODUCT_ID)},
{ } // terminating entry
};
MODULE_DEVICE_TABLE(hid, ledbadge_hid_table);
The resulting line in the modules.alias file should be like:
alias hid:b0003g*v00000483p00005750 ledbadge
| How to load my custom driver module on USB device connected? |
1,597,753,776,000 |
I would like to emulate an USB from an image file.
I am using Centos7 with the Kernel 4.11.7 installed through kernel-ml and kernel-ml-devel elrepo 4.11.7-1.el7.elrepo.x86_64 (actually I tried with 3.10.* 4.10.* 4.11.1 too)
We have 2 solutions:
with insmod
sudo insmod /link/to/g_mass_storage.ko file=/tmp/filebin.img stall=0 removable=y
In dmesg:
udc-core: couldn't find an available UDC - added [g_mass_storage] to list of pending drivers
with modprobe
$ sudo modprobe g_mass_storage file=/tmp/testusb.img stall=0 removable=y
modprobe: FATAL: Module g_mass_storage not found.
Nothing in dmesg.
I have also tried with dummy_hcd:
$ sudo modprobe dummy_hcd
modprobe: FATAL: Module dummy_hcd not found.
How can I fix this problem ?
I tried many things like recompiling the Kernel 4.11.1 by enabling everything with gadget etc...
/usr/src/kernels/4.11.7-1.el7.elrepo.x86_64 $ cat .config | grep CONFIG_USB_DUMMY_HCD
# CONFIG_USB_DUMMY_HCD is not set
Result:
After compiling the kernel, I was able to modprobe dummy_hcd and to emulate an usb with a binary file.
|
You need the dummy_hcd dummy (loopback) host controller device. The gadget USB drivers are meant for real USB hardware, and on normal PCs this hardware doesn't exist. The loopback controller provides both the framework for the gadget controller, and a USB host controller to access them. So:
$ sudo modprobe dummy_hcd
gives you a new root hub
$ lsusb
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Now you can modprobe the gadget driver
$ sudo modprobe g_mass_storage file=/path/to/backing_file idVendor=0x1d6b idProduct=0x0104 iManufacturer=Myself iProduct=VirtualBlockDevice iSerialNumber=123
and it will show up under the new root hub
$ lsusb
Bus 005 Device 002: ID 0525:a4a5 Netchip Technology, Inc. Pocketbook Pro 903
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Note that you don't need to simulate a USB mass storage device if you are just interested in the contents of the file, you can mount that directly (via the loop device, but that happens automatically).
| Emulating usb device with a file using g_mass_storage => udc-core: couldn't find an available UDC - added [g_mass_storage] to list of pending drivers |
1,597,753,776,000 |
One way is to create listening socket for some protocol, and module for that protocol will be loaded. For example, DCCP and SCTP.
Are there other ways?
UPD: Use case: virtual machine somewhere in AWS/Azure/... An attacker got local unprivileged user shell. No hardware changes can be done by unprivileged used. There is local privilege escalation vulnerability in kernel module that is not loaded now. How can he load this module to use it?
Question inspired by recent vulnerability in DCCP protocol kernel module.
UPD2: According to CVE-2017-2636, it's possible to load n_hdlc kernel module just by "activating HDLC for tty device" (russian article on CVE-2017-2636). So there are other ways, but nobody with this sacred knowledge was interested in the question :(
|
Many file-system drivers are implemented as kernel modules and will be loaded on demand, either because of user mounts or by the automount daemon.
Additionally there is whole range of hot-plug devices where plugging them in will result in the kernel loading the required kernel module to manage them, with USB peripherals a very big sub category therein,
| What are ways in Linux for non-root user to trigger kernel module loading |
1,597,753,776,000 |
There is a file version.h in /usr/include/linux. Many header files include this file and use the defines in there for their own ifdefs.
However, when I compile my own kernel, I cannot see how this can possibly be reflected correctly in e.g. version.h.
Actually this holds for all kernel-related header files. AFAICS /usr/include/linux always represent the kernel which came with my distribution and neither the running kernel, nor the kernel I tell make by means of SYSSRC.
In the past I resorted to creating symlinks to my own kernel sources, but I have a feeling that this is not the correct way.
How is this supposed to work? How do I compile (e.g. a kernel module) against a custom kernel?
|
When configuring a system against your own custom kernel, I would suggest adding a name to the current version in your modified kernel sources.
For instance, in Armbian they create their own kernel packages, and add a -sunxi to kernel.release.
Takin as an example modifying the 4.6.3 kernel version:
root@ruir:/usr/src/linux-headers-4.6.3-sunxi# grep -ri 4.6.3-sunxi *
include/generated/utsrelease.h:#define UTS_RELEASE "4.6.3-sunxi"
include/config/kernel.release:4.6.3-sunxi
and also, for the kernel modules, in /lib/modules/4.6.3-sunxi/build:
include/generated/utsrelease.h:#define UTS_RELEASE "4.6.3-sunxi"
include/config/auto.conf.cmd:ifneq "$(KERNELVERSION)" "4.6.3-sunxi"
include/config/kernel.release:4.6.3-sunxi
(see installing sysdig in ARM / Armbian Jessie - module compiled in wrong kernel version )
As we can see, this can be seen in uname -r:
$uname -r
4.6.3-sunxi
As for the custom kernel packages:
$dpkg -l | grep sunxi
ii linux-dtb-next-sunxi 5.16 armhf Linux DTB, version 4.6.3-sunxi
ii linux-firmware-image-next-sunxi 5.16 armhf Linux kernel firmware, version 4.6.3-sunxi
ii linux-headers-next-sunxi 5.16 armhf Linux kernel headers for 4.6.3-sunxi on armhf
ii linux-image-next-sunxi 5.16 armhf Linux kernel, version 4.6.3-sunxi
As for adding your own headers of your compile kernel, I will refer to KernelHeaders (emphasis as bold is mine); if you are replacing minor kernel versions you may (or may not) get away with only make headers_install.
User space programs
In general, user space programs are built against the header files
provided by the distribution, typically from a package named
glibc-devel, glibc-kernheaders or linux-libc-dev. These header files
are often from an older kernel version, and they cannot safely be
replaced without rebuilding glibc as well. In particular, installing
/usr/include/linux as a symbolic link to /usr/src/linux/include or
/lib/modules/*/build/include/linux is highly discouraged as it
frequently breaks rebuilding applications. For instance, older kernels
had the architecture specific header files in include/asm-${arch}
instead of arch/${arch}/include/asm and had on a symlink to the
architecture specific directory.
The correct way to package the header files for a distribution is to
run 'make headers_install' from the kernel source directory to install
the headers into /usr/include and then rebuild the C library package,
with a dependency on the specific version of the just installed kernel
headers.
If you are distributing a user space program that depends on a
specific version of some kernel headers, e.g. because your program
runs only on patched or very recent kernels, you cannot rely on the
headers in /usr/include. You also cannot use the header files from
/usr/src/linux/include or /lib/modules/*/build/include/ because they
have not been prepared for inclusion in user space. The kernel should
warn you about this if you try it and point you to this Wiki page. The
correct way to address this problem is to isolate the specific
interfaces that you need, e.g. a single header file that is patched in
a new kernel providing the ioctl numbers for a character device used
by your program. In your own program, add a copy of that source file,
with a notice that it should be kept in sync with new kernel versions.
If your program is not licensed under GPLv2, make sure you have
permission from the author of that file to distribute it under the
license of your own program. Since your program now depends on kernel
interfaces that may not be present in a regular kernel, it's a good
idea to add run-time checks that make sure the kernel understands the
interface and give a helpful error message if there is no fallback to
an older interface.
Also for kernel development; or compiling a kernel/module for a different server or for a different kernel with multiple kernel versions installed, SYSSRC maybe be used to specify an alternate kernel source location.
| How to compile against a custom kernel (Debian)? |
1,597,753,776,000 |
I have pre-compiled kernel 3.16.7 which has btusb v0.6 module; The current btusb v0.6 I'd like to replace with btusb v0.7 which is located in kernel 4.0; So my question is how to :
remove the current btusb 0.6 from kernel 3.16.7
extract btusb 0.7 from kernel 4.0 (compile it)
insert the compiled btusb 7.0 to kernel 3.16.7
EDIT :
lsusb outputs :
Bus 001 Device 004: ID 04ca:2006 Lite-On Technology Corp.
the broadcom device 04ca is quite new so maybe that's the major problem;
As I could get it, it needs btusb module version>=0.7; So I do need some kind of module replacement cause my current pre-compiled kernel has btusb 0.6; I really want not to deal with the whole kernel sources compilation but to figure out btusb local integration into my already pre-compiled kernel v3.16.7
EDIT :
I have $usb-devices output as :
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 11 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=04ca ProdID=2006 Rev=01.12
S: Manufacturer=Broadcom Corp
S: Product=BCM43142A0
S: SerialNumber=*******
C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
after the input :
sudo modprobe btusb
and...
sudo echo "04ca 2006" | sudo tee /sys/bus/usb/drivers/btusb/new_id
I can see btusb driver activated as $usb-devices:
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=04ca ProdID=2006 Rev=01.12
S: Manufacturer=Broadcom Corp
S: Product=BCM43142A0
S: SerialNumber=******
C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
...
EDIT
I try to download an install linux-headers as :
sudo pacman -S linux-headers
[sudo] password for ...:
:: There are 8 providers available for linux-headers:
:: Repository core
1) linux310-headers 2) linux312-headers 3) linux313-headers
4) linux314-headers 5) linux316-headers 6) linux318-headers
7) linux319-headers 8) linux40-headers
...but as I can get it the linux316-headers do install headers for 3.16.7.11-1-Arch; I can see it pretty clear cause after installation I have /lib/modules/3.16.7.11-1-Arch folder created :( Currently I have running kernel as 3.16.7.3-1 so the repo headers are not compatible or similar demanding me to upgrade; So is there a way to install headers which compatible with my kernel build version?
p.s. I am quite new to linux so please link some related tutorials links and give detailed steps
Thanks
p.p.s.
OS : Linux Arch x64
|
You should be able to download the source code with
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.7.tar.xz
Then you need to extract it
tar xpvf linux-3.16.7.tar.xz
Then cd into the correct directory
cd linux-3.16.7/drivers/bluetooth
When you post the result of lsusb I should be able to finish this answer
gedit btusb
Go to the end of line 116 which should be { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) }, Press Enter key twice, then Tab once and paste this in
/* Lite-On Technology - Broadcom based */
{ USB_VENDOR_AND_INTERFACE_INFO(0x04ca, 0xff, 0x01, 0x01),
.driver_info = BTUSB_BCM_PATCHRAM },
Check the spacing and format to see if it matches the other entries, then save and exit gedit.
Then we can copy some configuration files into the directory
zcat /proc/config.gz > .config
Now we can build the bluetooth modules with
make -C /lib/modules/$(uname -r)/build M=$PWD modules
When they are compiled we can copy the btusb.ko to the kernel directory
sudo cp btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth/
cd /usr/lib/modules/$(uname -r)/kernel/drivers/bluetooth/
gzip btusb.ko
This bluetooth device needs firmware
cd ~
wget https://www.dropbox.com/s/xbmm9vfg2fby2zn/fw-04ca_2006.hcd
sudo cp fw-04ca_2006.hcd /lib/firmware/
Then we can unload btusb and load it so that the new version is loaded
sudo modprobe -r btusb
sudo modprobe btusb
| bluetooth - btusb - How to replace module version with a newer one |
1,597,753,776,000 |
I'm attempting to upgrade and test kernel 3.12.
What is the most efficient way to identify out-of-tree modules that should be removed before testing?
There are a few mentioned (vitualbox, nvidia, fglrx, bcmwl), but is there a way to identify installed modules that are considered out-of-tree?
|
After discovering that the Ubuntu wiki I am using is referring to external modules, it was easier to find a solution by rtfm.
Summary of external modules install paths
External modules are installed with modules_install at /lib/modules/$(KERNELRELEASE)/extra/ by default.
When installing external modules elsewhere, INSTALL_MOD_PATH is used to prefix the installation path, or INSTALL_MOD_DIR is used to create a new directory under the usual /lib/modules/$(KERNELRELEASE) path.
See the bottom of this answer for more detailed explanation.
Searching for external modules
To narrow the search down to the above, I'm using locate to print paths containing lib/module and xargs to filter the output of paths that are not directories.
Lastly, grep -v is used to filter the output of a paths beginning with /lib/modules/$(uname -r)/kernel. This should still display paths that were prefixed using INSTALL_MOD_PATH during installation, for example /frodo/lib/modules/$(KERNELRELEASE)/kernel/.
This obviously won't print the path of modules that were somehow installed in a completely weird path. Here is the command:
locate --null "*lib/modules/$(uname -r)*" | xargs -r0 sh -c 'for i do [ -d "$i" ] && printf "%s\n" "$i"; done' sh {} + | grep -v "^/lib/modules/$(uname -r)/kernel\|^/lib/modules/$(uname -r)$\|^/lib/modules/$(uname -r)/build$\|^/lib/modules/$(uname -r)/initrd$"
This prunes the in-tree paths from the output, which for me was 4695 lines when using only locate "*lib/modules/$(uname -r)*". Now the output is much less and should only display known out-of-tree paths:
/frodo/lib/modules/3.12.3-031203-generic
/frodo/lib/modules/3.12.3-031203-generic/kernel
Excerpts from documentation Building External Modules
The details below are from Building External Modules
modules_install
Install the external module(s). The default location is
/lib/modules/<kernel_release>/extra/, but a prefix may
be added with INSTALL_MOD_PATH (discussed in section 5).
=== 5. Module Installation
Modules which are included in the kernel are installed in the
directory:
/lib/modules/$(KERNELRELEASE)/kernel/
And external modules are installed in:
/lib/modules/$(KERNELRELEASE)/extra/
--- 5.1 INSTALL_MOD_PATH
Above are the default directories but as always some level of
customization is possible. A prefix can be added to the
installation path using the variable INSTALL_MOD_PATH:
$ make INSTALL_MOD_PATH=/frodo modules_install
=> Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/
INSTALL_MOD_PATH may be set as an ordinary shell variable or,
as shown above, can be specified on the command line when
calling "make." This has effect when installing both in-tree
and out-of-tree modules.
--- 5.2 INSTALL_MOD_DIR
External modules are by default installed to a directory under
/lib/modules/$(KERNELRELEASE)/extra/, but you may wish to
locate modules for a specific functionality in a separate
directory. For this purpose, use INSTALL_MOD_DIR to specify an
alternative name to "extra."
$ make INSTALL_MOD_DIR=gandalf -C $KDIR \
M=$PWD modules_install
=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/
| Identify out of tree modules? |
1,597,753,776,000 |
I removed kernel modules installed with rpm using yum remove kmodname.
The *.ko was located under /lib/modules/$(uname -r)/extra/.
I run depmod -a and I get depmod: ERROR: fstatat(4, kmodname.ko.xz): No such file or directory
How can I force depmod to update its database?
|
Most likely you have symlinks, probably under one of your kernels' weak-modules, pointing at modules that have been deleted.
| Why does depmod keep trying to load deleted modules |
1,597,753,776,000 |
I just got an ASUS N13 USB wireless dongle, and unfortunately it's not detected and I can't load it with modprobe:
$ sudo modprobe rt2800usb
WARNING: All config files need .conf: /etc/modprobe.d/blacklist, it will be ignored in a future release.
WARNING: Error inserting rt2x00usb (/lib/modules/3.0.0-14-generic/kernel/drivers/net/wireless/rt2x00/rt2x00usb.ko): Invalid argument
WARNING: Error inserting crc_ccitt (/lib/modules/3.0.0-14-generic/kernel/lib/crc-ccitt.ko): Invalid argument
WARNING: Error inserting rt2800lib (/lib/modules/3.0.0-14-generic/kernel/drivers/net/wireless/rt2x00/rt2800lib.ko): Invalid argument
FATAL: Error inserting rt2800usb (/lib/modules/3.0.0-14-generic/kernel/drivers/net/wireless/rt2x00/rt2800usb.ko): Invalid argument
What's the problem here? I read that this works usually out of the box with Ubuntu 11.10? What can I do to fix this? Is there a package I can reinstall to try and fix things?
|
There's very little bandwidth for communication between the kernel and insmod or modprobe: the kernel can only choose from a small set of error codes. You'll find more information on what went wrong in the kernel logs; try the dmesg command or look in /var/log/kern.log.
The most common issue is a kernel module that is incompatible with the current kernel, because it's for a different version or used different compilation options. Occasionally you'll run into drivers that try to hook into the same place and prevent each other from loading. Or it could be a bug in the initialization code of the driver you're trying to load.
| Can't insert rt2800usb module: Invalid argument |
1,597,753,776,000 |
I don't have any IDE drives and my only SATA hard drive is running in AHCI mode, but my initrd image loads the pata_atiixp module. Is it safe to disable this module? And what about the ata_generic one?
|
To answer the first question: Yes
But anyway, it should be easy to generate a backup entry in your boot manager (with the original initrd and working kernel), in case something goes wrong.
To answer the second one - you can use
$ lsmod
Module Size Used by
...
On your running systems to see, if ata_generic is loaded and if it is, which modules depend on it (look at the used by column.
| Do I need pata_atiixp or ata_generic kernel modules on a SATA only system? |
1,597,753,776,000 |
My understanding of this is fairly minimal so bear with me. From what I gather so far, the i2c subsystem on Linux identifies devices that are attached, and then matches them against loaded driver modules somehow. Where it identifies a match, it calls that driver's probe function which actually kicks off the driver setup.
I'm struggling to debug a non-functional camera; I can see that the i2c subsystem sees that it exists and has built directories for it in /sys/bus/i2c/i2c-7, and I can tell that the .probe_new() function for this driver is not called, because I added a bunch of debug messages to it. I am guessing therefore that the step where device is linked to driver is missing, but I can't figure out how that works.
Can anyone explain how the i2c-subsystem performs the device -> driver matching?
Edit:
For clarity here; I know the driver declares that it's called "ov2680":
static const struct i2c_device_id ov2680[] = {
{"ov2680", 0},
{},
};
MODULE_DEVICE_TABLE(i2c, ov2680_id);
What I don't know is how does the i2c subsystem pick up a value from the device to try to match it against that declared device id in the drivers?
|
I²C doesn’t support device enumeration, so the kernel provides four different ways of initialising I²C devices:
listing them in a devicetree (the Warp i.MX7 Board does this with ov2680), in ACPI tables, or in board files (ignore the latter, it’s only provided for backward compatibility);
instantiating them explicitly, when the hardware “knows” they exist (this is common on TV adapters for example, which use an internal I²C bus to connect their various components);
probing for them during bus initialisation;
setting them up from user space.
The latter should allow you to force the device to be probed, if you know its address on the bus:
echo ov2680 0x50 > /sys/bus/i2c/devices/i2c-7/new_device
Once you’ve verified that that works, you can then figure out where you need to add information for the device to be initialised automatically, using either devicetree or bus-based probing. The kernel documentation (see the first link above) should get you going in the right direction.
Based on your comment referring to OVTI2680, I suspect the issue here is that there are two OmniVision OV2680 drivers, drivers/media/i2c/ov2680.c and drivers/staging/media/atomisp/i2c/atomisp-ov2680.c. The former is found using devicetree, the latter using ACPI, and the presence of an OVTI2680 file in your i2c directory suggests that the latter is being loaded.
| How does the i2c subsystem match devices against drivers? |
1,597,753,776,000 |
I am trying to access SD cards on Fedora 28, but do not have any success. System info is as follows:
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: Fedora
Description: Fedora release 28 (Twenty Eight)
Release: 28
Codename: TwentyEight
I was not able to access different SD cards using two different card readers. Despite of being accessible on both macOS and Windows, none of them is shown in the Nautilus file browser, the desktop or elsewhere obvious.
The card readers are recognized by the system as per lsusb output:
$ lsusb -v
# some other USB devices
Bus 001 Device 005: ID 058f:6362 Alcor Micro Corp. Flash Card Reader/Writer
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x058f Alcor Micro Corp.
idProduct 0x6362 Flash Card Reader/Writer
bcdDevice 1.29
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 250mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
# some other USB devices
Bus 001 Device 006: ID 0dda:2027 Integrated Circuit Solution, Inc. USB 2.0 Card Reader
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0dda Integrated Circuit Solution, Inc.
idProduct 0x2027 USB 2.0 Card Reader
bcdDevice 1.6e
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 4
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 5
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
# some other USB devices
I then had a look at the udev events while plugging a card in and out:
$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[701.434565] change /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:2/block/sde (block)
UDEV [714.263816] change /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:2/block/sde (block)
KERNEL[748.477184] change /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:2/block/sde (block)
UDEV [761.338940] change /devices/pci0000:00/0000:00:1d.7/usb1/1-3/1-3:1.0/host4/target4:0:0/4:0:0:2/block/sde (block)
In addition, I had a look at the kernel messages:
$ dmesg
[ 603.846840] usb-storage 1-3:1.0: USB Mass Storage device detected
[ 603.847749] scsi host4: usb-storage 1-3:1.0
[ 605.703531] scsi 4:0:0:0: Direct-Access Generic CF 1.6E PQ: 0 ANSI: 0 CCS
[ 605.704982] scsi 4:0:0:1: Direct-Access Generic MS 1.6E PQ: 0 ANSI: 0 CCS
[ 606.509034] scsi 4:0:0:2: Direct-Access Generic MMC/SD 1.6E PQ: 0 ANSI: 0 CCS
[ 606.510387] scsi 4:0:0:3: Direct-Access Generic SM 1.6E PQ: 0 ANSI: 0 CCS
[ 606.511519] sd 4:0:0:0: Attached scsi generic sg4 type 0
[ 606.511943] sd 4:0:0:1: Attached scsi generic sg5 type 0
[ 606.512177] sd 4:0:0:2: Attached scsi generic sg6 type 0
[ 606.512408] sd 4:0:0:3: Attached scsi generic sg7 type 0
[ 608.924586] sd 4:0:0:1: [sdd] Attached SCSI removable disk
[ 629.830776] sd 4:0:0:2: [sde] Attached SCSI removable disk
[ 633.048754] sd 4:0:0:3: [sdf] Attached SCSI removable disk
[ 639.490479] sd 4:0:0:0: [sdc] Attached SCSI removable disk
Both the output of dmesg and udevadm monitor are telling that the card should be shown as sde. However, fdisk -l does not list sde. Besides that, trying to mount the device manually, raises an error:
$ mount -t auto /dev/sde /mnt/
mount: /mnt: no medium found on /dev/sde.
I am not sure, whether the needed driver module is loaded properly, since there is no mmc0-like entry in the dmesg output (as I am used to know from Debian-based systems). lsmod does not list the mmc0 kernel module either:
$ lsmod | grep mm
rtl8192c_common 61440 1 rtl8192cu
rtlwifi 98304 3 rtl8192c_common,rtl_usb,rtl8192cu
The only mmc-like modules which seems to be available but are not loaded are mmc_block and mmc_core:
$ modprobe mm # listing suggestions using tab auto-completion
mma7660 mmc_block mmc_core mms114
How could I solve this problem or at least narrow it down?
|
All in all both card readers I tested were faulty. However, please refer to this answer if you can eliminate hardware-related issues.
| Unable to access/(auto)-mount SD card on Fedora 28 |
1,597,753,776,000 |
Context : sometimes my laptop won't go to sleep mode with the error
Freezing of tasks failed after 20.008 seconds (0 tasks refusing to freeze, wq_busy=1)
I know this is an indication that a workqueue is misbehaving (https://askubuntu.com/questions/692700/what-does-wq-busy-1-indicate-in-a-failure-to-suspend) and after much fiddling, I ended up checking the output of magic 't' SysRq, and that indicated a workqueue related to memstick was apparently stalled. The output of cat /proc/WORKER-PID/stack was always stuck in a function called memstick_set_rw_addr. IIUC this function is from a kernel module called memstick. This module is required by another module named rtsx_pci_ms, which I then tried to unload. I did modprobe -r rtsx_pci_ms but it showed nothing and wouldn't return (and I couldn't even kill modprobe once it was running, it simply did not react to killall -KILL modprobe nor to Control+C). [I then had to poweroff so I can't test anything right now but the situation happens about once or twice a week so I will encounter it again.]
So now the question is how do I force kill whatever a module is doing if "modprobe -r" is stuck ?
|
You cannot force-kill kernel code if it doesn't want to be killed. Kernel code can't be killed at arbitrary times because it might be in the middle of accessing a peripheral, it might hold a lock, it might have allocated some resources that need to be freed… Userland code can be killed because the kernel holds all these resources on behalf of the process and cleans them up if the process dies. But inside the kernel, each piece of code must handle its own cleanup.
Normally, kernel code will check for signals and cleanly quit what it's doing if it receives a signal. But you've encountered a kernel bug. In this case, you're out of luck. If the code is stuck, it's stuck. Since the stuck code is executing in the context of a process's system call, that system call will never return (unless the situation inside the kernel somehow corrects itself). The process is in the middle of a system call, so it can't be killed. The KILL signal is queued up, and if the system call ever returned then the process would die immediately, but if the system call doesn't return, the process is stuck.
| Unload unresponsive kernel module |
1,597,753,776,000 |
I have a development board which has an older version of Linux installed on it. The vendor supplies an image for the device with a heavily modified linux kernel, some loadable kernel modules, and some example software.
I would like to install a newer version of the linux kernel on the device, but the vendor has no support for this, as their modified linux kernel is based off of an older kernel version.
What I don't understand, is why start hacking away at the linux kernel, when you can make the kernel compatible with the device it is running on by writing drivers as kernel modules. It could be easily recompiled for any kernel version without problems. This way, if the vendor only supports a certain kernel version, you are "stuck" :(
But there must be some reason I am missing, because I see many projects use this approach of grabbing some version of the kernel, and heavily modifying it to fit their board. What I would be interested in, is:
Why modify the linux kernel instead of creating a kernel module?
What can be done if I need to run a newer kernel, but I get no support from the vendor (Device drivers should work on newer versions of the kernel...)
|
This question has a lot of assumptions in it.
Here are some reasons.
The kernel interface is not stable so a module for one version may not compile for a different version.
The kernel may not expose a required facility.
The kernel may expose a required facility but not in a way that is acceptable, for example requiring the module to have a particular license.
The people writing the code found it quicker to write the code this way.
As to your options if you need a newer kernel.
find someone else who has already ported the code
port it yourself
pay someone else to port it (may not need money, beer, flattery and curiosity may work).
| Why modify the linux kernel instead of creating a kernel module? |
1,597,753,776,000 |
I just compiled the qcserial module which is a driver module for a Gobi USB modem. Now I have a couple of questions.
Now I have two files: drivers/usb/serial/qcserial.ko and drivers/usb/serial/qcserial.o which one is the correct driver?
Also, as I understand, it will need to go into /lib/modules/3.11.6/kernel/drivers/ but how do I know which sub directories from there onwards?
Should I just be able to copy the files over and then load with modprobe qcserial?
What I have tried so far:
root@ariag25:~# mkdir /lib/modules/3.11.6/kernel/drivers/usb/serial
root@ariag25:~# cp drivers/usb/serial/qcserial.ko /lib/modules/3.11.6/kernel/drivers/usb/serial/
root@ariag25:~# ls -l /lib/modules/3.11.6/kernel/drivers/usb/serial
total 20
-rw-r--r-- 1 root root 17921 Jan 1 18:30 qcserial.ko
root@ariag25:~# modprobe qcserial
FATAL: Module qcserial not found.
root@ariag25:~#
What am I missing? Do I also need to copy the .o file?
From where I compiled it, I have:
ls -l drivers/usb/serial/qc*
-rw-r--r-- 1 reg reg 3776 Oct 18 18:24 drivers/usb/serial/qcaux.c
-rw-r--r-- 1 reg reg 3212 Dec 28 10:14 drivers/usb/serial/qcaux.o
-rw-r--r-- 1 reg reg 12577 Oct 18 18:24 drivers/usb/serial/qcserial.c
-rw-r--r-- 1 reg reg 17921 Dec 28 10:44 drivers/usb/serial/qcserial.ko
-rw-r--r-- 1 reg reg 7743 Dec 28 10:44 drivers/usb/serial/qcserial.mod.c
-rw-r--r-- 1 reg reg 11688 Dec 28 10:44 drivers/usb/serial/qcserial.mod.o
-rw-r--r-- 1 reg reg 6912 Dec 28 10:44 drivers/usb/serial/qcserial.o
edit for Answer 1
Ok, I copied my linux-3.11.6-arm.tar into the target's /tmp/. I then executed tar -C / -tvf linux-3.11.6-arm.tar to extract it onto / but after this, I still would get
# modprobe qcserial
FATAL: Module qcserial not found.
I then wondered if the driver gat even copied:
# tar -C / -tvf linux-3.11.6-arm.tar | grep qcserial
-rw-r--r-- root/root 17921 2013-12-28 13:22 lib/modules/3.11.6/kernel/drivers/usb/serial/qcserial.ko
so that looks fine, but if I want to ls it, # ls /lib/modules/3.11.6/kernel/drivers/usb/ there's no serial directory within usb/ - why not? What happened?
|
You'll need to create a kernel package (make tar-pkg). Then copy it to your ARM system, for example to /tmp and extract to /. You'll get all driver modules installed into correct folders including proper modules.dep and other files needed to automatically resolve module dependencies.
modprobe qcserial should be working then.
| How can I load a module at runtime? |
1,597,753,776,000 |
From here: http://www.xenomai.org/index.php/RTnet:Installation_%26_Testing#Debugging_RTnet
The Linux driver for the real-time network device was built into the kernel and blocks the hardware.
When I execute rmmod 8139too it says the module does not exist in /proc/modules.
Kernel is 2.6.38.8 (64 bit).
What other information should I provide for the question?
linux-y3pi:~ # uname -a
Linux linux-y3pi 2.6.38.8-12-desktop #2 SMP PREEMPT Fri Jun 1 17:27:16 IST 2012 x86_64 x86_64 x86_64 GNU/Linux
linux-y3pi:~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:24:8C:D9:D6:2E
inet addr:192.168.16.86 Bcast:192.168.16.255 Mask:255.255.255.0
inet6 addr: fe80::224:8cff:fed9:d62e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:414 errors:0 dropped:0 overruns:0 frame:0
TX packets:261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:118971 (116.1 Kb) TX bytes:35156 (34.3 Kb)
Interrupt:17 Base address:0x4000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4720 (4.6 Kb) TX bytes:4720 (4.6 Kb)
linux-y3pi:~ # ethtool -i eth0
driver: r8169
version: 2.3LK-NAPI
firmware-version:
bus-info: 0000:01:00.0
linux-y3pi:~ # rmmod r8169
linux-y3pi:~ # ethtool eth0
Settings for eth0:
Cannot get device settings: No such device
Cannot get wake-on-lan settings: No such device
Cannot get message level: No such device
Cannot get link status: No such device
No data available
linux-y3pi:~ # lsmod|grep 8169
linux-y3pi:~ # lsmod|grep 8139
linux-y3pi:~ #
.config from /usr/src/linux-2.6.38.8
CONFIG_R8169=m
CONFIG_R8169_VLAN=y
CONFIG_8139CP=m
CONFIG_8139TOO=m
#CONFIG_8139TOO_PIO is not set
#CONFIG_8139TOO_TUNE_TWISTER is not set
CONFIG_8139TOO_8129=y
#CONFIG_8139_OLD_RX_RESET is not set
|
rmmod 8139too doesn't work because either:
8139 support is built into the kernel, and the driver can't be unloaded because it's not a module. On many systems, there's a /boot/config-2.6.38.8 file (or similar). You can grep it for something like ‘8139TOO’. If you see something like CONFIG_8139TOO=m, then the 8139too driver is compiled as a module. If it's CONFIG_8139TOO=y, then the driver is built into the kernel. If it says something along the lines of # CONFIG_8139TOO is not set, then the driver has not been compiled at all.
Your ethernet card doesn't use the RTL8139 chip, so its driver isn't loaded. You must find your intended ethernet port's driver and unload that one instead. If you have lshw, say sudo lshw | less and look for eth0: the driver module will be listed. If you have systool, try sudo systool -c net -A uevent eth0 and look for the DRIVER= part. The right hand side should show the driver loaded to handle the device. dmesg | grep eth0 may also work, but it's not 100% reliable, especially if your system has been on for a while (if there's a /var/log/dmesg, you may want to grep eth0 /var/log/dmesg too).
| How to know whether the Linux driver for the real-time network device was built into the kernel? |
1,597,753,776,000 |
I have been fiddling with power management and I can't find a way to make the changes I want persistent. For example, I have set the maximum cpu frequency with this command:
sudo cpupower frequency-set --max 2GHz
but the value goes back to its original value on every reboot. Is there a standard way to make this change persistent? I have read about kernel modules but I don't know how they work... can anyone help me?
Note. My machine is running Ubuntu 20.04.
|
The Arch Wiki page on CPU frequency scaling suggests a couple of different ways to make changes performed in cpupower persistent.
One of those, as you mentioned, is adding a kernel module. But there are other simpler options that should be easier. The simpler is just to enable cpufreq's systemd service, as suggested in the Arch Wiki. Just run
sudo systemctl enable cpupower
and the service will be started every time you boot up the machine. I am not running in a machine with systemd right now, so I cannot perform any tests.
The second option is to add a udev rule. I've tested this one right now and it works perfectly. Just edit the file named /etc/udev/rules.d/50-scaling-governor.rules or similar (create it if it does not exist) and add the following content to it:
SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+="/bin/sh -c 'echo 2000000 | tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'"
This will change the maximum frequency of CPU0 to the value written. In your case, 2000000, or 2.0 GHz. To do the same for every CPU in your machine, just change the previous command to
SUBSYSTEM=="module", ACTION=="add", KERNEL=="acpi_cpufreq", RUN+="/bin/sh -c 'echo 2000000 | tee /sys/devices/system/cpu/cpu*[0-9]/cpufreq/scaling_max_freq'"
and this will change the maximum frequency for every CPU in your system.
| Making cpupower changes persistent |
1,597,753,776,000 |
I recently secure-booted Arch and Fedora on my RTX3050 equipped laptop.
As is the common knowledge, I had to sign my Nvidia modules on Fedora for the kernel to load them. However, I find that same is not the case with Arch. Arch loads the Nvidia modules even if they are not signed — provided, of course, that the kernel and the GRUB are signed.
Upon researching, I came across this post on the ArchWiki mentioning the module.sig_enforce=1 kernel parameter to force signature verification. However, table 3 in this entry of Fedora docs, mentions that the said kernel parameter doesn't make any difference when SecureBoot is enabled.
The kernel docs mention CONFIG_MODULE_SIG_FORCE option in the kernel configuration. So, I decided to take a look at Fedora's and Arch's configs.
And sure enough, Arch doesn't have the option set. But, so doesn't Fedora.
So why this difference in handling of the modules?
EDIT: I found CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT option that is present in Fedora's config but not in Arch's, after a chat in Fedora's Matrix Room. But, I cannot find any documentation related to this at docs.kernel.org; only a reference here. Is there a different site for documenting all kernel config options?
|
As you discovered, this is enforced by CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT. That setting is supported by a kernel patch which hasn’t been merged upstream; you’ll find it in Fedora and RHEL kernels but not in Arch.
Since it hasn’t been merged upstream, you won’t find it in the upstream kernel documentation, or on any other site which describes the upstream kernel.
| How come Fedora ignores `module.sig_enforce` kernel parameter if SB is enabled but Arch does not? |
1,597,753,776,000 |
I was wondering if someone has any info about how to implement a link layer portocol which uses the GPIOs (for example in a Raspberry Pi).
The idea is to implement a custom interface (similar to eth0) which would be point-to-point and when a message is sent through that interface instead of calling the ethernet module, my new kernel module (device driver) would be called which would use the GPIOs to send the packet.
I would like to know some stuff:
Does anyone know of any book/paper/... with an example of something similar or info I would need to know? I found quite a lot of stuff on kernel modules and so, but nothing about "connecting" the new interface with the kernel module.
Does it need to be implemented with TCP/IP if I want it to appear as a new interface? (I suppose the answer is yes)
My research lead me to some interesting webpages:
Device driver implementation example for raspberry pi (controlling GPIOs).
RFC1149 Implementation
But still I'm quite lost when it comes to the interface implementation part, and how to "connect it" to the driver. So when I do a ping using the new interface, it sends the IP Packet to my device driver, so I should encapsulate it and send it through my hardware.
Thanks, hope to get some answers!
|
Assuming it's sufficient for your protocol to control the GPIO pins from userspace via /sys/class/gpio/, the simplest way is to write a userspace tap driver. From the kernel documentation linux/Documentation/networking/tuntap.txt:
TUN/TAP provides packet reception and transmission for user space programs.
It can be seen as a simple Point-to-Point or Ethernet device, which,
instead of receiving packets from physical media, receives them from
user space program and instead of sending packets via physical media
writes them to the user space program.
In order to use the driver a program has to open /dev/net/tun and issue a
corresponding ioctl() to register a network device with the kernel. A network
device will appear as tunXX or tapXX, depending on the options chosen. When
the program closes the file descriptor, the network device and all
corresponding routes will disappear.
Depending on the type of device chosen the userspace program has to read/write
IP packets (with tun) or ethernet frames (with tap). Which one is being used
depends on the flags given with the ioctl().
The package from http://vtun.sourceforge.net/tun contains two simple examples
for how to use tun and tap devices. Both programs work like a bridge between
two network interfaces.
br_select.c - bridge based on select system call.
br_sigio.c - bridge based on async io and SIGIO signal.
However, the best example is VTun http://vtun.sourceforge.net :))
You can also google for lots of tutorials (though most will probably be about a tun interface, i.e. IP packets instead of Ethernet frames).
Even if the final product needs to be a kernel module, I'd still start out with a tap driver, because they are much easier to debug. You can still turn it into a kernel module after most of it already works.
| Custom link layer protocol in UNIX [closed] |
1,597,753,776,000 |
I am upgrading my Fedora OS to the latest version 20 as the current one is nearing end of life. Fedora introduces a new upgrade method called FedUp that allows user to perform an upgrade over the network. I followed the instructions in there and everything went smoothly with no errors in the fedup log:
# fedup --network 20
setting up repos...
getting boot images...
.treeinfo.signed | 2.0 kB 00:00:00
setting up update...
finding updates 100% [==========================================================]
verify local files 100% [=======================================================]
testing upgrade transaction
rpm transaction 100% [==========================================================]
rpm install 100% [==============================================================]
setting up system for upgrade
Finished. Reboot to start upgrade.
Packages without updates:
btparser-0.25-1.fc18.x86_64
firstboot-18.6-2.fc18.x86_64
google-chrome-stable-31.0.1650.63-1.x86_64
kernel-3.11.10-100.fc18.x86_64
kernel-3.11.7-100.fc18.x86_64
kernel-modules-extra-3.11.10-100.fc18.x86_64
kernel-modules-extra-3.11.7-100.fc18.x86_64
libgssglue-0.4-1.fc18.x86_64
mysql-connector-c++-1.1.2-1.fc18.x86_64
mysql-workbench-5.2.47-2.fc18.x86_64
Upon reboot, I encountered three errors:
Failed to start Load Kernel Modules.
Failed to start IPv6 firewall with ip6tables.
Failed to start IPv4 firewall with iptables.
After logging in and upon further examination with lsmod, I notice that several modules are missing, preventing the network from working. The missing modules include:
ebtable_nat
ebtables
ip6table_filter
ip6_tables
microcode
nf_conntrack
nf_conntrack_ipv4
nf_conntrack_ipv6
rt2800lib
rt2800usb
snd
uinput
xt_conntrack
xt_limit
It appears there are many missing modules, preventing me from completing the upgrade to the latest OS version.
Next I tried upgrading to version 19 by running the command fedup --network 19, but it seems to do an upgrade to the same version 20 instead. I also tried upgrading using the non-recommended way from DVD iso file and it generates warnings, advising me not to do so.
I am really fedup. What should I do now?
|
Use the latest fedup available for your distro. Check updates-testing for updates.
yum --enablerepo=updates-testing upgrade fedup
Don't try to jump over releases. Use standard distro kernel. Re-enable SELinux if you disabled it. Don't ignore fedup warnings.
I just upgraded two Fedora 19 systems to Fedora 20. One of them was upgraded from Fedora 18 in the past.
| FedUp, unable to upgrade to Fedora 20 |
1,631,655,996,000 |
I recently updated from the 4.9 kernel to 4.14 only to find my speakers have a constant buzzing sound. I've narrowed the problem down to the power_save parameter of the snd_hda_intel module. When enabled there is a constant buzz, but disabled (set to 0) it is silent.
I've attempted to set the value by using both a modprobe.d and a kernel parameter. The problem is, the value is being overwritten/set by something in my system.
Forcefully reloading the module (default is off) or writing 0 to /sys/module/snd_hda_intel/parameters/power_save will temporarily solve the problem, until a reboot or wake from suspend. I cannot determine what is enabling the power_save feature. I've even tried using inotifywait and lsof to find the culprit, with no results (doesn't seem to work across sleep/wake cycles).
This is a desktop PC, so no battery hence no AC vs BAT modes or anything like pm-util. I'm using a GNOME version of Manjaro, but I'm sure solutions for any platform may help. The audio is an onboard ALC887-VD chipset if that's any help.
Can anybody suggest where else I might look or what could be causing this?
Update:
I've noticed my distribution shipped with TLP (similar to pm-utils) and that on the 4.14 kernel TLP always starts up in battery mode. My PC doesn't have a battery but does have wireless peripherals. I think this may be a bug within TLP itself.
|
I’ve confirmed that TLP (version 1,0) is at fault here. It’s detecting the batteries of my two peripheral devices by scanning the contents of /sys/class/power_supply. Since it detects devices powered by battery and no devices powered by mains, it is incorrectly thinking the system is battery powered. The detection loop is here if anybody wants to look at this.
On kernel 4.9, my /sys/class/power_supply directory is empty, but on 4.14 it is populated with my Logitech wireless mouse and keyboard. I’m guessing many other TLP users, with wireless peripherals, may also be affected by this bug. Though, in most cases, many people may not even realize their desktop PC’s are running in battery mode.
Update:
The issue has been fixed in TLP 1.1 beta. It now ignores HID devices and the system correctly uses the AC mode.
| Unable to set kernel module parameters |
1,631,655,996,000 |
So I've been debugging a hairy suspend-to-ram issue, where I get
Oct 12 15:41:23 arjundesktop dbus[2863]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'
Oct 12 15:41:23 arjundesktop systemd[1]: Reached target Sleep.
Oct 12 15:41:23 arjundesktop systemd[1]: Starting Suspend...
Oct 12 15:41:23 arjundesktop systemd[1]: Starting Network Manager Script Dispatcher Service...
Oct 12 15:41:23 arjundesktop systemd-sleep[17199]: Suspending system...
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������May 21 16:33:31 arjundesktop rsyslogd: [origin software="rsyslogd" swVersion="8.4.2" x-pid="2929" x-info="http://www.rsyslog.com"] start
When this happens, I can no longer wakeup my system. I've run this on debian and ubuntu, with kernels ranging from 3.16 - 4.7. My current kernel is
Linux arjundesktop 4.7.6 #1 SMP Sat Oct 8 13:00:22 MDT 2016 x86_64 GNU/Linux
I've been following this basic guide to suspend debugging. My dmesg log shows
May 21 16:33:31 arjundesktop kernel: [ 1.225463] initcall deferred_probe_initcall+0x0/0x70 returned 0 after 87 usecs
May 21 16:33:31 arjundesktop kernel: [ 1.225863] calling late_resume_init+0x0/0x1a0 @ 1
May 21 16:33:31 arjundesktop kernel: [ 1.226255] Magic number: 14:34:278
May 21 16:33:31 arjundesktop kernel: [ 1.226655] tty tty15: hash matches
May 21 16:33:31 arjundesktop kernel: [ 1.227075] initcall late_resume_init+0x0/0x1a0 returned 0 after 799 usecs
May 21 16:33:31 arjundesktop kernel: [ 1.227466] calling rtc_hctosys+0x0/0x101 @ 1
May 21 16:33:31 arjundesktop kernel: [ 1.227889] rtc_cmos 00:02: setting system clock to 2014-01-01 12:16:03 UTC (1388578563)
May 21 16:33:31 arjundesktop kernel: [ 1.228291] initcall rtc_hctosys+0x0/0x101 returned 0 after 423 usecs
What does this magic number mean? Why is saying the crash happened from my tty? When I run
cat /sys/power/pm_trace_dev_match
I get
usb
tty
What does this mean? How would I proceed? Output of lsusb
Bus 004 Device 002: ID 8087:8001 Intel Corp.
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 8087:8009 Intel Corp.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 062a:4101 Creative Labs
Bus 001 Device 002: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0
Bus 001 Device 005: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
I have no real answers, but I changed my graphics card from an AMD 7950 to a AMD Vega 64. Now suspend to ram works fine on the amdgpu driver, so I suspect it was a graphics driver issue.
| Debugging a suspend to ram issue with PM_TRACE |
1,631,655,996,000 |
I'm using a box with Debian that has gone through many updates (at least lenny, squeeze, wheezy).
After a long time, I wanted to mount a floppy again which didn't work as it used to. I found a tutorial explaining I had to comment out the line about /dev/fd0 in /etc/fstab because the floppy module was dropped from the kernel and isn't invoked during boot.
Link: How to enable your floppy driver, refers to Can't read Floppy Disks.
The fix works, I can mount the floppy just fine. But now, I'm curious.
The big question: Why does commenting out the line in /etc/fstab fix the problem? I thought the info in fstab just makes typing # mount commands easier, allows applications to find mounting info, and lets you omit stuff like -t and the mount point? Commenting out a line in /etc/fstab will surely not load a kernel module, or does it?! Do I really enable the floppy driver itself when modifying /etc/fstab?
EDIT, just to be sure...
After a good comment asked if this was really the behavior of my system, I double-checked.
With
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
in /etc/fstab, mounting doesn't work:
box:/home/zebonaut# mount -t vfat /dev/fd0 /media/floppy0/
box:/home/zebonaut# ls -l /media/floppy0
total 0
box:/home/zebonaut# umount /media/floppy0
umount: /media/floppy0: not mounted
box:/home/zebonaut#
With
#/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
in /etc/fstab, I can mount the floppy just fine:
box:/home/zebonaut# mount -t vfat /dev/fd0 /media/floppy0/
box:/home/zebonaut# ls -l /media/floppy0
total 1241
-rwxr-xr-x 1 root root 340498 Sep 5 2002 file.01
-rwxr-xr-x 1 root root 410952 Sep 5 2002 file.02
-rwxr-xr-x 1 root root 43008 Jan 23 2000 file.03
-rwxr-xr-x 1 root root 26060 Jan 6 2005 file.04
-rwxr-xr-x 1 root root 20992 Jan 19 2000 file.05
-rwxr-xr-x 1 root root 54784 May 14 1999 file.06
-rwxr-xr-x 1 root root 217600 Apr 15 2005 file.07
-rwxr-xr-x 1 root root 32256 Mar 23 2005 file.08
-rwxr-xr-x 1 root root 32768 Jan 20 2000 file.09
-rwxr-xr-x 1 root root 91136 Jan 20 2000 file.10
box:/home/zebonaut# umount /media/floppy0
box:/home/zebonaut#
It really is this strange. I can turn on or off my ability to mount the floppy by opening /etc/fstab with an editor and putting a # in front of the line with the floppy info.
|
As unsatisfying as it is, I can not any more reproduce what I have mentioned in my question. Mounting the floppy works well either way now.
The only thing I have done was to edit the formatting of /etc/fstab, i.e. I have put tabs where spaces were and I may have modified some line breaks. I have tried to undo the edit, and still could not reproduce the strange behavior. I'm sorry I don't have an exact copy of the original file.
The most likely reason may have been a syntax error in /etc/fstab within the line for the floppy (too many spaces before the line break or something of similar strangeness). It may have been that during an update, a script may have looked at whatever it found in /etc/fstab, and it may have tried to parse it to some newer standard, breaking it in the process.
Sorry this is guesswork mostly, but for whatever reason, the problem is gone.
I'm fairly sure now it's really not a driver issue.
| Why do I need to comment out the floppy in /etc/fstab in new-ish Debian versions? |
1,631,655,996,000 |
i'm running Ubuntu 16.04 LTS and want to use an apple keyboard (wired). No i'm facing some problems whith making my custom settings permanent. I'm using the 'English internationl, AltGr dead keys' layout.
The keyboard has some keys swapped and i set the settings manually in the
/sys/module/hid_apple/parameters/ folder. I set fnmode to 2 , iso_layout to 0 and swap_opt_cmd to 1. After this everything works like intended. But after rebooting the settings are back to the default. I have to reset everything manually after each reboot.
For now i wrote a little shell script which would do it but that's not the best way i think.
How can i make these settings persistent?
|
It appears that you can create /etc/modprobe.d/hid_apple.conf and add the entries you need fixing in there, such as,
options hid_apple fnmode=2
NB: This assumes the hid_apple module is already being loaded.
| Make Apple Keyboard Settings persistent in ../hid_apple/parameters/ |
1,631,655,996,000 |
I understand that you can write custom udev rules to create a symlink in /dev directory.
But what is the use of having a symlink in /dev?
What is the symlink linking to?
I know you can interact with regular links in the /dev directory but not understanding what a symlink does.
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0461", ATTRS{idProduct}=="4d81", SYMLINK+="myusb"
|
Typically it's to give a known fixed pathname to access the device; /dev/mydevice is fixed but depending on the order things are plugged in it might be /dev/ttyUSB0 or /dev/ttyUSB1 or /dev/ttyUSB2 or...
This can be useful for devices which can present multiple endpoints; eg I have a USB HUBZ device that presents zigbee and zwave endpoints. These rules create easy to use names
SUBSYSTEM=="tty", ATTRS{interface}=="HubZ Z-Wave Com Port", SYMLINK+="zwave"
SUBSYSTEM=="tty", ATTRS{interface}=="HubZ ZigBee Com Port", SYMLINK+="zigbee"
In my case I also have multiple printers and so the rule
#Rules for Terow printer
KERNEL=="lp*" ATTRS{idVendor}=="0416", ATTRS{idProduct}=="5011", MODE="0666", SYMLINK+="lp_receipt"
Now I can just do cat file > /dev/lp_receipt and it will print and I don't need to know if it's really /dev/usb/lp0 or /dev/usb/lp1.
The symlimk created points to the "real" entry;
lrwxrwxrwx 1 root root 7 Sep 8 12:17 /dev/lp_receipt -> usb/lp1
| What's the reason to add a symlink to /dev directory with udev rules? |
1,631,655,996,000 |
I would be interested in finding ways to reduce the boot time, specially in embedded-related environments.
I've read somewhere of a method to avoid the kernel to load some drivers or modules but I'm completely lost and all the information I find on internet is quite complex and dense.
Could anyone please suggest the general steps needed to achieve this? Maybe I'm wrong and this is nothing to do with the kernel.
|
The arch linux documentation Improving performance/Boot process may help you to learn how to improve the boot performance.
Use systemd-analyze blame to check the timing for the enabled services, or systemd-analyze critical-chain to check the critical points then disable the unwanted services through systemctl disable service_name. or removing the un-necessary programs through apt.
| Reduce Boot time |
1,631,655,996,000 |
I have to demonstrate a practical where I have to make my own module, add this module to a kernel's source and implement the system call. I'm using 3.16 kernel on Ubuntu but it takes around 2 hours to install the kernel from source.
Is it possible to remove some part of kernel(like unnecessary drivers,etc) from the source to save time as I'm not going to use this newly installed kernel for regular use? If yes, how?
|
As mentioned in comments, you should be building using something like make -j4. Use a number equal or slightly higher than the number of CPU cores you have.
make localmodconfig
The following instructions apply to building a kernel from upstream. Personally I find that simplest. I don't know how to obtain a tree with the ubuntu patches applied, ready to build like this.
(1) Theoretically the way you build kernels in more reasonable
timespans for testing is supposed to be
cp /boot/config-`uname -r` .config
you don't need to enable anything newer, so - only problem is this
breaks if they renamed stuff:
make oldnoconfig
now disable all the modules not currently loaded. (Make
sure you have all your usb devices you need plugged in...):
make localmodconfig
It worked for me recently, so might be useful. Not so well the
previous time I tried it.
I think I got it from about one hour down to ten minutes. Even after make localmodconfig it's still building crazy amounts of stuff I don't need. OTOH actually finding and disabling that stuff (e.g. in make xconfig) takes a while too (and even longer if you mistakenly disable something you do need).
I guess it's worth knowing it exists, it's just not guaranteed to make you happy.
(2) I don't think it should take two hours to build every modification to your "module". (It actually needs to be a builtin if you're implementing a new system call). make will just recompile your modified files and integrate it into a kernel binary. So in case getting the Kconfig right is too much trouble, then maybe an initial two-hour build is not too bad.
You might be having this problem if you are building with a distribution kernel source package. (You can switch to manual builds, or you might be able to trick the distro source package into using ccache). Or, your modifications might be modifying a header file which is unfortunately included by many many source files.
Even so, it might be useful to make custom Kconfigs, e.g. much smaller Kconfigs, if you want to port to different kernel versions, do git bisect, test different build options, etc.
| Saving time while compiling Kernel |
1,631,655,996,000 |
I have compiled a kernel with some modules, for example the ath9k for my wireless card. I don't have anything in the autoload configuration (i.e my file /etc/modules.autoload.d/kernel-2.6 is empty). However, lsmod still shows that the module has been loaded. I also notice that when I compile filesystem support as modules (reiserfs, jfs, xfs etc.) they also get autoloaded.
Who is doing this? Can and should I disable it? I am using Gentoo.
Thanks
|
Udev loads modules automatically depending on what kind of hardware it finds. You can "blacklist" modules in order to stop them being autoloaded as described in the Gentoo udev guide.
| who loaded my kernel modules? |
1,631,655,996,000 |
Many of my modules are missing /sys/module/*/parameters directory and I can't check the module loaded parameters.
# printf "%s\n" /sys/module/*/parameters | wc -l
125
# lsmod | wc -l
151
# comm -13 <(printf "%s\n" /sys/module/*/parameters | xargs dirname | xargs basename -a | sort) <(lsmod | awk '{print $1}' | sort) | fmt
Module aesni_intel at24 blake2b_generic bpf_preload btbcm btintel
btmtk btrfs btrtl crc16 crc32_pclmul crc32c_generic crc32c_intel
crct10dif_pclmul cryptd crypto_simd crypto_user dummy ecdh_generic fat
gf128mul ghash_clmulni_intel i2c_smbus iTCO_vendor_support iTCO_wdt
intel_cstate intel_pmc_bxt intel_rapl_common intel_rapl_msr intel_uncore
ip6_tables ip6t_REJECT ip6table_filter ip6table_mangle ip6table_nat
ip6table_raw ip_tables ipt_REJECT iptable_filter iptable_mangle
iptable_nat iptable_raw irqbypass joydev ledtrig_audio libcrc32c lpc_ich
mac_hid mei mei_hdcp mei_me mei_pxp mei_wdt nf_conntrack_broadcast
nf_conntrack_netlink nf_conntrack_pptp nf_defrag_ipv4 nf_defrag_ipv6
nf_log_syslog nf_nat nf_nat_amanda nf_nat_ftp nf_nat_h323 nf_nat_irc
nf_nat_pptp nf_nat_sip nf_nat_snmp_basic nf_nat_tftp nf_reject_ipv4
nf_reject_ipv6 nfnetlink nfnetlink_log nvidia nvme_common parport
polyval_clmulni polyval_generic ppdev raid6_pq rapl sha512_ssse3
snd_hda_codec_conexant snd_hda_codec_generic snd_hda_core snd_hwdep ts_kmp
tun uas vboxnetadp vboxnetflt vfat vmd x_tables xhci_pci xhci_pci_renesas
xor xt_CT xt_LOG xt_NFLOG xt_addrtype xt_comment xt_conntrack xt_hashlimit
xt_mark xt_multiport xt_tcpudp
Most notably I was interested in:
# lsmod | grep nvidia
nvidia_drm 77824 20
nvidia_modeset 1515520 40 nvidia_drm
nvidia_uvm 2891776 0
video 69632 1 nvidia_modeset
nvidia 61472768 2179 nvidia_uvm,nvidia_modeset
# ls /sys/module/nvidia/parameters
ls: cannot access '/sys/module/nvidia/parameters': No such file or directory
But also dummy doesn't have parameters, which cmon, it's a dummy:
# modprobe dummy numdummies=12
# lsmod | grep dummy
dummy 16384 0
root@leonidas /root
# ls /sys/module/dummy/parameters
ls: cannot access '/sys/module/dummy/parameters': No such file or directory
# ip a | grep dummy | wc -l
12
I found https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1774731 about also missing dummy/parameters directory.
How to enable that directory so that I can get kernel module parameters?
|
In order for modules to have their parameters visible in /sys/module/*/parameters, the module needs to provide a module_param_cb() callback function for each parameter. Those functions will have to "know where to look" for the current setting of the respective parameter, so the sysfs filesystem driver can use them to figure out the parameters and their states on demand.
If the module uses the module_param(name, type, perm) or module_param_named(name, value, type, perm) macros to declare their parameters, the callback function is generated automatically unless perm is specified as 0.
The dummy module declares its module parameter like this:
module_param(numdummies, int, 0);
MODULE_PARM_DESC(numdummies, "Number of dummy pseudo devices");
explicitly specifying the perm as 0, which makes the parameter not visible in sysfs.
The main nvidia module declares its own NV_MODULE_PARAMETER(x) and NV_MODULE_STRING_PARAMETER(x) macros (in common/inc/nv-linux.h within the NVidia driver package), which use module_param() with the perm parameter set to 0:
#define NV_MODULE_PARAMETER(x) module_param(x, int, 0)
#define NV_MODULE_STRING_PARAMETER(x) module_param(x, charp, 0)
Other modules in the driver package, like nvidia_modeset, nvidia_drm and nvidia_uvm do use module_param() in a more normal fashion, and those modules do have their parameters in /sys/module/*/parameters as expected.
Apparently, the nvidia module internally handles its parameters as something called "registry keys" (see nvidia/nv-reg.h in the driver package). Perhaps this is some kind of attempt to provide a cross-platform interface for NVidia driver parameters, that is at least in some sense similar between Windows and Linux?
Note also that the nvidia module provides its own /proc/driver/nvidia/params pseudo-file, which provides all the parameters in one virtual file.
So, in a nutshell:
I would recommend you to look at /proc/driver/nvidia/params instead and to see if it fits your needs. If not, and if you are willing to build a custom version of the NVidia driver, you might (at your own risk) try changing the definitions of the NV_MODULE_PARAMETER() and NV_MODULE_STRING_PARAMETER() macros to have a perm value other than 0, e.g.:
#define NV_MODULE_PARAMETER(x) module_param(x, int, 0400)
#define NV_MODULE_STRING_PARAMETER(x) module_param(x, charp, 0400)
to make all parameters declared this way readable using the /sys/module/*/parameters interface, by the root user only.
If it works, you might then send NVidia an enhancement request.
| modules are missing /sys/module/*/parameters directories, how to enable them? |
1,631,655,996,000 |
I am trying to find out what kernel modules are loaded inside a OpenVZ virtual server. Command lsmod is empty and I believe the reason is the way how OpenVZ's virtualisation is working.
Specifically, I like to know if the inotify module is loaded.
I have only access to the guest system.
|
As far as I understand, OpenVZ guests share the host's kernel and all loaded modules. Guests and are not allowed to load modules into the host's kernel, consequently lsmod shows an empty list. Apparently it is not possible to show what modules are loaded into the host's kernel, without access to the host.
| How to show loaded kernel modules inside OpenVZ virtual server |
1,631,655,996,000 |
I'm curious:
What, exactly are the benefits to statically linking modules into the kernel rather than loading through rc.conf, etc?
For example:
To add Linux emulation, I could add linux_enable="YES" to /etc/rc.conf, or I could link it into the kernel by adding options COMPAT_LINUX to my kernel config.
Is there actually an advantage to this? If so, what?
|
Statically linking used to be the only way to load a module which is think is the primary reason to having options like COMPAT_LINUX. Also, prior to loader, it used to be the only way to load modules necessary to get FreeBSD to get the necessary drivers to mount the root file system and boot FreeBSD. Nowadays, I don't think there is any significant benefit to statically linking in a module if it can be easily loaded at runtime. I don't think you will see any benefit in performance by statically linking Linux compatibility support, but some users still swear by it. I would avoid it just because of the inconvenience of recompiling a Kernel for little to no perceived performance gain.
| Difference between rc.conf, loader.conf and static kernel linking in FreeBSD |
1,631,655,996,000 |
Hi there Linux experts!
I'm trying to find the best way possible to control and stress a PCI device.
I've started off with writing a simple bash script that uses the commands from pciutils (lspci & setpci) to configure the device and create traffic on the bus
While the scripts work just fine, their execution speed seems much slower than the PCIe link speeds, making it hard to create stress on the bus, or quickly change between power modes and link speeds.
I was wondering, if ill write a kernel module that will call functions from the pci.h library, will its execution be faster? Will I be able to achieve faster access to the PCI device?
Any help would be much much appreciated :)
|
There is a huge amount of overhead in the shell calling external commands to do anything. Fork/exec has a relatively high overhead.
Just moving from a shell script to a userspace C program using the API directly (instead of by calling CLI utilities) will be a huge speedup. Also easier than writing a kernel module. If you can find API bindings for a scripting language (Perl, Python, Ruby, etc.) then that'd be nearly as fast.
There is still overhead left (e.g., syscall overhead) that you could remove by then converting to a kernel module. At that point, you've eliminated essentially all the overhead and the only way you'd get faster would be getting rid of the operating system and/or custom test hardware.
PS: Questions about how to actually write the userspace C program or the kernel module are probably better asked on Stack Overflow, the Stack Exchange network site for programming questions. As with any Stack Exchange site, please check their Stack Overflow Help Center before posting a question there. Theirs especially has some useful tips on asking a well-received question.
| PCI hardware access speeds - Kernel vs user space [closed] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.