Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross compiling linux kernel module for ARM on x86 ubuntu [closed]

I want to cross compile an ARM kernel module on my x86 ubuntu linux. I have downloded kernel source(linux 2.6.26 since target ARM machine is running this linux version). and I apt-get'ed arm cross compiler. as you can see.

root@declspec-desktop:/var/www/module_test# arm-linux-gnueabi-
arm-linux-gnueabi-addr2line  arm-linux-gnueabi-cpp-4.5
arm-linux-gnueabi-gcov-4.5   arm-linux-gnueabi-ld.gold
arm-linux-gnueabi-ranlib     arm-linux-gnueabi-strip
arm-linux-gnueabi-ar         arm-linux-gnueabi-elfedit
arm-linux-gnueabi-gprof      arm-linux-gnueabi-nm
arm-linux-gnueabi-readelf    arm-linux-gnueabi-as
arm-linux-gnueabi-gcc        arm-linux-gnueabi-ld
arm-linux-gnueabi-objcopy    arm-linux-gnueabi-size       
arm-linux-gnueabi-c++filt    arm-linux-gnueabi-gcc-4.5
arm-linux-gnueabi-ld.bfd     arm-linux-gnueabi-objdump
arm-linux-gnueabi-strings  

following is the Makefile for my kernel module(hello_module.ko) compilation(for my x86 machine) and this works fine.

obj-m += hello_module.o
KDIR := /lib/modules/$(shell uname -r)/build
#PWD:=$(shell pwd)

all:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
        rm -rf *.o *.ko *.mod.* .c* .t*

now, what do I have to change in my original working Makefile in order to cross compile a kernel module for linux 2.6.26 for ARM?

and whats the difference between linux source and linux header source? I have seen these every time I compile some kernel stuff but I still dont get it.

I have googled some articles but it wont help...

like image 296
daehee Avatar asked Oct 21 '22 20:10

daehee


1 Answers

I'd suggest building the kernel source before you move to your hello_module. That will confirm your arm cross compiler installation went OK.

Many times, toolchain problems trace back to needing these:

export CROSS_COMPILE=arm-linux-gnueabi- 

export ARCH=arm

Also PATH needs to be updated at time of cross-toolchain installation, so the tools can be found from the executing make. CodeSourcery install can do that for you, but the PATH update only goes into effect after logout/login.

It isn't clear to me how you got your console output above. If problems remain, I'd suggest doing something like these, and post result as comment.

printenv | grep PATH

whereis arm-linux-gnueabi-gcc

which arm-linux-gnueabi-gcc
like image 122
Joe Kul Avatar answered Oct 27 '22 00:10

Joe Kul