1
votes

I have an android device, whose linux kernel is below.

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. So build modules on linux kernel 3.0.101. I didn't find 3.0.50 version kernel,so use 3.0.101 instead.

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

But I want to use insmod to install the modules in the device. 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 videobuf2-core.ko
filename:       videobuf2-core.ko
license:        GPL
author:         Pawel Osciak <[email protected]>, 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

$ 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? And I can use insmod command to install my module in the device.

1
You really should be starting with the kernel sources corresponding to the version running on the device, something the device vendor has an obligation to provide to you.Chris Stratton
I didn't understand answer! My android linux kernel is 3.0.50 and my linux is 3.13 . How can i compile my module with kernel 3.0.50 ?!Dr.jacky

1 Answers

1
votes

Probably the easiest way in such case will be to run android with your 3.0.101 linux version. Are you sure that you have proper toolchain (gcc) for this ARM architecture (armv5 vs armv7)?