You are not logged in.

#1 2021-09-13 16:57:33

greenbigfrog
Member
Registered: 2017-12-06
Posts: 33

[SOLVED] Building dkms module, trouble choosing proper paths etc

Hi.
Trying to put the patch from https://bugzilla.kernel.org/show_bug.cgi?id=204807#c100 into a dkms mod, I've come up with following:
dkms.conf:

MAKE="make -C /lib/modules/`uname -r`/build M=$PWD -d"
PACKAGE_NAME=nct6775
PACKAGE_VERSION=wim
BUILT_MODULE_NAME[0]="nct6775"
DEST_MODULE_LOCATION[0]="/kernel/drivers/hwmon"
AUTOINSTALL=yes
PATCH[0]="nct6775-wim.patch"

Makefile

obj-m := nct6775.o

And a script to set it up:

mkdir /usr/src/nct6775-wim
cd /usr/src/nct6775-wim
mkdir patches
wget -O patches/nct6775-wim.patch https://bugzilla.kernel.org/attachment.cgi?id=298703
sudo awk -i inplace '{gsub(/drivers\/hwmon\//,"");print}' patches/nct6775-wim.patch
wget https://github.com/torvalds/linux/raw/master/drivers/hwmon/lm75.h
wget https://github.com/torvalds/linux/raw/master/drivers/hwmon/nct6775.c
wget https://gist.github.com/greenbigfrog/26f948c9d86f1cb2fd23bfeaa23ca068/raw/44bb330af6fced59bb4a3cd79a81cc13a34aca93/Makefile
wget https://gist.github.com/greenbigfrog/26f948c9d86f1cb2fd23bfeaa23ca068/raw/44bb330af6fced59bb4a3cd79a81cc13a34aca93/dkms.conf

(Also, all at https://gist.github.com/greenbigfrog/26 … eaa23ca068 )


The nct6775.ko is there in /usr/src/nct6775-wim/, and yet dkms complains with:

Kernel preparation unnecessary for this kernel. Skipping...
patch -p1 < ./patches/nct6775-wim.patch
patching file nct6775.c


Building module:
make -C /usr/lib/modules/5.14.2-arch1-2/build M=/var/lib/dkms/nct6775/wim/build clean
make: Entering directory '/usr/lib/modules/5.14.2-arch1-2/build'
  CLEAN   /var/lib/dkms/nct6775/wim/build/Module.symvers
make: Leaving directory '/usr/lib/modules/5.14.2-arch1-2/build'

{ make -j12 KERNELRELEASE=5.14.2-arch1-2 -C /lib/modules/5.14.2-arch1-2/build M=/usr/src/nct6775-wim -d; } >> /var/lib/dkms/nct6775/wim/build/make.log 2>&1

Error!  Build of nct6775.ko failed for: 5.14.2-arch1-2 (x86_64)
Make sure the name of the generated module is correct and at the root of the
build directory, or consult make.log in the build directory
/var/lib/dkms/nct6775/wim/build/ for more information.

Previously I had missed the "/var/lib/dkms/nct6775/wim/build/" in the output above, and wow, suprise, the nct6775.ko isn't in /var/lib/dkms/nct6775/wim/build/, but it does exist in /usr/src/nct6775-wim/.
Why am I ending up with files in the wrong place?

I've been learning a lot about this stuff today, but still throwing wild guesses at it.
If anyone is able to spot my error, or provide some good documentation explaining what I might have missed, please let me know.

Thanks.

Last edited by greenbigfrog (2021-09-16 22:10:28)

Offline

#2 2021-09-13 17:11:00

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: [SOLVED] Building dkms module, trouble choosing proper paths etc

What if you remove the MAKE entry from dkms.conf so it uses the default "make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"

Last edited by loqs (2021-09-13 17:11:27)

Offline

#3 2021-09-13 17:29:44

greenbigfrog
Member
Registered: 2017-12-06
Posts: 33

Re: [SOLVED] Building dkms module, trouble choosing proper paths etc

Yeah, thanks. That worked.
So if I understand correctly, it's due to it pulling in the linux Makefile, which has the other paths, and they basically end up pointing to different places. Would that be correct?

Now to figure out why the patch isn't helping me. (modinfo is showing that it's loading wmi now, but somehow still getting the ACPI Warning.) But I think this is out of scope for this post.

Offline

#4 2021-09-13 19:55:04

loqs
Member
Registered: 2014-03-06
Posts: 17,372

Re: [SOLVED] Building dkms module, trouble choosing proper paths etc

You had

MAKE="make -C /lib/modules/`uname -r`/build M=$PWD -d"

which expanded to

make -C /lib/modules/5.14.2-arch1-2/build M=/usr/src/nct6775-wim -d

Which is why the build was using /usr/src/nct6775-wim
Also because you use `uname -r` it will always build for the running kernel rather than the kernel that DKMS build is targeting.

Offline

#5 2021-09-16 22:10:06

greenbigfrog
Member
Registered: 2017-12-06
Posts: 33

Re: [SOLVED] Building dkms module, trouble choosing proper paths etc

Alright. Thanks. Marking solved

Offline

Board footer

Powered by FluxBB