简体   繁体   中英

Compile Kernel Module for different Kernel

i am working with an embedded linux system, which i don't have kernel sources or headers too. Also i can not simply use another kernel.

However i got the kernel sources for another kernel-version and can compile that module for that kernel. But i can't load that module on my target system, because dmesg is saying 'version magic'

So, can i somehow make the module with a reference to another kernel? Where does the information about the kernel-version is read?

My target system has the kernel version '3.18.11-tegra', the kernel sources are 3.18.19..

Of course, your plan can only succeed if that module works unaltered with both kernel-versions, which is often the case; then you could plant SUBLEVEL = 11 in the top level Makefile of your 3.18.19 kernel sources.

Did the same thing some time ago on a different system You will need download and compile the 3.18.11 kernel using their config. Go to https://www.kernel.org/pub/linux/kernel/ and download 3.18.11 Unzip kernel into /usr/src/linux-3.18.11, cd into it then copy the current config

make mrproper zcat /proc/config.gz >.config make oldconfig make

After you compile your kernel you need to create 2 symlinks under /usr/src

ln -s linux-3.18.11 linux-3.18.11-tegra ln -s linux-3.18.11 linux

Now you should be able to compile your module with:

make -C /lib/modules/$(uname -r)/build M=$(pwd) module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM