imx6 android build hello driver module .ko
2016/03/09 14:09
瀏覽366
迴響0
推薦0
引用0
//---imx6 android build hello driver module .ko
//---init make environment
//---kernel in ~/dk2/imx6_android_4_4_KK/kernel_imx/
cd ~/dk2/imx6_android_4_4_KK/kernel_imx/
export ARCH=arm
export CROSS_COMPILE=~/dk2/imx6_android_4_4_KK/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
make menuconfig
make uImage
make modules
sudo make modules_install
#above cmd created a folder /lib/modules/3.0.35-06522-g0a3529b-dirty
//---Makefile
ifneq ($(KERNELRELEASE),)
obj-m:=hello_module_imx6_adrd.o
else
KERNELDIR?=/lib/modules/3.0.35-06522-g0a3529b-dirty/build
PWD:=$(shell pwd)
all:
$(MAKE) ARCH=arm -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *.ko *~ *.mod.c *.order *.symvers
endif
//---hello_module_imx6_adrd.c
#include
#include
static int __init hello_module_init(void)
{
printk("Hello, imx6_adrd module is installed !\n");
return 0;
}
static void __exit hello_module_cleanup(void)
{
printk("Good-bye, imx6_adrd module was removed!\n");
}
module_init(hello_module_init);
module_exit(hello_module_cleanup);
MODULE_DESCRIPTION("hello_module");
MODULE_AUTHOR("Greatcat");
MODULE_LICENSE("GPL");
//---host send .ko to target
adb push hello_module_imx6_adrd.ko /sdcard/
//---target test
insmod /sdcard/hello_module_imx6_adrd.ko
lsmod
rmmod hello_module_imx6_adrd
//---init make environment
//---kernel in ~/dk2/imx6_android_4_4_KK/kernel_imx/
cd ~/dk2/imx6_android_4_4_KK/kernel_imx/
export ARCH=arm
export CROSS_COMPILE=~/dk2/imx6_android_4_4_KK/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
make menuconfig
make uImage
make modules
sudo make modules_install
#above cmd created a folder /lib/modules/3.0.35-06522-g0a3529b-dirty
//---Makefile
ifneq ($(KERNELRELEASE),)
obj-m:=hello_module_imx6_adrd.o
else
KERNELDIR?=/lib/modules/3.0.35-06522-g0a3529b-dirty/build
PWD:=$(shell pwd)
all:
$(MAKE) ARCH=arm -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *.ko *~ *.mod.c *.order *.symvers
endif
//---hello_module_imx6_adrd.c
#include
#include
static int __init hello_module_init(void)
{
printk("Hello, imx6_adrd module is installed !\n");
return 0;
}
static void __exit hello_module_cleanup(void)
{
printk("Good-bye, imx6_adrd module was removed!\n");
}
module_init(hello_module_init);
module_exit(hello_module_cleanup);
MODULE_DESCRIPTION("hello_module");
MODULE_AUTHOR("Greatcat");
MODULE_LICENSE("GPL");
//---host send .ko to target
adb push hello_module_imx6_adrd.ko /sdcard/
//---target test
insmod /sdcard/hello_module_imx6_adrd.ko
lsmod
rmmod hello_module_imx6_adrd
你可能會有興趣的文章:
限會員,要發表迴響,請先登入

