I have an OLinuXino board. I downloaded the ArchLinux img file (ArchLinuxARM-2013.02-olinuxino-rootfs.img) and wrote it to the SD card using dd and booted the board using the card. I connected the board to the internet using ethernet and installed gcc and make on it using pacman. I was able to build userspace program for the board o n the board.
The ArchLinux SD card image already had the kernel headers directory in the rootfs (/lib/modules/linux-3.7.2-2-ARCH/build). And so I was able to build loadable kernel modules for the board on the board itself too.
I have an Ubuntu 12.04.1 development PC. I have installed Sourcery CodeBench Lite for ARM GNU/Linux (arm-2012.09-64-arm-none-linux-gnueabi.bin) on it. I am able to cross compile userspace programs for OLinuXino on this development PC and transfer it to the board over SFTP and run it on the board (using console over ttyAMA0 Serial port).
Now I want to cross compile kernel modules for the OLinuXino board. I have done this earlier for another custom build imx233 board - in that case I had configured the kernel build system (LTIB) to leave the kernel sources and rootfs intact after building the image. That way I was able to specify the kernel headers build directory for cross compiling the kernel module and it worked.
This time for OLinuXino I don't have the build sources so I copied the rootfs (using cp -dR) to my Ubuntu PC and tried cross compiling a hello world kernel module by specifying the kernel headers directory as /lib/modules/linux-3.7.2-2-ARCH/build and it threw the following error:
anurag@anurag-VirtualBox:~/HelloKS$ make
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C /mnt/ArchOL/lib/modules/3.7.2-2- ARCH/build M=/home/anurag/HelloKS modules
make[1]: Entering directory `/mnt/ArchOL/usr/src/linux-3.7.2-2-ARCH'
CC [M] /home/anurag/HelloKS/khello.o
/bin/sh: scripts/basic/fixdep: cannot execute binary file
make[2]: *** [/home/anurag/HelloKS/khello.o] Error 126
make[1]: *** [_module_/home/anurag/HelloKS] Error 2
make[1]: Leaving directory `/mnt/ArchOL/usr/src/linux-3.7.2-2-ARCH'
make: *** [all] Error 2
The fixdep binary in the scripts folder was precompiled for ARM, so I deleted the binary and recompiled it for x86 and placed it there. When I tried cross compiling the kernel module again, a similar error was thrown complaining about another executable in the scripts folder (this time modpost).
My question is how can I replace these arm binaries in the kernel-header / build folder with x86 version? is there a script in the build folder to do this? Can I replace the scripts folder in the copied ArchLinux with the scripts folder from my ubuntu's kernel module build folder? Or do I modify kernel modules's makefile to instruct the build script to rebuild binaries in the scripts folder or use a different scripts folder for this binary (I would specify) the path to ubuntu's scripts folder in its kernel headers folder? Or am I going about this the wrong way and there a better way to setup cross compilation for the board and setup I have?
PS. FYI: Cross compiler uses libc 2.16 and the ArchLinux img for OLinuXino has libc 2.17 on it
.config
, usemake distclean
on the copied directory and then cross-build the kernel on the PC. After that all the binaries should be setup properly. – artless noisescripts
(via mount --bind) to make the sources compile, but I got a strange error withmodpost
afterwards:FATAL: section header offset=11258999068426292 in file '/ldata/DATA/src/rtl8192eu-linux-driver/8192eu.o' is bigger than filesize=1100031
– lilydjwg