Recently I’ve discovered some topics about building modules for Manjaro (like How to build a kernel module?) but nobody succeeded to build. Hence, I’m providing my solution to the problem.
I’ve got problematic, not supported USB MIDI device. No vendor/device id in quirks table (sound/usb). So I’ve managed compile standalone module (I’ll try to explain for beginners also):
- Download sources from kernel.org (the same version, including minor - check with
uname - r
). For me it was linux-5.15.85.tar.gz - Unpack sources with
tar xfv linux-5.xx.xx.tar.gz
- Change dir to sources
- Copy your current config :
zcat /proc/config.gz > .config
- Ensure, in .config file your config set as module, not =y (for me : CONFIG_SND_USB_AUDIO=m)
- Perform changes in source code as you wish (this is up to your imagination and responsibility also)
-
make EXTRAVERSION=-1 modules_prepare
- EXTRAVERSION should be the same as for your kernel. Check withuname -r
-
make M=path_to_module_dir
(in my case make M=sound/usb) - Compilation should take few seconds (depending on your machine)
- You can find freshly compiled kernel object(s) (*.ko) in the appropriate directory
- Replace existing modules or copy to /usr/lib/modules/<your_kernel>/extra (depending whether you would like replace existing modules or compiled new one)
- You can strip modules with running
strip --strip-debug <ko file>
to remove debugging info and symbols (this is to reduce size of the modules we’ve compiled) - Run
sudo depmod
to rescan module dependencies - Your module should work after running
modprobe <module>
. You can play also with modprobe and rmmod (to add and remove modules). Get module info/path withmodinfo <modname>
. Monitor real time situation withdmesg -kW
(in separate terminal window)
If any questions, I will try to help