1:查看主板原理图获取硬件信息
系统硬件平台是sdm450/msm8953
在主板原理图上可以找到指纹相关的原理图部分如下:
该IC使用两路电, LDO6 1.8v, LDO10 2.8v。
- SPI通讯,追到模块上是 BLSP7 spi7 这组管脚,具体的管脚信息如下:
- FP_RST 脚硬件上悬空。
- FP_INIT 中断引脚,追到模块上,是gpio44。
2:驱动加载
2.1:添加驱动 code
a)配置编译选项
modified: msm-3.18/arch/arm64/configs/msmcortex-perf_defconfig
modified: msm-3.18/arch/arm64/configs/msmcortex_defconfig
modified: msm-3.18/drivers/input/Kconfig
modified: msm-3.18/drivers/input/Makefile
--- a/kernel/msm-3.18/arch/arm64/configs/msmcortex_defconfig
+++ b/kernel/msm-3.18/arch/arm64/configs/msmcortex_defconfig
+CONFIG_MICROARRAY_FINGERPRINT=y
--- a/kernel/msm-3.18/arch/arm64/configs/msmcortex-perf_defconfig
+++ b/kernel/msm-3.18/arch/arm64/configs/msmcortex-perf_defconfig
+CONFIG_MICROARRAY_FINGERPRINT=y
--- a/kernel/msm-3.18/drivers/input/Kconfig
+++ b/kernel/msm-3.18/drivers/input/Kconfig
+config MICROARRAY_FINGERPRINT
+ tristate "MICROARRAY fingerprint IC"
+ depends on SPI_MASTER
+ help
+ MICROARRAY fingerprint ic
+#yujixuan modify
+source "drivers/input/fingerprint/Kconfig"--- a/kernel/msm-3.18/drivers/input/Makefile
+++ b/kernel/msm-3.18/drivers/input/Makefile
+obj-$(CONFIG_MICROARRAY_FINGERPRINT) += fingerprint/
b)添加驱动源码文件
fingerprint
├── Kconfig
├── Makefile
└── microarray├── ioctl_cmd.h├── Kconfig├── madev.c
├── madev.h
├── Makefile├── qualcomm-settings.c
└── qualcomm-settings.h
2.1.1:配置设备树信息
在获取硬件的硬件信息中,可知该指纹使用的 spi是 spi7, msm8953平台默认情况下,spi7是被配置在TZ端安全环境中, 被限制不能在AP侧使用的,
如果我们在AP侧使用spi7,需要解除限制,并且修改设备树种的 spi7 相关配置。
a)添加spi7 的设备树配置
--- a/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953-pinctrl.dtsi
+++ b/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953-pinctrl.dtsi
@@ -1543,6 +1543,67 @@
+ /* start for fingerprint spi end */
+ spi7 {
+ spi7_default: spi7_default {
+ /* active state */
+ mux {
+ /* MOSI, MISO, CLK */
+ pins = "gpio137", "gpio138", "gpio135";
+ function = "blsp_spi7";
+ };
+ config {
+ pins = "gpio137", "gpio138", "gpio135";
+ drive-strength = <12>; /* 12 MA */
+ bias-disable = <0>; /* No PULL */
+ };
+ };
+ spi7_sleep: spi7_sleep {
+ /* suspended state */
+ mux {
+ /* MOSI, MISO, CLK */
+ pins = "gpio137", "gpio138", "gpio135";
+ function = "gpio";
+ };
+ config {
+ pins = "gpio137", "gpio138", "gpio135";
+ drive-strength = <2>; /* 2 MA */
+ bias-pull-down; /* PULL Down */
+ };
+ };
+ spi7_cs0_active: cs0_active {
+ /* CS */
+ mux {
+ pins = "gpio136";
+ function = "blsp_spi7";
+ };
+ config {
+ pins = "gpio136";
+ drive-strength = <2>;
+ bias-disable = <0>;
+ };
+ };
+ spi7_cs0_sleep: cs0_sleep {
+ /* CS */
+ mux {
+ pins = "gpio136";
+ function = "gpio";
+ };
+ config {
+ pins = "gpio136";
+ drive-strength = <2>;
+ bias-disable = <0>;
+ };
+ };
+ };
--- a/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953.dtsi
+++ b/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953.dtsialiases {
+ spi7 = &spi_7;};
+ spi_7: spi@7af7000 { /* BLSP1 QUP7 */
+ compatible = "qcom,spi-qup-v2";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg-names = "spi_physical", "spi_bam_physical";
+ reg = <0x7af7000 0x600>,
+ <0x7AC4000 0x1f000>;
+ interrupt-names = "spi_irq", "spi_bam_irq";
+ interrupts = <0 301 0>, <0 239 0>;
+ spi-max-frequency = <19200000>;
+ pinctrl-names = "spi_default", "spi_sleep";
+ pinctrl-0 = <&spi7_default &spi7_cs0_active>;
+ pinctrl-1 = <&spi7_sleep &spi7_cs0_sleep>;
+ clocks = <&clock_gcc clk_gcc_blsp2_ahb_clk>,
+ <&clock_gcc clk_gcc_blsp2_qup3_spi_apps_clk>;
+ clock-names = "iface_clk", "core_clk";
+ qcom,infinite-mode = <0>;
+ qcom,use-bam;
+ qcom,use-pinctrl;
+ qcom,ver-reg-exists;
+ qcom,bam-consumer-pipe-index = <8>;
+ qcom,bam-producer-pipe-index = <9>;
+ qcom,master-id = <84>;
+ status = "disabled";
+ };
b)添加改指纹驱动设备树节点
如果是REE环境 spi在AP端控制,配置如下:
--- a/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953.dtsi
+++ b/kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953.dtsi
+ +&spi_7 {
+ status = "ok";
+ microarray_fp@0 {
+ status = "ok";
+ compatible = "microarray,fingerprint";
+ reg = <0x0>;
+ spi-max-frequency = <4800000>;
+ vcc_io = <&pm8953_l6>;
+ microarray,gpio_reset = <&tlmm 20 0>;
+ microarray,gpio_irq = <&tlmm 44 0>;
+ microarray,gpio_pwr = <&tlmm 97 0>;
+ };
+};
另外,需要在 TZ中解除对spi7的使用限制。
--- a/TZ.BF.4.0.5/trustzone_images/core/buses/qup_accesscontrol/bear/config/QUPAC_8953_Access.xml
+++ b/TZ.BF.4.0.5/trustzone_images/core/buses/qup_accesscontrol/bear/config/QUPAC_8953_Access.xml
@@ -149,7 +149,7 @@<props name="IS_GPIO_PROTECTED" type=DALPROP_ATTR_TYPE_UINT32> 1 </props><props name="GPIO_NUMBERS" type=DALPROP_ATTR_TYPE_BYTE_SEQ> 135, 136, 137, 138, end </props><props name="GPIO_RG_INDEX" type=DALPROP_ATTR_TYPE_BYTE_SEQ> 15, end </props>
- <props name="SUBSYSTEM_ID" type=DALPROP_ATTR_TYPE_UINT32> AC_TZ </props>
+ <props name="SUBSYSTEM_ID" type=DALPROP_ATTR_TYPE_UINT32> AC_HLOS </props>
如果是TEE环境 spi在TZ端控制,AP侧便可以不添加SPI7相关的配置,直接在soc下配置。
+&soc {
+ microarray_fp{
+ status = "ok";
+ compatible = "microarray,fingerprint";
+ spi-max-frequency = <4800000>;
+ //microarray,gpio_reset = <&tlmm 2 0>;
+ microarray,gpio_irq = <&tlmm 44 0>;
+ microarray,gpio_pwr = <&tlmm 97 0>;
+ avdd-supply = <&pm8953_l10>;
+ vdd-supply = <&pm8953_l6>;
+ };
+}
c)修改驱动,打开log开关,观察开机log,查找设备节点通过阅读供应商提供的驱动源码,该驱动的主要目的是配置gpio,创建设备,通过上层iotcl读写,检测中断,收发信息,详细内容这里不做讨论,主要关注的是发现无上电内容, 驱动直接在 init过程中加载,通过
of_find_compatible_node接口直接 获取设备树的填充信息。所以需要我们 在设备树里添加 avdd-supply = <&pm8953_l10>;vdd-supply = <&pm8953_l6>;
创建device结构体,将 device_node 传入device,然后使用regulator_get,regulator_enable来上电。
成功加载后的log 如下::
msm8953_64:/ # dmesg | grep MAFP
[ 7.924438] MAFP_mas_init: debug log! start!
[ 8.063001] MAFP_mas_do_some_for_probe: Get the regulator for vdd_l6 sucessfully.
[ 8.081571] MAFP_mas_do_some_for_probe: Get the regulator for avdd_l10 sucessfully.
[ 8.100764] MAFP_mas_probe: debug log! end!msm8953_64:/dev # ls -l madev0
crw-rw-rw- 1 system system 231, 0 1970-01-01 00:28 madev0指纹的初始化是在tz端spi通信,读取id。基本ok后 通过ioctl控制会在驱动中注册相关中断。
如果驱动中已经成功注册了中断,指纹基本上是ok的,查询到的中断应如下。
msm8953_64:/ # cat proc/interruptsCPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU751: 156 0 0 0 0 0 0 0 msmgpio 44 qcom,finger_print-eint在TEE环环境中的指纹,AP侧不做spi通信
3:添加库及权限修改
3.1:添加fingerprintd,拷贝库文件
这里直接将编译好的ta 固件放到源码下,将其编译到system.img中,具体的路径要根据上层服务调用的库中open调用的具体路径来决定。 具体ta库文件的编译,后面再介绍。
diff --git a/device/qcom/msm8953_64/msm8953_64.mk b/device/qcom/msm8953_64/msm8953_64.mk
index ae2d3bb..ee36498 100755
--- a/device/qcom/msm8953_64/msm8953_64.mk
+++ b/device/qcom/msm8953_64/msm8953_64.mk
@@ -102,6 +102,28 @@ PRODUCT_PACKAGES += \+#fingerprint
+PRODUCT_PACKAGES += \
+ fingerprintd \
+
+PRODUCT_COPY_FILES += device/qcom/msm8953_64/mafp/fingerprint.default.so:/system/lib64/hw/fingerprint.default.so
+PRODUCT_COPY_FILES += device/qcom/msm8953_64/mafp/libfprint-x64.so:/system/lib64/libfprint-x64.so
+PRODUCT_COPY_FILES += \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b00:/system/etc/firmware/mafp.b00 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b01:/system/etc/firmware/mafp.b01 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b02:/system/etc/firmware/mafp.b02 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b03:/system/etc/firmware/mafp.b03 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b04:/system/etc/firmware/mafp.b04 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b05:/system/etc/firmware/mafp.b05 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.b06:/system/etc/firmware/mafp.b06 \
+ device/qcom/msm8953_64/mafp/firmware/mafp.mbn:/system/etc/firmware/mafp.mbn \
+ device/qcom/msm8953_64/mafp/firmware/mafp.mdt:/system/etc/firmware/mafp.mdt \ frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml
3.2:Selinux权限相关的修改
在调试指纹的时候,会遇到很多的selinux报错,举一个例子如下:
01-01 22:47:08.185 697 697 E QSEECOMAPI: Error::Failed to open /dev/qseecom device
01-01 22:47:08.185 697 697 D MICROARRAY: [qsc_start_app_V2:90] end. ret=-1
01-01 22:47:08.185 697 697 E MICROARRAY: [ma_tac_create:124] start app ret = -1
01-01 22:47:08.185 697 697 D MICROARRAY: [get_app_name:104] s_app_name = mafp
01-01 22:47:08.185 697 697 D QSEECOMAPI: QSEECom_get_handle sb_length = 0x58000
01-01 22:47:08.179 697 697 W fingerprintd: type=1400 audit(0.0:14): avc: denied { read write } for name="qseecom" dev="tmpfs" info=5621 scontext=u:r:fingerprintd:s0 tcontext=u:object_r:tee_device:s0 tclass=chr_file permissive=0
本着缺什么补什么的原则,以及项目修改的经验,添加一个指纹需要修改的权限大致如下:
--- a/device/qcom/sepolicy/common/device.te
+++ b/device/qcom/sepolicy/common/device.te
++#add by microarray
+type microarray_finger_device_type, dev_type;--- a/device/qcom/sepolicy/common/file.te
+++ b/device/qcom/sepolicy/common/file.te
+#add by microarray gur
+type ma_data_file, file_type, data_file_type;--- a/device/qcom/sepolicy/common/file_contexts
+++ b/device/qcom/sepolicy/common/file_contexts
@@ -388,3 +388,24 @@
+# Devices
+/dev/madev0 u:object_r:microarray_finger_device_type:s0
+/data/system/ma_fingerprint(/.*)? u:object_r:ma_data_file:s0--- a/device/qcom/sepolicy/common/fingerprintd.te
+++ b/device/qcom/sepolicy/common/fingerprintd.te
+allow fingerprintd microarray_finger_device_type:chr_file {create_file_perms};
+allow fingerprintd ma_data_file:file create_file_perms;
+allow fingerprintd ma_data_file:dir create_dir_perms;--- a/device/qcom/sepolicy/common/init.te
+++ b/device/qcom/sepolicy/common/init.te
+allow init ma_data_file:dir {create_file_perms};
+allow init ma_data_file:file {create_file_perms};--- a/device/qcom/sepolicy/common/platform_app.te
+++ b/device/qcom/sepolicy/common/platform_app.te
+allow platform_app microarray_finger_device_type:chr_file {create_file_perms};--- a/device/qcom/sepolicy/common/system_app.te
+++ b/device/qcom/sepolicy/common/system_app.te
+allow system_app microarray_finger_device_type:chr_file {create_file_perms};
修改 开机启动相关服务
--- a/device/qcom/common/rootdir/etc/init.qcom.rc
+++ b/device/qcom/common/rootdir/etc/init.qcom.rc
+ #add by microarray gur
+ mkdir /data/system/ma_fingerprint 0777 system system
@@ -990,6 +993,14 @@ service usb_uicc_enable /system/bin/sh /system/etc/init.qcom.uicc.shdisabledoneshot
+#fingerprint
+service fingerprintd /system/bin/fingerprintd
+ class late_start
+ user system
修改设备节点文件权限
--- a/device/qcom/common/rootdir/etc/ueventd.qcom.rc
+++ b/device/qcom/common/rootdir/etc/ueventd.qcom.rc
@@ -125,6 +125,10 @@
+/dev/madev0 0666 system system
4:TZ侧安全环境的搭建
4.1:编译配置
4.1.1:查看TZ版本
PATH:\TZ.BF.4.0.5\trustzone_images\build\ manifest.xml
<config><image_tree><name>TZ.BF.4.0.5</name><build_id>TZ.BF.4.0.5-00065-M8937AAAAANAZT-1</build_id><branch_point_revision/><revision>00065</revision><spin>1</spin><client>M8937AAAAANAZT</client></image_tree>
</config>
4.1.2:QSEE SDK移植
检查编译环境是否OK配置好编译环境后,可以先编译 sampleapp ta来测试编译环境是否ok。
- 通过阅读BP侧的编译脚本,在TZ下的编译命令是:
else if /i "%1" == "tz" (cd TZ.BF.4.0.5/trustzone_images/build/msif /i "%2" == "" (build.cmd CHIPSET=msm8953 devcfg sampleapp )
- 所以先切换到 编译目录下:
cd \smartmodule\code\TZ.BF.4.0.5\trustzone_images\build\ms
- 清除编译的内容:
build.cmd CHIPSET=msm8953 devcfg sampleapp -c
- 重新编译sampleapp:
build.cmd CHIPSET=msm8953 devcfg sampleapp
- 编译成功,应无error提醒,编译出相关ta文件,产生如下的log,即表示SDKSDK环境OK。
=== Generating sampleapp/A53_64/SANAANAA/smplap64.mdt...
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.mdt
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b00
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b01
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b02
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b03
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b04
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b05
BIN D:\SC60_BP\TZ.BF.4.0.5\trustzone_images\build\ms\bin\PIL_IMAGES\SPLITBINS_SANAANAA\unsigned\smplap64.b06
编译环境加载:
如果SDK编译无法通过,按照以下过程检查环境
- /opt环境添加
解压并拷贝gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux到/opt/arm
解压并拷贝gcc-linaro-aarch64-none-elf-4.9-2014.07_linux到/opt/arm
解压并拷贝Snapdragon_LLVM到/opt
- /home/xxx/bin环境添加
解压并拷贝gcc-arm-none-eabi-4_8-2014q3到/home/xxx/bin
解压并拷贝gcc-linaro-6.1.1-2016.08-i686_arm-linux-gnueabihf到/home/xxx/bin
解压并拷贝arm-eabi-4.8到/home/xxx/bin
- QSEE环境
解压并拷贝TZ.BF.4.0.5到/home/xxx/workspace
- Python安装
将python.exe 添加到 高级环境变量中。
4.1.3:QSEE中添加microarray app
添加ID:
--- a/apps/bsp/trustzone/qsapps/build/secimage.xml
+++ b/apps/bsp/trustzone/qsapps/build/secimage.xml
@@ -118,6 +118,12 @@
+ <image sign_id="mafp" name="mafp.mbn" image_type="elf_has_ht">
+ <general_properties_overrides>
+ <sw_id>0x000000000000000C</sw_id>
+ <app_id>0x0000000000008888</app_id>
+ </general_properties_overrides>
+ </image>--- a/core/bsp/trustzone/qsapps/build/secimage.xml
+++ b/core/bsp/trustzone/qsapps/build/secimage.xml
+ <image sign_id="mafp" name="mafp.mbn" image_type="elf_has_ht">
+ <general_properties_overrides>
+ <sw_id>0x000000000000000C</sw_id>
+ <app_id>0x0000000000008888</app_id>
+ </general_properties_overrides>
+ </image>
拷贝工程文件:
- 拷贝bsp工程文件
cd trustzone_images/core/bsp/trustzone/qsapps/sampleapp/build/ mkdir mafp cp -r ./sampleapp/* mafp
修改 trustzone_images/core/bsp/trustzone/qsapps/myapp/mafp/SConscript
替换所有的sampleapp 和 SAMPLEAPP 为mafp MAFP.
掉 除了 'mafp','all' 所有的 aliases - 拷贝kernel工程文件
cd trustzone_images/core/kernel/libstd/build mkdir mafp cp -r ./sampleapp/* mafp
- 拷贝secure libstd 工程文件
拷贝secure libstd 工程文件 cd trustzone_images/core/securemsm/trustzone/qsee/mink/libstd/build mkdir mafp
- 拷贝secure biometric 工程文件
cd trustzone_images/core/securemsm/trustzone/qsapps/libs/biometric/build mkdir mafp cp -r ./sampleapp/* mafp
- 拷贝secure qsee 工程文件
cd trustzone_images/core/securemsm/trustzone/qsapps/libs/applib/qsee/build mkdir mafp cp -r ./sampleapp/* mafp
- 拷贝secure proxy 工程文件
cd trustzone_images/core/securemsm/trustzone/qsapps/libs/applib/proxy/build mkdir mafp cp -r ./sampleapp/* mafp
- 拷贝secure common_applib 工程文件
cd trustzone_images/core/securemsm/trustzone/qsapps/libs/applib/common_applib/build mkdir mafp cp -r ./sampleapp/* mafp
加入工程文件到编译环境
- 在相关的编译文件中添加 编译选项内容 可以都在'SAMPLEAPP_IMAGE'后面添加。
- 修改文件trustzone_images/core/kernel/libstd/build/Sconscript, 添加'MAFP_IMAGE',共两处。
--- a/core/kernel/libstd/build/SConscript
+++ b/core/kernel/libstd/build/SConscript
@@ -72,13 +72,13 @@ if 'LIBSTD_TEST' in env:env.AddBinaryLibrary(['TZOS_IMAGE','MONITOR_IMAGE','HYPERVISOR_IMAGE', 'CTZL_IMAGE', 'CTZL64_IMAGE', 'TZTESTEXEC_IMAGE', 'WIDEVINE_IMAGE', 'PLAYREADY_IMAGE', 'MACCHIATO_SAMPLE_IMAGE', 'FIDOSUI_IMAGE','GPSAMPLE', 'GPTEST_IMAGE', 'GPTEST2', 'TTAARI1', 'TTACAPI1', 'TTACAPI2', 'TTACAPI3', 'TTACAPI4', 'TTACAPI5', 'TTACRP1', 'TTADS1', 'TTATIME1', 'TTATCF1', 'TTATCF2', 'TTATCF3', 'TTATCF4', 'TTATCF5',
- 'SAMPLEAPP_IMAGE', 'QMPSECAPP_IMAGE', 'SAMPLEAPP64_IMAGE', 'ISDBTMM_IMAGE', 'APTTESTAPP_IMAGE', 'APTCRYPTOTESTAPP_IMAGE', 'ASSURANCETEST_IMAGE', 'ASSURANCETEST64_IMAGE', 'SECURITYTEST_IMAGE','DXHDCP2_IMAGE', 'DXHDCP2DBG_IMAGE',
+ 'SAMPLEAPP_IMAGE', 'MAFP_IMAGE', 'QMPSECAPP_IMAGE', 'SAMPLEAPP64_IMAGE', 'ISDBTMM_IMAGE', 'APTTESTAPP_IMAGE', 'APTCRYPTOTESTAPP_IMAGE', 'ASSURANCETEST_IMAGE', 'ASSURANCETEST64_IMAGE', 'SECURITYTEST_IMAGE','DXHDCP2_IMAGE', 'DXHDCP2DBG_IMAGE',
if 'LIBSTD_TEST' in env:
- env.AddBinaryLibrary(['TZOS_IMAGE', 'HYPERVISOR_IMAGE', 'CTZL_IMAGE', 'CTZL64_IMAGE', 'TZTESTEXEC_IMAGE', 'SAMPLEAPP_IMAGE', 'SAMPLEAPP64_IMAGE', 'FINGERPRINT_IMAGE', 'FINGERPRINT64_IMAGE', 'IRIS_IMAGE', 'RETSTAPP_IMAGE',
+ env.AddBinaryLibrary(['TZOS_IMAGE', 'HYPERVISOR_IMAGE', 'CTZL_IMAGE', 'CTZL64_IMAGE', 'TZTESTEXEC_IMAGE', 'SAMPLEAPP_IMAGE', 'MAFP_IMAGE', 'SAMPLEAPP64_IMAGE', 'FINGERPRINT_IMAGE', 'FINGERPRINT64_IMAGE', 'IRIS_IMAGE', 'RETSTAPP_IMAGE',
- 修改文件trustzone_images/core/securemsm/trustzone/qsee/mink/libstd/build/Sconscript, 添加'MAFP_IMAGE',共一处。
--- a/core/securemsm/trustzone/qsee/mink/libstd/build/SConscript
+++ b/core/securemsm/trustzone/qsee/mink/libstd/build/SConscript
@@ -108,7 +108,7 @@ images = ['TZOS_IMAGE', 'MONITOR_IMAGE', 'HYPERVISOR_IMAGE','GPSAMPLE', 'GPTEST_IMAGE', 'TTAARI1', 'TTACAPI1', 'TTACAPI2', 'TTACAPI3','TTACAPI4', 'TTACAPI5', 'TTACRP1', 'TTADS1', 'TTATIME1','TTATCF1', 'TTATCF2', 'TTATCF3', 'TTATCF4', 'TTATCF5',
- 'SAMPLEAPP_IMAGE', 'SMPLSERV_IMAGE', 'SMPLCERT_IMAGE',
+ 'SAMPLEAPP_IMAGE', 'MAFP_IMAGE', 'SMPLSERV_IMAGE', 'SMPLCERT_IMAGE',
- 修改文件 trustzone_images/core/securemsm/trustzone/qsapps/libs/biometric/build/Sconscript,添加MAFP_IMAGE,共一处。
--- a/core/securemsm/trustzone/qsapps/libs/biometric/build/SConscript
+++ b/core/securemsm/trustzone/qsapps/libs/biometric/build/SConscript
@@ -80,6 +80,7 @@ biometric_lib = '${BUILDPATH}/biometric_lib'env.AddBinaryLibrary (['SAMPLEAPP_IMAGE'],biometric_lib, [BIOMETRIC_LIB_SOURCES])
+env.AddBinaryLibrary (['MAFP_IMAGE'],biometric_lib, [BIOMETRIC_LIB_SOURCES])
- 修改文件 trustzone_images/core/securemsm/trustzone/qsapps/libs/applib/qsee/build/Sconscript,添加MAFP_IMAGE,共两处。
--- a/core/securemsm/trustzone/qsapps/libs/applib/qsee/build/SConscript
+++ b/core/securemsm/trustzone/qsapps/libs/applib/qsee/build/SConscript
@@ -156,6 +156,8 @@ elif env.has_key('KEYMASTERLAT_IMAGE'):LIB_ENTRY_SOURCES += [ '${BUILDPATH}/src/tzapp_lib_main.c',]elif env.has_key('SAMPLEAPP_IMAGE'):LIB_ENTRY_SOURCES += [ '${BUILDPATH}/src/tzapp_lib_main.c',]
+elif env.has_key('MAFP_IMAGE'):
+ LIB_ENTRY_SOURCES += [ '${BUILDPATH}/src/tzapp_lib_main.c',]
@@ -211,6 +213,9 @@ else:env.AddBinaryObject('SAMPLEAPP_IMAGE', IMG_ENTRY_SOURCES)env.AddBinaryLibrary('SAMPLEAPP_IMAGE', '${BUILDPATH}/tzapp_entrylib', LIB_ENTRY_SOURCES)
+env.AddBinaryObject('MAFP_IMAGE', IMG_ENTRY_SOURCES)
+env.AddBinaryLibrary('MAFP_IMAGE', '${BUILDPATH}/tzapp_entrylib', LIB_ENTRY_SOURCES)
- 修改文件 trustzone_images/core/securemsm/trustzone/qsapps/libs/applib/proxy/build/Sconscript,添加MAFP_IMAGE,共一处。
--- a/core/securemsm/trustzone/qsapps/libs/applib/proxy/build/SConscript
+++ b/core/securemsm/trustzone/qsapps/libs/applib/proxy/build/SConscript
@@ -118,7 +118,7 @@ env.LoadSoftwareUnits()env.AddBinaryLibrary(['KEYMASTER_IMAGE', 'KEYMASTER64_IMAGE', 'KEYMASTERLAT_IMAGE','GPSAMPLE', 'GPTEST_IMAGE', 'GPTEST2', 'TTAARI1', 'TTACAPI1', 'TTACAPI2', 'TTACAPI3', 'TTACAPI4', 'TTACAPI5', 'TTACRP1', 'TTADS1', 'TTATIME1', 'TTATCF1', 'TTATCF2', 'TTATCF3',
- 'TTATCF4', 'TTATCF5', 'SAMPLEAPP_IMAGE', 'SAMPLEAPP64_IMAGE', 'ASSURANCETEST_IMAGE', 'ASSURANCETEST64_IMAGE', 'SECUREUISAMPLE_IMAGE', 'SECUREUISAMPLE64_IMAGE', 'APTTESTAPP_IMAGE', 'APTCRYPTOTESTAPP_IMAGE', 'FIDOCONFIG_IMAGE',
+ 'TTATCF4', 'TTATCF5', 'SAMPLEAPP_IMAGE', 'MAFP_IMAGE', 'SAMPLEAPP64_IMAGE', 'ASSURANCETEST_IMAGE', 'ASSURANCETEST64_IMAGE', 'SECUREUISAMPLE_IMAGE', 'SECUREUISAMPLE64_IMAGE', 'APTTESTAPP_IMAGE', 'APTCRYPTOTESTAPP_IMAGE', 'FIDOCONFIG_IMAGE',
- 修改文件trustzone_images/core/securemsm/secrsa/build/SConscript,添加以下脚本:
--- a/core/securemsm/secrsa/build/SConscript
+++ b/core/securemsm/secrsa/build/SConscript
@@ -70,6 +70,11 @@ if env.has_key('WINSECAPP_IMAGE'):
+if env.has_key('MAFP_IMAGE'):
+ env.Append(CPPPATH = "${COREBSP_ROOT}/securemsm/secrsa/env/sampleapp/inc")
+ env.Append(CPPPATH = "${COREBSP_ROOT}/securemsm/secmath/env/sampleapp/inc")
+ env.Append(CPPPATH = "${COREBSP_ROOT}/api/securemsm/trustzone/qsee")
+ env.Append(CPPPATH = "${COREBSP_ROOT}/api/securemsm/crypto")
@@ -84,6 +89,8 @@ elif env.has_key('GPTEST_IMAGE'): env.Append(CCFLAGS = " -O3 ") elif env.has_key('SAMPLEAPP_IMAGE'): env.Append(CCFLAGS = " -O3 ")
+elif env.has_key('MAFP_IMAGE'):
+ env.Append(CCFLAGS = " -O3 ")
4.2:修改TA meory size
QSEE中的修改:
--- a/core/securemsm/trustzone/qsee/mink/oem/config/msm8953/oem_config.xml
+++ b/core/securemsm/trustzone/qsee/mink/oem/config/msm8953/oem_config.xml
@@ -40,10 +40,10 @@</props><!-- PIL load region information --><props name="OEM_pil_secure_app_load_region_start" type=DALPROP_ATTR_TYPE_UINT32>
- 0x85B00000
+ 0x84a00000</props><props name="OEM_pil_secure_app_load_region_size" type=DALPROP_ATTR_TYPE_UINT32>
- 0x800000
+ 0x1900000</props><props name="OEM_pil_subsys_load_region_start" type=DALPROP_ATTR_TYPE_UINT32>
LK中的修改:
--- a/bootable/bootloader/lk/platform/msm8953/include/platform/iomap.h
+++ b/bootable/bootloader/lk/platform/msm8953/include/platform/iomap.h
@@ -221,8 +221,12 @@#define RPMB_SND_RCV_BUF_SZ 0x1/* QSEECOM: Secure app region notification */
-#define APP_REGION_ADDR 0x85B00000
-#define APP_REGION_SIZE 0x800000
+#define APP_REGION_ADDR 0x84a00000
+#define APP_REGION_SIZE 0x1900000
Kernel中的修改:
--- a/kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953.dtsi
+++ b/kernel/msm-3.18/arch/arm/boot/dts/qcom/msm8953.dtsi
@@ -34,7 +34,8 @@other_ext_mem: other_ext_region@0 {compatible = "removed-dma-pool";no-map;
- reg = <0x0 0x85b00000 0x0 0xd00000>;
+ // reg = <0x0 0x85b00000 0x0 0xd00000>;
+ reg = <0x0 0x84a00000 0x0 0x1E00000>;};modem_mem: modem_region@0 {
@@ -2084,9 +2085,10 @@qcom,ce-opp-freq = <100000000>;};
- qcom_seecom: qseecom@85b00000 {
+ qcom_seecom: qseecom@84a00000 {compatible = "qcom,qseecom";
- reg = <0x85b00000 0x800000>;
+ // reg = <0x85b00000 0x800000>;
+ reg = <0x84a00000 0x1900000>;
5:debug 流程
- 查看 上电 是否正常
- 驱动加载是否ok,查看/dev/madev0 是否生成
- 查看logcat 查询上层服务是否正常运行
adb logcat -v time -s MICROARRAY
在log中观察是否存在 .so无法使用,固件库加载不到,selinux权限问题等。
服务加载上通讯不ok,指纹界面应该有了但是无法录入如下图,需要和FAE沟通是否是 库文件的问题。
- 查看 上电 是否正常
- 驱动加载是否ok,查看/dev/madev0 是否生成
- 查看logcat 查询上层服务是否正常运行
adb logcat -v time -s MICROARRAY - 在log中观察是否存在 .so无法使用,固件库加载不到,selinux权限问题等。
- 查看qsee log,查看TZ端是否有报错
cat /sys/kernel/debug/tzdbg/qsee_log - 在添加TZ环境的时候,建议创建git 仓库,把相关文件目录加到仓库中,这样在添加一直过程中可以反复确认移植添加的代码否有缺漏。
- 确认TZ下的spi通道是否配置ok,可以使用高通平台下的可执行命令查看:
adb shell qseecom_sample_client v smplap64 19 1 6 //备注,最后一位代表SPI总线,枚举从0开始,6理论代表SPI7 。
成功添加指纹的状态是如下状态: