title: Cross-compiling kernel module for ARM
body: <p>I want to cross-compile <em>rtl8192cu driver</em> targeting ARM Angstrom <em>(BeagleBoard)</em>, on x86 Ubuntu 13.04.</p>
  
  <p>Cross-compile prerequisites:</p>
  
  <ol>
  <li>rtl8192cu driver</li>
  <li>Cross-toolchain <em>(CodeSourcery / arm-angstrom-linux-gnueabi)</em></li>
  <li>kernel sources</li>
  </ol>
  
  <p>For this reason, I copied kernel sources <em>usr/src</em> directory of BeagleBoard, on Ubuntu machine <em>(they heve been compiled on BeagleBoard, as I needed to rebuild the kernel)</em>.</p>
  
  <p>Running <code>make</code> for cross-compile, I get this error:</p>
  
  <pre><code>make ARCH=arm CROSS_COMPILE=/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi- -C /home/demetres/Desktop/ks1 M=/home/demetres/Desktop/rtl3  modules
  make[1]: Entering directory `/home/demetres/Desktop/ks1'
    CC [M]  /home/demetres/Desktop/rtl3/core/rtw_cmd.o
  /bin/sh: scripts/basic/fixdep: cannot execute binary file
  make[2]: *** [/home/demetres/Desktop/rtl3/core/rtw_cmd.o] Error 126
  make[1]: *** [_module_/home/demetres/Desktop/rtl3] Error 2
  make[1]: Leaving directory `/home/demetres/Desktop/ks1'
  make: *** [modules] Error 2
  </code></pre>
  
  <p>If I run <code>file fixdep</code> I get:</p>
  
  <pre><code>fixdep: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
  </code></pre>
  
  <p>This makes sense, as fixdep, is part of kernel sources <em>(compiled on ARM platform)</em>. </p>
  
  <p><em><strong>My query is:</em></strong> Is that procedure correct and how can I fix this error?</p>
  
  <p><em><strong>EDIT:</em></strong></p>
  
  <p>Running <code>make V=1</code>:</p>
  
  <pre><code>make ARCH=arm CROSS_COMPILE=/home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi- -C /home/demetres/Desktop/ks M=/home/demetres/Desktop/rtl  modules
  make[1]: Entering directory `/home/demetres/Desktop/ks'
  test -e include/linux/autoconf.h -a -e include/config/auto.conf || (        \
      echo;                               \
      echo "  ERROR: Kernel configuration is invalid.";       \
      echo "         include/linux/autoconf.h or include/config/auto.conf are missing.";  \
      echo "         Run 'make oldconfig &amp;&amp; make prepare' on kernel src to fix it.";  \
      echo;                               \
      /bin/false)
  mkdir -p /home/demetres/Desktop/rtl/.tmp_versions ; rm -f /home/demetres/Desktop/rtl/.tmp_versions/*
  make -f scripts/Makefile.build obj=/home/demetres/Desktop/rtl
    /home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-gcc -Wp,-MD,/home/demetres/Desktop/rtl/core/.rtw_cmd.o.d  -nostdinc -isystem /home/demetres/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/include -Iinclude  -I/home/demetres/Desktop/ks/arch/arm/include -include include/linux/autoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-versatile/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -marm -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fno-dwarf2-cfi-asm -fconserve-stack -O1 -Wno-unused-variable -Wno-unused-value -Wno-unused-label -Wno-unused-parameter -Wno-unused-function -Wno-unused -Wno-uninitialized -I/home/demetres/Desktop/rtl/include -DCONFIG_POWER_SAVING -DCONFIG_LITTLE_ENDIAN  -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(rtw_cmd)"  -D"KBUILD_MODNAME=KBUILD_STR(8192cu)"  -c -o /home/demetres/Desktop/rtl/core/rtw_cmd.o /home/demetres/Desktop/rtl/core/rtw_cmd.c
  /bin/sh: scripts/basic/fixdep: cannot execute binary file
  make[2]: *** [/home/demetres/Desktop/rtl/core/rtw_cmd.o] Error 126
  make[1]: *** [_module_/home/demetres/Desktop/rtl] Error 2
  make[1]: Leaving directory `/home/demetres/Desktop/ks'
  make: *** [modules] Error 2
  </code></pre>