Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

c - Cross-compiling of kernel module for ARM architecture

I'm trying to make a .ko file for ARM from a linux x86 machine. I tried the following Makefile:

1 obj-m +=helloworldtest_module.o 
2 modules_install:
3     make ARCH=$(ARCH) CC=$(CROSS_COMPILER) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
4 clean:
5     make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

... but I got an error on giving make -f Makefile ARCH=arm CROSS_COMPILER=arm-linux-gnueabi-gcc in command prompt as follows:

make ARCH=arm CC=arm-linux-gnueabi-gcc -C /lib/modules/3.2.0-29-generic/build M=/home/terenesas/sample modules
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-29-generic'
  CC [M]  /home/terenesas/sample/helloworldtest_module.o
In file included from /usr/src/linux-headers-3.2.0-29-generic/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/terenesas/sample/helloworldtest_module.c:2:
include/asm-generic/int-ll64.h:11:29: fatal error: asm/bitsperlong.h: No such file or directory
compilation terminated.
make[2]: *** [/home/terenesas/sample/helloworldtest_module.o] Error 1
make[1]: *** [_module_/home/terenesas/sample] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-29-generic'
make: *** [modules_install] Error 2

What did I do wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A quick fix, change from:

#include <asm/bitsperlong.h>

to:

#include <asm-generic/bitsperlong.h>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...