I want to cross-compile a loadable simple hello world module on imx6ulevk target, by using make command directly. Could anyone tell me how to set the $(KERNEL_SRC) properly? I searched a lot articles on internet and also read module.txt in kernel document, but didn't get a solution...
I have two files hello_module.c, and single line Makefile, as shown below
//========hello_module.c====
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void){
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void){
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
#=====test above code in ubuntu_14.04: PASS ===
>sudo apt-get install build-essential linux-headers-$(uname -r)
>echo 'obj-m += hello_module.o' > Makefile #<=== single line Makefile
>make -C /lib/modules/$(uname -r)/build M=`pwd` #specify make parameter on the fly
>sudo insmod hello_module.ko
>rmmod hello_module
>dmesg | tail -3
#=====prepare cross-compile environment parameters=====
>source ~/IMX/toolchain/opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
>echo $CC
arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/home/dev/IMX/toolchain/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi
now how to prepare KERNEL_SRC below to let cross-compile success?
make M=`pwd` -C <KERNEL_SRC>
Many thanks
-Shawn
P.S.
here are are all linux/module.h that can be found in fsl-release-bsp
dev@dev-vm:~/IMX/fsl-release-bsp$ find -name module.h | grep /include/linux/module.h
./build_imx6ulevk/tmp/work-shared/imx6ulevk/kernel-source/include/linux/module.h
./build_imx6ulevk/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/linux-libc-headers/4.1-r0/linux-4.1/include/linux/module.h
./build_imx6ulevk/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-linux-libc-headers/4.4-r0/linux-4.4/include/linux/module.h
### below are operations I did to build corss-compile toolchain ###
>cd /home/dev/IMX/fsl-release-bsp
>DISTRO=fsl-imx-x11 MACHINE=imx6ulevk source fsl-setup-release.sh -b build_imx6ulevk
>bitbake fsl-image-gui #<==build image
>bitbake meta-toolchain #<==build sdk
>cd /home/dev/IMX/fsl-release-bsp/build_imx6ulevk/tmp/deploy/sdk/
>./fsl-imx-x11-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.1.15-2.1.0.sh -d /home/dev/IMX/toolchain/opt/fsl-imx-x11/4.1.15-2.1.0 #<===install sdk
>source /home/dev/IMX/toolchain/opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi