1. 硬件连接
看原理图可知,指纹芯片有六个只要功能引脚,POWER, RST, MI, MO,CLK, EINT,再dws中将spi的四个引脚和中断脚配置好,mt6753只有一组spi即spi0,65-68脚。
2.软件代码
(1) 拿到代码后将代码放在Z:\heqian\53_m_base\alps\kernel-3.18\drivers\input\fingerprint文件夹,如果没有此文件夹,新建fingerprint,并解决编译中出现的各种错误
这里出现了几个错误,都是头文件引用找不到的问题,再makefile中将索要包含的头文件目录指定一下就可以解决
ccflags-y +=-I$(srctree)/drivers/spi/mediatek/$(MTK_PLATFORM)
ccflags-y +=-I$(srctree)/drivers/misc/mediatek/include
ccflags-y +=-I$(srctree)/drivers/misc/mediatek/include/mt-plat
ccflags-y+=-I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include
ccflags-y+=-I$(srctree)/drivers/misc/mediatek/mach/mt6735/magc6753_65u_1_m0/dct/dct/
ccflags-y += -I$(srctree)/drivers/spi/mediatek/mt6735/
ccflags-y += -DMT6735
其他头文件未包含错误,可通过搜索将函数所在的.h文件找到并在C文件中include
将驱动中的spi总线号写为0,否则无法加载spi驱动
(2) 将库文件替换Z:\heqian\53_m_base\alps\out\target\product\magc6753_65u_1_m0\system\lib64\hw\fingerprint.default.so
在.fc_spi.c中将char* uevent_env_str[2] = {"FC909_STATE=WAKEUP", NULL};
改为char* uevent_env_str[2] = {"FC909_STATE=WAKEUP", NULL};
因为库里面写的节点是jmt101,指纹模块启动后会通过库去度这个字段,匹配之后才能开始采集数据
(3)在Z:\heqian\53_m_base\alps\device\mediatek\mt6735\device.mk中加入PRODUCT_PACKAGES +=fingerprintd
可自动编译至system/bin目录下
(4)解决完编译问题后配置dts和dtsi文件,由于mt6753只有一组spi0,所以dtsi文件里面我们最多只能配一组,通过查看代码后发现,spi0平台驱动挂载会在指纹驱动初始化的时候自动加载, dts里每一个&后面的节点再dtsi里面都要对应定义
/* fingerprint start */
&fc909{
debounce = <86 0>;
pinctrl-names="finger_rst_low","finger_rst_high","default";
pinctrl-0 = <&finger_rst_low>;
pinctrl-1 = <&finger_rst_high>;
pinctrl-2 = <&finger_pins_default>;
status = "okay";
};
&pio {
finger_rst_low: finger_rst_low@gpio83 {
pins_cmd_dat {
pins =
slew-rate = <1>;
bias-disable;
output-low;
};
};
finger_rst_high: finger_rst_high@gpio83 {
pins_cmd_dat {
pins =
slew-rate = <1>;
bias-disable;
output-high;
};
};
finger_pins_default:fp_pins_default{
pins_cmd_dat {
pins =
slew-rate = <1>;
bias-disable;
output-high;
};
};
};
(5)dts设置完成之后,可通过adb shell 查看相关节点
与dtsi中 spi0:spi@1100a000{
compatible= "mediatek,mt6753-spi";
cell-index= <0>;
spi-padmacro= <0>;
reg= <0x1100a000 0x1000>;
interrupts=
};相对应
Fc-input指纹节点
adb shell"cat /sys/devices/virtual/misc/mtgpio/pin"
第一位均为1说明gpio在spi状态,如果不在spi状态有可能dts里io被复用发生冲突了同时也可改变gpio状态
Tochange GPIO status:
adb shell "echo \"-w=99:0 1 0 0 0 1 0\">/sys/devices/virtual/misc/mtgpio/pin"
每行分别对应:
IO编号: 模式,输入上拉选择,输入值,输出值,输入上拉使能,方向,输入翻转
指纹模块的中断注册以及申请在dtsi和dws中设置,修改为如下方式注册
然后再dtsi中设置
到此spi驱动基本调通,可关闭selinux用代理商提供的apk进行指纹录入识别测试
(6)selinux相关权限及库设置adb shell "cat /proc/kmsg | grep avc" >avc_log.txt
selinux权限:
1、/device/mediatek/common/sepolicy/device.te
+ type jmt101_device,dev_type;
2、/device/mediatek/common/sepolicy/file_contexts
+ /dev/ jmt101 u:object_r: jmt101_device:s0
3、/device/mediatek/common/sepolicy/platform_app.te
+ allow platform_app jmt101_device:chr_file{openread write ioctl};
4、/device/mediatek/common/sepolicy/radio.te
+ allow radio jmt101_device:chr_file{openread write ioctl};
5、/device/mediatek/common/sepolicy/system_app.te
+ allow system_app jmt101_device:chr_file{openread write ioctl};
6、/device/mediatek/common/sepolicy/untrusted_app.te
+ allow untrusted_app jmt101_device:chr_filerw_file_perms;
7、/device/mediatek/mt6735/init.mt6735.rc
+ chown system system/dev/jmt101
chmod 0666 /dev/jmt101
service fingerprintd /system/bin/fingerprintd
class late_start
user system
8、device/mediatek/mt6735/ueventd.mt6735.rc
/dev/fc909 0666 system system
9.Z:\heqian\53_m_base\alps\external\sepolicy\fingerprintd.te
allow fingerprintdpermission_service:service_manager find;
allow fingerprintdself:netlink_kobject_uevent_socket {create bind read write};
allow fingerprintd jmt101_device:chr_file{open read write ioctl};
selinux权限添加说明
[ 275.373172] (1)[253:logd.auditd]type=1400audit(1262304448.940:180): avc:denied { create }for pid=3886comm="fingerprintd" scontext=u:r:fingerprintd:s0 tcontext=u:r:fingerprintd:s0tclass=netlink_kobject_uevent_socket permissive=0
scontext=u:r:fingerprintd 这个r:后面代表是哪个进程缺少权限
tcontext=u:r:fingerprintd 这个r:代表那个节点缺少权限
如果scontext=u:r: 和tcontext=u:r:后的名字相同,进程后面要写self
像这样allowfingerprintd self:netlink_kobject_uevent_socket {create bind read write};
tclass=netlink_kobject_uevent_socket “tclass”后面节点的文件类型
denied { create }大括号里面表示缺少什么权限,如果还缺说明权限,可根据avc log进行添加
权限设置完之后可在Z:\heqian\53_m_base\alps\out\target\product\magc6753_65u_1_m0\obj\ETC\sepolicy_intermediates\policy.conf中查看
(7)fingerprintd服务的开启
查看服务状态 ps | grep system/bin/ fingerprintd
有id说明服务已经开启,如果没有开启可手动开启服务验证“fingerprintd &”表示后台运行,开启服务后可在设置-安全-指纹中录入指纹