I've built an android kernel (source code), now I'm trying to cross-compile a kernel module for it, v4l2loopback
to be precise. I've used this toolchain to build the kernel (kernel version is 4.9).
Here on github you can see that someone actually succeeded in compiling the module, and I've been trying to replicate their success myself. But in the last stage of actually building the kernel module I don't get a .ko
file output. Here is what I get:
# setting up
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-android-
$ export PATH=/home/username/redmi_7a/aarch64-linux-android-4.9-kernel/bin:$PATH
# go to the source code directory
$ cd v4l2loopback
$ export M="$PWD"
# I have the compiled kernel at /home/username/redmi_7a/kernel
make -C ../kernel
make: entering catalogue «/home/username/redmi_7a/kernel»
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK scripts/mod/devicetable-offsets.h
Building modules, stage 2.
MODPOST 4 modules
make: exiting catalogue «/home/username/redmi_7a/kernel»
Seems like no errors, no nothing, but all I get is a v4l2loopback.o
file, instead of v4l2loopback.ko
file, as mentioned per v4l2loopback github page.
I tried find . -name "*.ko"
, but it didn't return anything.
I might've screwed something up during the kernel compilation, so it might not module's fault. I don't really know where to look, I'm really new to this.
Maybe I need to set some flag in the kernel .config
file and recompile?
All I really ask is a direction, what are the things I might've done wrong?
You seem to be building incorrectly. With make -C ../kernel
you are completely ignoring the Makefile
that is in the repository of the module you are trying to build and using the kernel Makefile
alone. You should take a look at the Makefile
inside v4l2loopback
and notice the following lines at the beginning of the file:
include Kbuild
ifeq ($(KBUILD_MODULES),)
KERNELRELEASE ?= `uname -r`
KERNEL_DIR ?= /lib/modules/$(KERNELRELEASE)/build
PWD := $(shell pwd)
...
So the PWD
and kernel dir are already set for you. You should just override KERNEL_DIR
and the needed cross-compilation variables:
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-android-
export PATH=/home/username/redmi_7a/aarch64-linux-android-4.9-kernel/bin:$PATH
export KERNEL_DIR=/home/username/redmi_7a/kernel
cd v4l2loopback
make
The above works on my machine and correctly produces v4l2loopback.ko
. Make sure you have built the kernel before doing this of course.