xref: /aosp_15_r20/external/ms-tpm-20-ref/Samples/ARM32-FirmwareTPM/README.md (revision 5c591343844d1f9da7da26467c4bf7efc8a7a413)
1*5c591343SA. Cody SchuffelenMS-IoT fTPM
2*5c591343SA. Cody Schuffelen===========
3*5c591343SA. Cody Schuffelen## Trusted firmware for Windows based AArch32 (32-bit) ARM SoC's
4*5c591343SA. Cody SchuffelenPlease see the [build-firmware document](https://github.com/ms-iot/imx-iotcore/blob/develop/Documentation/build-firmware.md) in the iMX IoT Core repo for additional information on including this TA in an IoT Core image for iMX boards.
5*5c591343SA. Cody Schuffelen
6*5c591343SA. Cody Schuffelen## Included TAs
7*5c591343SA. Cody Schuffelen
8*5c591343SA. Cody Schuffelen### fTPM TA
9*5c591343SA. Cody SchuffelenThe fTPM Trusted Application (TA) provides a secure firmware implementation of a TPM using the MS reference implementation.
10*5c591343SA. Cody SchuffelenPlatform specific code is copied and modified locally in [`optee_ta/fTPM/platform`](./optee_ta/fTPM/platform), while [`/fTPM/reference`](./fTPM/reference) contains files to support WolfSSL, control the fTPM's functionality, and define basic types, which may not be found in OpTEE.
11*5c591343SA. Cody Schuffelen
12*5c591343SA. Cody SchuffelenSee the reference implementation for more details.
13*5c591343SA. Cody Schuffelen
14*5c591343SA. Cody Schuffelen---
15*5c591343SA. Cody Schuffelen
16*5c591343SA. Cody Schuffelen## Extra Installation Steps
17*5c591343SA. Cody Schuffelen
18*5c591343SA. Cody SchuffelenThe secure firmware utilizes the OP-TEE implementation of the Global Platform specifications. The OP-TEE project is
19*5c591343SA. Cody Schuffelennot duplicated in this repository but is obtained directly from the public release. The build of OP-TEE is based on a
20*5c591343SA. Cody Schuffelennative Linux build, however the following installation steps allow OP-TEE to be built under Windows using WSL. Only the optee_os
21*5c591343SA. Cody Schuffelenrepository is relevant for trusted firmware use - the optee_client & optee_linuxdriver repositories are integration
22*5c591343SA. Cody Schuffelencomponents for Linux and can serve as a reference for the Windows equivalent components. Note that optee_linuxdriver
23*5c591343SA. Cody Schuffelenis GPL.
24*5c591343SA. Cody Schuffelen
25*5c591343SA. Cody SchuffelenOpTEE generates a build environment for trusted applications which is based on Make (See TA_DEV_KIT_DIR in the build directions).
26*5c591343SA. Cody SchuffelenThis build environment places several constraints on how the code is organized, which are explained in the relevant makefiles.
27*5c591343SA. Cody SchuffelenSee the [optee_os documentation](https://github.com/OP-TEE/optee_os/blob/master/documentation/build_system.md) for details about how OpTEE build works.
28*5c591343SA. Cody Schuffelen
29*5c591343SA. Cody Schuffelen#### 1. Enable Windows Subsystem for Linux
30*5c591343SA. Cody SchuffelenSee instructions [here](https://docs.microsoft.com/en-us/windows/wsl/install-win10):
31*5c591343SA. Cody Schuffelen
32*5c591343SA. Cody Schuffelen#### 2. Launch Bash
33*5c591343SA. Cody SchuffelenSearch for "bash" in the start menu, OR press Windows key + 'R', then type bash.
34*5c591343SA. Cody SchuffelenUpdate if needed.
35*5c591343SA. Cody Schuffelen
36*5c591343SA. Cody SchuffelenIn WSL:
37*5c591343SA. Cody Schuffelen```sh
38*5c591343SA. Cody Schuffelensudo apt-get update
39*5c591343SA. Cody Schuffelen```
40*5c591343SA. Cody Schuffelen
41*5c591343SA. Cody Schuffelen#### 3. Install the ARM tool chain
42*5c591343SA. Cody SchuffelenInstall the ARM toolchain to a directory of your choice.
43*5c591343SA. Cody Schuffelen```sh
44*5c591343SA. Cody Schuffelencd ~
45*5c591343SA. Cody Schuffelenwget https://releases.linaro.org/components/toolchain/binaries/6.4-2017.11/arm-linux-gnueabihf/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
46*5c591343SA. Cody Schuffelentar xf gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
47*5c591343SA. Cody Schuffelenrm gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
48*5c591343SA. Cody Schuffelen```
49*5c591343SA. Cody Schuffelen
50*5c591343SA. Cody Schuffelen#### 4. Clone the OpTEE OS source code
51*5c591343SA. Cody SchuffelenIf you do not already have a version of the OP-TEE OS repo cloned on your machine you may run:
52*5c591343SA. Cody Schuffelen```sh
53*5c591343SA. Cody Schuffelencd ~
54*5c591343SA. Cody Schuffelengit clone https://github.com/ms-iot/ms-iot-optee_os.git
55*5c591343SA. Cody Schuffelen```
56*5c591343SA. Cody Schuffelen
57*5c591343SA. Cody Schuffelen#### 5. Build OP-TEE OS for the target platform
58*5c591343SA. Cody Schuffelen
59*5c591343SA. Cody Schuffelen`TA_CROSS_COMPILE` should point to the ARM toolchain installed in [step 3](#3-install-the-arm-tool-chain).
60*5c591343SA. Cody Schuffelen
61*5c591343SA. Cody Schuffelen```sh
62*5c591343SA. Cody Schuffelencd ~/optee_os
63*5c591343SA. Cody SchuffelenCROSS_COMPILE=~/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- make PLATFORM=imx-mx6qhmbedge CFG_TEE_CORE_LOG_LEVEL=4 CFG_REE_FS=n CFG_RPMB_FS=y CFG_RPMB_TESTKEY=y CFG_RPMB_WRITE_KEY=y -j20
64*5c591343SA. Cody Schuffelen```
65*5c591343SA. Cody SchuffelenAdditional information on Microsoft IoT fork of OP-TEE OS can be found [here](https://github.com/ms-iot/ms-iot-optee_os).
66*5c591343SA. Cody Schuffelen
67*5c591343SA. Cody Schuffelen#### 6. Clone the ms-tpm-20-ref source code
68*5c591343SA. Cody Schuffelen```sh
69*5c591343SA. Cody Schuffelencd ~
70*5c591343SA. Cody Schuffelengit clone https://github.com/Microsoft/ms-tpm-20-ref.git
71*5c591343SA. Cody Schuffelen```
72*5c591343SA. Cody Schuffelen
73*5c591343SA. Cody Schuffelen#### 7. Initialize the git submodules
74*5c591343SA. Cody Schuffelen```sh
75*5c591343SA. Cody Schuffelencd ~/ms-tpm-20-ref
76*5c591343SA. Cody Schuffelengit submodule init
77*5c591343SA. Cody Schuffelengit submodule update
78*5c591343SA. Cody Schuffelen```
79*5c591343SA. Cody Schuffelen
80*5c591343SA. Cody Schuffelen---
81*5c591343SA. Cody Schuffelen
82*5c591343SA. Cody Schuffelen## Building the TPM
83*5c591343SA. Cody Schuffelen
84*5c591343SA. Cody Schuffelen#### 1. Build the Firmware TPM Trusted Application
85*5c591343SA. Cody Schuffelen`TA_CROSS_COMPILE` should point to the ARM toolchain installed in [step 3](#3-install-the-arm-tool-chain).
86*5c591343SA. Cody Schuffelen
87*5c591343SA. Cody Schuffelen`TA_DEV_KIT_DIR` should point to the directory the optee_os TA devkit was compiled to in [step 5](#6-clone-the-ms-tpm-20-ref-source-code
88*5c591343SA. Cody Schuffelen).
89*5c591343SA. Cody Schuffelen
90*5c591343SA. Cody Schuffelen`-j` increases the parallelism of the build process.
91*5c591343SA. Cody Schuffelen
92*5c591343SA. Cody Schuffelen```sh
93*5c591343SA. Cody Schuffelencd ~/ms-tpm-20-ref/Samples/ARM32-FirmwareTPM/optee_ta
94*5c591343SA. Cody SchuffelenTA_CPU=cortex-a9 TA_CROSS_COMPILE=~/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-imx/export-ta_arm32 CFG_TEE_TA_LOG_LEVEL=2 make -j20
95*5c591343SA. Cody Schuffelen```
96*5c591343SA. Cody SchuffelenDebugging options you may want to add:
97*5c591343SA. Cody Schuffelen
98*5c591343SA. Cody Schuffelen`CFG_TEE_TA_LOG_LEVEL=3` 1 is fatal errors only, other values increase debug tracing output.
99*5c591343SA. Cody Schuffelen
100*5c591343SA. Cody Schuffelen`CFG_TA_DEBUG=y` Turns on debug output from the TAs, and enables extra correctness checks in the fTPM TA.
101*5c591343SA. Cody Schuffelen
102