blob: ce58ea93088597973cbf86d83ff7e56a7cc0bdcd [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
77 export PLANTUML_JAR_PATH=<install path>/bin/plantuml/plantuml.jar
78 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -DRMM_DOCS=ON
79 cmake --build ${RMM_BUILD_DIR} -- docs
80
815. Perform a clean verbose build:
82
83.. code-block:: bash
84
85 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
86 cmake --build ${RMM_BUILD_DIR} --clean-first --verbose
87
886. Perform a build with Ninja Genenerator:
89
90.. code-block:: bash
91
92 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -G "Ninja" -DLOG_LEVEL=50
93 cmake --build ${RMM_BUILD_DIR}
94
957. Perform a build with Ninja Multi Config Genenerator:
96
97.. code-block:: bash
98
99 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR} -G "Ninja Multi-Config" -DLOG_LEVEL=50
100 cmake --build ${RMM_BUILD_DIR} --config ${BUILD_TYPE}
101
1028. Perform a Cppcheck static analysis:
103
104.. code-block:: bash
105
106 cmake -DRMM_CONFIG=fvp_defcfg -DRMM_STATIC_ANALYSIS_CPPCHECK=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
107 cmake --build ${RMM_BUILD_DIR} -- cppcheck
108 cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
109
1109. Perform a Cppcheck static analysis with CERT_C/MISRA/THREAD SAFETY (example with MISRA):
111
112.. code-block:: bash
113
114 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}
115 cmake --build ${RMM_BUILD_DIR} -- cppcheck
116 cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
117
11810. Perform a checkpatch analysis:
119
120Run checkpatch on commits in the current branch against BASE_COMMIT (default origin/master):
121
122.. code-block:: bash
123
124 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
125 cmake --build ${RMM_BUILD_DIR} -- checkpatch
126
127Run checkpatch on entire codebase:
128
129.. code-block:: bash
130
131 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
132 cmake --build ${RMM_BUILD_DIR} -- checkcodebase
133
13411. Perform a checkspdx analysis:
135
136Run checkspdx on commits in the current branch against BASE_COMMIT (default origin/master):
137
138.. code-block:: bash
139
140 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
141 cmake --build ${RMM_BUILD_DIR} -- checkspdx-patch
142
143Run checkspdx on entire codebase:
144
145.. code-block:: bash
146
147 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
148 cmake --build ${RMM_BUILD_DIR} -- checkspdx-codebase
149
15013. Check header file include order:
151
152Run checkincludes-patch on commits in the current branch against BASE_COMMIT (default origin/master):
153
154.. code-block:: bash
155
156 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
157 cmake --build ${RMM_BUILD_DIR} -- checkincludes-patch
158
159Run checkincludes on entire codebase:
160
161.. code-block:: bash
162
163 cmake -DRMM_CONFIG=fvp_defcfg -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
164 cmake --build ${RMM_BUILD_DIR} -- checkincludes-codebase
165
166.. _build_options_table:
167
168###################
169RMM Build Options
170###################
171
172The |RMM| build system supports the following CMake build options.
173
174.. csv-table:: RMM CMake Options Table
175 :header: "Option", "Valid values", "Default", "Description"
176
177 RMM_CONFIG , , ,"Platform build configuration, eg: fvp_defcfg for the FVP"
178 RMM_ARCH ,aarch64 | fake_host ,aarch64 ,"Target Architecture for RMM build"
179 RMM_MAX_SIZE , ,0x0 ,"Maximum size for RMM image"
180 MAX_CPUS , ,16 ,"Maximum number of CPUs supported by RMM"
181 GRANULE_SIZE , ,4096 ,"Granule Size used by RMM"
182 RMM_DOCS ,ON | OFF ,OFF ,"RMM Documentation build"
183 CMAKE_BUILD_TYPE ,Debug | Release ,Release ,"CMake Build type"
184 CMAKE_CONFIGURATION_TYPES ,Debug & Release ,Debug & Release ,"Multi-generator configuration types"
185 CMAKE_DEFAULT_BUILD_TYPE ,Debug | Release ,Release ,"Default multi-generator configuration type"
186 MbedTLS_BUILD_TYPE ,Debug | Release ,Release ,"MbedTLS build type"
187 RMM_PLATFORM ,fvp | host , ,"Platform to build"
188 RMM_TOOLCHAIN ,gnu | llvm , ,"Toolchain name"
189 LOG_LEVEL , ,40 ,"Log level to apply for RMM (0 - 50)"
190 RMM_STATIC_ANALYSIS , , ,"Enable static analysis checkers"
191 RMM_STATIC_ANALYSIS_CPPCHECK ,ON | OFF ,ON ,"Enable Cppcheck static analysis"
192 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_CERT_C ,ON | OFF ,ON ,"Enable Cppcheck's SEI CERT C checker"
193 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_MISRA ,ON | OFF ,ON ,"Enable Cppcheck's MISRA C:2012 checker"
194 RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_THREAD_SAFETY ,ON | OFF ,ON ,"Enable Cppcheck's thread safety checker"
195 RMM_UART_ADDR , ,0x0 ,"Base addr of UART to be used for RMM logs"
196 PLAT_CMN_CTX_MAX_XLAT_TABLES , ,0 ,"Maximum number of translation tables used by the runtime context"
197 PLAT_CMN_MAX_MMAP_REGIONS , ,5 ,"Maximum number of mmap regions to be allocated for the platform"
198 RMM_NUM_PAGES_PER_STACK , ,3 ,"Number of pages to use per CPU stack"
199 MBEDTLS_ECP_MAX_OPS ,248 - ,1000 ,"Number of max operations per ECC signing iteration"
200 RMM_FPU_USE_AT_REL2 ,ON | OFF ,OFF(fake_host) ON(aarch64),"Enable FPU/SIMD usage in RMM."
201 RMM_MAX_GRANULES , ,0 ,"Maximum number of memory granules available to the system"
202
203
204
205.. _llvm_build:
206
207################
208RMM LLVM Build
209################
210
211RMM can be built using LLVM Toolchain (Clang). To build using LLVM
212toolchain, set RMM_TOOLCHAIN=llvm during configuration stage.
213
214.. _fake_host_build:
215
216#####################
217RMM Fake Host Build
218#####################
219
220RMM also provides a ``fake_host`` target architecture which allows the code to
221be built natively on the host using the host toolchain. To build for
222``fake_host`` architecture, set RMM_CONFIG=host_defcfg during the
223configuration stage.