本文转载自简书,原文作者:后知晚觉,https://www.jianshu.com/p/17af7a8f7864

CP代码编译方法

交叉编译工具下载

在高通网站上下载llvm,

llvm编译器版本,可以在llvm.py脚本中通过print获取:

vim /....../CP/TZ.XF.5.1/trustzone_images/tools/build/scons/scripts/llvm.py +189

增加代码:print(os.environ.has_key('LLVMBIN'))

我的环境中,打印LLVMBIN的路径为:/pkg/LLVM/8.0.9

下载完成后,解压后,将目录重命名为8.0.9,并mv到/pkg/LLVM目录下。

然后在CP目录下执行./build.sh tz命令。

会报错,提示找不到gcc-linaro编译器,根据报错版本描述,在linaro网站下下载对应的版本。

我搜到的下载地址为:https://releases.linaro.org/archive/14.07/components/toolchain/binaries/

下载解压后,mv到报错提示的位置:/pkg/LLVM/linaro/

编译

再次在CP目录下执行./build.sh tz命令:

./build.sh tz

提示编译成功:

scons: done building targets.==============================================================================SCons build summary
==============================================================================
** Build time...Build start  : Wed Jun  9 09:28:52 2021Build end    : Wed Jun  9 09:28:58 2021Elapsed time : 0:00:06Start Time = 2021年 06月 09日 星期三 09:28:52 CST - End Time = 2021年 06月 09日 星期三 09:28:58 CST
Elapsed Time = 6 seconds
WARNING:build_all:Extra artifacts: devcfg.mbn, focal32.mbn, gpsample.mbn, smplap32.mbn, smplap64.mbn, smplcert.mbn, smplserv.mbn, teetest.mbn, teetest64.mbn
INFO:build_all:Build completed successfully
INFO:build_all:Total elapsed time: 0 minutes, 8 seconds

上面的步骤是整编trustzone,如果只编译某个App,则执行下面的命令:

cd /....../CP/TZ.XF.5.1/trustzone_images/build/ms
python build_all.py -b TZ.XF.5.1 CHIPSET=kamorta --cbt=sampleapp

测试

将编译好的sampleapp push到系统中测试:

adb root
adb remount
adb shell mount -o remount,RW /vendor/firmware_mnt
cd /....../TZ.XF.5.1/trustzone_images/build/ms/bin/PIL_IMAGES/SPLITBINS_FADAANAA/signed
adb push smplap* /vendor/firmware_mnt/image/
adb shell sync

运行测试程序:

$ adb shell qseecom_sample_client v smplap32 0 1
Note: Command line arguments do not belong to legacy test
Starting qsc_run_get_version test: cmd = 0, thread = 1
qsc_run_get_version PASSED

调试

执行qseecom_sample_client命令时,查看TA侧的log:

$ adb shell cat /sys/kernel/debug/tzdbg/qsee_log
[7eb1a0662]<1>smplap32: SAMPLEApp constructor
[7eb1a072d]<1>smplap32: SAMPLEApp constructor2
[7eb1a07d3]<1>smplap32: SAMPLEApp Init
[7eb1a0875]<1>smplap32: Version: 1.3
[7eb1c3af2]<1>smplap32: TZ App cmd handler, cmd_id = 0
[7eb1c3c5a]<1>smplap32: ****PASSED : get version test
[7eb1c9864]<1>smplap32: SAMPLE App shutdown
[7eb1c9a33]<1>smplap32: SAMPLEApp destructor2
[7eb1c9acc]<1>smplap32: SAMPLEApp destructor

TA侧的log可以反映出sampleapp源码的app_main.c中的生命周期函数。

app_main.c中的如下函数被依次执行:

  1. tz_contructor
  2. tz_contructor2
  3. tz_app_init
  4. tz_app_cmd_handler
  5. tz_app_shutdown
  6. tz_destructor2
  7. tz_destructor

sampleapp中cmd_id为0命令为获取sampleapp的版本号,对应tz_app_cmd_handler函数中“case CLIENT_CMD0_GET_VERSION" 逻辑。

自定义TA---keyzeroapp

参考sampleapp创建app

拷贝sampleapp,重命名为hellotrustapp。

sampleapp代码在/....../CP/TZ.XF.5.1/trustzone_images/ssg/securemsm/trustzone/qsapps目录下。

并将src目录下的SConscript文件中红出现的smplap和sampleapp字符串修改为hellota和hellotrustapp。

修复hellotrustapp中的uuid变量值,使用HelloTrustApp字符串对应的十六进制值:

HelloTrustApp -> 48656c6c6f5472757374417070

修改app_main.c中的SAMPLEApp字符串为:HelloTrustApp

增加编译配置

