2013-02-11 4 views
3

Linux x86 시스템에서 ARM 용 .ko 파일을 만들려고합니다. 나는 다음 메이크 시도 :ARM 아키텍처 용 커널 모듈의 교차 컴파일

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 

을 ... 그러나 나는 다음과 같이 명령 프롬프트에서 make -f Makefile ARCH=arm CROSS_COMPILER=arm-linux-gnueabi-gcc을주는 오류를 가지고 :

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 

내가 무슨 일을 했는가?

답변

2

빠른 수정에서 변경 :

#include <asm/bitsperlong.h> 

에 :

#include <asm-generic/bitsperlong.h> 
2

shell uname -r이 메이크는 호스트 (86) 시스템이 아닌 ARM의 모듈을 만들 것을 의미합니다.

ARM 커널의 소스 디렉토리를 지정해야합니다. 다음 Makefile을 사용하여 모듈을 크로스 컴파일 할 수 있습니다.

메이크 :

CC=$(CROSS_COMPILE)gcc 
# If KERNELRELEASE is defined, we've been invoked from the 
# kernel build system and can use its language. 
ifneq ($(KERNELRELEASE),) 
    obj-m := modulename.o 

# Otherwise we were called directly from the command 
# line; invoke the kernel build system. 
else 

    KERNELDIR ?= /path/to/kernel/linux 
    PWD := $(shell pwd) 

default: 
    ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules 

clean: 
    ${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean 
endif