交叉编译内核模块 [英] Cross compiling a kernel module

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

问题描述

我正在尝试在intel x86主机上交叉编译用于ARM体系结构的helloworld内核(2.6.x)模块.

I'm trying to cross compile a helloworld kernel (2.6.x) module for ARM architecture on my intel x86 host.

ARM的代码源工具链位于:/home/ravi/workspace/hawk/arm-2009q3

The codesourcery tool chain for ARM is located at: /home/ravi/workspace/hawk/arm-2009q3

内核源位于:/home/ravi/workspace/hawk/linux-omapl1

我的Makefile:

My Makefile:

ARCH=arm
CROSS_COMPILE=arm-none-linux-gnueabi
obj-m := Hello.o
KDIR := /home/ravi/workspace/hawk/linux-omapl1
PWD := $(shell pwd)
default:
          $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
          $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

当我运行 make 时,生成的.ko是我的主机上的.ko,这意味着makefile正在调用本机编译器而不是交叉编译器.我在做什么错?交叉编译器的二进制文件在我的路径中.

When i run make, the .ko produced is that of my host machine which means 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.

推荐答案

在Makefile中放入ARCHCROSS_COMPILE无效.您需要将它们放在命令行中:

Putting ARCH and CROSS_COMPILE in the Makefile doesn't work. You need to put them on the command line:

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

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

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