编辑/....../CP/TZ.XF.5.1/trustzone_images/ssg/bsp/trustzone/build/SConscript文件,按照sampleapp的配置,复制出hellotrustapp的编译配置(共三处)。

增加hellotrustapp的依赖文件:

在/....../CP/TZ.XF.5.1/trustzone_images/ssg/bsp/trustzone/qsapps目录下,复制sampleapp和smplap64目录,重命名为hellotrustapp和hellota64目录。

配置mdt split规则

/....../CP/TZ.XF.5.1/trustzone_images/sectools/config/kamorta/kamorta_secimage.xml

在kamorta_secimage文件中按照sampleapp的格式编写hellotrustapp的文件split规则。

添加整编规则

vim /....../CP/TZ.XF.5.1/trustzone_images/build/ms/build_config_deploy_kamorta.xml

在文件中sampleapp前面增加:

<alias build-once="false" disable="false" internal-test="false" name="keyzeroapp" recompile="true" strip="false"><artifact name="keyzero32"/><artifact name="keyzero64"/><mapreport path="ssg/bsp/trustzone/qsapps"/>
</alias>

编译

整编:

cd /....../CP
./build.sh tz

只有整编的情况下,才会生成split文件,生成的split文件在/....../CP/TZ.XF.5.1/trustzone_images/build/ms/bin/PIL_IMAGES/SPLITBINS_FADAANAA目录下:

SPLITBINS_FADAANAA$ ls hellota*
hellota32.b00  hellota32.b02  hellota32.b04  hellota32.b06  hellota32.mdt  hellota64.b01  hellota64.b03  hellota64.b05  hellota64.b07
hellota32.b01  hellota32.b03  hellota32.b05  hellota32.b07  hellota64.b00  hellota64.b02  hellota64.b04  hellota64.b06  hellota64.mdt

测试

push到设备中:

adb push hellota* /vendor/firmware_mnt/image/
hellota32.b00: 1 file pushed. 0.0 MB/s (308 bytes in 0.027s)
hellota32.b01: 1 file pushed. 0.3 MB/s (6952 bytes in 0.025s)
hellota32.b02: 1 file pushed. 3.3 MB/s (256860 bytes in 0.074s)
hellota32.b03: 1 file pushed. 0.0 MB/s (205 bytes in 0.013s)
hellota32.b04: 1 file pushed. 13.0 MB/s (1475900 bytes in 0.108s)
hellota32.b05: 1 file pushed. 0.1 MB/s (1212 bytes in 0.009s)
hellota32.b06: 1 file pushed. 0.0 MB/s (152 bytes in 0.011s)
hellota32.b07: 1 file pushed. 2.5 MB/s (42991 bytes in 0.016s)
hellota32.mdt: 1 file pushed. 0.5 MB/s (7260 bytes in 0.013s)
hellota64.b00: 1 file pushed. 0.0 MB/s (512 bytes in 0.013s)
hellota64.b01: 1 file pushed. 0.4 MB/s (6952 bytes in 0.015s)
hellota64.b02: 1 file pushed. 4.6 MB/s (305840 bytes in 0.064s)
hellota64.b03: 1 file pushed. 0.0 MB/s (249 bytes in 0.014s)
hellota64.b04: 1 file pushed. 13.2 MB/s (1485648 bytes in 0.108s)
hellota64.b05: 1 file pushed. 0.2 MB/s (2424 bytes in 0.009s)
hellota64.b06: 1 file pushed. 0.0 MB/s (304 bytes in 0.007s)
hellota64.b07: 1 file pushed. 4.8 MB/s (78789 bytes in 0.016s)
hellota64.mdt: 1 file pushed. 0.7 MB/s (7464 bytes in 0.010s)
18 files pushed. 6.1 MB/s (3680022 bytes in 0.575s)adb shell sync

运行测试程序:

$ adb shell qseecom_sample_client v hellota32 0 1
Note: Command line arguments do not belong to legacy test
Starting qsc_run_get_version test: cmd = 0, thread = 1
qsc_run_get_version PASSED

观察TA运行日志:

 adb shell cat /sys/kernel/debug/tzdbg/qsee_log
[66fc0d1a7b]<1>hellota32: HelloTrustApp constructor
[66fc0d1b6c]<1>hellota32: HelloTrustApp constructor2
[66fc0d1c1b]<1>hellota32: HelloTrustApp Init
[66fc0d1cb7]<1>hellota32: Version: 1.3
[66fc0f7c30]<1>hellota32: TZ App cmd handler, cmd_id = 0
[66fc0f7da9]<1>hellota32: ****PASSED : get version test
[66fc0fe53b]<1>hellota32: SAMPLE App shutdown
[66fc0fe702]<1>hellota32: HelloTrustApp destructor2
[66fc0fe7a3]<1>hellota32: HelloTrustApp destructor

