1

我正在尝试交叉编译一个简单的 Hello world 程序,我计划将其作为模块上传到 android ARM 设备中。下面是c代码。

#include<linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("CW");
MODULE_DESCRIPTION("Demo Hello");

static int init_module(void)
{
      printk(KERN_ALERT "Hello World\n");

      return 0;
}

static void cleanup_module(void)
{
      printk(KERN_ALERT "Good Bye World\n");
}

module_init(init_module);
module_exit(cleanup_module);

下面是生成文件

VERSION = 3
PATCHLEVEL = 2
SUBLEVEL = 0
EXTRAVERSION = 00763-g4071679


obj-m :=hello.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
    $(MAKE) ARCH=arm CROSS_COMPILE=/home/userid/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

以下是错误日志的初始部分

make ARCH=arm CROSS_COMPILE=/home/userid/rowboat-android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C /lib/modules/3.5.0-23-generic/build SUBDIRS=/home/userid/myfiles modules
make[1]: Entering directory `/usr/src/linux-headers-3.5.0-23-generic'
    CC [M]  /home/userid/myfiles/hello.o
    In file included from /usr/src/linux-headers-3.5.0-23-generic/arch/arm/include/asm/types.h:4,
             from include/linux/types.h:4,
             from include/linux/init.h:5,
             from /home/userid/myfiles/hello.c:1:
 include/asm-generic/int-ll64.h:11:29: error: asm/bitsperlong.h: No such file or directory
  In file included from /usr/src/linux-headers-3.5.0-23-generic/arch/arm/include/asm/posix_types.h:35,
             from include/linux/posix_types.h:35,
             from include/linux/types.h:17,
             from include/linux/init.h:5,
             from /home/userid/myfiles/hello.c:1:

主机上uname -r => 3.5.0-23 generic => Ubuntu 12.04 LTS

Android ARM 设备/proc/version => Linux 版本 3.2.0-00763-g407167a (gcc 版本 4.4.3(GCC)) ....

提前感谢您的帮助。

4

0 回答 0