Version Magic does not match in kernel module

Hi,

When trying to insert a simple kernel-module, i get the following error:

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

And dmesg outputs the following:

main: version magic '3.10.67 SMP preempt mod_unload aarch64' should be '3.10.67-tegra SMP preempt mod_unload aarch64'

Where the kernel-module i compiled is missing the “-tegra” part of the vermagic version.

The board is flashed with the pre-compiled R24.1 L4T release, and i myself compiled the kernel source given for R24.1 and used to build kernel-module is build from that.

So the question is, in order to get the vermagic version to match. Do i need to flash the board with the version i compiled, or is there a setting i am missing?

R24.1 is a beta release, the most recent release was just in the last couple of days and is R23.2. There may be some custom version numbering associated with R24.1 (not sure), but can you flash R23.2 instead and try that?

FYI, the kernel source provides the main kernel numbering, e.g., the 3.10.67, while CONFIG_EXTRAVERSION provides any suffix, e.g., “-tegra” is a CONFIG_LOCALVERSION suffix. You would have to add “-tegra” to this in the config prior to building the kernel for them to match.

EDIT: It used to be CONFIG_EXTRAVERSION was used, but these days it is CONFIG_LOCALVERSION. I’m not sure what the story is behind those two config items doing the same thing. So far as I know, they are identical, other than the menuconfig and other frontend config editors use CONFIG_LOCALVERSION. My little brain-burp for mentioning EXTRAVERSION instead of LOCALVERSION.

The R23.2 gave me the same error:

main: version magic '3.10.67 SMP preempt mod_unload aarch64' should be '3.10.67-g458d45c SMP preempt mod_unload aarch64'

But many thanks for your FYI, thanks to that i was able to change the CONFIG_LOCALVERSION to the missing suffix, and thereby successfully inserting the device driver… Thank you very much linuxdev! :)

Hello linuxdev,

I got the same problem on Jetpack 3.2.1:

[ 95.526310] Unsupported IOCTL call
[ 195.319315] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’
[ 226.442564] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’
[ 251.176083] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’
[ 413.739114] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’
[ 700.912929] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’
[ 755.360108] IPVS: Creating netns size=1424 id=5
[ 2399.801465] time_synchronizer_lkm: version magic ‘4.4.38-tegra SMP preempt mod_unload aarch64’ should be ‘4.4.38+ SMP preempt mod_unload aarch64’

My: CONFIG_LOCALVERSION=""
is empty. How should I do?

Under “/usr/src” I have two “linux-headers-4.4.3.38-tega” and “linux-headers-4.4.38+”. And under “/lib/modules” I have only “4.4.38+”. Which one should I use? I find “.config” file under two header folder, should change CONFIG_LOCALVERSION there?

Best Regards,
Tao Wang

Some kernel sources can add the “+” to the “uname -r”. Normally it is the kernel base version (4.4.38 in this case), plus CONFIG_LOCALVERSION (in this case “-tegra”). This particular source has its own “+” on top of this. Kernel modules will be searched for with this kernel at “/lib/modules/$(uname -r)/”, thus:

/lib/modules/4.4.38-tegra+/

This means you need to place all of your modules in that directory in order for this kernel to find them. There may be options in place which force versions to be the same, and then you need to build your modules as well and place all of the modules at the above location.

FYI, before you put in or build a new kernel you should always know what the current “uname -r” is. You should also save a copy (with the known working kernel) of “/proc/config.gz”. Unless your original “uname -r” did not have anything except the “4.4.38”, you should have CONFIG_LOCALVERSION.

The recommended kernel source is from the driver package script “source_sync.sh”. This is in the “Linux_for_Tegra/” subdirectory of the driver package…and if you used JetPack, then this is there also because JetPack downloads the driver package. This script can be copied to the Jetson, e.g., copy it to “/usr/local/src/”. Then run based on which L4T release you are interested (this example is for R28.2, adjust for your system):

./source_sync.sh -k tegra-l4t-r28.2

This would be the most authoritative version of kernel source for your Jetson.

This is written for the TX2, but other than substituting “jetson-tx1” for “jetson-tx2” it should be the same:
https://devtalk.nvidia.com/default/topic/1038175/jetson-tx2/tx2i-wifi-support/post/5274619/#5274619

FYI, I suggest booting to the original kernel, getting a copy of “/proc/config.gz” for future use, and then building a kernel.

Thanks linuxdev,

As I understand, I need to rebuild the kernel, am I right?

Is there any way to solve the problem without rebuilding the kernel?

My “$uname -r” is “4.4.38+”, not “4.4.38-tegra+”.

I checked the folder “/usr/src/linux-headers-4.4.38+” is empty.

There is “.config” file in /usr/src/linux-header-4.4.38-tegra", “CONFIG_LOCALVERSION” is “” in default, I play with it with “-tegra”, “+”, but no effect.

Best Regards,
Tao

The “+” was a result of rebuilding the kernel. The version magic requirement is a need to rebuild the modules due to change in the Image/kernel. It is probably a mistake that the kernel had been built without any CONFIG_LOCALVERSION, this is why it is only “4.4.38+”. Either way it means your kernel won’t find the modules unless you have rebuilt them and put them in the “/lib/modules/$(uname -r)/” directory tree.

The fact that “-tegra” is seen in most places is a result of having “-tegra” for CONFIG_LOCALVERSION. Most people should build modules with this set to “-tegra” to match. If you changed something in the base Image (and not just modules), then you might want to change to something like “-custom”.

Btw, if you have the full source code (such as via source_sync.sh), then you don’t need the headers directory.

Use “make mrproper” to clean all out, copy the “/proc/config.gz” (and gunzip after to decompress, then mv to file name “.config”), and then set CONFIG_LOCALVERSION before you do anything else.