Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _build: |
| 2 | |
| 3 | ##### |
| 4 | build |
| 5 | ##### |
| 6 | Why this particular git? As it turns out it's totally possible to put together |
| 7 | everything on your own. You can build all the individual components, os, client, |
| 8 | xtest, Linux kernel, TF-A, TianoCore, QEMU, Buildroot_ etc and put all the |
| 9 | binaries at correct locations and write your own command lines, Makefiles, |
| 10 | shell-scripts etc that will work nicely on the devices you are interested in. If |
| 11 | you know how to do that, fine, please go a head. But for newcomers it's way to |
| 12 | much behind the scenes to be able to setup a working environment. Also, if you |
| 13 | for some reason want to run something in an automated way, then you need |
| 14 | something else wrapping it up for you. |
| 15 | |
| 16 | With this particular git **built.git** our goal is to simply to make it easy for |
| 17 | newcomers to get started with OP-TEE using the devices we've listed in this |
| 18 | document. |
| 19 | |
| 20 | |
| 21 | git location |
| 22 | ************ |
| 23 | https://github.com/OP-TEE/build |
| 24 | |
| 25 | |
| 26 | Why repo? |
| 27 | ********* |
| 28 | We discussed alternatives, initially we started out with having a simple |
| 29 | shell-script, that worked to start with, but after getting more gits in use and |
| 30 | support for more devices it started to be difficult to maintain. In the end we |
| 31 | ended up choosing between repo_ from the Google AOSP project and `git |
| 32 | submodules`_. No matter which you choose, there will always be some person |
| 33 | arguing that one is better than the other. For us we decided to use repo. Not |
| 34 | directly for the features itself from repo, but for the ability to simply work |
| 35 | with different manifests containing both stable and non-stable release. Using |
| 36 | some tips and tricks you can also speed up setup time significantly. For day to |
| 37 | day work with commits, branches etc we tend to use git commands directly. |
| 38 | |
| 39 | |
| 40 | .. _root_fs: |
| 41 | |
| 42 | Root filesystem |
| 43 | *************** |
| 44 | The rootfs in the builds that we cover here are as small as possible and is |
| 45 | based on a stripped down Buildroot_ configuration adding just enough in the |
| 46 | rootfs such that one can: |
| 47 | |
| 48 | - Boot OP-TEE. |
| 49 | - Run xtest with no regressions. |
| 50 | - Easily add additional developer tools like, strace, valgrind etc. |
| 51 | |
| 52 | .. note:: |
| 53 | |
| 54 | As a consequence of enabling "just enough", it is likely that **non-UART** |
| 55 | based enviroments won't work out of the box. I.e., if you try to boot up an |
| 56 | enviroment using HDMI and connect keyboards and other devices it is likely |
| 57 | that things will not work. To make them work, you probably need to rebuild |
| 58 | Linux kernel with correct drivers/frameworks enabled and in addition to that |
| 59 | enable binaries/daemons in Buildroot that might be necessary (user space |
| 60 | tools and drivers). |
| 61 | |
| 62 | |
| 63 | How do I build using AOSP / OpenEmbedded? |
| 64 | ***************************************** |
| 65 | For guides how to build AOSP, please refer to our :ref:`aosp` page. For |
Joakim Bech | e58b15c | 2020-04-15 10:48:41 +0200 | [diff] [blame^] | 66 | OpenEmbedded we have no guide ready. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 67 | |
| 68 | .. _optee_developer_setup: |
| 69 | |
| 70 | Platforms supported by build.git |
| 71 | ******************************** |
| 72 | Below is a table showing the platforms supported by build.git. OP-TEE as such |
Joakim Bech | e58b15c | 2020-04-15 10:48:41 +0200 | [diff] [blame^] | 73 | supports many more platforms. To find out how to run OP-TEE on those, please |
| 74 | reach out to the maintainer of that platform directly if you have build related |
| 75 | questions etc. Please see the MAINTAINERS_ file for contact information. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 76 | |
| 77 | .. Please keep this list sorted in alphabetic order: |
| 78 | .. list-table:: |
| 79 | :header-rows: 1 |
| 80 | |
| 81 | * - Platform |
| 82 | - Composite flag |
| 83 | - Publicly available? |
| 84 | |
| 85 | * - `ARM Juno Board`_ |
| 86 | - ``PLATFORM=vexpress-juno`` |
| 87 | - Yes |
| 88 | |
| 89 | * - `ARM Foundation FVP`_ |
| 90 | - ``PLATFORM=vexpress-fvp`` |
| 91 | - Yes |
| 92 | |
Pipat Methavanitpong | 83e734b | 2019-06-05 17:20:31 +0900 | [diff] [blame] | 93 | * - `DeveloperBox`_ |
| 94 | - ``PLATFORM=synquacer`` |
| 95 | - Yes |
| 96 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 97 | * - `HiKey Kirin 620`_ |
| 98 | - ``PLATFORM=hikey`` |
| 99 | - Yes |
| 100 | |
| 101 | * - `HiKey 960`_ |
| 102 | - ``PLATFORM=hikey-hikey960`` |
| 103 | - Yes |
| 104 | |
| 105 | * - `MediaTek MT8173 EVB Board`_ (deprecated) |
| 106 | - ``PLATFORM=mediatek-mt8173`` |
| 107 | - No |
| 108 | |
| 109 | * - `Poplar`_ |
| 110 | - ``PLATFORM=poplar`` |
| 111 | - Yes |
| 112 | |
| 113 | * - `QEMU`_ |
| 114 | - ``PLATFORM=vexpress-qemu_virt`` |
| 115 | - Yes |
| 116 | |
| 117 | * - `QEMUv8`_ |
| 118 | - ``PLATFORM=vexpress-qemu_armv8a`` |
| 119 | - Yes |
| 120 | |
| 121 | * - `Raspberry Pi 3`_ |
| 122 | - ``PLATFORM=rpi3`` |
| 123 | - Yes |
| 124 | |
| 125 | * - `Texas Instruments DRA7xx`_ |
| 126 | - ``PLATFORM=ti-dra7xx`` |
| 127 | - Yes |
| 128 | |
| 129 | * - `Texas Instruments AM57xx`_ |
| 130 | - ``PLATFORM=ti-am57xx`` |
| 131 | - Yes |
| 132 | |
| 133 | * - `Texas Instruments AM43xx`_ |
| 134 | - ``PLATFORM=ti-am43xx`` |
| 135 | - Yes |
| 136 | |
| 137 | |
| 138 | Manifests |
| 139 | ********* |
| 140 | .. _current_version: |
| 141 | |
| 142 | Current version |
| 143 | =============== |
| 144 | Here is a list of manifests for the devices currently supported in |
| 145 | ``build.git``. With these you will get a setup containing the all necessary |
| 146 | software components to run OP-TEE on the chosen device. Beware that this will |
| 147 | run latest available on OP-TEE gits meaning that if you re-sync then you will |
| 148 | most likely get new commits. If you need a stable/tagged version with non-moving |
| 149 | gits, then please refer to the next section instead. |
| 150 | |
| 151 | .. Please keep this list sorted in alphabetic order: |
| 152 | |
Pipat Methavanitpong | 83e734b | 2019-06-05 17:20:31 +0900 | [diff] [blame] | 153 | +----------------+-------------------+----------------------+ |
| 154 | | Target | Manifest xml | Device documentation | |
| 155 | +================+===================+======================+ |
| 156 | | AM43xx | ``am43xx.xml`` | :ref:`ti` | |
| 157 | +----------------+-------------------+----------------------+ |
| 158 | | AM57xx | ``am57xx.xml`` | :ref:`ti` | |
| 159 | +----------------+-------------------+----------------------+ |
| 160 | | DeveloperBox | ``synquacer.xml`` | :ref:`devbox` | |
| 161 | +----------------+-------------------+----------------------+ |
| 162 | | ARM Juno board | ``juno.xml`` | :ref:`juno` | |
| 163 | +----------------+-------------------+----------------------+ |
| 164 | | DRA7xx | ``dra7xx.xml`` | :ref:`ti` | |
| 165 | +----------------+-------------------+----------------------+ |
| 166 | | FVP | ``fvp.xml`` | :ref:`fvp` | |
| 167 | +----------------+-------------------+----------------------+ |
| 168 | | HiKey 960 | ``hikey960.xml`` | :ref:`hikey960` | |
| 169 | +----------------+-------------------+----------------------+ |
| 170 | | HiKey | ``hikey.xml`` | :ref:`hikey` | |
| 171 | +----------------+-------------------+----------------------+ |
| 172 | | Poplar Debian | ``poplar.xml`` | | |
| 173 | +----------------+-------------------+----------------------+ |
| 174 | | QEMU | ``default.xml`` | :ref:`qemu_v7` | |
| 175 | +----------------+-------------------+----------------------+ |
| 176 | | QEMUv8 | ``qemu_v8.xml`` | :ref:`qemu_v8` | |
| 177 | +----------------+-------------------+----------------------+ |
| 178 | | Raspberry Pi 3 | ``rpi3.xml`` | :ref:`rpi3` | |
| 179 | +----------------+-------------------+----------------------+ |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 180 | |
| 181 | Stable releases |
| 182 | =============== |
| 183 | Starting from OP-TEE ``v3.1`` you can check out stable releases by using the |
| 184 | same manifests as for current version above, but with the difference that **you |
| 185 | also need to specify a branch** where the name corresponds to the release |
| 186 | version. I.e., when we are doing releases we are creating a branch with a name |
| 187 | corresponding to the release version. So, let's for example say that you want to |
| 188 | checkout a stable OP-TEE ``v3.4`` for Raspberry Pi 3, then you do like this |
| 189 | instead of what is mentioned further down in section |
| 190 | ":ref:`build_get_the_source`" (note the ``-b 3.4.0``): |
| 191 | |
| 192 | .. code-block:: bash |
| 193 | |
| 194 | ... |
| 195 | $ repo init -u https://github.com/OP-TEE/manifest.git -m rpi3.xml -b 3.4.0 |
| 196 | ... |
| 197 | |
| 198 | Stable releases prior to OP-TEE v3.1 (v1.0.0 to v3.0.0) |
| 199 | ======================================================= |
| 200 | Before OP-TEE ``v3.1`` we used to have separate xml-manifest files for the |
| 201 | stable builds. If you for some reason need an older stable release, then you can |
| 202 | use the ``xyz_stable.xml`` file corresponding to your device. The way to init |
| 203 | ``repo`` is almost the same as described above, the major difference is the name |
| 204 | of manifest being referenced (``-m xyz_stable.xml``) and that we are referring |
| 205 | to a tag instead of a branch (``-b refs/tags/MAJOR.MINOR.PATCH``). So as an |
| 206 | example, if you need to setup the ``2.1.0`` stable release for HiKey, then you |
| 207 | would do like this instead of what is mentioned further down in section |
| 208 | ":ref:`build_get_the_source`". |
| 209 | |
| 210 | .. code-block:: bash |
| 211 | |
| 212 | ... |
| 213 | repo init -u https://github.com/OP-TEE/manifest.git -m hikey_stable.xml -b refs/tags/2.1.0 |
| 214 | ... |
| 215 | |
| 216 | Here is a list of targets and the names of the stable manifests files which were |
| 217 | supported by older releases: |
| 218 | |
| 219 | .. Please keep this list sorted in alphabetic order: |
| 220 | |
| 221 | +----------------+-----------------------------+ |
| 222 | | Target | Stable manifest xml | |
| 223 | +================+=============================+ |
| 224 | | AM43xx | ``am43xx_stable.xml`` | |
| 225 | +----------------+-----------------------------+ |
| 226 | | AM57xx | ``am57xx_stable.xml`` | |
| 227 | +----------------+-----------------------------+ |
| 228 | | ARM Juno board | ``juno_stable.xml`` | |
| 229 | +----------------+-----------------------------+ |
| 230 | | DRA7xx | ``dra7xx_stable.xml`` | |
| 231 | +----------------+-----------------------------+ |
| 232 | | FVP | ``fvp_stable.xml`` | |
| 233 | +----------------+-----------------------------+ |
| 234 | | HiKey 960 | ``hikey960_stable.xml`` | |
| 235 | +----------------+-----------------------------+ |
| 236 | | HiKey Debian | ``hikey_debian_stable.xml`` | |
| 237 | +----------------+-----------------------------+ |
| 238 | | HiKey | ``hikey_stable.xml`` | |
| 239 | +----------------+-----------------------------+ |
| 240 | | MTK8173 | ``mt8173-evb_stable.xml`` | |
| 241 | +----------------+-----------------------------+ |
| 242 | | QEMU | ``default_stable.xml`` | |
| 243 | +----------------+-----------------------------+ |
| 244 | | QEMUv8 | ``qemu_v8_stable.xml`` | |
| 245 | +----------------+-----------------------------+ |
| 246 | | Raspberry Pi 3 | ``rpi3_stable.xml`` | |
| 247 | +----------------+-----------------------------+ |
| 248 | |
| 249 | .. _get_and_build_the_solution: |
| 250 | |
| 251 | |
| 252 | Get and build the solution |
| 253 | ************************** |
| 254 | Below we will describe the general way of how to get the source, build the |
| 255 | solution and how to run xtest on the device. For device specific instructions, |
| 256 | please see the links in the table in the ":ref:`current_version`" section. |
| 257 | |
| 258 | .. _build_prerequisites: |
| 259 | |
| 260 | Step 1 - Prerequisites |
| 261 | ====================== |
| 262 | Install prerequisites according to the :ref:`prerequisites` page. |
| 263 | |
| 264 | |
| 265 | .. _build_install_repo: |
| 266 | |
| 267 | Step 2 - Install Android repo |
| 268 | ============================= |
| 269 | Note that here you don't install a huge SDK, it's simply a Python script that |
| 270 | you download and put in your ``$PATH``, that's it. Exactly how to "install" |
| 271 | repo, can be found at the Google repo_ pages, so follow those instructions |
| 272 | before continuing. |
| 273 | |
| 274 | |
| 275 | .. _build_get_the_source: |
| 276 | |
| 277 | Step 3 - Get the source code |
| 278 | ============================ |
| 279 | Choose the manifest corresponding to the platform you intend to use (see the |
| 280 | table in section ":ref:`current_version`". For example, if you intend to use |
| 281 | Raspberry Pi3, then at line 3 below, ``${TARGET}.xml`` shall be ``rpi3.xml``. |
| 282 | The ``<optee-project>`` is whatever location where you want to store the entire |
| 283 | OP-TEE developer setup. |
| 284 | |
| 285 | .. code-block:: bash |
| 286 | :linenos: |
| 287 | :emphasize-lines: 3 |
| 288 | |
| 289 | $ mkdir -p <optee-project> |
| 290 | $ cd <optee-project> |
| 291 | $ repo init -u https://github.com/OP-TEE/manifest.git -m ${TARGET}.xml [-b ${BRANCH}] |
| 292 | $ repo sync -j4 --no-clone-bundle |
| 293 | |
| 294 | .. hint:: |
| 295 | |
| 296 | By referencing an existing and locally saved repo forest you can save lots |
| 297 | of time. We are talking about doing repo sync in 30 seconds instead of 15-30 |
| 298 | minutes (see the :ref:`tips_and_tricks` section for more details). |
| 299 | |
| 300 | |
| 301 | .. _build_get_toolchains: |
| 302 | |
| 303 | Step 4 - Get the toolchains |
| 304 | =========================== |
| 305 | In OP-TEE we're using different toolchains for different targets (depends on |
| 306 | ARMv7-A ARMv8-A 64/32bit solutions). In any case start by downloading the |
| 307 | toolchains by: |
| 308 | |
| 309 | .. code-block:: bash |
| 310 | |
| 311 | $ cd <optee-project>/build |
| 312 | $ make -j2 toolchains |
| 313 | |
| 314 | |
| 315 | .. _build_make: |
| 316 | |
| 317 | Step 5 - Build the solution |
| 318 | =========================== |
| 319 | We've configured our repo manifests, so that repo will always automatically |
| 320 | symlink the ``Makefile`` to the correct device specific makefile, that means |
| 321 | that you simply start the build by running (still in ``<optee-project>/build``) |
| 322 | |
| 323 | .. code-block:: bash |
| 324 | |
| 325 | $ make -j `nproc` |
| 326 | |
| 327 | This step will also take some time, but you can speed up subsequent builds by |
| 328 | enabling ccache_ (again see :ref:`tips_and_tricks`). |
| 329 | |
| 330 | .. hint:: |
| 331 | |
| 332 | **If you're having build issues**, then you can pipe the entire build log to |
| 333 | a file, which makes it easier to search for the issue using a regular |
| 334 | editor. In that case also avoid the ``-j`` flag so it's easier to see in what |
| 335 | order things are happening. To create a ``build.log`` file do: ``$ make 2>&1 |
| 336 | | tee build.log`` |
| 337 | |
| 338 | |
| 339 | .. _build_flash: |
| 340 | |
| 341 | Step 6 - Flash the device |
| 342 | ========================= |
| 343 | On **non-emulated** solutions (this means that you shouldn't do this step when |
| 344 | you are running QEMU-v7/v8 and FVP), you will need to flash the software in some |
| 345 | way. We've tried to "hide" that under the following make target: |
| 346 | |
| 347 | .. code-block:: bash |
| 348 | |
| 349 | $ make flash |
| 350 | |
| 351 | But, since some devices are trickier to flash than others, please see the |
| 352 | :ref:`device_specific`. See this just as a general instruction. |
| 353 | |
| 354 | Step 7 - Boot up the device |
| 355 | =========================== |
| 356 | This is device specific (see :ref:`device_specific`). |
| 357 | |
| 358 | |
| 359 | .. _build_tee_supplicant: |
| 360 | |
| 361 | Step 8 - Load tee-supplicant |
| 362 | ============================ |
| 363 | On **most** solutions tee-supplicant is already running (check by running ``$ ps |
| 364 | aux | grep tee-supplicant``) on others not. If it's **not** running, then start |
| 365 | it by running: |
| 366 | |
| 367 | .. code-block:: bash |
| 368 | |
| 369 | $ tee-supplicant -d |
| 370 | |
| 371 | .. note:: |
| 372 | If you've built using our manifest you should not need to modprobe any |
| 373 | OP-TEE/TEE kernel driver since it's built into the kernel in all our setups. |
| 374 | |
| 375 | |
| 376 | .. _build_run_xtest: |
| 377 | |
| 378 | Step 9 - Run xtest |
| 379 | ================== |
| 380 | The entire xtest test suite has been deployed when you we're making the builds |
| 381 | in previous steps, i.e, in general there is no need to copy any binaries |
| 382 | manually. Everything has been put into the :ref:`root_fs` automatically. So, to |
| 383 | run xtest, you simply type: |
| 384 | |
| 385 | .. code-block:: bash |
| 386 | |
| 387 | $ xtest |
| 388 | |
| 389 | If there are no regressions / issues found, xtest should end with something like |
| 390 | this: |
| 391 | |
| 392 | .. code-block:: none |
| 393 | |
| 394 | ... |
| 395 | +----------------------------------------------------- |
| 396 | 23476 subtests of which 0 failed |
| 397 | 67 test cases of which 0 failed |
| 398 | 0 test case was skipped |
| 399 | TEE test application done! |
| 400 | |
| 401 | .. hint:: |
| 402 | |
| 403 | For other ways to run xtest, please refer to the ":ref:`optee_test_run_xtest`" |
| 404 | page at :ref:`optee_test`. |
| 405 | |
| 406 | .. _tips_and_tricks: |
| 407 | |
| 408 | Tips and Tricks |
| 409 | *************** |
| 410 | Reference existing project to speed up repo sync |
| 411 | ================================================ |
| 412 | Doing a ``repo init``, ``repo sync`` from scratch can take a fair amount of |
| 413 | time. The main reason for that is simply because of the size of some of the gits |
| 414 | we are using, like for the Linux kernel and EDK2. With repo you can reference an |
| 415 | existing forest and by doing so you can speed up repo sync to taking 30 seconds |
| 416 | instead of 15-30 minutes. The way to do this are as follows. |
| 417 | |
| 418 | 1. Start by setup a clean forest that you will not touch, in this example, |
| 419 | let us call that ``optee-ref`` and put that under for |
| 420 | ``$HOME/devel/optee-ref``. This step will take somewhere between 15- to |
| 421 | 45 minutes, depending on your connection speed to internet. |
| 422 | |
| 423 | 2. Then setup a cronjob (``crontab -e``) that does a ``repo sync`` in this |
| 424 | folder particular folder once a night (that is more than enough). |
| 425 | |
| 426 | 3. Now you should setup your actual tree which you are going to use as your |
| 427 | working tree. The way to do this is almost the same as stated in the |
| 428 | instructions above (see the ":ref:`build_get_the_source`" section) , the |
| 429 | only difference is that you **also** reference the other local forest |
| 430 | when running ``repo init``, like this |
| 431 | |
| 432 | .. code-block:: bash |
| 433 | |
| 434 | $ repo init -u https://github.com/OP-TEE/manifest.git --reference $HOME/devel/optee-ref |
| 435 | |
| 436 | 4. The rest is the same above, but now it will only take a couple of seconds |
| 437 | to clone a forest. |
| 438 | |
| 439 | Normally '1' and '2' above is something you will only do once. Also if you |
| 440 | ignore step '2', then you will **still** get the latest from official git trees, |
| 441 | since repo will also check for updates that aren't at the local reference. |
| 442 | |
| 443 | Use ccache |
| 444 | ========== |
| 445 | ccache_ is a tool that caches build object-files etc locally on the disc and can |
| 446 | speed up build time significantly in subsequent builds. On Debian-based systems |
| 447 | (Ubuntu, Mint etc) you simply install it by running: |
| 448 | |
| 449 | .. code-block:: bash |
| 450 | |
| 451 | $ sudo apt-get install ccache |
| 452 | |
| 453 | The makefiles in build.git are configured to automatically find and use ccache |
| 454 | if ccache is installed on your system, so other than having it installed you |
| 455 | don't have to think about anything. |
| 456 | |
| 457 | .. _Buildroot: https://buildroot.org |
| 458 | .. _ccache: https://ccache.samba.org |
| 459 | .. _git submodules: https://git-scm.com/book/en/v2/Git-Tools-Submodules |
| 460 | .. _MAINTAINERS: https://github.com/OP-TEE/optee_os/blob/master/MAINTAINERS |
| 461 | .. _repo: https://source.android.com/source/downloading.html |
| 462 | |
| 463 | .. Links to devices etc: |
| 464 | .. _ARM Juno Board: http://www.arm.com/products/tools/development-boards/versatile-express/juno-arm-development-platform.php |
| 465 | .. _ARM Foundation FVP: http://www.arm.com/fvp |
Pipat Methavanitpong | 83e734b | 2019-06-05 17:20:31 +0900 | [diff] [blame] | 466 | .. _DeveloperBox: https://www.96boards.org/product/developerbox |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 467 | .. _HiKey Kirin 620: https://www.96boards.org/products/hikey |
| 468 | .. _HiKey 960: https://www.96boards.org/product/hikey960 |
| 469 | .. _MediaTek MT8173 EVB Board: http://www.mediatek.com/en/products/mobile-communications/tablet/mt8173 |
| 470 | .. _Poplar: https://www.96boards.org/product/poplar/ |
| 471 | .. _QEMU: http://wiki.qemu.org/Main_Page |
| 472 | .. _QEMUv8: http://wiki.qemu.org/Main_Page |
| 473 | .. _Raspberry Pi 3: https://www.raspberrypi.org/products/raspberry-pi-3-model-b |
| 474 | .. _Texas Instruments DRA7xx: http://www.ti.com/product/DRA746 |
| 475 | .. _Texas Instruments AM57xx: http://www.ti.com/product/AM5728 |
| 476 | .. _Texas Instruments AM43xx: http://www.ti.com/product/AM4379 |