Kernel module compatibility issue

I’m trying to load a kernel module onto a Jetson TX2, but I’m having compatibility issues with the precompiled module. The kernel version of the module matches with the kernel version of my OS; however, I am getting the error: “module: disagrees about version of symbol module_layout” when I try and load the module with “insmod”. I’ve attached a relevant screenshot below:

I’ve attempted to recompile the module on my machine; however, I cannot get the Makefile to work. It throws a list of “command not found” errors when I attempt to execute it. My guess is that recompiling the module on my machine while solve the module_layout issues, but I’m stuck trying to get the module to recompile.

Attached are the .ko file and Makefile for this module. I can upload the additional files required to execute the Makefile if needed.

pixci_aarch64.ko (207.6 KB)

Makefile (2.2 KB)

What shows by uname -a
Do you define local version by export LOCALVERSION=-tegra to build kernel?

uname -a shows the following:

Linux tx2-elroy 4.9.140 #1 SMP PREEMPT Mon Jun 8 10:38:13 IST 2020 aarch64 aarch64 aarch64 GNU/Linux

I’m not sure how to implement “export LOCALVERSION=-tegra”. Should this command get included in the Makefile? Also, here’s the output when I try executing the Makefile:

I’m not sure why I’m getting these “command not found” errors". These commands look to be implemented correctly in the original Makefile.

Btw, you would never use a Makefile with “./Makefile”. You’d use the “make” command, and this would default to using file “Makefile”. “Makefile” is not an executable file, it is a specification the “make” command reads. What happens if you run the command “make” in the directory with the “Makefile”?

Here’s the output when I try using “make”

I tried making the directory “/lib/modules/4.9.140/build” but it says the file already exists. However, if I try to change directory to “/lib/modules/4.9.140/build” it says there is no such file or directory.

It looks like you are compiling directly on the Jetson. Correct me if I am wrong about this, but other than the possibility of running out of disk space this is the simplest build.

There are a number of steps you have to take to configure the source of a kernel build prior to actually building. I will suggest that you look at the docs for building a kernel, and that once you can “make Image” (the uncompressed kernel), then you can build any subtarget without issue. For example, if Image can build, then your particular module can be built. The error you mention is actually good since it says “make” is now working (and not trying to execute “Makefile” as a program). However, one would not modify the Makefile of kernel source, so I am suspicious of this Makefile.

I will recommend downloading clean source for your kernel, and then building as follows (this is sort of a note on native compile directly on the Jetson) once you know you have plenty of disk space (assumes your kernel source is unpacked to “/usr/src/sources/kernel/kernel-4.9”):

# --- Setting Up: -------------------------------------------------------
# DO NOT BUILD AS ROOT/SUDO!!! You might need to install source code as root/sudo.
mkdir -p "${HOME}/build/kernel"
mkdir -p "${HOME}/build/modules"

export TOP="/usr/src/sources/kernel/kernel-4.9"
export TEGRA_KERNEL_OUT="${HOME}/build/kernel"
export TEGRA_MODULES_OUT="${HOME}/build/modules"
export TEGRA_BUILD="${HOME}/build"

# --- Notes: ------------------------------------------------------------
# It is assumed kernel source is at "/usr/src/sources/kernel/kernel-4.9".
# Check if you have 6 CPU cores, e.g., via "htop" (the TX2 has 6 cores).
# If you are missing cores, then experiment with "sudo nvpmodel -m 0, -m 1, and -m 2".
# Perhaps use "htop" to see core counts.
# Using "-j 6" in hints below because of assumption of 6 cores.
# -----------------------------------------------------------------------

# Compile commands start in $TOP, thus:
cd $TOP

# Need to emphasize, perform the note step regarding copy of "`config.gz`".
# Do not forget to provide a starting configuration. Probably copy of "/proc/config.gz",
# to $TEGRA_KERNEL_OUT, but also perhaps add additional customization via:
make O=$TEGRA_KERNEL_OUT nconfig
# You might need to install "`sudo apt-get install libncurses5-dev`" for "`nconfig`" to work.

# If building the kernel Image:
make -j 6 O=$TEGRA_KERNEL_OUT Image
# Note that you only want a module, but building Image has a side effect of propagating
# configuration...this is the "acid test" to know your module will compile, plus a basic
# sanity check to perform at least once.

# If you did not build Image, but are building modules:
make -j 6 O=$TEGRA_KERNEL_OUT modules_prepare
# The above is not needed if you successfully built target "Image".

# To build modules:
make -j 6 O=$TEGRA_KERNEL_OUT modules

# To build device tree content:
make -j 6 O=$TEGRA_KERNEL_OUT dtbs

# To put modules in "$TEGRA_MODULES_OUT":
make -j 6 O=$TEGRA_KERNEL_OUT INSTALL_MOD_PATH=$TEGRA_MODULES_OUT

The above has other content you don’t necessarily need, e.g., in your case you don’t need to build or install target “dtbs” (device tree).

In your case, when you “make nconfig”, you can use that editor to enable the module you want to add. Then you can simply copy that module file to the right place and it should “just work”.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.