title: Build linux kernel modules for a special ARM device with Android system
body: <p>I have an android device, whose linux kernel is below.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>$ export ARCH=arm
  $ export CROSS_COMPILE=arm-linux-gnueabi-
  $ build modules
  </code></pre>
  
  <p>But I want to use insmod to install the modules in the device. I meet an error.</p>
  
  <pre><code>$ insmod /tmp/videobuf2-core.ko
  init_module 'videobuf2-core.ko' failed (Exec format error)
  </code></pre>
  
  <p>So I use the modinfo, file and arm-linux-gnueabi-readelf command to check the videobuf2_core.ko</p>
  
  <pre><code>$ modinfo videobuf2-core.ko
  filename:       videobuf2-core.ko
  license:        GPL
  author:         Pawel Osciak &lt;pawel@osciak.com&gt;, 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
  </code></pre>
  
  <p>But I found a normal module in the device dhd.ko, the information about dhd.ko is below</p>
  
  <pre><code>$ 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
  </code></pre>
  
  <p>By the comparison of the two files.  I found there are some differences. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>