0

My situation:

I have a prebuilt kernel running fedora already installed and running. Now, I want to install the mcp251x and mcp25xfd driver modules, which depends on the can-dev driver module, so I need to install that one too. Apparently, the source code for these modules existed in the kernel source for this version, but my guess is that they were not "enabled" via the .config file during the kernel compilation. So this is an after-the-fact driver module installation attempt.

I've never done this, so please guide me if there is an easier way.

What I've tried:

I first went into the /lib/modules directory and looked to see if my 3 modules already existed, ready to be installed. I found one of them: can-dev.ko.xz

So I install it:

$ sudo insmod can-dev.ko.xz

This completes, no error message. For the other 2 modules, I see the source code for them and a makefile, but calling "make" just says "No targets" and fails to build.

I then looked at the version using uname -a:

Linux fedora 5.11.3-300.fc34.x86_64

So I go and download the source code for 5.11.3 from: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/refs/tags

I check my current compiler version:

$ gcc --version
$ gcc (GCC) 11.0.0 20210210 (Red Hat 11.0.0-0) 

I verify that this is the same gcc version used to build the kernel:

$ cat /proc/version
$ gcc (GCC) 11.0.0 20210210 (Red Hat 11.0.0-0)

So apparently I can't just go into the driver folder and call "make", even though it has a makefile. The driver makefile is all tangled together with the kernel makefile, so I go into the kernel source code root directory and modify the Makefile:

EXTRAVERSION = -300.fc34.x86_64

This ensures the "vermagic" string in the module is compatible with the currently installed OS version.

Then, in the kernel source code root directory, I call:

$ make oldconfig

This generates a .config file. I manually edit the .config file to add these lines:

CONFIG_CAN_MCP251X=m
CONFIG_CAN_MCP251XFD=m

This tells the kernel to build MCP251x and MCP251xfd as modules (they were defaulted to not build at all).

I then call

$ make prepare

Then, I cd into the specific driver directory I am trying to build (which contains c code and a Makefile), and call:

$ make -C ~/linux-5.11.3 M=`pwd` modules

Which calls the kernel-source-root Makefile with some special arguments instructing to only build the kernel modules in the current directory. This works, and it generates the files mcp251xfd.ko and mcp251x.ko.

I try to install these modules:

$ sudo insmod mcp251x.ko
$ sudo insmod mcp251xfd.ko

But both return the following error message:

insmod: ERROR: could not insert module mcp251xfd.ko: Invalid module format

and a call to

$ dmesg

Returns:

module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 00000000abe7d4fb, val ffffffffc10b3a77

The only thing I know left to check is that the magic number matches to uname -r number:

$ uname -r
5.11.3-300.fc34.x86_64

Check against module:

$ modinfo mcp251xfd.ko
vermagic: 5.11.3-300.fc34.x86_64

So I'm out of ideas on what to do or try to get these drivers installed.

0

The kernel linux-5.11.3 is not the same one as supplied with your distro, which is 5.11.3-300.fc34. That -300.fc34 makes all the difference. It has RH updates added.

Download the kernel source using yum, since it appears to be Fedora 34.

Change directory into /usr/src/<source dir>, then run make oldconfig && make menuconfig or make oldconfig && make xconfig and locate Networking Support->CAN bus subsystem support->CAN device drivers->CAN SPI Interfaces, and you will find the devices listed and tick them.

Once that is done, you can run make modules modules_install && depmod -a and the kernel modules will be somewhere under /lib/modules.

However, these will probably still fail to load if kernel module signing is in place.

If so, one option would be to fully rebuild a kernel and install it.

An alternative is to ask RH to enable those modules with the next kernel update.

Or you can generate your own CA cert and code signing cert, sign the new modules and load parent cert into the UEFI DB.

You may get away with ensuring the UEFI is not configured for secure boot

You are going to get your hands very dirty....

I think I've covered everything...

As an aside, do you really need these modules for a pc?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.