Dkms not triggered on update

Hello. I’m using external module for my wifi. I followed this guide https://clearlinux.org/documentation/clear-linux/guides/maintenance/kernel-modules-dkms to automate rebuilding of the module on kernel update. But dkms build/install is not triggered on update. I checked the dkms-new-kernel.service and the status is inactive:

pm@clrlinux~ $ sudo systemctl status dkms-new-kernel
Password:
● dkms-new-kernel.service - Run DKMS to build modules for new kernel
Loaded: loaded (/usr/lib/systemd/system/dkms-new-kernel.service; static; vendor preset: disabled)
Active: inactive (dead)

I can manually start the service but after reboot it is again inactive. What should I do? Thanks.

P.S. When I run dkms build … dkms install … there are no errors and module is correctly installed.

Does dkms status show that the modules are built against the currently running kernel?

It is ok that the dkms-new-kernel.service is “disabled” and not running because it is meant to be activated on-demand by the update-trigggers.target and immediately exit after an update.

You should however see some output from the sudo systemctl status dkms-new-kernel command if an update has occurred.

If you crack open the dkms-new-kernel.service with the command systemctl cat dkms-new-kernel.service you’ll see it’s calling a very simple script at /usr/bin/dkms-new-kernel.sh. You can try running this script manually.

OK, thank you. I’ll wait next kernel update and will check output of systemctl status dkms-new-kernel after the update.
I saw the script it calls dkms autoinstall … if there is new kernel, I’ll run it manually on next update if dkms service is not activated again.

Hi puneetse. I just updated my system to kernel 5.1.12.
I run sudo systemctl status dkms-new-kernel and it showed that dkms-new-kernel.service “Succeeded”, but when I checked /lib/modules/5.1.12-785.native/kernel/drivers/net/wireless again my module wl.ko (broadcom wl driver) wasn’t there. Then I run /usr/bin/dkms-new-kernel.sh but it did nothing. I realized that the script is using dkms autoinstall which requires AUTOINSTALL=yes directive in dkms.conf file. After I set AUTOINSTALL=yes in conf file and run dkms-new-kernel.sh again it worked. The problem is that initially I copied dkms.conf example from the “Add kernel modules with DKMS” guide in CL docs and it doesn’t mention that you should have AUTOINSTALL directive set to yes.

Now after reboot I have another problem. Driver is not loaded on boot and in dmesg I have following error:
wl: version magic ‘5.1.11-784.native SMP mod_unload’ should be ‘5.1.12-785.native SMP mod_unload’

When I run sudo modprobe wl I got following error:
modprobe: ERROR: could not insert ‘wl’: Exec format error

Nice work figuring out the AUTOINSTALL=yes nuance that is required in the dkms.conf for the system to work @p_m. We can certainly update the documentation to make a note about this.

I suspect your second issue is due not having rebooted yet (i.e. the module has been compiled against the newest kernel on disk, but the running kernel is still an older one from before the update).

@btwarden Your 2c please. Do you think we should change the dkms-new-kernel.sh based of this? I’m thinking using dkms autoinstall still makes sense to differentiate between modules people may want updated with kernel updates versus ones they want to keep closer eye over.

Yes, otherwise we’d basically have to implement autoinstall ourselves to try to figure out which modules to update.

Most likely, there’s something wrong with the makefile or other build configuration in the module source directory itself. It sounds like it’s building against the current, running kernel (ignoring the parameters provided by dkms), but installing to the specified version directory. Aside from fixing the driver’s makefile(s), rebooting to the latest kernel and rebuilding it will probably get you past this hurdle, but only until the next kernel update.

Thank you @puneetse and @btwarden. Obviously now the problem is not in CL, so I’ll stop wasting your time. I’ll read more to figure out how to properly configure dkms. If I find what is the problem with my configuration I’ll post it here.