[英]Build linux kernel modules for a special ARM device with Android system
I have an android device, whose linux kernel is below. 我有一个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
And I want to build a uvc drive module for the device. 我想为该设备构建一个uvc驱动器模块。 So build modules on linux kernel 3.0.101.
因此,请在Linux内核3.0.101上构建模块。 I didn't find 3.0.50 version kernel,so use 3.0.101 instead.
我没有找到3.0.50版本的内核,所以改用3.0.101。
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabi-
$ build modules
But I want to use insmod to install the modules in the device. 但是我想使用insmod在设备中安装模块。 I meet an error.
我遇到一个错误。
$ insmod /tmp/videobuf2-core.ko
init_module 'videobuf2-core.ko' failed (Exec format error)
So I use the modinfo, file and arm-linux-gnueabi-readelf command to check the videobuf2_core.ko 因此,我使用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
But I found a normal module in the device dhd.ko, the information about dhd.ko is below 但是我在设备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
By the comparison of the two files. 通过比较两个文件。 I found there are some differences.
我发现有一些差异。
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
How could I configure to build linux kernel modules to make my videobuf2-core.ko similiar to the normal module dhd.ko? 如何配置以构建Linux内核模块,使我的videobuf2-core.ko与普通模块dhd.ko类似? And I can use insmod command to install my module in the device.
而且我可以使用insmod命令将我的模块安装在设备中。
Probably the easiest way in such case will be to run android with your 3.0.101 linux version. 在这种情况下,最简单的方法可能是使用3.0.101 Linux版本运行android。 Are you sure that you have proper toolchain (gcc) for this ARM architecture (armv5 vs armv7)?
您确定针对此ARM体系结构(armv5与armv7)具有正确的工具链(gcc)吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.