繁体   English   中英

使用Android系统为特殊的ARM设备构建linux内核模块

[英]Build linux kernel modules for a special ARM device with Android system

我有一个android设备,其Linux内核在下面。

shell@android:/ # uname -a
uname -a
Linux localhost 3.0.50-g72b01fe #1 SMP PREEMPT Tue Nov 26 14:22:32 CST 2013 armv
7l GNU/Linux

我想为该设备构建一个uvc驱动器模块。 因此,请在Linux内核3.0.101上构建模块。 我没有找到3.0.50版本的内核,所以改用3.0.101。

$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabi-
$ build modules

但是我想使用insmod在设备中安装模块。 我遇到一个错误。

$ insmod /tmp/videobuf2-core.ko
init_module 'videobuf2-core.ko' failed (Exec format error)

因此,我使用modinfo,file和arm-linux-gnueabi-readelf命令来检查videobuf2_core.ko

$ modinfo videobuf2-core.ko
filename:       videobuf2-core.ko
license:        GPL
author:         Pawel Osciak <pawel@osciak.com>, Marek Szyprowski
description:    Driver helper framework for Video for Linux 2
srcversion:     30ECE251825184452C89B09
depends:        
vermagic:       3.0.101  mod_unload modversions ARMv5 
parm:           debug:int 

$ file videobuf2-core.ko
videobuf2-core.ko: ELF 32-bit LSB relocatable, ARM, version 1, BuildID[sha1]=0x06240ff3b9f45700086c387fb2b411848ad65fcd, not stripped

$ arm-linux-gnueabi-readelf -a videobuf2-core.ko | head
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            ARM
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1

但是我在设备dhd.ko中找到了一个正常的模块,有关dhd.ko的信息如下

$ modinfo dhd.ko
filename:       dhd.ko
license:        GPL v2
depends:        
vermagic:       3.0.50-g72b01fe SMP preempt mod_unload modversions ARMv7 

$ file dhd.ko
dhd.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), BuildID[sha1]=0x2db993479965068d38e108b675a8315aa0965f5f, not stripped

$ arm-linux-gnueabi-readelf -a dhd.ko | head
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1

通过比较两个文件。 我发现有一些差异。

vermagic:

    videobuf2-core.ko which is built by me
        3.0.101  mod_unload modversions ARMv5 

    dhd.ko which is normal module in the device
        3.0.50-g72b01fe SMP preempt mod_unload modversions ARMv7 

ELF info

    videobuf2-core.ko which is built by me
        ELF 32-bit LSB relocatable, ARM, version 1, BuildID[sha1]=0x06240ff3b9f45700086c387fb2b411848ad65fcd, not stripped

    dhd.ko which is normal module in the device
        ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), BuildID[sha1]=0x2db993479965068d38e108b675a8315aa0965f5f, not stripped

OS/ABI

    videobuf2-core.ko which is built by me
        ARM

    dhd.ko which is normal module in the device
        UNIX - System V

如何配置以构建Linux内核模块,使我的videobuf2-core.ko与普通模块dhd.ko类似? 而且我可以使用insmod命令将我的模块安装在设备中。

在这种情况下,最简单的方法可能是使用3.0.101 Linux版本运行android。 您确定针对此ARM体系结构(armv5与armv7)具有正确的工具链(gcc)吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM