user1951358
user1951358

Reputation: 21

crosscompile a linuxmodule for arm(raspberryPi)

Im trying to crosscompile a (example)linuxmodule for the raspberryPi(arm), with crosstool-ng 1.15.3.

I got the following output:

markus@markus-R55S:~/Desktop/speakerarm$ make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- 
make -C /lib/modules/3.2.0-35-generic-pae/build SUBDIRS=/home/markus/Desktop/speakerarm modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-35-generic-pae'
  CC [M]  /home/markus/Desktop/speakerarm/speaker.o
In file included from /usr/src/linux-headers-3.2.0-35-generic-pae/arch/arm/include/asm/types.h:4:0,
                 from include/linux/types.h:4,
                 from include/linux/list.h:4,
                 from include/linux/module.h:9,
                 from /home/markus/Desktop/speakerarm/speaker.c:1:
include/asm-generic/int-ll64.h:11:29: fatal error: asm/bitsperlong.h: No such file or directory
compilation terminated.
make[2]: *** [/home/markus/Desktop/speakerarm/speaker.o] Error 1
make[1]: *** [_module_/home/markus/Desktop/speakerarm] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-35-generic-pae'
make: *** [default] Error 2

I guess there is something wrong with the include-path. My Hostmachine has the Kernel 3.2.35, my target machine the 3.2.27+. What is my mistake? The Makefile contains the following:

obj-m   := speaker.o

KDIR    := /lib/modules/$(shell uname -r)/build
PWD     := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Upvotes: 2

Views: 3508

Answers (2)

duslabo
duslabo

Reputation: 1517

Download kernel 3.2.27 rpi-3.3.27, and follow the steps mentioned in RPi_Kernel_Compilation

Upvotes: 0

marko
marko

Reputation: 9159

A couple of things to watch for:

  1. You're compiling against your development host's linux source tree - which judging from the -generic-pae post-fix is possibly not the kernel mainline. ARM SoC changes take a long time to find their way into the main-line, and even less quickly into other non-ARM kernel branches. You would be advised to find the kernel tree into which your SoC's changes are integrated and get a tagged version such as 3.2 rather than head.

  2. Did you configure the linux build system for building an ARM kernel? e.g.

export ARCH=arm

make clean

make rpi_defconfig

If you didn't, your kernel will be configured for x86 build and headers in the /arch/arm folder won't be available - even though you're set ARCH

It would be a good idea to attempt to build a full kernel and ensure that works first before building modules.

Upvotes: 1

Related Questions