MoodeAudio
Posts: 2
Joined: Thu Sep 26, 2019 12:11 pm

How to maintain correct module_layout value when compiling driver

Thu Sep 26, 2019 2:52 pm

Hi,

I'm just getting started with kernel / driver compiles and I'm trying to determine how to maintain the correct module_layout value when compiling a custom driver. The driver is compiled on a Pi dedicated to kernel builds and then installed into a target Pi running a stock rpi-update kernel. The kernel sources used are same version as target system rpi-update kernel for example 4.19.73-v7+ #1265.

I'm downloading the kernel sources by Git hash from https://github.com/raspberrypi/linux/commits/rpi-4.19.y

The process I'm using to compile the driver is the kernel build recipe documented at https://www.raspberrypi.org/documentati ... uilding.md.

Code: Select all

- After "sudo make -j4 zImage modules dtbs" I copy the custom driver .h and .c files to the appropriate dir in the source tree
- Then "sudo make -j4 modules"
- Then copy the driver.ko file to the appropriate dir on the target system
When the target system boots the driver fails to load and the error below is logged.

Code: Select all

[email protected]:~ $ dmesg | grep ax88
[    6.235563] ax88179_178a: disagrees about version of symbol module_layout
The original and custom driver have different module_layout values

Code: Select all

# Original driver included in stock kernel
[email protected]:/lib/modules/4.19.73-v7+/kernel/drivers/net/usb $ modprobe --dump-modversions ax88179_178a.ko.orig | grep module_layout
0xf230cadf      module_layout

# Custom  driver
[email protected]:/lib/modules/4.19.73-v7+/kernel/drivers/net/usb $ modprobe --dump-modversions ax88179_178a.ko.tim | grep module_layout
0xae9bea50      module_layout
-Tim

Kendek
Posts: 145
Joined: Thu Jul 25, 2019 4:39 pm
Location: Kaposvár, Hungary

Re: How to maintain correct module_layout value when compiling driver

Thu Sep 26, 2019 5:40 pm

So you maybe significantly modified the source code, that's why the module_layout value change.
Try to edit your .ko file with a hex editor, change the value to match the original.

Image

MoodeAudio
Posts: 2
Joined: Thu Sep 26, 2019 12:11 pm

Re: How to maintain correct module_layout value when compiling driver

Thu Sep 26, 2019 6:12 pm

That approach has come up in my research on the subject.

Do you know if thats the technique used for the drivers that are available as part of the nice install-wifi utility from MrEngman?

Return to “Advanced users”