这是机器未来的第62篇文章
原文首发地址:https://robotsfutures.blog.youkuaiyun.com/article/details/127863892
《深入浅出i.MX8企业级开发实战》快速导航:
【01】imx8qxp yocto工程构建指南
【02】Yocto工程repo源码gitee加速配置方法
【03】imx8qxp一键独立编译指南
【04】嵌入式Linux设备掉电数据容错研究
文章目录
写在开始:
- 博客简介:专注AIoT领域,追逐未来时代的脉搏,记录路途中的技术成长!
- 博主社区:AIoT机器智能, 欢迎加入!
- 专栏简介:imx8qxp小白从拿到板子到完成项目的过程记录
- 面向人群:嵌入式工程师
1. 概述
本文描述了optee-os在Qemu仿真开发环境的搭建
2. 环境搭建
2.1 创建项目根目录
mkdir optee_qemu_project
2.1 安装repo和配置板卡
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml -b 3.18.0 --repo-url=https://gerrit-googlesource.lug.ustc.edu.cn/git-repo
因为国内无法访问谷歌,因此需要指定清华的源。版本选择最新的3.18.0版本,如果下载失败,重新下载的话,需要删除.repo目录。
下载成功的输出信息如下:
如果下载失败,重新下载的话,需要删除.repo目录。
repo has been initialized in /home/zhoushimin/workspace/optee_qemu_project/
If this is not the directory in which you want to initialize repo, please run:
rm -r /home/zhoushimin/workspace/optee_qemu_project//.repo
and try again.
2.2 下载源码
repo sync -j $(nproc)
-j $(nproc)选项表示根据CPU核心数配置最大线程加速。
如果出现网络不好,可以使用VPN,博主使用VPN下载速度还可以。
2.3 下载工具链
cd build
make -f toolchains.mk
下载完毕后,会在上层目录,也就是根目录下创建toochains工具链文件夹
3. 编译
cd build
make -f qemu_v8.mk all
3.1 编译过程中遇到的问题
3.1.1 提示找不到OpenSC-0.21.0.tar.gz: No such file or directory
opensc下载目录发生变化,opensc-0.21已不存在,需要调整,修改build/br-ext/package/opensc/opensc.mk文件中的
OPENSC_VERSION = 0.21.0
OPENSC_SOURCE = /OpenSC-$(OPENSC_VERSION).tar.gz
为
OPENSC_VERSION = 0.22.0
OPENSC_SOURCE = /opensc-$(OPENSC_VERSION).tar.gz
3.1.2 编译出错,仅清除指定目录编译输出的方法
make -C ../imx-optee-test/ clean TA_DEV_KIT_DIR=/home/zhoushimin/workspace/imx8qxp-mek/build/../optee_os/out/arm/export-ta_arm64
4. 运行
cd build
make -f qemu_v8.mk run-only
启动后除了原来的终端,会弹出另外的2个终端窗口,一个为TEE运行环境跑OPTEE OS,一个REE运行环境跑Linux OS
注释:
- REE(Rich Execution Environment)是所有移动设备通用的环境,运行通用的 OS(Operating System),例如 Android,IOS 系统等
- TEE (Trusted Execution Environment )是可信执行环境。通常用来进行数字版权管理(DRM : Digital Rights Management )、移动支付和敏感数据保护。
TEE运行唤醒窗口输出:
REE运行环境窗口输出:
执行终端的输出如下:
在执行终端输入c或者cont启动模拟器
(qemu)c
可以看到REE的打印日志:
listening on port 54320
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
NOTICE: Booting Trusted Firmware
NOTICE: BL1: v2.6(release):v2.6
NOTICE: BL1: Built : 14:29:04, Sep 8 2022
WARNING: Firmware Image Package header check failed.
NOTICE: BL1: Booting BL2
NOTICE: BL2: v2.6(release):v2.6
NOTICE: BL2: Built : 14:29:07, Sep 8 2022
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
WARNING: Firmware Image Package header check failed.
NOTICE: BL1: Booting BL31
NOTICE: BL31: v2.6(release):v2.6
NOTICE: BL31: Built : 14:29:13, Sep 8 2022
UEFI firmware (version built at 14:28:15 on Sep 8 2022)
EFI stub: Booting Linux Kernel...
EFI stub: Using DTB from configuration table
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Exiting boot services...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[ 0.000000] Linux version 5.17.0 (zhoushimin@zsm) (aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 10.2.1 20201103, GNU ld (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16)) 2.35.1.20201028) #1 SMP PREEMPT Thu Sep 8 16:12:54 CST 2022
[ 0.000000] Machine model: linux,dummy-virt
[ 0.000000] printk: debug: skip boot console de-registration.
[ 0.000000] efi: EFI v2.70 by EDK II
[ 0.000000] efi: SMBIOS=0x81510000 SMBIOS 3.0=0x7e0d0000 MEMATTR=0x7e408118 RNG=0x8161d318 MEMRESERVE=0x7e183f18
[ 0.000000] efi: seeding entropy pool
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x00000000820fffff]
[ 0.000000] NUMA: NODE_DATA [mem 0x81edeb40-0x81ee0fff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x00000000820fffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000041ffffff]
[ 0.000000] node 0: [mem 0x0000000042000000-0x00000000421fffff]
[ 0.000000] node 0: [mem 0x0000000042200000-0x000000007de3ffff]
[ 0.000000] node 0: [mem 0x000000007de40000-0x000000007e17ffff]
[ 0.000000] node 0: [mem 0x000000007e180000-0x000000008145ffff]
[ 0.000000] node 0: [mem 0x0000000081460000-0x00000000814effff]
[ 0.000000] node 0: [mem 0x00000000814f0000-0x00000000814fffff]
[ 0.000000] node 0: [mem 0x0000000081500000-0x000000008161ffff]
[ 0.000000] node 0: [mem 0x0000000081620000-0x00000000820fffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x00000000820fffff]
[ 0.000000] On node 0, zone DMA: 24320 pages in unavailable ranges
[ 0.000000] cma: Reserved 32 MiB at 0x000000007ac00000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.1 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS migration not required
[ 0.000000] psci: SMC Calling Convention v1.2
[ 0.000000] percpu: Embedded 20 pages/cpu s41752 r8192 d31976 u81920
[ 0.000000] Detected PIPT I-cache on CPU0
[ 0.000000] CPU features: detected: Branch Target Identification
[ 0.000000] CPU features: detected: Address authentication (architected algorithm)
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] CPU features: detected: Spectre-v4
[ 0.000000] CPU features: kernel page table isolation forced ON by KASLR
[ 0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[ 0.000000] alternatives: patching kernel code
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 266364
[ 0.000000] Policy zone: DMA
[ 0.000000] Kernel command line: console=ttyAMA0,38400 keep_bootcon root=/dev/vda2 initrd=initrd
[ 0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 976272K/1082368K available (15552K kernel code, 3224K rwdata, 8584K rodata, 6528K init, 511K bss, 73328K reserved, 32768K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Preemptible hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=2.
[ 0.000000] Trampoline variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] GICv3: 224 SPIs implemented
[ 0.000000] GICv3: 0 Extended SPIs implemented
[ 0.000000] GICv3: Distributor has no Range Selector support
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GICv3: 16 PPIs implemented
[ 0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000080a0000
[ 0.000000] ITS [mem 0x08080000-0x0809ffff]
[ 0.000000] ITS@0x0000000008080000: allocated 8192 Devices @40040000 (indirect, esz 8, psz 64K, shr 1)
[ 0.000000] ITS@0x0000000008080000: allocated 8192 Interrupt Collections @40050000 (flat, esz 8, psz 64K, shr 1)
[ 0.000000] GICv3: using LPI property table @0x0000000040060000
[ 0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000040070000
[ 0.000000] random: get_random_bytes called from start_kernel+0x478/0x664 with crng_init=0
[ 0.000000] arch_timer: cp15 timer(s) running at 62.50MHz (virt).
[ 0.000000] clocksource: arch_sys_counter: mask: 0x1ffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[ 0.000156] sched_clock: 57 bits at 62MHz, resolution 16ns, wraps every 4398046511096ns
[ 0.024686] Console: colour dummy device 80x25
[ 0.031160] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[ 0.034860] pid_max: default: 32768 minimum: 301
[ 0.041305] LSM: Security Framework initializing
[ 0.048346] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.049065] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.159505] /cpus/cpu-map: empty cluster
[ 0.180384] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.180768] cblist_init_generic: Setting shift to 1 and lim to 1.
[ 0.187404] rcu: Hierarchical SRCU implementation.
[ 0.198603] Platform MSI: its@8080000 domain created
[ 0.202599] PCI/MSI: /intc@8000000/its@8080000 domain created
[ 0.205495] fsl-mc MSI: its@8080000 domain created
[ 0.232816] Remapping and enabling EFI services.
[ 0.248810] smp: Bringing up secondary CPUs ...
[ 0.266595] Detected PIPT I-cache on CPU1
[ 0.268481] GICv3: CPU1: found redistributor 1 region 0:0x00000000080c0000
[ 0.270092] GICv3: CPU1: using allocated LPI pending table @0x0000000040080000
[ 0.272950] CPU1: Booted secondary processor 0x0000000001 [0x000f0510]
[ 0.283506] smp: Brought up 1 node, 2 CPUs
[ 0.283975] SMP: Total of 2 processors activated.
[ 0.284250] CPU features: detected: 32-bit EL0 Support
[ 0.284477] CPU features: detected: 32-bit EL1 Support
[ 0.284788] CPU features: detected: Common not Private translations
[ 0.284967] CPU features: detected: CRC32 instructions
[ 0.285256] CPU features: detected: Generic authentication (architected algorithm)
[ 0.285447] CPU features: detected: RCpc load-acquire (LDAPR)
[ 0.285623] CPU features: detected: LSE atomic instructions
[ 0.285795] CPU features: detected: Privileged Access Never
[ 0.285978] CPU features: detected: Random Number Generator
[ 0.286190] CPU features: detected: Speculation barrier (SB)
[ 0.286387] CPU features: detected: TLB range maintenance instructions
[ 0.286687] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[ 0.823910] CPU: All CPU(s) started at EL1
[ 0.947981] devtmpfs: initialized
[ 1.030803] KASLR enabled
[ 1.036515] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 1.037814] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[ 1.066678] pinctrl core: initialized pinctrl subsystem
[ 1.111001] SMBIOS 3.0.0 present.
[ 1.111920] DMI: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
[ 1.135952] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 1.178043] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[ 1.180788] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 1.183742] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 1.184973] audit: initializing netlink subsys (disabled)
[ 1.190868] audit: type=2000 audit(1.036:1): state=initialized audit_enabled=0 res=1
[ 1.222240] thermal_sys: Registered thermal governor 'step_wise'
[ 1.222731] thermal_sys: Registered thermal governor 'power_allocator'
[ 1.228298] cpuidle: using governor menu
[ 1.232826] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[ 1.234640] ASID allocator initialised with 32768 entries
[ 1.269530] Serial: AMBA PL011 UART driver
[ 1.693585] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 45, base_baud = 0) is a PL011 rev1
[ 1.775713] printk: console [ttyAMA0] enabled
[ 2.076429] HugeTLB registered 1.00 GiB page size, pre-allocated 0 pages
[ 2.077699] HugeTLB registered 32.0 MiB page size, pre-allocated 0 pages
[ 2.079835] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[ 2.081713] HugeTLB registered 64.0 KiB page size, pre-allocated 0 pages
[ 2.127635] ACPI: Interpreter disabled.
[ 2.186944] iommu: Default domain type: Translated
[ 2.188118] iommu: DMA domain TLB invalidation policy: strict mode
[ 2.195666] vgaarb: loaded
[ 2.204132] SCSI subsystem initialized
[ 2.215355] usbcore: registered new interface driver usbfs
[ 2.217017] usbcore: registered new interface driver hub
[ 2.218358] usbcore: registered new device driver usb
[ 2.243789] pps_core: LinuxPPS API ver. 1 registered
[ 2.244771] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 2.246009] PTP clock support registered
[ 2.249768] EDAC MC: Ver: 3.0.0
[ 2.269959] ARM FF-A: FFA_VERSION returned not supported
[ 2.281037] Registered efivars operations
[ 2.309579] FPGA manager framework
[ 2.312979] Advanced Linux Sound Architecture Driver Initialized.
[ 2.353152] clocksource: Switched to clocksource arch_sys_counter
[ 2.363411] VFS: Disk quotas dquot_6.6.0
[ 2.365582] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 2.373672] pnp: PnP ACPI: disabled
[ 2.586214] NET: Registered PF_INET protocol family
[ 2.591113] IP idents hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 2.605331] tcp_listen_portaddr_hash hash table entries: 1024 (order: 2, 16384 bytes, linear)
[ 2.606857] TCP established hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 2.608317] TCP bind hash table entries: 16384 (order: 6, 262144 bytes, linear)
[ 2.610388] TCP: Hash tables configured (established 16384 bind 16384)
[ 2.613972] UDP hash table entries: 1024 (order: 3, 32768 bytes, linear)
[ 2.615998] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes, linear)
[ 2.622781] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 2.633788] RPC: Registered named UNIX socket transport module.
[ 2.634576] RPC: Registered udp transport module.
[ 2.635128] RPC: Registered tcp transport module.
[ 2.635694] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 2.637078] PCI: CLS 0 bytes, default 64
[ 2.651763] Unpacking initramfs...
[ 2.660376] hw perfevents: enabled with armv8_pmuv3 PMU driver, 5 counters available
[ 2.663945] kvm [1]: HYP mode not available
[ 2.686115] Initialise system trusted keyrings
[ 2.691974] workingset: timestamp_bits=42 max_order=18 bucket_order=0
[ 2.910934] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 2.929871] NFS: Registering the id_resolver key type
[ 2.931209] Key type id_resolver registered
[ 2.931808] Key type id_legacy registered
[ 2.934928] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 2.935768] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 2.939597] 9p: Installing v9fs 9p2000 file system support
[ 3.019585] Key type asymmetric registered
[ 3.020298] Asymmetric key parser 'x509' registered
[ 3.022444] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[ 3.023695] io scheduler mq-deadline registered
[ 3.024768] io scheduler kyber registered
[ 3.395121] pl061_gpio 9030000.pl061: PL061 GPIO chip registered
[ 3.451448] pci-host-generic 4010000000.pcie: host bridge /pcie@10000000 ranges:
[ 3.454412] pci-host-generic 4010000000.pcie: IO 0x003eff0000..0x003effffff -> 0x0000000000
[ 3.457204] pci-host-generic 4010000000.pcie: MEM 0x0010000000..0x003efeffff -> 0x0010000000
[ 3.458394] pci-host-generic 4010000000.pcie: MEM 0x8000000000..0xffffffffff -> 0x8000000000
[ 3.460689] pci-host-generic 4010000000.pcie: Memory resource size exceeds max for 32 bits
[ 3.462820] pci-host-generic 4010000000.pcie: ECAM at [mem 0x4010000000-0x401fffffff] for [bus 00-ff]
[ 3.468915] pci-host-generic 4010000000.pcie: PCI host bridge to bus 0000:00
[ 3.470084] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 3.470941] pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
[ 3.471924] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[ 3.473206] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[ 3.477441] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[ 3.489689] pci 0000:00:01.0: [1af4:1005] type 00 class 0x00ff00
[ 3.491738] pci 0000:00:01.0: reg 0x10: [io 0x0000-0x001f]
[ 3.495759] pci 0000:00:01.0: reg 0x20: [mem 0x8000000000-0x8000003fff 64bit pref]
[ 3.525369] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[ 3.527131] pci 0000:00:01.0: BAR 0: assigned [io 0x1000-0x101f]
[ 3.579995] EINJ: ACPI disabled.
[ 4.013555] virtio-pci 0000:00:01.0: enabling device (0005 -> 0007)
[ 4.167746] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 4.235149] SuperH (H)SCI(F) driver initialized
[ 4.250654] msm_serial: driver initialized
[ 4.297997] random: fast init done
[ 4.312811] random: crng init done
[ 4.335459] cacheinfo: Unable to detect cache hierarchy for CPU 0
[ 4.472838] loop: module loaded
[ 4.494800] megasas: 07.719.03.00-rc1
[ 4.677917] tun: Universal TUN/TAP device driver, 1.6
[ 4.730824] thunder_xcv, ver 1.0
[ 4.733807] thunder_bgx, ver 1.0
[ 4.736089] nicpf, ver 1.0
[ 4.773190] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[ 4.774020] hns3: Copyright (c) 2017 Huawei Corporation.
[ 4.776004] hclge is initializing
[ 4.777078] e1000: Intel(R) PRO/1000 Network Driver
[ 4.777661] e1000: Copyright (c) 1999-2006 Intel Corporation.
[ 4.779228] e1000e: Intel(R) PRO/1000 Network Driver
[ 4.779801] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 4.781550] igb: Intel(R) Gigabit Ethernet Network Driver
[ 4.782192] igb: Copyright (c) 2007-2014 Intel Corporation.
[ 4.783421] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[ 4.784094] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[ 4.790448] Freeing initrd memory: 7796K
[ 4.793269] sky2: driver version 1.30
[ 4.822882] VFIO - User Level meta-driver version: 0.3
[ 4.876725] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 4.877614] ehci-pci: EHCI PCI platform driver
[ 4.878951] ehci-platform: EHCI generic platform driver
[ 4.882649] ehci-orion: EHCI orion driver
[ 4.885520] ehci-exynos: EHCI Exynos driver
[ 4.887856] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 4.889091] ohci-pci: OHCI PCI platform driver
[ 4.890452] ohci-platform: OHCI generic platform driver
[ 4.893996] ohci-exynos: OHCI Exynos driver
[ 4.910662] usbcore: registered new interface driver usb-storage
[ 4.985102] rtc-efi rtc-efi.0: registered as rtc0
[ 4.988167] rtc-efi rtc-efi.0: setting system clock to 2022-09-08T10:20:15 UTC (1662632415)
[ 5.005443] i2c_dev: i2c /dev entries driver
[ 5.168216] sdhci: Secure Digital Host Controller Interface driver
[ 5.169220] sdhci: Copyright(c) Pierre Ossman
[ 5.189476] Synopsys Designware Multimedia Card Interface Driver
[ 5.216056] sdhci-pltfm: SDHCI platform and OF driver helper
[ 5.260919] ledtrig-cpu: registered to indicate activity on CPUs
[ 5.310268] pstore: Registered efi as persistent store backend
[ 5.318452] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[ 5.335119] usbcore: registered new interface driver usbhid
[ 5.335812] usbhid: USB HID core driver
[ 5.424814] optee: probing for conduit method.
[ 5.426849] optee: revision 3.18 (1ee64703)
[ 5.437035] optee: dynamic shared memory is enabled
[ 5.459639] optee: initialized driver
[ 5.463130] Driver 'optee' was unable to register with bus_type 'arm_ffa' because the bus was not initialized.
[ 5.509634] NET: Registered PF_PACKET protocol family
[ 5.514789] 9pnet: Installing 9P2000 support
[ 5.516198] Key type dns_resolver registered
[ 5.521537] Loading compiled-in X.509 certificates
[ 5.535034] pstore: Using crash dump compression: deflate
[ 5.587752] Key type trusted registered
[ 5.594575] Key type encrypted registered
[ 5.714371] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[ 5.730571] ALSA device list:
[ 5.731456] No soundcards found.
[ 5.739878] uart-pl011 9000000.pl011: no DMA platform data
[ 5.834861] Freeing unused kernel memory: 6528K
[ 5.839118] Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: OK
Set permissions on /dev/tee*: OK
Create/set permissions on /data/tee: OK
Starting tee-supplicant: Using device /dev/teepriv0.
OK
Starting network: OK
Starting network (udhcpc): OK
Welcome to Buildroot, type root or test to login
buildroot login:
可以看到TEE的打印日志输出:
listening on port 54321
soc_term: accepted fd 4
soc_term: read fd EOF
soc_term: accepted fd 4
D/TC:0 add_phys_mem:635 ROUNDDOWN((0x08000000 + 0x10000), CORE_MMU_PGDIR_SIZE) type IO_SEC 0x08000000 size 0x00200000
D/TC:0 add_phys_mem:635 ROUNDDOWN((0x08000000 + 0), CORE_MMU_PGDIR_SIZE) type IO_SEC 0x08000000 size 0x00200000
D/TC:0 add_phys_mem:649 Physical mem map overlaps 0x8000000
D/TC:0 add_phys_mem:635 ROUNDDOWN(0x09040000, CORE_MMU_PGDIR_SIZE) type IO_SEC 0x09000000 size 0x00200000
D/TC:0 add_phys_mem:635 TEE_SHMEM_START type NSEC_SHM 0x42000000 size 0x00200000
D/TC:0 add_phys_mem:635 TA_RAM_START type TA_RAM 0x0e300000 size 0x00d00000
D/TC:0 add_phys_mem:635 VCORE_UNPG_RW_PA type TEE_RAM_RW 0x0e172000 size 0x0018e000
D/TC:0 add_phys_mem:635 VCORE_UNPG_RX_PA type TEE_RAM_RX 0x0e100000 size 0x00072000
D/TC:0 add_va_space:675 type RES_VASPACE size 0x00a00000
D/TC:0 add_va_space:675 type SHM_VASPACE size 0x02000000
D/TC:0 init_mem_map:1237 Mapping core at 0x82128000 offs 0x74028000
D/TC:0 dump_mmap_table:800 type IDENTITY_MAP_RX va 0x0e100000..0x0e101fff pa 0x0e100000..0x0e101fff size 0x00002000 (smallpg)
D/TC:0 dump_mmap_table:800 type NSEC_SHM va 0x7de00000..0x7dffffff pa 0x42000000..0x421fffff size 0x00200000 (pgdir)
D/TC:0 dump_mmap_table:800 type IO_SEC va 0x7e000000..0x7e1fffff pa 0x09000000..0x091fffff size 0x00200000 (pgdir)
D/TC:0 dump_mmap_table:800 type IO_SEC va 0x7e200000..0x7e3fffff pa 0x08000000..0x081fffff size 0x00200000 (pgdir)
D/TC:0 dump_mmap_table:800 type RES_VASPACE va 0x7e400000..0x7edfffff pa 0x00000000..0x009fffff size 0x00a00000 (pgdir)
D/TC:0 dump_mmap_table:800 type SHM_VASPACE va 0x7f000000..0x80ffffff pa 0x00000000..0x01ffffff size 0x02000000 (pgdir)
D/TC:0 dump_mmap_table:800 type TA_RAM va 0x81300000..0x81ffffff pa 0x0e300000..0x0effffff size 0x00d00000 (smallpg)
D/TC:0 dump_mmap_table:800 type TEE_RAM_RX va 0x82128000..0x82199fff pa 0x0e100000..0x0e171fff size 0x00072000 (smallpg)
D/TC:0 dump_mmap_table:800 type TEE_RAM_RW va 0x8219a000..0x82327fff pa 0x0e172000..0x0e2fffff size 0x0018e000 (smallpg)
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 1 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 2 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 3 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 4 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 5 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 6 / 8
D/TC:0 core_mmu_xlat_table_alloc:526 xlat tables used 7 / 8
I/TC:
I/TC: Non-secure external DT found
D/TC:0 0 carve_out_phys_mem:337 No need to carve out 0xe100000 size 0x200000
D/TC:0 0 carve_out_phys_mem:337 No need to carve out 0xe300000 size 0xd00000
I/TC: Embedded DTB found
D/TC:0 0 get_console_node_from_dt:72 No console directive from DTB
I/TC: OP-TEE version: 3.18.0 (gcc version 10.2.1 20201103 (GNU Toolchain for the A-profile Architecture 10.2-2020.11 (arm-10.16))) #1 Thu Sep 8 06:26:42 UTC 2022 aarch64
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
D/TC:0 0 boot_init_primary_late:1314 Executing at offset 0x74028000 with virtual load address 0x82128000
D/TC:0 0 call_preinitcalls:21 level 2 mobj_mapped_shm_init()
D/TC:0 0 mobj_mapped_shm_init:463 Shared memory address range: 7f000000, 81000000
D/TC:0 0 call_initcalls:40 level 1 register_time_source()
D/TC:0 0 call_initcalls:40 level 1 teecore_init_pub_ram()
D/TC:0 0 call_initcalls:40 level 2 probe_dt_drivers_early()
D/TC:0 0 add_node_to_probe:553 element: dt-test-consumer on node dt-test-consumer
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b0 on node simple-bus
D/TC:0 0 add_node_to_probe:553 element: dt-test-crypt-consumer on node dt-test-crypt-consumer
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 1 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b1 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b0 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 1 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 2 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b2 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b1 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 2 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 3 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-bus-b3 on node simple-bus
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b2 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 3 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-consumer on node dt-test-consumer deferred 4 time(s)
D/TC:0 0 add_node_to_probe:553 element: dt-test-provider@0 on node dt_test_rstctrl_provider
D/TC:0 0 add_node_to_probe:553 element: dt-test-provider@0 on node dt_test_clock_provider
D/TC:0 0 probe_driver_node:355 element: simple-bus on node dt-test-bus-b3 initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 4 time(s)
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 5 time(s)
D/TC:0 0 clk_register:104 Registered clock dt_test-clk3, freq 0
D/TC:0 0 clk_register:104 Registered clock dt_test-clk7, freq 0
D/TC:0 0 probe_driver_node:355 element: dt_test_clock_provider on node dt-test-provider@0 initialized
D/TC:0 0 probe_driver_node:355 element: dt_test_rstctrl_provider on node dt-test-provider@0 initialized
D/TC:0 0 probe_driver_node:355 element: dt-test-consumer on node dt-test-consumer initialized
D/TC:0 0 probe_driver_node:361 element: dt-test-crypt-consumer on node dt-test-crypt-consumer deferred 6 time(s)
D/TC:0 0 process_probe_list:502 Unresolved dependencies after 6 rounds, 6 deferred
D/TC:0 0 probe_dt_drivers_early:690 Deferred drivers probing
D/TC:0 0 print_probe_list:309 Probe list: 1 elements
D/TC:0 0 print_probe_list:311 |- Driver dt-test-crypt-consumer probes on node dt-test-crypt-consumer
D/TC:0 0 print_probe_list:315 `- Probe list end
D/TC:0 0 print_probe_list:321 Failed list: 0 elements
D/TC:0 0 print_probe_list:326 `- Failed list end
D/TC:0 0 call_initcalls:40 level 3 check_ta_store()
D/TC:0 0 check_ta_store:408 TA store: "early TA"
D/TC:0 0 check_ta_store:408 TA store: "Secure Storage TA"
D/TC:0 0 check_ta_store:408 TA store: "REE"
D/TC:0 0 call_initcalls:40 level 3 early_ta_init()
D/TC:0 0 early_ta_init:56 Early TA f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c size 33366 (compressed, uncompressed 55144)
D/TC:0 0 call_initcalls:40 level 3 verify_pseudo_tas_conformance()
D/TC:0 0 call_initcalls:40 level 3 tee_cryp_init()
D/TC:0 0 call_initcalls:40 level 4 tee_fs_init_key_manager()
D/TC:0 0 call_initcalls:40 level 5 init_console_itr()
D/TC:0 0 gic_it_set_cpu_mask:307 cpu_mask: writing 0xff to 0x7e200828
D/TC:0 0 gic_it_set_cpu_mask:309 cpu_mask: 0x0
D/TC:0 0 gic_it_set_prio:321 prio: writing 0x1 to 0x7e200428
D/TC:0 0 call_initcalls:40 level 5 probe_dt_drivers()
D/TC:0 0 probe_driver_node:355 element: dt-test-crypt-consumer on node dt-test-crypt-consumer initialized
D/TC:0 0 call_initcalls:40 level 6 mobj_init()
D/TC:0 0 call_initcalls:40 level 6 default_mobj_init()
D/TC:0 0 call_initcalls:40 level 7 release_probe_lists()
D/TC:0 0 call_initcalls:40 level 7 dt_test_release()
D/TC:0 0 call_finalcalls:59 level 1 release_external_dt()
I/TC: Primary CPU switching to normal world boot
I/TC: Secondary CPU 1 initializing
I/TC: Secondary CPU 1 switching to normal world boot
D/TC:1 tee_entry_exchange_capabilities:100 Asynchronous notifications are disabled
D/TC:1 tee_entry_exchange_capabilities:109 Dynamic shared memory is enabled
D/TC:1 0 core_mmu_xlat_table_alloc:526 xlat tables used 8 / 8
D/TC:? 0 tee_ta_init_pseudo_ta_session:296 Lookup pseudo TA 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_init_pseudo_ta_session:309 Open device.pta
D/TC:? 0 tee_ta_init_pseudo_ta_session:326 device.pta : 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_close_session:511 csess 0x821b76b0 id 1
D/TC:? 0 tee_ta_close_session:530 Destroy session
D/TC:? 0 tee_ta_init_pseudo_ta_session:296 Lookup pseudo TA f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c
D/TC:? 0 ldelf_load_ldelf:96 ldelf load address 0xc0006000
D/LD: ldelf:134 Loading TS f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c
D/TC:? 0 ldelf_syscall_open_bin:142 Lookup user TA ELF f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c (early TA)
D/TC:? 0 ldelf_syscall_open_bin:146 res=0
D/LD: ldelf:168 ELF (f04a0fe7-1f5d-4b9b-abf7-619b85b4ce8c) at 0xc004f000
D/TC:? 0 tee_ta_init_session_with_context:606 Re-open TA 7011a688-ddde-4053-a5a9-7b3c4ddf13b8
D/TC:? 0 tee_ta_close_session:511 csess 0x821ac9d0 id 2
D/TC:? 0 tee_ta_close_session:530 Destroy session
5. 测试
在REE运行环境输入root登录后,输入xtest启动optee测试demo
xtest
# xtest
Run test suite with level=0
TEE test application started over default TEE instance
######################################################
#
# regression
#
######################################################
* regression_1001 Core self tests
o regression_1001.1 Core self tests
regression_1001.1 OK
o regression_1001.2 Core dt_driver self tests
regression_1001.2 OK
regression_1001 OK
* regression_1002 PTA parameters
regression_1002 OK
* regression_1003 Core internal read/write mutex
Number of parallel threads: 6 (2 writers and 4 readers)
......
参考文献
— 博主热门专栏推荐—
- Python零基础快速入门系列
- 深入浅出i.MX8企业级开发实战系列
- MQTT从入门到提高系列
- 物体检测快速入门系列
- 自动驾驶模拟器AirSim快速入门
- 安全利器SELinux入门系列
- Python数据科学快速入门系列