Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame^] | 1 | Building Hafnium |
| 2 | ================ |
| 3 | |
| 4 | Prerequisites |
| 5 | ------------- |
| 6 | |
| 7 | Build Host |
| 8 | ^^^^^^^^^^ |
| 9 | |
| 10 | A relatively recent Linux distribution is recommended. |
| 11 | CI runs are done using Ubuntu 22.04 LTS (64-bit). |
| 12 | |
| 13 | Toolchain |
| 14 | ^^^^^^^^^ |
| 15 | |
| 16 | The following toolchain is recommended for building Hafnium and the test |
| 17 | infrastructure: |
| 18 | |
| 19 | - For a x86_64 Ubuntu host, |
| 20 | |
| 21 | .. code:: shell |
| 22 | |
| 23 | https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz |
| 24 | |
| 25 | - For a AArch64 Ubuntu host, |
| 26 | |
| 27 | .. code:: shell |
| 28 | |
| 29 | https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-aarch64-linux-gnu.tar.xz |
| 30 | |
| 31 | .. note:: |
| 32 | |
| 33 | Use of a native toolchain installed on the host (e.g. /usr/bin/clang) is |
| 34 | not supported. |
| 35 | |
| 36 | .. note:: |
| 37 | |
| 38 | Using a toolchain version greater, or significantly lesser than the one |
| 39 | specified is not guaranteed to work. |
| 40 | |
| 41 | .. _prerequisites_software_and_libraries: |
| 42 | |
| 43 | Dependencies |
| 44 | ^^^^^^^^^^^^ |
| 45 | |
| 46 | If you are using the recommended Ubuntu distribution then you can install the |
| 47 | required packages with the following command: |
| 48 | |
| 49 | .. code:: shell |
| 50 | |
| 51 | sudo apt install make libssl-dev flex bison python3 python3-serial |
| 52 | python3-pip device-tree-compiler |
| 53 | |
| 54 | pip3 install fdt |
| 55 | |
| 56 | .. _prerequisites_get_source: |
| 57 | |
| 58 | Getting the sources |
| 59 | ^^^^^^^^^^^^^^^^^^^ |
| 60 | |
| 61 | Hafnium source code is maintained in a Git repository hosted on |
| 62 | trustedfirmware.org. |
| 63 | To clone this repository from the server, run the following |
| 64 | in your shell: |
| 65 | |
| 66 | .. code:: shell |
| 67 | |
| 68 | git clone --recurse-submodules https://git.trustedfirmware.org/hafnium/hafnium.git |
| 69 | |
| 70 | In order to import gerrit hooks useful to add a Change-Id footer in commit messages, |
| 71 | it is recommended to use: |
| 72 | |
| 73 | .. code:: shell |
| 74 | |
| 75 | git clone --recurse-submodules https://git.trustedfirmware.org/hafnium/hafnium.git && { cd hafnium && f="$(git rev-parse --git-dir)"; curl -Lo "$f/hooks/commit-msg" https://review.trustedfirmware.org/tools/hooks/commit-msg && { chmod +x "$f/hooks/commit-msg"; git submodule --quiet foreach "cp \"\$toplevel/$f/hooks/commit-msg\" \"\$toplevel/$f/modules/\$path/hooks/commit-msg\""; }; } |
| 76 | |
| 77 | Building |
| 78 | -------- |
| 79 | |
| 80 | The PATH environment variable shall be adjusted to the LLVM/clang directory, prior to building e.g.: |
| 81 | |
| 82 | .. code:: shell |
| 83 | |
| 84 | PATH=<toolchain_dir>/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH |
| 85 | |
| 86 | By default, the Hafnium SPMC is built with clang for a few target platforms along |
| 87 | with tests. From Hafnium top level directory, simply type: |
| 88 | |
| 89 | .. code:: shell |
| 90 | |
| 91 | make |
| 92 | |
| 93 | The resulting FVP image is located in |
| 94 | `out/reference/secure_aem_v8a_fvp_vhe_clang/hafnium.bin`. |
| 95 | |
| 96 | The presence of assertions in the final build can be set using the `ENABLE_ASSERTIONS` |
| 97 | make variable, by default this is set to `true`, meaning asserts are included in the build. |
| 98 | |
| 99 | .. code:: shell |
| 100 | |
| 101 | make ENABLE_ASSERTIONS=<true|false> |
| 102 | |
| 103 | Each project in the `project` directory specifies a root configurations of the |
| 104 | build. Adding a project is the preferred way to extend support to new platforms. |
| 105 | The target project that is built is selected by the `PROJECT` make variable, the |
| 106 | default project is 'reference'. |
| 107 | |
| 108 | .. code:: shell |
| 109 | |
| 110 | make PROJECT=<project_name> |
| 111 | |
| 112 | If you wish to change the value of the make variables you may need to first use: |
| 113 | |
| 114 | .. code:: shell |
| 115 | |
| 116 | make clobber |
| 117 | |
| 118 | So the `args.gn` file will be regenerated with the new values. |
| 119 | |
| 120 | -------------- |
| 121 | |
| 122 | *Copyright (c) 2023, Arm Limited. All rights reserved.* |