Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 1 | Building |
J-Alves | 241c66c | 2023-10-19 13:59:29 +0100 | [diff] [blame] | 2 | ======== |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 3 | |
J-Alves | 241c66c | 2023-10-19 13:59:29 +0100 | [diff] [blame] | 4 | This page assumes the :ref:`Prerequisites` have been followed to install all project dependencies. |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 5 | |
J-Alves | 241c66c | 2023-10-19 13:59:29 +0100 | [diff] [blame] | 6 | Hafnium |
| 7 | ^^^^^^^ |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 8 | |
Olivier Deprez | 40d09d2 | 2023-11-20 17:46:21 +0100 | [diff] [blame] | 9 | Most common options |
| 10 | ~~~~~~~~~~~~~~~~~~~ |
| 11 | |
| 12 | By default, Hafnium builds all target platforms along with tests with clang. |
| 13 | From Hafnium top level directory, use: |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 14 | |
| 15 | .. code:: shell |
| 16 | |
| 17 | make |
| 18 | |
Olivier Deprez | 40d09d2 | 2023-11-20 17:46:21 +0100 | [diff] [blame] | 19 | The resulting Hafnium images are located in `out/reference/<platform>/hafnium.bin`. |
| 20 | |
| 21 | It is possible to build Hafnium for a single platform target omitting tests, |
| 22 | resulting in faster builds when the test suite is not required. |
| 23 | For example to build the SPMC targeting FVP: |
| 24 | |
| 25 | .. code:: shell |
| 26 | |
| 27 | make PLATFORM=secure_aem_v8a_fvp_vhe |
| 28 | |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 29 | The resulting FVP image is located in |
| 30 | `out/reference/secure_aem_v8a_fvp_vhe_clang/hafnium.bin`. |
| 31 | |
Olivier Deprez | 40d09d2 | 2023-11-20 17:46:21 +0100 | [diff] [blame] | 32 | Multiple platform names can be provided for building e.g.: |
| 33 | |
| 34 | .. code:: shell |
| 35 | |
| 36 | make PLATFORM="secure_aem_v8a_fvp_vhe,secure_tc" |
| 37 | |
| 38 | To get a list of available platforms, you may use: |
| 39 | |
| 40 | .. code:: shell |
| 41 | |
| 42 | make list |
| 43 | |
| 44 | resulting in: |
| 45 | |
| 46 | .. code:: shell |
| 47 | |
Karl Meakin | 11f0547 | 2025-03-27 15:04:39 +0000 | [diff] [blame] | 48 | Supported platforms: ['secure_rd_fremont', 'secure_rd_fremont_cfg1', 'secure_aem_v8a_fvp_vhe', 'aem_v8a_fvp_vhe', 'aem_v8a_fvp_vhe_ffa_v1_1', 'qemu_aarch64_vhe', 'secure_qemu_aarch64', 'rpi4', 'secure_tc'] |
Olivier Deprez | 40d09d2 | 2023-11-20 17:46:21 +0100 | [diff] [blame] | 49 | |
| 50 | Additional options |
| 51 | ~~~~~~~~~~~~~~~~~~ |
| 52 | |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 53 | The presence of assertions in the final build can be set using the `ENABLE_ASSERTIONS` |
| 54 | make variable, by default this is set to `true`, meaning asserts are included in the build. |
| 55 | |
| 56 | .. code:: shell |
| 57 | |
| 58 | make ENABLE_ASSERTIONS=<true|false> |
| 59 | |
| 60 | Each project in the `project` directory specifies a root configurations of the |
| 61 | build. Adding a project is the preferred way to extend support to new platforms. |
| 62 | The target project that is built is selected by the `PROJECT` make variable, the |
| 63 | default project is 'reference'. |
| 64 | |
| 65 | .. code:: shell |
| 66 | |
| 67 | make PROJECT=<project_name> |
| 68 | |
| 69 | If you wish to change the value of the make variables you may need to first use: |
| 70 | |
| 71 | .. code:: shell |
| 72 | |
| 73 | make clobber |
| 74 | |
| 75 | So the `args.gn` file will be regenerated with the new values. |
| 76 | |
Jayanth Dodderi Chidanand | 02a3393 | 2025-04-01 13:39:48 +0100 | [diff] [blame] | 77 | Troubleshoot(Clean Up Artifacts) |
| 78 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 79 | Before building Hafnium, ensure the Clang toolchain is installed and available |
| 80 | in your `PATH`. This is usually sufficient for a successful build. |
| 81 | |
| 82 | If you encounter errors related to missing or incompatible C library headers |
| 83 | (e.g., after a failed build or toolchain update), clean up stale artifacts by running: |
| 84 | |
| 85 | .. code:: shell |
| 86 | |
| 87 | make clobber |
| 88 | |
| 89 | This command removes previously generated build outputs, which can help resolve |
| 90 | issues caused by outdated intermediate files. It's a useful troubleshooting step |
| 91 | but not required for a fresh setup. |
| 92 | |
J-Alves | 3678f20 | 2025-05-27 18:05:57 +0100 | [diff] [blame^] | 93 | .. _Using_Docker: |
| 94 | |
Karl Meakin | 0f6b5ce | 2025-02-25 11:26:09 +0000 | [diff] [blame] | 95 | Using Docker |
| 96 | ^^^^^^^^^^^^ |
| 97 | |
J-Alves | 3678f20 | 2025-05-27 18:05:57 +0100 | [diff] [blame^] | 98 | We provide a Docker container to ensure a consistent development environment. |
| 99 | Build the container with `./build/docker/build.sh`. You can run commands in the |
| 100 | container with `./build/run_in_container.sh -i bash`: |
Karl Meakin | 0f6b5ce | 2025-02-25 11:26:09 +0000 | [diff] [blame] | 101 | |
J-Alves | 3a75fa8 | 2025-03-28 17:46:59 +0000 | [diff] [blame] | 102 | .. code:: shell |
| 103 | |
Karl Meakin | 0f6b5ce | 2025-02-25 11:26:09 +0000 | [diff] [blame] | 104 | ./build/docker/build.sh |
| 105 | ./build/run_in_container.sh -i bash |
| 106 | make |
| 107 | |
| 108 | Alternatively, the Makefile will automatically use the Docker container |
| 109 | if the environment variable `HAFNIUM_HERMETIC_BUILD` is set to `true`: |
| 110 | |
J-Alves | 3a75fa8 | 2025-03-28 17:46:59 +0000 | [diff] [blame] | 111 | .. code:: shell |
| 112 | |
Karl Meakin | 0f6b5ce | 2025-02-25 11:26:09 +0000 | [diff] [blame] | 113 | ./build/docker/build.sh |
| 114 | HAFNIUM_HERMETIC_BUILD=true make |
| 115 | |
J-Alves | 241c66c | 2023-10-19 13:59:29 +0100 | [diff] [blame] | 116 | Hafnium Documentation |
| 117 | ^^^^^^^^^^^^^^^^^^^^^ |
| 118 | |
| 119 | If you have already sourced a virtual environment, Poetry will respect this and |
| 120 | install dependencies there. |
| 121 | |
| 122 | .. code:: shell |
| 123 | |
| 124 | poetry run make doc |
| 125 | |
Olivier Deprez | 5ed0bee | 2023-06-08 10:55:05 +0200 | [diff] [blame] | 126 | -------------- |
| 127 | |
| 128 | *Copyright (c) 2023, Arm Limited. All rights reserved.* |