1# OP-TEE Trusted OS 2## Contents 31. [Introduction](#1-introduction) 42. [License](#2-license) 53. [Platforms supported](#3-platforms-supported) 6 3. [Development board for community user] (#31-development-board-for-community-user) 74. [Get and build OP-TEE software](#4-get-and-build-op-tee-software) 8 4. [Prerequisites](#41-prerequisites) 9 4. [Basic setup](#42-basic-setup) 10 4. [STMicroelectronics boards](#44-stmicroelectronics-boards) 11 4. [Allwinner A80](#45-allwinner-a80) 12 4. [Freescale MX6UL EVK](#46-freescale-mx6ul-evk) 135. [repo manifests](#5-repo-manifests) 14 5. [Install repo](#51-install-repo) 15 5. [Get the source code](#52-get-the-source-code) 16 5. [Targets](#521-targets) 17 5. [Branches](#522-branches) 18 5. [Get the toolchains](#523-get-the-toolchains) 19 5. [QEMU](#53-qemu) 20 5. [FVP](#54-fvp) 21 5. [HiKey](#55-hikey) 22 5. [MT8173-EVB](#56-mt8173-evb) 23 5. [Juno](#57-juno) 24 5. [Update flash and its layout](#571-update-flash-and-its-layout) 25 5. [Tips and tricks](#57-tips-and-tricks) 26 5. [Reference existing project to speed up repo sync](#571-reference-existing-project-to-speed-up-repo-sync) 27 5. [Use ccache](#572-use-ccache) 286. [Load driver, tee-supplicant and run xtest](#6-load-driver-tee-supplicant-and-run-xtest) 297. [Coding standards](#7-coding-standards) 30 7. [checkpatch](#71-checkpatch) 31 32# 1. Introduction 33The `optee_os git`, contains the source code for the TEE in Linux using the 34ARM® TrustZone® technology. This component meets the GlobalPlatform 35TEE System Architecture specification. It also provides the TEE Internal core API 36v1.1 as defined by the GlobalPlatform TEE Standard for the development of 37Trusted Applications. For a general overview of OP-TEE and to find out how to 38contribute, please see the [Notice.md](Notice.md) file. 39 40The Trusted OS is accessible from the Rich OS (Linux) using the 41[GlobalPlatform TEE Client API Specification v1.0](http://www.globalplatform.org/specificationsdevice.asp), 42which also is used to trigger secure execution of applications within the TEE. 43 44--- 45## 2. License 46The software is distributed mostly under the 47[BSD 2-Clause](http://opensource.org/licenses/BSD-2-Clause) open source 48license, apart from some files in the `optee_os/lib/libutils` directory 49which are distributed under the 50[BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause) or public domain 51licenses. 52 53--- 54## 3. Platforms supported 55Several platforms are supported. In order to manage slight differences 56between platforms, a `PLATFORM_FLAVOR` flag has been introduced. 57The `PLATFORM` and `PLATFORM_FLAVOR` flags define the whole configuration 58for a chip the where the Trusted OS runs. Note that there is also a 59composite form which makes it possible to append `PLATFORM_FLAVOR` directly, 60by adding a dash in-between the names. The composite form is shown below 61for the different boards. For more specific details about build flags etc, 62please read the file [build_system.md](documentation/build_system.md). Some 63platforms have different sub-maintainers, please refer to the file 64[MAINTAINERS.md](MAINTAINERS.md) for contact details for various platforms. 65 66<!-- Please keep this list sorted in alphabetic order --> 67| Platform | Composite PLATFORM flag | Publicly available? | 68|----------|-------------------------|---------------------| 69| [Allwinner A80 Board](http://www.allwinnertech.com/en/clq/processora/A80.html)|`PLATFORM=sunxi`| No | 70| [ARM Juno Board](http://www.arm.com/products/tools/development-boards/versatile-express/juno-arm-development-platform.php) |`PLATFORM=vexpress-juno`| Yes | 71| [FSL ls1021a](http://www.freescale.com/tools/embedded-software-and-tools/hardware-development-tools/tower-development-boards/mcu-and-processor-modules/powerquicc-and-qoriq-modules/qoriq-ls1021a-tower-system-module:TWR-LS1021A?lang_cd=en)|`PLATFORM=ls-ls1021atwr`| Yes | 72| [FSL i.MX6 UltraLite EVK Board](http://www.freescale.com/products/arm-processors/i.mx-applications-processors-based-on-arm-cores/i.mx-6-processors/i.mx6qp/i.mx6ultralite-evaluation-kit:MCIMX6UL-EVK) |`PLATFORM=imx`| Yes | 73| [ARM Foundation FVP](http://www.arm.com/fvp) |`PLATFORM=vexpress-fvp`| Yes | 74| [HiKey Board (HiSilicon Kirin 620)](https://www.96boards.org/products/hikey)|`PLATFORM=hikey`| Yes | 75| [MediaTek MT8173 EVB Board](http://www.mediatek.com/en/products/mobile-communications/tablet/mt8173)|`PLATFORM=mediatek-mt8173`| No | 76| [QEMU](http://wiki.qemu.org/Main_Page) |`PLATFORM=vexpress-qemu_virt`| Yes | 77| [STMicroelectronics b2120 - h310 / h410](http://www.st.com/web/en/catalog/mmc/FM131/SC999/SS1628/PF258776) |`PLATFORM=stm-cannes`| No | 78| [STMicroelectronics b2020-h416](http://www.st.com/web/catalog/mmc/FM131/SC999/SS1633/PF253155?sc=internet/imag_video/product/253155.jsp)|`PLATFORM=stm-orly2`| No | 79| [Texas Instruments DRA7xx](http://www.ti.com/product/DRA746)|`PLATFORM=ti-dra7xx`| Yes | 80| [Xilinx Zynq UltraScale+ MPSOC](http://www.xilinx.com/products/silicon-devices/soc/zynq-ultrascale-mpsoc.html)|`PLATFORM=zynqmp-zcu102`| Yes | 81 82### 3.1 Development board for community user 83For community users, we suggest using [HiKey board](https://www.96boards.org/products/ce/hikey/) 84as development board. It provides detailed documentation including chip 85datasheet, board schematics, source code, binaries etc on the download link at 86the website. 87 88--- 89## 4. Get and build OP-TEE software 90There are a couple of different build options depending on the target you are 91going to use. If you just want to get the software and compile it, then you 92should follow the instructions under the "Basic setup" below. In case you are 93going to run for a certain hardware or FVP, QEMU for example, then please follow 94the respective section found below instead, having that said, we are moving from 95the shell script based setups to instead use 96[repo](https://source.android.com/source/downloading.html), so for some targets 97you will see that we are using repo ([section 5](#5-repo-manifests)) and for 98others we are still using the shell script based setup 99([section 4](#4-get-and-build-op-tee-software)), please see this transitions as 100work in progress. 101 102--- 103### 4.1 Prerequisites 104We believe that you can use any Linux distribution to build OP-TEE, but as 105maintainers of OP-TEE we are mainly using Ubuntu-based distributions and to be 106able to build and run OP-TEE there are a few packages that needs to be installed 107to start with. Therefore install the following packages regardless of what 108target you will use in the end. 109``` 110$ sudo apt-get install android-tools-adb android-tools-fastboot autoconf bison \ 111 cscope curl flex gdisk libc6:i386 libfdt-dev \ 112 libglib2.0-dev libpixman-1-dev libstdc++6:i386 \ 113 libz1:i386 netcat python-crypto python-serial \ 114 python-wand uuid-dev xdg-utils xz-utils zlib1g-dev 115``` 116 117--- 118### 4.2 Basic setup 119#### 4.2.1 Get the compiler 120We strive to use the latest available compiler from Linaro. Start by downloading 121and unpacking the compiler. Then export the `PATH` to the compilers `bin` 122folder. Beware that we are using a couple of different toolchains depending on 123the target device. This includes both 64- and 32-bit toolchains. For the exact 124toolchain in use, please have a look at [toolchain.mk](https://github.com/OP-TEE/build/blob/master/toolchain.mk) 125and then look at the targets makefile (see [build.git](https://github.com/OP-TEE/build)) 126to find out where the respective toolchain will be used. For example in the 127[QEMU makefile](https://github.com/OP-TEE/build/blob/master/qemu.mk#L12-L15) you 128will see: 129``` 130CROSS_COMPILE_NS_USER ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)" 131CROSS_COMPILE_NS_KERNEL ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)" 132CROSS_COMPILE_S_USER ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)" 133CROSS_COMPILE_S_KERNEL ?= "$(CCACHE)$(AARCH32_CROSS_COMPILE)" 134``` 135 136However, if you only want to compile optee_os, then you can do like this: 137``` 138$ cd $HOME 139$ mkdir toolchains 140$ cd toolchains 141$ wget http://releases.linaro.org/14.08/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.08_linux.tar.xz 142$ tar xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.08_linux.tar.xz 143$ export PATH=$HOME/toolchains/gcc-linaro-arm-linux-gnueabihf-4.9-2014.08_linux/bin:$PATH 144``` 145 146#### 4.2.2 Download the source code 147``` 148$ cd $HOME 149$ mkdir devel 150$ cd devel 151$ git clone https://github.com/OP-TEE/optee_os.git 152``` 153 154#### 4.2.3 Build 155``` 156$ cd $HOME/devel/optee_os 157$ CROSS_COMPILE=arm-linux-gnueabihf- make 158``` 159 160#### 4.2.4 Compiler flags 161To be able to see the full command when building you could build using 162following flag: 163``` 164$ make V=1 165``` 166 167To enable debug builds use the following flag: 168``` 169$ make DEBUG=1 170``` 171 172OP-TEE supports a couple of different levels of debug prints for both TEE core 173itself and for the Trusted Applications. The level ranges from 1 to 4, where 174four is the most verbose. To set the level you use the following flag: 175``` 176$ make CFG_TEE_CORE_LOG_LEVEL=4 177``` 178 179--- 180### 4.4 STMicroelectronics boards 181Currently OP-TEE is supported on Orly-2 (`b2020-h416`) and Cannes family 182(`b2120` both `h310` and `h410` chip). 183 184#### 4.4.1 Get the compiler for Orly-2 185Will be written soon. 186 187#### 4.4.2 Download the source code 188See section "4.2.2 Download the source code". 189 190#### 4.4.3 Build for Orly-2 191For Orly-2 do as follows 192``` 193$ PLATFORM=stm-orly2 CROSS_COMPILE=arm-linux-gnueabihf- make 194``` 195 196For Cannes family do as follows 197``` 198$ PLATFORM=stm-cannes CROSS_COMPILE=arm-linux-gnueabihf- make 199``` 200 201#### 4.4.4 Prepare and install the images 202Will be written soon. 203 204#### 4.4.5 Boot and run the software 205<!-- All magic with STM and so on must be stated here. --> 206Will be written soon. 207 208--- 209### 4.5 Allwinner A80 210 211#### 4.5.1 Locked versus unlocked A80 boards 212**Important!** All A80 boards sold to the general public are boards where secure 213side has been locked down, which means that you **cannot** use them for secure 214side development, i.e, it will not be possible to put OP-TEE on those devices. 215If you want to use A80 board for secure side development, then you will need to 216talk to 217[Allwinner](https://github.com/OP-TEE/optee_os/blob/master/MAINTAINERS.md) 218directly and ask if it is possible get a device from them. 219 220#### 4.5.2 Get the compiler and source 221Follow the instructions in the "4.2 Basic setup". 222 223#### 4.5.3 Build 224``` 225$ cd optee_os 226$ export PLATFORM=sunxi 227$ export CROSS_COMPILE=arm-linux-gnueabihf- 228$ make 229``` 230 231#### 4.5.4 Prepare the images to run on A80 Board 232 233Download Allwinner A80 platform SDK, the SDK refers to Allwinner A80 platform 234SDK root directory. A80 SDK directory tree looks like this: 235``` 236SDK/ 237 Android 238 lichee 239``` 240`Android` contains all source code related to Android and `lichee` 241contains the bootloader and Linux kernel. 242 243##### 4.5.4.1 Copy OP-TEE output to package directory 244Copy the OP-TEE output binary to `SDK/lichee/tools/pack/sun9i/bin` 245 246``` 247$ cd optee_os 248$ cp ./out/arm32-plat-sunxi/core/tee.bin SDK/lichee/tools/pack/sun9i/bin 249``` 250 251##### 4.5.4.2 Build Linux kernel 252In the `lichee` directory, run the following commands: 253``` 254$ cd SDK/lichee 255$ ./build.sh 256``` 257 258##### 4.5.4.3 Build Android 259In the Android directory, run the following commands: 260``` 261$ cd SDK/android 262$ extract-bsp 263$ make -j 264``` 265 266##### 4.5.4.4 Create the Android image 267In the Android directory, run the following commands: 268``` 269$ cd SDK/android 270$ pack 271``` 272The output image will been signed internally when packed. The output image name 273is `a80_android_board.img`. 274 275##### 4.5.4.5 Download the Android image 276Use `Allwinner PhoenixSuit` tool to download to A80 board. 277Choose the output image(`a80_android_board.img`), select download and wait 278for the download to complete. 279 280#### 4.5.5 Boot and run the software on A80 Board 281When the host platform is Windows, use a console application to connect A80 282board `uart0`. In the console window, You can install OP-TEE linux kernel 283driver `optee.ko`, load OP-TEE-Client daemon `tee-supplicant` and run 284the example "hello world" Trusted Application, do this by running: 285``` 286$ insmod /system/vendor/modules/optee.ko 287$ /system/bin/tee-supplicant & 288$ /system/bin/tee-helloworld 289``` 290 291--- 292### 4.6 Freescale MX6UL EVK 293Build: 294``` 295 PLATFORM_FLAVOR=mx6ulevk make PLATFORM=imx 296 ${CROSS_COMPILE}-objcopy -O binary out/arm-plat-imx/core/tee.elf optee.bin 297 copy optee.bin to the first partition of SD card which is used for boot. 298``` 299Run using U-Boot: 300``` 301 run loadfdt; 302 run loadimage; 303 fatload mmc 1:1 0x9c100000 optee.bin; 304 run mmcargs; 305 bootz ${loadaddr} - ${fdt_addr}; 306``` 307 308Note: 309 CAAM is not implemented now, this will be added later. 310 311--- 312## 5. repo manifests 313 314A Git repository is available at https://github.com/OP-TEE/manifest where you 315will find XML-files for use with the Android 'repo' tool. 316 317### 5.1. Install repo 318Follow the instructions under the "Installing Repo" section 319[here](https://source.android.com/source/downloading.html). 320 321### 5.2. Get the source code 322First ensure that you have the necessary Ubuntu packages installed, see [4.1 323Prerequisites](#41-prerequisites) (this is the only important step from section 3244 in case you are setting up any of the target devices mentioned below). 325 326``` 327$ mkdir -p $HOME/devel/optee 328$ cd $HOME/devel/optee 329$ repo init -u https://github.com/OP-TEE/manifest.git -m ${TARGET}.xml [-b ${BRANCH}] 330$ repo sync 331``` 332**Notes**<br> 333* The folder could be at any location, we are just giving a suggestion by 334 saying `$HOME/devel/optee`. 335* `repo sync` can take an additional parameter -j to sync multiple remotes. For 336 example `repo sync -j3` will sync three remotes in parallel. 337 338#### 5.2.1 Targets 339| Target | Latest | Stable | 340|--------|--------|--------| 341| QEMU | `default.xml` | `default_stable.xml` | 342| FVP | `fvp.xml` | `fvp_stable.xml` | 343| HiKey | `hikey.xml` | `hikey_stable.xml` | 344| HiKey Debian (experimental) | `hikey_debian.xml` | Not available | 345| MediaTek MT8173 EVB Board | `mt8173-evb.xml` | `mt8173-evb_stable.xml` | 346| ARM Juno board| `juno.xml` | `juno_stable.xml` | 347 348#### 5.2.2 Branches 349Currently we are only using one branch, i.e, the `master` branch. 350 351#### 5.2.3 Get the toolchains 352This is a one time thing you run only once after getting all the source code 353using repo. 354``` 355$ cd build 356$ make toolchains 357``` 358 359--- 360### 5.3. QEMU 361After getting the source and toolchain, just run (from the `build` folder) 362``` 363$ make all run 364``` 365and everything should compile and at the end QEMU should start. 366 367--- 368### 5.4. FVP 369After getting the source and toolchain you must also obtain Foundation Model 370([link](http://www.arm.com/products/tools/models/fast-models/foundation-model.php)) 371binaries and untar it to the forest root, then just run (from the `build` folder) 372 373``` 374$ make all run 375``` 376and everything should compile and at the end FVP should start. 377 378--- 379### 5.5. HiKey 380#### 5.5.1 Initramfs based 381After getting the source and toolchain, just run (from the `build` folder) 382``` 383$ make all 384``` 385 386After that connect the board and flash the binaries by running: 387``` 388$ make flash 389``` 390 391(more information about how to flash individual binaries could be found 392[here](https://github.com/96boards/documentation/wiki/HiKeyUEFI#flash-binaries-to-emmc-)) 393 394The board is ready to be booted. 395#### 5.5.2 Debian based / 96boards RPB (experimental) 396Start by getting the source and toolchain (see above), then continue by 397downloading the system image (root fs). Note that this step is something you 398only should do once. 399 400``` 401$ make system-img 402``` 403 404Which should be followed by 405``` 406$ make all 407``` 408 409When everything has been built, flash the files to the device: 410``` 411$ make flash 412``` 413 414Now you can boot up the device, note that OP-TEE normal world binaries still 415hasn't been put on the device at this stage. So by now you're basically booting 416up an RPB build. When you have a prompt, the next step is to connect the device 417to the network. WiFi is preferable, since HiKey has no Ethernet jack. Easiest is 418to edit `/etc/network/interfaces`. To find out what to add, run: 419``` 420$ make help 421``` 422 423When that's been added, reboot and when you have a prompt again, you're ready to 424push the OP-TEE client binaries and the kernel with OP-TEE support. First find 425out the IP for your device (`ifconfig`). Then send the files to HiKey by 426running: 427``` 428$ IP=111.222.333.444 make send 429 430Credentials for the image are: 431username: linaro 432password: linaro 433``` 434 435When the files has been transfered, please follow the commands from the `make 436send` command which will install the debian packages on the device. Typically it 437tells you to run something like this on the device itself: 438``` 439$ dpkg --force-all -i /tmp/out/optee_2.0-1.deb 440$ dpkg --force-all -i /tmp/linux-image-*.deb 441``` 442 443Now you are ready to use OP-TEE on HiKey using Debian, please goto step 6 below 444to continue. 445 446##### Good to know 447Just want to update secure side? Put the device in fastboot mode and 448``` 449$ make arm-tf 450$ make flash-fip 451 452``` 453 454Just want to update OP-TEE client software? Put the device in fastboot mode and 455``` 456$ make optee-client 457$ make xtest 458``` 459 460Boot up the device and follow the instructions from make send 461``` 462$ IP=111.222.333.444 make send 463``` 464 465--- 466### 5.6. MT8173-EVB 467After getting the source and toolchain, just run (from the `build` folder) 468 469``` 470$ make all run 471``` 472 473When `< waiting for device >` prompt appears, press reset button and the 474flashing procedure should begin. 475 476--- 477### 5.7 Juno 478After getting the source and toolchain, just run (from the `build` folder) 479``` 480$ make all 481``` 482 483Enter the firmware console on the juno board and press enter to stop 484the auto boot flow 485``` 486ARM V2M_Juno Firmware v1.3.9 487Build Date: Nov 11 2015 488 489Time : 12:50:45 490Date : 29:03:2016 491 492Press Enter to stop auto boot... 493 494``` 495Enable ftp at the firmware prompt 496``` 497Cmd> ftp_on 498Enabling ftp server... 499 MAC address: xxxxxxxxxxxx 500 501 IP address: 192.168.1.158 502 503 Local host name = V2M-JUNO-A2 504``` 505 506Flash the binary by running (note the IP address from above): 507``` 508make JUNO_IP=192.168.1.158 flash 509``` 510 511Once the binaries are transferred, reboot the board: 512``` 513Cmd> reboot 514 515``` 516 517#### 5.7.1 Update flash and its layout 518The flash in the board may need to be updated for the flashing above to 519work. If the flashing fails or if ARM-TF refuses to boot due to wrong 520version of the SCP binary the flash needs to be updated. To update the 521flash please follow the instructions at [Using Linaro's deliverable on 522Juno](https://community.arm.com/docs/DOC-10804) selecting one of the zips 523under "4.1 Prebuilt configurations" flashing it as described under "5. 524Running the software". 525 526#### 5.7.2 GlobalPlatform testsuite support 527##### Warning : 528Depending on the Juno pre-built configuration, the built ramdisk.img 529size with GlobalPlatform testsuite may exceed its pre-defined Juno flash 530memory reserved location (image.txt file). 531In that case, you will need to extend the Juno flash block size reserved 532location for the ramdisk.img in the image.txt file accordingly and 533follow the instructions under "5.7.1 Update flash and its layout". 534 535##### Example with juno-latest-busybox-uboot.zip: 536The current ramdisk.img size with GlobalPlatform testsuite 537is 8.6 MBytes. 538 539###### Updated file is /JUNO/SITE1/HBI0262B/images.txt (limited to 8.3 MB) 540``` 541NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE 542NOR4ADDRESS: 0x01800000 ;Image Flash Address 543NOR4FILE: \SOFTWARE\ramdisk.img ;Image File Name 544NOR4NAME: ramdisk.img 545NOR4LOAD: 00000000 ;Image Load Address 546NOR4ENTRY: 00000000 ;Image Entry Point 547``` 548 549###### Extended to 16MB 550``` 551NOR4UPDATE: AUTO ;Image Update:NONE/AUTO/FORCE 552NOR4ADDRESS: 0x01000000 ;Image Flash Address 553NOR4FILE: \SOFTWARE\ramdisk.img ;Image File Name 554NOR4NAME: ramdisk.img 555NOR4LOAD: 00000000 ;Image Load Address 556NOR4ENTRY: 00000000 ;Image Entry Point 557``` 558 559--- 560### 5.8 Tips and tricks 561#### 5.8.1 Reference existing project to speed up repo sync 562Doing a `repo init`, `repo sync` from scratch can take a fair amount of time. 563The main reason for that is simply because of the size of some of the gits we 564are using, like for the Linux kernel and EDK2. With repo you can reference an 565existing forest and by doing so you can speed up repo sync to instead taking ~20 566seconds instead of an hour. The way to do this are as follows. 567 5681. Start by setup a clean forest that you will not touch, in this example, let 569 us call that `optee-ref` and put that under for `$HOME/devel/optee-ref`. This 570 step will take roughly an hour. 5712. Then setup a cronjob (`crontab -e`) that does a `repo sync` in this folder 572 particular folder once a night (that is more than enough). 5733. Now you should setup your actual tree which you are going to use as your 574 working tree. The way to do this is almost the same as stated in the 575 instructions above, the only difference is that you reference the other local 576 forest when running `repo init`, like this 577 ``` 578 repo init -u https://github.com/OP-TEE/manifest.git --reference /home/jbech/devel/optee-ref 579 ``` 5804. The rest is the same above, but now it will only take a couple of seconds to 581 clone a forest. 582 583Normally step 1 and 2 above is something you will only do once. Also if you 584ignore step 2, then you will still get the latest from official git trees, since 585repo will also check for updates that aren't at the local reference. 586 587#### 5.8.2. Use ccache 588ccache is a tool that caches build object-files etc locally on the disc and can 589speed up build time significantly in subsequent builds. On Debian-based systems 590(Ubuntu, Mint etc) you simply install it by running: 591``` 592$ sudo apt-get install ccache 593``` 594 595The helper makefiles are configured to automatically find and use ccache if 596ccache is installed on your system, so other than having it installed you don't 597have to think about anything. 598 599--- 600## 6. Load driver, tee-supplicant and run xtest 601Since release v2.0.0 you don't have to load the kernel driver explicitly. In the 602standard configuration it will be built into the kernel directly. To actually 603run something on a device you however need to run tee-supplicant. This is the 604same for all platforms, so when a device has booted, then run 605``` 606$ tee-supplicant & 607``` 608and OP-TEE is ready to be used. 609 610In case you want to try run something that triggers both normal and secure side 611code you could run xtest (the main test suite for OP-TEE), run 612``` 613$ xtest 614``` 615 616--- 617## 7. Coding standards 618In this project we are trying to adhere to the same coding convention as used in 619the Linux kernel (see 620[CodingStyle](https://www.kernel.org/doc/Documentation/CodingStyle)). We achieve this by running 621[checkpatch](http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl) 622from Linux kernel. However there are a few exceptions that we had to make since 623the code also follows GlobalPlatform standards. The exceptions are as follows: 624 625- CamelCase for GlobalPlatform types are allowed. 626- And we also exclude checking third party code that we might use in this 627 project, such as LibTomCrypt, MPA, newlib (not in this particular git, but 628 those are also part of the complete TEE solution). The reason for excluding 629 and not fixing third party code is because we would probably deviate too much 630 from upstream and therefore it would be hard to rebase against those projects 631 later on (and we don't expect that it is easy to convince other software 632 projects to change coding style). 633 634### 7.1 checkpatch 635Since checkpatch is licensed under the terms of GNU GPL License Version 2, we 636cannot include this script directly into this project. Therefore we have 637written the Makefile so you need to explicitly point to the script by exporting 638an environment variable, namely CHECKPATCH. So, suppose that the source code for 639the Linux kernel is at `$HOME/devel/linux`, then you have to export like follows: 640 641 $ export CHECKPATCH=$HOME/devel/linux/scripts/checkpatch.pl 642thereafter it should be possible to use one of the different checkpatch targets 643in the [Makefile](Makefile). There are targets for checking all files, checking 644against latest commit, against a certain base-commit etc. For the details, read 645the [Makefile](Makefile). 646 647