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