【问题标题】:Cross-compiling of kernel module for ARM architectureARM架构内核模块的交叉编译
【发布时间】:2013-10-25 15:12:49
【问题描述】:

我正在尝试从一台 linux x86 机器上为 ARM 制作一个 .ko 文件。我尝试了以下 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

...但我在命令提示符中给出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

我做错了什么?

【问题讨论】:

    标签: c linux makefile arm


    【解决方案1】:

    快速修复,更改自:

    #include <asm/bitsperlong.h>
    

    到:

    #include <asm-generic/bitsperlong.h>
    

    【讨论】:

      【解决方案2】:

      shell uname -r 表示此 Makefile 将为您的主机(x86)系统而不是 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
      

      【讨论】:

        猜你喜欢
        • 2014-10-23
        • 2014-05-01
        • 2011-03-28
        • 2018-05-29
        • 1970-01-01
        • 1970-01-01
        • 2014-01-25
        • 2014-04-30
        • 2020-08-15
        相关资源
        最近更新 更多