Trust App(高通)相关推荐

  1. [App] 高通系统闹钟app DeskClock的修改

    系统主界面本来是4个fragment, 分别是alarm, clock, timer, stopwatch.现在应用写不了闹钟app,我直接让他在需要闹钟的地方,跳到系统闹钟DeskClock的设置闹 ...

  2. 基于高通410c开发板,开发android端家庭控制中心APP(1)

    家庭控制中心APP运行在android端,通过与服务器通讯控制高通410c开发板. 基本功能如下: 1. 应用分为三个功能模块,包括电动窗帘.智能照明以及烟雾模块. 2. 电动窗帘模块中,包括调整窗帘 ...

  3. 简谈高通Trustzone的实现

    从trust zone之我见知道,支持trustzone的芯片会跑在两个世界. 普通世界.安全世界,对应高通这边是HLOS,QSEE. 如下图: 如下是HLOS与QSEE的软件架构图 HLOS这两分为 ...

  4. 简谈高通Trustzone的实现【转】

    本文转载自:https://blog.csdn.net/hovan/article/details/42520879 从trust zone之我见知道,支持trustzone的芯片会跑在两个世界. 普 ...

  5. 高通平台android开发总结

    http://www.cnblogs.com/yuzaipiaofei/archive/2012/07/24/4124179.html 1.高通平台android开发总结 1.1 搭建高通平台环境开发 ...

  6. 高通平台android 环境配置编译及开发经验总结

    完全转自:http://blog.csdn.net/dongwuming/article/details/12784535 1.高通平台android开发总结 1.1 搭建高通平台环境开发环境 在高通 ...

  7. 高通Android智能平台环境搭建_编译流程分析

    高通Android智能平台环境搭建_编译流程分析 高通平台环境搭建,编译,系统引导流程分析 TOC \o \h \z \u 1. 高通平台android开发总结. 7 1.1 搭建高通平台环境开发环境 ...

  8. 高通Android智能平台开发总结

    高通Android智能平台开发总结 1. 高通平台android开发总结. 7 1.1 搭建高通平台环境开发环境. 7 1.2 搭建高通平台环境开发环境. 7 1.2.1 高通android智能平台概 ...

  9. 高通平台android开发总结 .

    http://blog.csdn.net/mirkerson/article/details/7691029 http://blog.csdn.net/mirkerson/article/detail ...

最新文章

  1. 深入理解 python 元类
  2. lifekeeper for linxu安装步骤
  3. getsockname和getpeername
  4. 创建、编辑、删除目录
  5. python脚本创建拓扑_实验 1:Mininet --拓扑的命令脚本生成
  6. oracle 如何数组变成表,Oracle从零开始19——表的管理09——嵌套表和可变数组
  7. Partial Sums ZOJ - 1569
  8. 前端学习(1970)vue之电商管理系统电商系统之渲染添加参数的对话框
  9. CJOJ 1087 【NOIP2010】乌龟棋 / Luogu 1541 乌龟棋(动态规划)
  10. OJ1158: 又是排序(指针专题)(C语言)
  11. AYUI第12个作品-英雄联盟-魔法少女的星光水晶2.0-WPF版本
  12. 离散数学及其应用(第七版黑书)笔记
  13. Texture ASTC转换ETC
  14. 已通过认证的微信公众号名字可以改吗?
  15. 项目开发-工具-版本控制Git完整系统化使用说明
  16. Week10-树形数据结构与应用
  17. java异常在控制台和日志里面的打印记录
  18. Java 8 并发篇 - 冷静分析 Synchronized(上)
  19. WAP手机安全上网防病毒攻略
  20. 【物联网那些事儿】18 大物联网操作系统,Raspbian Pi、Ubuntu Core、Windows 10 IoT、Micropython、OpenWrt ....你用过哪几个?

热门文章

  1. linux ubantu snmp服务,ubuntu 20.04 snmp安装配置
  2. 白鹭小游戏-成语挑战-资源放置
  3. 微信公众号客服系统怎么生成能追踪效果的二维码?
  4. VM虚拟机(VMware)设置外网连接
  5. 非标准武术擂台机器人的设计思想——机械结构的设计思想
  6. 新加坡国立大学Robby T. Tan教授招收计算机视觉方向博士生
  7. 2021年12月电子学会图形化三级编程题解析含答案:跳高比赛
  8. mysql笛卡尔积查询很慢_浅谈MySQL使用笛卡尔积原理进行多表查询
  9. “盘古”走向产业山峦,打开了一串AI落地的新脑洞
  10. 华为运营商级路由器配置示例 | IPv4静态路由