在 Linux 上建立 helloDriver.ko for Android
參考:http://telesky.pixnet.net/blog/post/6969608
1. 先準備 helloDriver.c and Makefile helloDriver.c
$ make oldconfig
全部enter
$ make modules_prepare
3. 回到 helloDriver.c 所在的目錄 $ make 這樣就會得到 helloDriver.ko $ file helloDriver.ko
1. 先準備 helloDriver.c and Makefile helloDriver.c
#include #include MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_INFO "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_INFO "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);Makefile
KERNELDIR := /home/____/_____/982_Android/kernel/ PWD :=$(shell pwd) ARCH=arm CROSS_COMPILE=/home/____/_____/991_Android/other/vanilla/tools/arm-eabi-4.2.1/bin/arm-eabi- CC=$(CROSS_COMPILE)gcc LD=$(CROSS_COMPILE)ld obj-m := hello.o modules: $(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules clean: rm *.o *.ko *.mod.c *.markers *.order *.symvers2. 在 /home/____/_____/982_Android/kernel/ 裡修改 Makefile
ARCH := arm CROSS_COMPILE := /home/____/_____/991_Android/other/vanilla/tools/arm-eabi-4.2.1/bin/arm-eabi-$ make mrproper
$ make oldconfig
全部enter
$ make modules_prepare
3. 回到 helloDriver.c 所在的目錄 $ make 這樣就會得到 helloDriver.ko $ file helloDriver.ko
留言
張貼留言