You are not logged in.

#1 2018-11-21 05:32:05

afx
Member
Registered: 2018-11-21
Posts: 2

[SOLVED] building custom kernel modules

Hello,

I am trying to compile a kernel module using the following makefile,

TARGET = printk_user
obj-m := $(TARGET).o

KERNEL_VERSION=$(shell uname -r)
KDIR = /lib/modules/$(KERNEL_VERSION)/build
PWD = $(shell pwd)

all: printk

printk:
        $(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
        $(MAKE) -C $(KDIR) M=$(PWD) clean

However the build directory doesn't seem to exist as it does in other distributions. The following error output is received,

make -C /lib/modules/4.19.2-arch1-1-ARCH/build M=/home/afx/kernPrintk modules
make[1]: *** /lib/modules/4.19.2-arch1-1-ARCH/build: No such file or directory.  Stop.
make: *** [makefile:11: printk] Error 2

I saw a post where it was suggested to install kernel-devel package but I couldn't find any version of this in the pac repos.

Feel free to tell me to rtfm but I couldn't find anything about it in the wiki short of recompiling the entire kernel LFS style.

Thanks

Last edited by afx (2018-11-21 05:56:05)

Offline

#2 2018-11-21 05:47:00

bugsmanagement
Member
Registered: 2017-04-21
Posts: 201

Re: [SOLVED] building custom kernel modules

IIRC, perhaps you looking for linux-headers package instead?

Offline

#3 2018-11-21 05:50:55

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] building custom kernel modules

You cannot possibly have seen a recommendation for "kernel-devel" since our kernel is named "linux" and any suffix would need to follow that.

$ pacman -S linux<TAB>
linux                   linux-docs              linux-hardened-docs     linux-lts               linux-tools-meta        
linux-api-headers       linuxdoc-tools          linux-hardened-headers  linux-lts-docs          linux-zen               
linux-atm               linux-firmware          linux-headers           linux-lts-headers       linux-zen-docs          
linuxconsole            linux-hardened          linux_logo              linuxsampler            linux-zen-headers       

Signs point to "linux-headers". Tab-complete is amazing and undervalued. smile

Last edited by eschwartz (2018-11-21 05:52:26)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#4 2018-11-21 05:57:49

afx
Member
Registered: 2018-11-21
Posts: 2

Re: [SOLVED] building custom kernel modules

Thank you both it was linux-headers I needed. I didn't say it was a good tip @eschwartz.

tab-complete is undervalued, i was trying to find it with pkgfile which may have been overkill for that.

Offline

#5 2018-11-21 12:48:55

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] building custom kernel modules

pkgfile will try to match it strictly as a file by default, and therefore not find it -- which means you likely want to use -d and end with a directory component "/" in order for it to match correctly.

You can also search for a common, well-known file unique to the Linux headers, like Kconfig.

$ pkgfile Kconfig
core/linux-firmware
core/linux-headers
core/linux-lts-headers
extra/linux-hardened-headers
extra/linux-zen-headers
community/wireguard-dkms

Or use regex mode (which will allow matching anywhere on the filepath rather than just the last filename component or the full path)  *and* directory matching:

$ pkgfile --verbose --regex --directories "4.19.2-arch1-1-ARCH/build/$"
core/linux-docs 4.19.2.arch1-1   	/usr/lib/modules/4.19.2-arch1-1-ARCH/build/
core/linux-headers 4.19.2.arch1-1	/usr/lib/modules/4.19.2-arch1-1-ARCH/build/

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB