一、实现思路
新建驱动源码目录,编写Makefile,将android SDK中kernel目录链接进来即可
二、源码分析
//driver目录 ~/linux_driver/isl29501/ //android sdk的kernel目录 ~/3399_master/kernel/
1.在~/linux_driver/isl29501/下编写Makefile
obj-m := isl29501.o KERNELDIR := ~/3399_master/kernel CURRENT_PATH := $(shell pwd) ARCH =arm64 #-Wno-unused-variable KBUILD_CFLAGS := -Werror-implicit-function-declaration build: kernel_modules kernel_modules: $(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) M=$(CURRENT_PATH) modules clean: $(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) clean
2.进入~/linux_driver/isl29501/目录,输入make编译驱动,make clean是清除工程生成文件。
3.用adb push命令,推到adndroid镜像目录中测试驱动即可
insmod xxx.ko //加载驱动 rmmod xxx.ko //卸载驱动