/home/lucio.albenga.es

FreeBSD: KLD i915kms.ko depends on kernel - not available or version mismatch

After upgrading from FreeBSD 14.1 to FreeBSD 14.2 some people like me had some problems because the graphics modules were built for 14.1 only. One of the drawbacks was loosing access to virtual terminals. Let's see how I solved that problem and I got rid of the: "KLD i915kms.ko depends on kernel - not available or version mismatch", error.

First attempt

At first, I checked out the internet and it seems it was a documented problem. Many people were telling to rebuild the drm-61-kmod package from ports tree, so I tried that approach first.

Following The FreeBSD Handbook1, I cloned the ports tree from git:

git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports

Then I built the drm-61-kmod:

cd /usr/ports/graphics/drm-61-kmod/
make
make install

I got a message about that I already have that module installed followed by the instructions to reinstall it, so I executed make reinstall on my console, restarted the system, and hoped for the best. It didn't work.

I kept searching for my problem and I found another thread about rebuilding drm-kmod too. I did it:

cd /usr/ports/graphics/drm-kmod/
make
make reinstall

But it didn't work. I noticed that I got the following error on dmesg: KLD i915kms.ko depends on kernel - not available or version mismatch. I know I have the module loaded, so I started to look for other modules that maybe I need to build in ports, especially things related to i915. I found the port /usr/ports/graphics/gpu-firmware-kmod, so I built it:

cd /usr/ports/graphics/gpu-firmware-kmod/
make
make reinstall

Restarted the system only to find out that the very same error was still there.

Second attempt

At that point I thought: "ok, maybe I messed up by building the modules in a wrong order or something. Let's redo it". First, I uninstalled and cleaned the build of all those modules:

cd /usr/ports/graphics/gpu-firmware-kmod/
make deinstall
make clean

cd ../drm-61-kmod/
make deinstall
make clean

cd ../drm-kmod/
make deinstall
make clean

Then I rebuilt the modules. This time I started by building drm-kmod. Doing this I discovered that drm-kmod automatically builds also drm-61-kmod. I built also the gpu-firmware-kmod, installed the modules and restarted the system. This time for sure things are going to work… Nope! After rebooting the system, dmesg was still showing that damn message.

Final solution

I'm new to FreeBSD, but I was using, setting up, and administering GNU/Linux systems since the 90s, thus I thought the solution to that pesky KLD i915kms.ko depends on kernel - not available or version mismatch error, could be solved by building a new kernel and the modules, to have everything in sync.

I cloned the kernel sources from FreeBSD's git2

git clone https://git.FreeBSD.org/src.git

Then I checked out the sources for the kernel version for FreeBSD 14.2 (at the moment of this writing they are under the tag release/14.2.0-p3):

git fetch --all --tags --prune
git checkout release/14.2.0-p3

Then I rebuilt the GENERIC kernel because I don't use a custom one. If you use a custom kernel, you already know the steps you should take to build it.

cd /usr/src
make buildkernel KERNCONF=GENERIC
make installkernel KERNCONF=GENERIC

With the new kernel, I rebuilt and reinstalled the modules:

cd /usr/ports/graphics/gpu-firmware-kmod/
make deinstall
make clean

cd /usr/ports/graphics/drm-61-kmod/
make deinstall
make clean

cd /usr/ports/graphics/drm-kmod/
make deinstall
make clean
make
make install

cd ../drm-61-kmod/
make install

cd ../gpu-firmware-kmod/
make
make install

Then I restarted the system and now everything works as expected. Mission accomplished!

Final words

I have to say that it was really fun because it took me back to the good old days when you had to compile the Linux kernel in order to make your hardware work. I haven't compiled a kernel in about 20 years or so. Probably there is a better approach but this one worked for me and maybe it will work for others too.