blob: b863cd560abec64b1bd39d4ff8f135c321a07c44 [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001.. SPDX-License-Identifier: BSD-3-Clause
2.. SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
3
4
5.. _build_options_examples:
6
7#####################
8RMM Build Examples
9#####################
10
11The |RMM| supports a wide range of build configuration options. Some of these options
12are more regularly exercised by developers, while others are for **advanced** and
13**experimental** usage only.
14
15|RMM| can be built using either GNU(GCC) or :ref:`LLVM(Clang)<llvm_build>`
16toolchain. See :ref:`this section<getting_started_toolchain>` for toolchain
17setup and the supported versions.
18
19The build is performed in 2 stages:
20
21**Configure Stage:** In this stage, a default config file can be specified which configures
22a sane config for the chosen platform. If this default config needs to be modified, it is
23recommended to first perform a default config and then modify using the cmake ncurses as
24shown in :ref:`CMake UI Example<build_config_example>`.
25
26**Build Stage:** In this stage, the source build is performed by specifying the `--build` option.
27See any of the commands below for an example.
28
29.. note::
30
31 It is recommended to clean build if any of the build options are changed from previous build.
32
33Below are some of the typical build and configuration examples frequently used in |RMM| development
34for the FVP Platform. Detailed configuration options are described :ref:`here<build_options_table>`.
35
36RMM also supports a ``fake_host`` build which can be used to build RMM for test
37and code analysis on the host machine. See
38:ref:`this section here<fake_host_build>` for more details.
39
401. Perform an initial default build with minimum configuration options:
41
42Build using gnu toolchain
43
44.. code-block:: bash
45
46 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
47 cmake --build ${RMM_BUILD_DIR}
48
49Build using LLVM toolchain
50
51.. code-block:: bash
52
53 cmake -DRMM_CONFIG=fvp_defcfg -DRMM_TOOLCHAIN=llvm -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
54 cmake --build ${RMM_BUILD_DIR}
55
56.. _build_config_example:
57
582. Perform an initial default config, then modify using ccmake ncurses UI:
59
60.. code-block:: bash
61
62 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
63 ccmake -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
64 cmake --build ${RMM_BUILD_DIR}
65
663. Perform a debug build and specify a log level:
67
68.. code-block:: bash
69
70 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DLOG_LEVEL=50
71 cmake --build ${RMM_BUILD_DIR}
72
734. Perform a documentation build:
74
75.. code-block:: bash
76
Soby Mathewb4c6df42022-11-09 11:13:29 +000077 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -DRMM_DOCS=ON
78 cmake --build ${RMM_BUILD_DIR} -- docs
79
805. Perform a clean verbose build:
81
82.. code-block:: bash
83
84 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
85 cmake --build ${RMM_BUILD_DIR} --clean-first --verbose
86
876. Perform a build with Ninja Genenerator:
88
89.. code-block:: bash
90
91 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -G "Ninja" -DLOG_LEVEL=50
92 cmake --build ${RMM_BUILD_DIR}
93
947. Perform a build with Ninja Multi Config Genenerator:
95
96.. code-block:: bash
97
98 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -G "Ninja Multi-Config" -DLOG_LEVEL=50
99 cmake --build ${RMM_BUILD_DIR} --config ${BUILD_TYPE}
100
1018. Perform a Cppcheck static analysis:
102
103.. code-block:: bash
104
105 cmake -DRMM_CONFIG=fvp_defcfg -DRMM_STATIC_ANALYSIS_CPPCHECK=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
106 cmake --build ${RMM_BUILD_DIR} -- cppcheck
107 cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
108
1099. Perform a Cppcheck static analysis with CERT_C/MISRA/THREAD SAFETY (example with MISRA):
110
111.. code-block:: bash
112
113 cmake -DRMM_CONFIG=fvp_defcfg -DRMM_STATIC_ANALYSIS_CPPCHECK=ON -DRMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_MISRA=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
114 cmake --build ${RMM_BUILD_DIR} -- cppcheck
115 cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
116
11710. Perform a checkpatch analysis:
118
119Run checkpatch on commits in the current branch against BASE_COMMIT (default origin/master):
120
121.. code-block:: bash
122
123 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
124 cmake --build ${RMM_BUILD_DIR} -- checkpatch
125
126Run checkpatch on entire codebase:
127
128.. code-block:: bash
129
130 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
131 cmake --build ${RMM_BUILD_DIR} -- checkcodebase
132
13311. Perform a checkspdx analysis:
134
135Run checkspdx on commits in the current branch against BASE_COMMIT (default origin/master):
136
137.. code-block:: bash
138
139 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
140 cmake --build ${RMM_BUILD_DIR} -- checkspdx-patch
141
142Run checkspdx on entire codebase:
143
144.. code-block:: bash
145
146 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
147 cmake --build ${RMM_BUILD_DIR} -- checkspdx-codebase
148
14913. Check header file include order:
150
151Run checkincludes-patch on commits in the current branch against BASE_COMMIT (default origin/master):
152
153.. code-block:: bash
154
155 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
156 cmake --build ${RMM_BUILD_DIR} -- checkincludes-patch
157
158Run checkincludes on entire codebase:
159
160.. code-block:: bash
161
162 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
163 cmake --build ${RMM_BUILD_DIR} -- checkincludes-codebase
164
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +010016514. Perform unit tests on development host:
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +0100166
Javier Almansa Sobrinoe9653182023-09-05 16:36:52 +0100167Build and run unit tests on host platform. It is recommended to enable the
168Debug build of RMM.
Javier Almansa Sobrinoc4ad5b02022-07-05 19:05:14 +0100169
170.. code-block:: bash
171
172 cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
173 cmake --build ${RMM_BUILD_DIR} -- run-unittests
174
Javier Almansa Sobrinoe9653182023-09-05 16:36:52 +0100175Run unittests for a specific test group(s) (e.g. unittests whose group starts with 'xlat')
176
177.. code-block:: bash
178
179 cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
180 cmake --build ${RMM_BUILD_DIR} -- build -j
181 ${RMM_BUILD_DIR}/Debug/rmm.elf -gxlat -v -r${NUMBER_OF_TEST_ITERATIONS}
182
18315. Generate Coverage Report.
184
185It is possible to generate a coverage report for a last execution of the host
186platform (whichever the variant) by using the `run-coverage` build target.
187
188For example, to generate coverate report on the whole set of unittests:
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100189
190.. code-block:: bash
191
192 cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DRMM_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
Javier Almansa Sobrinoe9653182023-09-05 16:36:52 +0100193 cmake --build ${RMM_BUILD_DIR} -- run-unittests
194 cmake --build ${RMM_BUILD_DIR} -- run-coverage
195
196Run coverage analysis on a specific set of unittests (e.g. unittests whose group starts with 'xlat')
197
198.. code-block:: bash
199
200 cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_test -DRMM_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
201 cmake --build ${RMM_BUILD_DIR} -- build -j
202 ${RMM_BUILD_DIR}/Debug/rmm.elf -gxlat
203 cmake --build ${RMM_BUILD_DIR} -- run-coverage
204
205Run coverage analysis on the `host_build` variant of host platform:
206
207.. code-block:: bash
208
209 cmake -DRMM_CONFIG=host_defcfg -DHOST_VARIANT=host_build -DRMM_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
210 ${RMM_BUILD_DIR}/Debug/rmm.elf
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100211 cmake --build ${RMM_BUILD_DIR} -- run-coverage
212
213The above commands will automatically generate the HTML coverage report in folder
Javier Almansa Sobrinoe9653182023-09-05 16:36:52 +0100214`build/Debug/coverage` within the build directory. The HTML generation can be
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100215disabled by setting `RMM_HTML_COV_REPORT=OFF`.
216
Soby Mathewb4c6df42022-11-09 11:13:29 +0000217.. _build_options_table:
218
219###################
220RMM Build Options
221###################
222
223The |RMM| build system supports the following CMake build options.
224
225.. csv-table:: RMM CMake Options Table
226 :header: "Option", "Valid values", "Default", "Description"
227
228 RMM_CONFIG , , ,"Platform build configuration, eg: fvp_defcfg for the FVP"
229 RMM_ARCH ,aarch64 | fake_host ,aarch64 ,"Target Architecture for RMM build"
230 RMM_MAX_SIZE , ,0x0 ,"Maximum size for RMM image"
231 MAX_CPUS , ,16 ,"Maximum number of CPUs supported by RMM"
232 GRANULE_SIZE , ,4096 ,"Granule Size used by RMM"
233 RMM_DOCS ,ON | OFF ,OFF ,"RMM Documentation build"
234 CMAKE_BUILD_TYPE ,Debug | Release ,Release ,"CMake Build type"
235 CMAKE_CONFIGURATION_TYPES ,Debug & Release ,Debug & Release ,"Multi-generator configuration types"
236 CMAKE_DEFAULT_BUILD_TYPE ,Debug | Release ,Release ,"Default multi-generator configuration type"
237 MbedTLS_BUILD_TYPE ,Debug | Release ,Release ,"MbedTLS build type"
238 RMM_PLATFORM ,fvp | host , ,"Platform to build"
239 RMM_TOOLCHAIN ,gnu | llvm , ,"Toolchain name"
240 LOG_LEVEL , ,40 ,"Log level to apply for RMM (0 - 50)"
241 RMM_STATIC_ANALYSIS , , ,"Enable static analysis checkers"
242 RMM_STATIC_ANALYSIS_CPPCHECK ,ON | OFF ,ON ,"Enable Cppcheck static analysis"
243 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_CERT_C ,ON | OFF ,ON ,"Enable Cppcheck's SEI CERT C checker"
244 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_MISRA ,ON | OFF ,ON ,"Enable Cppcheck's MISRA C:2012 checker"
245 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_THREAD_SAFETY ,ON | OFF ,ON ,"Enable Cppcheck's thread safety checker"
246 RMM_UART_ADDR , ,0x0 ,"Base addr of UART to be used for RMM logs"
247 PLAT_CMN_CTX_MAX_XLAT_TABLES , ,0 ,"Maximum number of translation tables used by the runtime context"
Javier Almansa Sobrinoed932592023-01-24 12:50:41 +0000248 PLAT_CMN_EXTRA_MMAP_REGIONS , ,0 ,"Extra platform mmap regions that need to be mapped in S1 xlat tables"
Mate Toth-Pal7f5b27d2023-08-08 13:49:19 +0200249 RMM_NUM_PAGES_PER_STACK , ,5 ,"Number of pages to use per CPU stack"
Soby Mathewb4c6df42022-11-09 11:13:29 +0000250 MBEDTLS_ECP_MAX_OPS ,248 - ,1000 ,"Number of max operations per ECC signing iteration"
251 RMM_FPU_USE_AT_REL2 ,ON | OFF ,OFF(fake_host) ON(aarch64),"Enable FPU/SIMD usage in RMM."
252 RMM_MAX_GRANULES , ,0 ,"Maximum number of memory granules available to the system"
Javier Almansa Sobrino576071e2022-09-09 16:01:17 +0100253 HOST_VARIANT ,host_build | host_test ,host_build ,"Variant to build for the host platform. Only available when RMM_PLATFORM=host"
254 RMM_COVERAGE ,ON | OFF ,OFF ,"Enable coverage analysis"
255 RMM_HTML_COV_REPORT ,ON | OFF ,ON ,"Enable HTML output report for coverage analysis"
Soby Mathewb4c6df42022-11-09 11:13:29 +0000256
257.. _llvm_build:
258
259################
260RMM LLVM Build
261################
262
263RMM can be built using LLVM Toolchain (Clang). To build using LLVM
264toolchain, set RMM_TOOLCHAIN=llvm during configuration stage.
265
266.. _fake_host_build:
267
268#####################
269RMM Fake Host Build
270#####################
271
272RMM also provides a ``fake_host`` target architecture which allows the code to
273be built natively on the host using the host toolchain. To build for
274``fake_host`` architecture, set RMM_CONFIG=host_defcfg during the
275configuration stage.