Monday, 1 December 2014

cross compiling out of tree kernel modules


Its easy to use the target kernels' Kbuild  by creating  Kbuild file at the module source root with :

obj-m := foo.o

and then calling make with the usual ARCH and CROSS_COMPILE variables: 
e.g. for arm-v7 : (allwinner A20)

 make -C $(KDIR) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- SUBDIRS=$PWD modules  

this will create a foo.ko  module for the cross compiled target

and to clean:

 make -C $(KDIR) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- SUBDIRS=$PWD modules   

where KDIR is the path to the top of the kernel source tree.


No comments:

Post a Comment