blob: 33b35331095411af582fbc18a9100db0f1840924 [file] [log] [blame]
Paul Beesleyfc9ee362019-03-07 15:47:15 +00001Contributor's Guide
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +00002*******************
Douglas Raillardd7c21b72017-06-28 15:23:03 +01003
4Getting Started
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +00005===============
Douglas Raillardd7c21b72017-06-28 15:23:03 +01006
Sandrine Bailleuxd3147342020-05-12 10:36:05 +02007- Make sure you have a Github account and you are logged on both
8 `developer.trustedfirmware.org`_ and `review.trustedfirmware.org`_.
Douglas Raillardd7c21b72017-06-28 15:23:03 +01009
Sandrine Bailleux9c2db482024-01-26 11:48:32 +010010 Also make sure that you have registered your full name and email address in
11 your `review.trustedfirmware.org`_ profile. Otherwise, the Gerrit server
12 might reject patches you attempt to post for review.
13
Sandrine Bailleux6ef77ce2020-08-03 10:27:19 +020014- If you plan to contribute a major piece of work, it is usually a good idea to
Sandrine Bailleux9c2db482024-01-26 11:48:32 +010015 start a discussion around it on the `TF-A mailing list`_. This gives everyone
Sandrine Bailleux6ef77ce2020-08-03 10:27:19 +020016 visibility of what is coming up, you might learn that somebody else is
17 already working on something similar or the community might be able to
18 provide some early input to help shaping the design of the feature.
19
20 If you intend to include Third Party IP in your contribution, please mention
21 it explicitly in the email thread and ensure that the changes that include
22 Third Party IP are made in a separate patch (or patch series).
Douglas Raillardd7c21b72017-06-28 15:23:03 +010023
Sandrine Bailleux9c2db482024-01-26 11:48:32 +010024- Clone the Trusted Firmware-A source code on your own machine as described in
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +010025 :ref:`prerequisites_get_source`.
Sandrine Bailleux75804e52020-08-12 11:29:46 +020026
Sandrine Bailleux9c2db482024-01-26 11:48:32 +010027- Create a local topic branch based on the Trusted Firmware-A ``master``
Douglas Raillardd7c21b72017-06-28 15:23:03 +010028 branch.
29
30Making Changes
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +000031==============
Douglas Raillardd7c21b72017-06-28 15:23:03 +010032
Sandrine Bailleux9c2db482024-01-26 11:48:32 +010033- Ensure commits adhere to the project's :ref:`Commit Style`.
Chris Kay1b706e62021-11-15 10:50:30 +000034
Douglas Raillardd7c21b72017-06-28 15:23:03 +010035- Make commits of logical units. See these general `Git guidelines`_ for
36 contributing to a project.
Sandrine Bailleux75804e52020-08-12 11:29:46 +020037
Douglas Raillardd7c21b72017-06-28 15:23:03 +010038- Keep the commits on topic. If you need to fix another bug or make another
Sandrine Bailleux6ef77ce2020-08-03 10:27:19 +020039 enhancement, please address it on a separate topic branch.
Sandrine Bailleux75804e52020-08-12 11:29:46 +020040
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +020041- Split the patch in manageable units. Small patches are usually easier to
42 review so this will speed up the review process.
43
Douglas Raillardd7c21b72017-06-28 15:23:03 +010044- Avoid long commit series. If you do have a long series, consider whether
45 some commits should be squashed together or addressed in a separate topic.
Sandrine Bailleux75804e52020-08-12 11:29:46 +020046
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +020047- Follow the :ref:`Coding Style` and :ref:`Coding Guidelines`.
48
49 - Use the checkpatch.pl script provided with the Linux source tree. A
50 Makefile target is provided for convenience, see :ref:`this
51 section<automatic-compliance-checking>` for more details.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010052
Sandrine Bailleux75804e52020-08-12 11:29:46 +020053- Where appropriate, please update the documentation.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010054
Sandrine Bailleux75804e52020-08-12 11:29:46 +020055 - Consider whether the :ref:`Porting Guide`, :ref:`Firmware Design` document
56 or other in-source documentation needs updating.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010057
Sandrine Bailleuxd3147342020-05-12 10:36:05 +020058 - If you are submitting new files that you intend to be the code owner for
59 (for example, a new platform port), then also update the
60 :ref:`code owners` file.
Sandrine Bailleux75804e52020-08-12 11:29:46 +020061
62 - For topics with multiple commits, you should make all documentation changes
63 (and nothing else) in the last commit of the series. Otherwise, include
64 the documentation changes within the single commit.
65
Sandrine Bailleux398b1882020-08-17 08:52:33 +020066.. _copyright-license-guidance:
67
Sandrine Bailleux75804e52020-08-12 11:29:46 +020068- Ensure that each changed file has the correct copyright and license
69 information. Files that entirely consist of contributions to this project
70 should have a copyright notice and BSD-3-Clause SPDX license identifier of
71 the form as shown in :ref:`license`. Files that contain changes to imported
72 Third Party IP files should retain their original copyright and license
73 notices.
74
75 For significant contributions you may add your own copyright notice in the
76 following format:
77
78 ::
79
80 Portions copyright (c) [XXXX-]YYYY, <OWNER>. All rights reserved.
81
82 where XXXX is the year of first contribution (if different to YYYY) and YYYY
83 is the year of most recent contribution. <OWNER> is your name or your company
84 name.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010085
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +020086- Ensure that each patch in the patch series compiles in all supported
87 configurations. Patches which do not compile will not be merged.
88
Louis Mayencourt72ef3d42019-03-22 11:47:22 +000089- Please test your changes. As a minimum, ensure that Linux boots on the
Paul Beesleyd2fcc4e2019-05-29 13:59:40 +010090 Foundation FVP. See :ref:`Arm Fixed Virtual Platforms (FVP)` for more
91 information. For more extensive testing, consider running the `TF-A Tests`_
92 against your patches.
Douglas Raillardd7c21b72017-06-28 15:23:03 +010093
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +020094- Ensure that all CI automated tests pass. Failures should be fixed. They might
95 block a patch, depending on how critical they are.
96
Douglas Raillardd7c21b72017-06-28 15:23:03 +010097Submitting Changes
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +000098==================
Douglas Raillardd7c21b72017-06-28 15:23:03 +010099
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100100.. note::
101 Please follow the `How to Contribute Code`_ section of the OpenCI
102 documentation for general instructions on setting up Gerrit and posting
103 patches there. The rest of this section provides details about patch
104 submission rules specifically for the TF-A project.
105
106- Submit your changes for review using the ``git review`` command.
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000107
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100108 This will automatically rebase them onto the upstream ``integration`` branch,
109 as required by TF-A's patch submission process.
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000110
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100111- From the Gerrit web UI, add reviewers for your patch:
112
113 - At least one code owner for each module modified by the patch. See the
114 list of modules and their :ref:`code owners`.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100115
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200116 - At least one maintainer. See the list of :ref:`maintainers`.
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000117
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200118 - If some module has no code owner, try to identify a suitable (non-code
119 owner) reviewer. Running ``git blame`` on the module's source code can
120 help, as it shows who has been working the most recently on this area of
121 the code.
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000122
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200123 Alternatively, if it is impractical to identify such a reviewer, you might
124 send an email to the `TF-A mailing list`_ to broadcast your review request
125 to the community.
126
127 Note that self-reviewing a patch is prohibited, even if the patch author is
128 the only code owner of a module modified by the patch. Getting a second pair
129 of eyes on the code is essential to keep up with the quality standards the
130 project aspires to.
131
132- The changes will then undergo further review by the designated people. Any
133 review comments will be made directly on your patch. This may require you to
134 do some rework. For controversial changes, the discussion might be moved to
135 the `TF-A mailing list`_ to involve more of the community.
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000136
137 Refer to the `Gerrit Uploading Changes documentation`_ for more details.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100138
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200139- The patch submission rules are the following. For a patch to be approved
140 and merged in the tree, it must get:
141
142 - One ``Code-Owner-Review+1`` for each of the modules modified by the patch.
143 - A ``Maintainer-Review+1``.
144
145 In the case where a code owner could not be found for a given module,
146 ``Code-Owner-Review+1`` is substituted by ``Code-Review+1``.
147
148 In addition to these various code review labels, the patch must also get a
149 ``Verified+1``. This is usually set by the Continuous Integration (CI) bot
150 when all automated tests passed on the patch. Sometimes, some of these
151 automated tests may fail for reasons unrelated to the patch. In this case,
152 the maintainers might (after analysis of the failures) override the CI bot
153 score to certify that the patch has been correctly tested.
154
155 In the event where the CI system lacks proper tests for a patch, the patch
156 author or a reviewer might agree to perform additional manual tests
157 in their review and the reviewer incorporates the review of the additional
158 testing in the ``Code-Review+1`` or ``Code-Owner-Review+1`` as applicable to
159 attest that the patch works as expected. Where possible additional tests should
160 be added to the CI system as a follow up task. For example, for a
161 platform-dependent patch where the said platform is not available in the CI
162 system's board farm.
163
Paul Beesleyf8640672019-04-12 14:19:42 +0100164- When the changes are accepted, the :ref:`maintainers` will integrate them.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100165
Paul Beesleyf8640672019-04-12 14:19:42 +0100166 - Typically, the :ref:`maintainers` will merge the changes into the
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000167 ``integration`` branch.
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200168
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000169 - If the changes are not based on a sufficiently-recent commit, or if they
Paul Beesleyf8640672019-04-12 14:19:42 +0100170 cannot be automatically rebased, then the :ref:`maintainers` may rebase it
Sandrine Bailleuxd3147342020-05-12 10:36:05 +0200171 on the ``integration`` branch or ask you to do so.
Sandrine Bailleuxe0cb1892020-08-14 15:58:50 +0200172
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000173 - After final integration testing, the changes will make their way into the
Sandrine Bailleuxd3147342020-05-12 10:36:05 +0200174 ``master`` branch. If a problem is found during integration, the
175 :ref:`maintainers` will request your help to solve the issue. They may
176 revert your patches and ask you to resubmit a reworked version of them or
177 they may ask you to provide a fix-up patch.
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100178
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000179Add CI Configurations
180=====================
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100181
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100182TF-A uses Jenkins for Continuous Integration and testing activities. Various CI
183jobs are deployed to run tests on every patch before being merged. Each of your
184patches go through a series of checks before they get merged on to the master
185branch. Kindly ensure that every time you add new files under your platform,
186they are covered by the following two sections.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000187
188Coverity Scan
189-------------
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100190
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100191The TF-A project makes use of `Coverity Scan` for static analysis, a service
192offered by Synopsys for open-source projects. This tool is able to find defects
193and vulnerabilities in a code base, such as dereferences of NULL pointers, use
194of uninitialized data, control flow issues and many other things.
195
196The TF-A source code is submitted daily to this service for analysis. Results of
197the latest and previous scans, as well as the complete list of defects it
198detected, are accessible online from
199https://scan.coverity.com/projects/arm-software-arm-trusted-firmware.
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100200
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100201The `tf-a-ci-scripts repository`_ contains scripts to run the Coverity Scan
202tools on the integration branch of the TF-A code base and make them available on
203https://scan.coverity.com. These scripts get executed daily by the
204`tf-a-coverity Jenkins job`_.
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100205
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100206In order to maintain a high level of coverage, including on newly introduced
207code, it is important to maintain the appropriate TF-A CI scripts. Details of
208when to update these scripts and how to do so follow.
209
210We maintain a build script - ``tf-cov-make`` - which contains the build
211configurations of various platforms in order to cover the entire source code
212being analysed by Coverity.
213
214When you submit your patches for review, and if they contain new source files,
215`TF-A CI static checks job`_ might report that these files are not covered. In
216this case, the job's console output will show the following error message::
217
218 ****** Newly added files detection check for Coverity Scan analysis on patch(es) ******
219
220 Result : FAILURE
221
222 New source files have been identified in your patch..
223 some/dir/file.c
224
225 please ensure to include them for the ``Coverity Scan analysis`` by adding
226 the respective build configurations in the ``tf-cov-make`` build script.
227
228In this section you find the details on how to append your new build
229configurations for Coverity scan analysis illustrated with examples:
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100230
231#. We maintain a separate repository named `tf-a-ci-scripts repository`_
232 for placing all the test scripts which will be executed by the CI Jobs.
233
234#. In this repository, ``tf-cov-make`` script is located at
235 ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make``
236
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100237#. Edit the `tf-cov-make`_ script by appending all the possible build
238 configurations with the specific build flags relevant to your platform, so
239 that newly added source files get built and analysed by Coverity.
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100240
241#. For better understanding follow the below specified examples listed in the
242 ``tf-cov-make`` script.
243
Jayanth Dodderi Chidanandef7d6f32021-09-09 14:23:10 +0100244.. code:: shell
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100245
246 Example 1:
247 #Intel
248 make PLAT=stratix10 $(common_flags) all
249 make PLAT=agilex $(common_flags) all
250
251- In the above example there are two different SoCs ``stratix`` and ``agilex``
252 under the Intel platform and the build configurations has been added suitably
253 to include most of their source files.
254
Jayanth Dodderi Chidanandef7d6f32021-09-09 14:23:10 +0100255.. code:: shell
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100256
257 Example 2:
258 #Hikey
259 make PLAT=hikey $(common_flags) ${TBB_OPTIONS} ENABLE_PMF=1 all
260 make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all
261 make PLAT=poplar $(common_flags) all
262
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100263- In this case for ``Hikey`` boards additional build flags have been included
264 along with the ``common_flags`` to cover most of the files relevant to it.
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100265
266- Similar to this you can still find many other different build configurations
267 of various other platforms listed in the ``tf-cov-make`` script. Kindly refer
268 them and append your build configurations respectively.
269
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100270Test Build Configurations
271-------------------------
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000272
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100273We have CI jobs which run a set of test configurations on every TF-A patch
274before they get merged upstream.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000275
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100276At the bare minimum, TF-A code should build without any errors for every
277supported platform - and every feature of this platform. To make sure this is
278the case, we maintain a set of build tests. ``tf-l1-build-plat`` is the test
279group which holds all build tests for all platforms. So be kind enough to
280verify that your newly added files are covered by such a build test.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000281
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100282If this is not the case, please follow the instructions below to add the
283appropriate files. We will illustrate this with an example for the ``Hikey``
284platform.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000285
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100286- In the `tf-a-ci-scripts repository`_ we need to add a build configuration file
287 ``hikey-default`` under ``tf_config/`` folder. ``tf_config/hikey-default``
288 must list all the build parameters relevant to it.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000289
290.. code:: shell
291
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100292 # Hikey Build Parameters
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000293 CROSS_COMPILE=aarch64-none-elf-
294 PLAT=hikey
295
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100296- Further another file, ``hikey-default:nil``, needs to be added under
297 ``group/tf-l1-build-plat/`` folder to allow the platform to be built as part
298 of this test group. ``group/tf-l1-build-plat/hikey-default:nil`` file just
299 needs to exist but does not contain anything meaningful, apart from a
300 mandatory copyright notice:
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000301
302.. code:: shell
303
304 #
305 # Copyright (c) 2019-2022 Arm Limited. All rights reserved.
306 #
307 # SPDX-License-Identifier: BSD-3-Clause
308 #
309
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100310- As illustrated above, you need to add similar files supporting your platform.
311
312For a more elaborate explanation of the TF-A CI scripts internals, including how
313to add more complex tests beyond a simple build test, please refer to the `TF-A
314CI scripts overview`_ section of the OpenCI documentation.
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000315
Julius Wernercece91a2019-04-18 16:47:46 -0700316Binary Components
Jayanth Dodderi Chidanandf69f1982022-02-08 14:18:24 +0000317=================
Julius Wernercece91a2019-04-18 16:47:46 -0700318
319- Platforms may depend on binary components submitted to the `Trusted Firmware
320 binary repository`_ if they require code that the contributor is unable or
321 unwilling to open-source. This should be used as a rare exception.
322- All binary components must follow the contribution guidelines (in particular
323 licensing rules) outlined in the `readme.rst <tf-binaries-readme_>`_ file of
324 the binary repository.
325- Binary components must be restricted to only the specific functionality that
326 cannot be open-sourced and must be linked into a larger open-source platform
327 port. The majority of the platform port must still be implemented in open
328 source. Platform ports that are merely a thin wrapper around a binary
329 component that contains all the actual code will not be accepted.
330- Only platform port code (i.e. in the ``plat/<vendor>`` directory) may rely on
331 binary components. Generic code must always be fully open-source.
332
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100333--------------
334
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100335*Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.*
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100336
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000337.. _developer.trustedfirmware.org: https://developer.trustedfirmware.org
Sandrine Bailleuxd3147342020-05-12 10:36:05 +0200338.. _review.trustedfirmware.org: https://review.trustedfirmware.org
Douglas Raillardd7c21b72017-06-28 15:23:03 +0100339.. _Git guidelines: http://git-scm.com/book/ch5-2.html
Louis Mayencourt72ef3d42019-03-22 11:47:22 +0000340.. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html
Sandrine Bailleuxd3147342020-05-12 10:36:05 +0200341.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io
Julius Wernercece91a2019-04-18 16:47:46 -0700342.. _Trusted Firmware binary repository: https://review.trustedfirmware.org/admin/repos/tf-binaries
343.. _tf-binaries-readme: https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst
Sandrine Bailleux1a4efb12022-04-21 10:17:22 +0200344.. _TF-A mailing list: https://lists.trustedfirmware.org/mailman3/lists/tf-a.lists.trustedfirmware.org/
Jayanth Dodderi Chidanand32e5fa02021-08-31 12:27:48 +0100345.. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/
346.. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make
Sandrine Bailleux9c2db482024-01-26 11:48:32 +0100347.. _How to Contribute Code: https://tf-ci-users-guide.readthedocs.io/en/latest/#how-to-contribute-code
348.. _TF-A CI scripts overview: https://tf-ci-users-guide.readthedocs.io/en/latest/#tf-a-ci-scripts-overview
349.. _tf-a-coverity Jenkins job: https://ci.trustedfirmware.org/job/tf-a-coverity/
350.. _TF-A CI static checks job: https://ci.trustedfirmware.org/job/tf-a-static-checks/