TrustZone——运行环境—QEMU—OP-TEE

终于看到一款算是比较完善的安全OS。看它支持的平台就知道开发投入的工作量不小。

支持FastModels和QEMU两个虚拟模拟器,其他5款开发板。今天先看看QEMU运行起来效果怎么样吧。

 

  1. Foundation Models
  2. ARM Juno board
  3. QEMU
  4. STMicroelectronics boards
  5. Allwinner A80
  6. Mediatek MT8173 EVB
  7. HiKey Board

 

下面是编译说明。我就说一下关键点吧。下面的内容在git服务器optee-os的根目录下README.MD。

linux是3.18就可以,如果不好下载,下载3.18或者3.18rc1解压到qemu_optee下,把目录的名字改为linux即可。

第一步:

安装需要的包,apt-get解决。没有难度。如果有冲突的包,remove一下再安装即可。

第二步:

运行下载和编译环境脚本setup_qemu_optee.sh

执行完成之后,如果目录不变的话,应该在~/devel/qemu_optee目录下出现build.sh等一系列脚本。

如果有需要调整的,只需要编译对应的文件即可。如果你更换了linux的内核,或者文件系统。记得重新编译bios.bin,也就是运行buid_bios.sh。链接都在bios.bin里面。

TrustZone——运行环境—QEMU—OP-TEE_第1张图片

第三步:

运行build.sh。主要是干几件事。bios.bin(qemu引导文件),nsec_blob.bin(非安全系统bin,调整过的zImage),nsec_rootfs.bin(linux文件系统,包含optee_client、TEE_Client的驱动和xtest测试程序等),secure_blob.bin(安全系统包含安全ta)。

具体的几个文件的关系是bios.bin,里面有后面三个文件的地址。需要调用的时候,切换到对应的地址去运行。

TrustZone——运行环境—QEMU—OP-TEE_第2张图片

第四步:

运行两个终端和一个qemu模拟器。就能够看到linux和安全系统运行的效果了。如下图:一个是非安全侧XTEST调用成功,一个是安全侧TEE-CORE打印。另外是qemu运行界面。

刚刚运行起来的linux是这样的。

TrustZone——运行环境—QEMU—OP-TEE_第3张图片

后面的图是运行完xtest之后的效果。

 TrustZone——运行环境—QEMU—OP-TEE_第4张图片

TrustZone——运行环境—QEMU—OP-TEE_第5张图片

 

总结:

整体编译还算顺利。遇到问题如下:

1.网速不够快,独立下载linux内核。

2.tbconv.c代码有问题,const使用强转修正即可。也许你编译的时候问题已经修正了。

3.busybox无法编译。这个主要是编译工具链的问题。可以下载gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz。安装一下。以前有arm编译器的尽量取消关联以免影响。在setup_qemu_optee.sh文件中,编译gen_rootfs部分开始,指定cross_compiler到脚本提供的那个编译器也能解决。

4.如果某个部分无法成功,需要删除整个目录,再次运行setup_qemu_optee.sh才有效果。

 

祝大家编译顺利!!!

 

下一次,我们再看看fastmodels运行的效果。

 

后面是从下面地址截取出来的。

https://github.com/OP-TEE/optee_os#44-qemu

4.4 QEMU

You can run OP-TEE using QEMU since October 2014.

4.4.1 Prerequisites

To be able run this script you will need to install a couple of dependencies. On a Debian based system (Ubuntu, Mint etc.), you will at least need to install the following packages:

$ sudo apt-get install zlib1g-dev libglib2.0-dev libpixman-1-dev libfdt-dev \
               libc6:i386 libstdc++6:i386 libz1:i386 cscope

4.4.2 Download and setup QEMU

$ wget https://raw.githubusercontent.com/OP-TEE/optee_os/master/scripts/setup_qemu_optee.sh
$ chmod 711 setup_qemu_optee.sh
$ ./setup_qemu_optee.sh

4.4.3 Compile for QEMU

During installation a couple of helper scripts were generated, the main reason for this is that there is a lot of interdependencies between the different software components and it's a bit tricky to point to the correct toolchains and to know in which order to build things.

  • build_bios.sh: This build the BIOS needed in QEMU

  • build_linux.sh: This is used to build the Linux Kernel.

  • build_optee_client.sh: This will build OP-TEEs client library.

  • build_optee_linuxkernel.sh: This will build OP-TEEs Linux Kernel driver (as a module).

  • build_optee_os.sh: Builds the Trusted OS itself.

  • build.sh: Builds all software components in the correct order.

  • run_qemu.sh: This script starts QEMU.

  • serial_0.sh: Starts listening to QEMUs normal world UART console.

  • serial_1.sh: Starts listening to QEMUs secure world UART console.

  • update_rootfs.sh: This script will update rootfs. For example when you have updated normal world component, you will need to put them into rootfs. Calling this script will do so. In case you are creating a new Trusted Application, you must also edit filelist-tee.text in the gen_rootfs folder accordingly.

To build everything you will need to run the script build.sh, which will build all gits and in the correct order.

4.4.4 Boot and run QEMU and OP-TEE

To run this you need to lunch two consoles for the UARTs and one console for QEMU itself, so in separate shell windows run:

  $ ./serial_0.sh
$ ./serial_1.sh

and finally

$ ./run_qemu.sh
...
QEMU 2.1.50 monitor - type 'help' for more information
(qemu) c

In the window for serial_0 you will now get the normal world console and here you need to load and OP-TEEs Linux Kernel driver and also load tee-supplicant. This is done by the following lines:

$ root@Vexpress:/ modprobe optee_armtz
$ root@Vexpress:/ tee-supplicant &

你可能感兴趣的:(linux,qemu,ARM,trustzone)