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!

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines