Jump to content

How to use the kernel source to cross compile an .ko kernel module?


Recommended Posts

Posted

I could set up the `armbian/build` repository to compile the kernel for my board. I would like to compile an out-of-tree kernel module on the host machine and copy it to the target machine. I understand that my target machine (Nano Pi Neo Air) has enough resource to compile the module but I just want to try this out. I built the kernel with the following command:

./compile.sh BOARD=nanopiair BRANCH=current KERNEL_CONFIGURE=prebuilt KERNEL_ONLY=yes CLEAN_LEVEL="" KERNEL_CONFIGURE=no CLEAN_LEVEL= KERNEL_KEEP_CONFIG=yes BUILD_MINIMAL=yes BUILD_DESKTOP=no
EXTERNAL=no

The problem I encountered was that the kernel source (~/build/cache/sources/linux-mainline/orange-pi-5.10) will clear after build, so if I build my kernel module with this source, it prompted that files like 

`./scripts/basic/fixdep` are missing. I tried to fixed it by running `make  ARCH=arm CROSS_COMPILE=.....` . The compilation succeeded. But the kernel module compiled with this source is not compatible with my kernel, because the vermagic (modinfo) is `5.10.60+ SMP mod_unload ARMv7 thumb2 p2v8` rather than `5.10.60-sunxi SMP mod_unload ARMv7 thumb2 p2v8`.

 

I wonder how could I retain the kernel build after running `./complile.sh` so that I can reuse it for kernel module cross compilation purpose?

 

Thank you!

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines