I'm trying to cross compile a module for ARM. I am using a Sabrelite as a board with 3.0.35 kernel version. I'm using open-embedded to generate the kernel image.
I have all of the toolchain needed for the cross compilation as cited below:
echo $CC :
arm-oe-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/usr/local/oecore-x86_64/sysroots/cortexa9hf-vfp-neon-oe-linux-gnueabi
echo $CROSS_COMPILE: arm-oe-linux-gnueabi-
echo ARCH: arm
(This is just some part of my toolchain.)
This is part of my makefile:
KSRC = kaodv-mod.c kaodv-debug.c kaodv-netlink.c kaodv-queue.c kaodv-ipenc.c kaodv-expl.c
KERNEL_DIR=/home/user/script_emulation/AODV/kernel
KERNEL_INC=$(KERNEL_DIR)/include THIS_DIR=$(shell pwd)
obj-m += kaodv.o kaodv-objs := kaodv-mod.o kaodv-debug.o kaodv-netlink.o kaodv-queue.o kaodv-ipenc.o kaodv-expl.o
default:
$(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(THIS_DIR) modules
when I launch it with make command, I get a module (.ko) but the weird thing is that the module generated is compiled with my host machine toolchain which means that the makefile is invoking the native compiler instead of the cross compiler. What am I doing wrong? The cross compiler's binaries are in my path.
This is part of the output I get on terminal:
CC /home/user/script_emulation/AODV/aodv-uu/lnx/kaodv.mod.o
LD [M] /home/user/script_emulation/AODV/aodv-uu/lnx/kaodv.ko
We can see there that native CC and LD is used instead of the the cross compiler tools
Can anyone suggest a solution ?
thanks
Update:
$ readelf -h kaodv.ko
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 13480 (bytes into file)
Flags: 0x5000000, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 33
Section header string table index: 30
make V=1 ...
to see what it's actually doing. Can you confirm the .ko file really is the wrong format, with e.g. readelf? – Notlikethatreadelf -h kaodv.ko
, and any error thatinsmod
on the target system returns, to the question? – Notlikethat