This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: Include paths when cross-compiling kernel module

Part Number: AM6442

Dear TI team,

I am trying to cross-compile my own kernel module from my Ubuntu machine to my Sitara AM6442 with linux 6.1.33-rt11-g685e771524. I include the standard headers

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>

and I receive the following error:

aarch64-none-linux-gnu-gcc -O2 -c -D__KERNEL__ -DMODULE -Wall -I/home/leon/sdk/board-support/ti-linux-kernel/include -I/home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include -c -o sm_mod.o sm_mod.c
In file included from /home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include/asm/lse.h:5,
from /home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include/asm/cmpxchg.h:14,
from /home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include/asm/atomic.h:16,
from /home/leon/sdk/board-support/ti-linux-kernel/include/linux/atomic.h:7,
from /home/leon/sdk/board-support/ti-linux-kernel/include/asm-generic/bitops/atomic.h:5,
from /home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include/asm/bitops.h:25,
from /home/leon/sdk/board-support/ti-linux-kernel/include/linux/bitops.h:68,
from /home/leon/sdk/board-support/ti-linux-kernel/include/linux/kernel.h:22,
from sm_mod.c:1:
/home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include/asm/atomic_ll_sc.h:123:30: error: unknown type name ‘atomic64_t’; did you mean ‘atomic_t’?
123 | __ll_sc_atomic64_##op(s64 i, atomic64_t *v)

I have tried various variants of include paths (e.g. "arm" instead of "arm64"), hoping that the required files/definitions would be found, but it does not work. What are the correct include paths that I need?

Many thanks

Leon Rigoni

  • Hi Leon,

    aarch64-none-linux-gnu-gcc -O2 -c -D__KERNEL__ -DMODULE -Wall -I/home/leon/sdk/board-support/ti-linux-kernel/include -I/home/leon/sdk/board-support/ti-linux-kernel/arch/arm64/include -c -o sm_mod.o sm_mod.c

    This compile command is not correct. You cannot simply just use gcc to compile the kernel module c files. You have to have a kernel-style Makefile.

    Attached below is a Makefile I used to build my off-tree kernel module. You can use it as a reference.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/8461.rules.make

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/8461.Makefile

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/Kbuild