内核模块的交叉编译为ARM架构 [英] Cross-compiling of kernel module for ARM architecture

查看:695
本文介绍了内核模块的交叉编译为ARM架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Linux的x86机器做出ARM一个.ko文件。我想下面的Makefile:

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

...但我在给予了一个错误使-f Makefile的ARCH =手臂CROSS_COMPILER =臂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

我做了什么错了?

What did I do wrong?

推荐答案

外壳使用uname -r 意味着这个Makefile将建立你的主机(x86)的系统模块不是ARM。

shell uname -r means that this Makefile will build the module for you host(x86) system and not for ARM.

您需要指定ARM内核的源目录。您可以使用下面的Makefile交叉编译的模块。

You need to specify the source directory of your ARM Kernel. You may use following Makefile to cross-compile your module.

的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

这篇关于内核模块的交叉编译为ARM架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