Trusted side of the TEE
core | 8 years ago | ||
documentation | 9 years ago | ||
keys | 9 years ago | ||
lib | 9 years ago | ||
mk | 9 years ago | ||
scripts | 9 years ago | ||
ta | 9 years ago | ||
.gitignore | 10 years ago | ||
.travis.yml | 9 years ago | ||
CHANGELOG.md | 8 years ago | ||
LICENSE | 9 years ago | ||
Makefile | 9 years ago | ||
Notice.md | 9 years ago | ||
README.md | 9 years ago |
The optee_os git, contains the source code for the TEE in Linux using the ARM(R) TrustZone(R) technology. This component meets the GlobalPlatform TEE System Architecture specification. It also provides the TEE Internal API v1.0 as defined by the Global Platform TEE Standard for the development of Trusted Applications. For a general overview of OP-TEE and to find out how to contribute, please see the Notice.md file.
The Trusted OS is accessible from the Rich OS (Linux) using the GlobalPlatform TEE Client API Specification v1.0, which also is used to trigger secure execution of applications within the TEE.
The software is distributed mostly under the BSD 2-Clause open source license, apart from some files in the optee_os/lib/libutils directory which are distributed under the BSD 3-Clause or public domain licenses.
Several platforms are supported. In order to manage slight differences between platforms, a PLATFORM_FLAVOR
flag has been introduced. The PLATFORM
and PLATFORM_FLAVOR
flags define the whole configuration for a chip the where the Trusted OS runs. Note that there is also a composite form which makes it possible to append PLATFORM_FLAVOR
directly, by adding a dash inbetween the names. The composite form is shown below for the different boards. For more specific details about build flags etc, please read the file build_system.md.
Platform | Composite PLATFORM flag |
---|---|
Foundation FVP | PLATFORM=vexpress-fvp |
ARMs Juno Board | PLATFORM=vexpress-juno |
QEMU | PLATFORM=vexpress-qemu_virt |
STMicroelectronics b2120 - h310 / h410 | PLATFORM=stm-cannes |
STMicroelectronics b2020-h416 | PLATFORM=stm-orly2 |
Allwinner A80 Board | PLATFORM=sunxi |
HiKey Board (HiSilicon Kirin 620) | PLATFORM=hikey |
MediaTek MT8173 EVB Board | PLATFORM=mediatek-mt8173 |
Texas Instruments DRA7xx | PLATFORM=ti-dra7xx |
For community users, we suggest using Hikey board as development board. It provides detailed documentation including chip datasheet, board schematics, ...etc. and also related open source software download link on the website.
There are a couple of different build options depending on the target you are going to use. If you just want to get the software and compile it, then you should follow the instructions under the "Basic setup" below. In case you are going to run for a certain hardware or FVP, QEMU for example, then please follow the respective section instead.
We will strive to use the latest available compiler from Linaro. Start by downloading and unpacking the compiler. Then export the PATH to the bin folder.
$ cd $HOME $ mkdir toolchains $ cd toolchains $ wget http://releases.linaro.org/14.05/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz $ tar xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz $ export PATH=$HOME/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux/bin:$PATH
$ cd $HOME $ mkdir devel $ cd devel $ git clone https://github.com/OP-TEE/optee_os.git
$ cd $HOME/devel/optee_os $ CROSS_COMPILE=arm-linux-gnueabihf- make
To be able to see the full command when building you could build using following flag:
$ make V=1
To enable debug builds use the following flag:
$ make DEBUG=1
OP-TEE supports a couple of different levels of debug prints for both TEE core itself and for the Trusted Applications. The level ranges from 1 to 4, where four is the most verbose. To set the level you use the following flag:
$ make CFG_TEE_CORE_LOG_LEVEL=4
See section 6. repo manifests.
Juno has been supported in OP-TEE since mid October 2014.
The setup_juno_optee.sh
script provides a coherent set of components (OP-TEE client/driver/os, Linux kernel version 3-16.0-rc5)
Further release will align the ARM Juno setup with other OP-TEE supported platforms:
Temporary patch files required for linux kernel and juno dtb definition:
$ sudo apt-get install zlib1g-dev libglib2.0-dev libpixman-1-dev libfdt-dev \ libc6:i386 libstdc++6:i386 libz1:i386 cscope netcat
$ wget https://raw.githubusercontent.com/OP-TEE/optee_os/master/scripts/setup_juno_optee.sh $ chmod 711 setup_juno_optee.sh $ ./setup_juno_optee.sh
List of helper scripts generated during installation:
build_atf_opteed.sh
: This is used to build ARM-Trusted-Firmware and must be called when you have updated any component that are included in the FIP (like for example OP-TEE os).
build_linux.sh
: This is used to build the Linux Kernel.
build_normal.sh
: This is a pure helper script that build all the normal world components (in correct order).
build_optee_client.sh
: This will build OP-TEEs client library.
build_optee_linuxdriver.sh
: This will build OP-TEEs Linux Kernel driver (as a module).
build_optee_os.sh
: Builds the Trusted OS itself.
build_optee_tests.sh
: This will build the test suite (pay attention to the access needed).
build_secure.sh
: This is the helper script for the secure side that will build all secure side components in the correct order.
clean_gits.sh
: This will clean all gits. Beware that it will not reset the commit to the one used when first cloning. Also note that it will only clean git's.
Run the scripts in the following order:
$ ./build_secure.sh $ ./build_normal.sh
Update the ARM Juno embedded flash memory (path: JUNO/SOFTWARE):
Copy OP-TEE binaries on the filesystem(*) located on the external USB key:
Connect the USB key (filesystem) on any connector of the rear panel
Connect a serial terminal (115200, 8, n, 1) to the upper 9-pin (UART0) connector.
Connect the 12 volt power, then press the red button on the rear panel.
Note: The default configuration is to automatically boot a Linux kernel, which expects to find a root filesystem on /dev/sda1 (any one of the rear panel USB ports).
(*)Download a minimal filesytem at: http://releases.linaro.org/14.02/openembedded/aarch64/ linaro-image-minimal-genericarmv8-20140223-649.rootfs.tar.gz
UEFI offers a 10 second window to interrupt the boot sequence by pressing a key on the serial terminal, after which the kernel is launched.
Once booted you will get the prompt:
root@genericarmv8:~#
Write in the console:
root@genericarmv8:~# modprobe optee root@genericarmv8:~# tee-supplicant &
Now everything has been set up and OP-TEE is ready to be used.
ARM Juno could be sensitive on the USB memory type (filesystem) Recommendation: Use USB memory 3.0 (ext3/ext4 filesystem)
Please refer to section 6. repo manifests.
Currently OP-TEE is supported on Orly-2 (b2020-h416) and Cannes family (b2120 both h310 and h410 chip).
Will be written soon.
See section "4.1.2 Download the source code".
Will be written soon.
For Orly-2 do as follows
$ PLATFORM_FLAVOR=orly2 CROSS_COMPILE=arm-linux-gnueabihf- make
For Cannes family do as follows
$ PLATFORM_FLAVOR=cannes CROSS_COMPILE=arm-linux-gnueabihf- make
Will be written soon.
For Orly-2 do as follows
To be written.
For Cannes family do as follows
To be written.
Will be written soon. All magic with STM and so on must be stated here.
For Orly-2 do as follows
To be written.
For Cannes family do as follows
To be written.
Allwinner A80 platform has been supported in OP-TEE since mid December 2014.
Follow the instructions in the "4.1 Basic setup".
$ cd optee_os $ export PLATFORM=sunxi $ export CROSS_COMPILE=arm-linux-gnueabihf- $ make
Download Allwinner A80 platform SDK. The SDK refer to Allwinner A80 platform SDK root directory. A80 SDK directory tree like this:
SDK/ Android lichee
Android include all Android source code, lichee include bootloader and linux kernel.
copy the OP-TEE output binary to SDK/lichee/tools/pack/sun9i/bin
$ cd optee_os $ cp ./out/arm32-plat-sunxi/core/tee.bin SDK/lichee/tools/pack/sun9i/bin
In lichee directory, Type the following commands:
$ cd SDK/lichee $ ./build.sh
In Android directory, Type the following commands:
$ cd SDK/android $ extract-bsp $ make -j
In andoid directory, Type the following commands:
$ cd SDK/android $ pack
The output image will been signed internally when pack. The output image name is a80_android_board.img.
Use Allwinner PhoenixSuit tool to download to A80 board. Choose the output image(a80_android_board.img), Choose download, Wait for the download to complete.
When the host platform is Windows, Use a console application to connect A80 board uart0. In the console window, You can install OP-TEE linux kernel driver optee.ko, Load OP-TEE-Client daemon tee-supplicant, Run OP-TEE example hello world application. This is done by the following lines:
$ insmod /system/vendor/modules/optee.ko $ /system/bin/tee-supplicant & $ /system/bin/tee-helloworld
Enjoying OP-TEE on A80 board.
Please refer to 8173 wiki to setup MT8173 evaluation board.
To build the software, please see section 6. repo manifests.
HiKey is a 96Boards Consumer Edition compliant board equipped with a HiSilicon Kirin 620 SoC (8-core, 64-bit ARM Cortex A53). It can run OP-TEE in 32- and 64-bit modes.
To build for HiKey, please refer to 6. repo manifests.
In this project we are trying to adhere to the same coding convention as used in the Linux kernel (see CodingStyle). We achieve this by running checkpatch from Linux kernel. However there are a few exceptions that we had to make since the code also follows GlobalPlatform standards. The exceptions are as follows:
Since checkpatch is licensed under the terms of GNU GPL License Version 2, we cannot include this script directly into this project. Therefore we have written the Makefile so you need to explicitly point to the script by exporting an environment variable, namely CHECKPATCH. So, suppose that the source code for the Linux kernel is at $HOME/devel/linux
, then you have to export like follows:
$ export CHECKPATCH=$HOME/devel/linux/scripts/checkpatch.pl
thereafter it should be possible to use one of the different checkpatch targets in the Makefile. There are targets for checking all files, checking against latest commit, against a certain base-commit etc. For the details, read the Makefile.
A Git repository is available at https://github.com/OP-TEE/manifest where you will find configuration files for use with the Android 'repo' tool. This sections explains how to use it.
Follow the instructions under the "Installing Repo" section here.
$ mkdir -p $HOME/devel/optee $ cd $HOME/devel/optee $ repo init -u https://github.com/OP-TEE/manifest.git -m ${TARGET}.xml [-b ${BRANCH}] $ repo sync
Currently we are only using one branch, i.e, the master branch.
$ cd build $ make toolchains
Notes
$HOME/devel/optee
.repo sync
can take an additional parameter -j to sync multiple remotes. For example repo sync -j3
will sync three remotes in parallel.After getting the source and toolchain, just run:
$ make all run
and everything should compile and at the end QEMU should start.
After getting the source and toolchain you must also get the get Foundation Model (link) and untar it to the forest root, then just run:
$ make all run
and everything should compile and at the end FVP should start.
After running make
above, follow the instructions at flash-binaries-to-emmc to flash all the required images to and boot the board.
Location of files/images mentioned in the link above:
$HOME/devel/optee/burn-boot/hisi-idt.py
$HOME/devel/optee/l-loader/l-loader.bin
$HOME/devel/optee/l-loader/ptable.img
$HOME/devel/optee/arm-trusted-firmware/build/hikey/release/fip.bin
$HOME/devel/optee/out/boot-fat.uefi.img
After getting the source and toolchain, please run:
$ make all run
When < waiting for device >
prompt appears, press reset button
Doing a repo init
, repo sync
from scratch can take a fair amount of time. The main reason for that is simply because of the size of some of the gits we are using, like for the Linux kernel and EDK2. With repo you can reference an existing forest and by doing so you can speed up repo sync to instead taking ~20 seconds instead of an hour. The way to do this are as follows.
optee-ref
and put that under for $HOME/devel/optee-ref
. This step will take roughly an hour.crontab -e
) that does a repo sync
in this folder particular folder once a night (that is more than enough).repo init
, like this
repo init -u https://github.com/OP-TEE/manifest.git --reference /home/jbech/devel/optee-ref
Normally step 1 and 2 above is something you will only do once. Also if you ignore step 2, then you will still get the latest from official git trees, since repo will also check for updates that aren't at the local reference.
ccache is a tool that caches build object-files etc locally on the disc and can speed up build time significantly in subsequent builds. On Debian-based systems (Ubuntu, Mint etc) you simply install it by running:
$ sudo apt-get install ccache
The helper makefiles are configured to automatically find and use ccache if ccache is installed on your system, so other than having it installed you don't have to think about anything.