18aa05055SPaul BeesleyContributor's Guide 2*a092825dSJayanth Dodderi Chidanand******************* 340d553cfSPaul Beesley 440d553cfSPaul BeesleyGetting Started 5*a092825dSJayanth Dodderi Chidanand=============== 640d553cfSPaul Beesley 73d28b0a4SSandrine Bailleux- Make sure you have a Github account and you are logged on both 83d28b0a4SSandrine Bailleux `developer.trustedfirmware.org`_ and `review.trustedfirmware.org`_. 940d553cfSPaul Beesley 10a88b3c29SSandrine Bailleux- If you plan to contribute a major piece of work, it is usually a good idea to 11a88b3c29SSandrine Bailleux start a discussion around it on the mailing list. This gives everyone 12a88b3c29SSandrine Bailleux visibility of what is coming up, you might learn that somebody else is 13a88b3c29SSandrine Bailleux already working on something similar or the community might be able to 14a88b3c29SSandrine Bailleux provide some early input to help shaping the design of the feature. 15a88b3c29SSandrine Bailleux 16a88b3c29SSandrine Bailleux If you intend to include Third Party IP in your contribution, please mention 17a88b3c29SSandrine Bailleux it explicitly in the email thread and ensure that the changes that include 18a88b3c29SSandrine Bailleux Third Party IP are made in a separate patch (or patch series). 1940d553cfSPaul Beesley 2043f35ef5SPaul Beesley- Clone `Trusted Firmware-A`_ on your own machine as described in 2143f35ef5SPaul Beesley :ref:`prerequisites_get_source`. 22e256cc63SSandrine Bailleux 23f6ad51c8SJohn Tsichritzis- Create a local topic branch based on the `Trusted Firmware-A`_ ``master`` 2440d553cfSPaul Beesley branch. 2540d553cfSPaul Beesley 2640d553cfSPaul BeesleyMaking Changes 27*a092825dSJayanth Dodderi Chidanand============== 2840d553cfSPaul Beesley 297d3b5193SChris Kay- Ensure commits adhere to the the project's :ref:`Commit Style`. 307d3b5193SChris Kay 3140d553cfSPaul Beesley- Make commits of logical units. See these general `Git guidelines`_ for 3240d553cfSPaul Beesley contributing to a project. 33e256cc63SSandrine Bailleux 3440d553cfSPaul Beesley- Keep the commits on topic. If you need to fix another bug or make another 35a88b3c29SSandrine Bailleux enhancement, please address it on a separate topic branch. 36e256cc63SSandrine Bailleux 377969747eSSandrine Bailleux- Split the patch in manageable units. Small patches are usually easier to 387969747eSSandrine Bailleux review so this will speed up the review process. 397969747eSSandrine Bailleux 4040d553cfSPaul Beesley- Avoid long commit series. If you do have a long series, consider whether 4140d553cfSPaul Beesley some commits should be squashed together or addressed in a separate topic. 42e256cc63SSandrine Bailleux 437969747eSSandrine Bailleux- Follow the :ref:`Coding Style` and :ref:`Coding Guidelines`. 447969747eSSandrine Bailleux 457969747eSSandrine Bailleux - Use the checkpatch.pl script provided with the Linux source tree. A 467969747eSSandrine Bailleux Makefile target is provided for convenience, see :ref:`this 477969747eSSandrine Bailleux section<automatic-compliance-checking>` for more details. 48e256cc63SSandrine Bailleux 4940d553cfSPaul Beesley- Where appropriate, please update the documentation. 5040d553cfSPaul Beesley 51e256cc63SSandrine Bailleux - Consider whether the :ref:`Porting Guide`, :ref:`Firmware Design` document 52e256cc63SSandrine Bailleux or other in-source documentation needs updating. 53e256cc63SSandrine Bailleux 54e256cc63SSandrine Bailleux - If you are submitting new files that you intend to be the code owner for 55e256cc63SSandrine Bailleux (for example, a new platform port), then also update the 56e256cc63SSandrine Bailleux :ref:`code owners` file. 57e256cc63SSandrine Bailleux 58e256cc63SSandrine Bailleux - For topics with multiple commits, you should make all documentation changes 59e256cc63SSandrine Bailleux (and nothing else) in the last commit of the series. Otherwise, include 60e256cc63SSandrine Bailleux the documentation changes within the single commit. 61e256cc63SSandrine Bailleux 621f19411aSSandrine Bailleux.. _copyright-license-guidance: 631f19411aSSandrine Bailleux 6440d553cfSPaul Beesley- Ensure that each changed file has the correct copyright and license 65e256cc63SSandrine Bailleux information. Files that entirely consist of contributions to this project 66e256cc63SSandrine Bailleux should have a copyright notice and BSD-3-Clause SPDX license identifier of 67e256cc63SSandrine Bailleux the form as shown in :ref:`license`. Files that contain changes to imported 68e256cc63SSandrine Bailleux Third Party IP files should retain their original copyright and license 69e256cc63SSandrine Bailleux notices. 70e256cc63SSandrine Bailleux 71e256cc63SSandrine Bailleux For significant contributions you may add your own copyright notice in the 72e256cc63SSandrine Bailleux following format: 7340d553cfSPaul Beesley 7440d553cfSPaul Beesley :: 7540d553cfSPaul Beesley 7640d553cfSPaul Beesley Portions copyright (c) [XXXX-]YYYY, <OWNER>. All rights reserved. 7740d553cfSPaul Beesley 78e256cc63SSandrine Bailleux where XXXX is the year of first contribution (if different to YYYY) and YYYY 79e256cc63SSandrine Bailleux is the year of most recent contribution. <OWNER> is your name or your company 80e256cc63SSandrine Bailleux name. 8140d553cfSPaul Beesley 827969747eSSandrine Bailleux- Ensure that each patch in the patch series compiles in all supported 837969747eSSandrine Bailleux configurations. Patches which do not compile will not be merged. 847969747eSSandrine Bailleux 8540d553cfSPaul Beesley- Please test your changes. As a minimum, ensure that Linux boots on the 8643f35ef5SPaul Beesley Foundation FVP. See :ref:`Arm Fixed Virtual Platforms (FVP)` for more 8743f35ef5SPaul Beesley information. For more extensive testing, consider running the `TF-A Tests`_ 8843f35ef5SPaul Beesley against your patches. 8940d553cfSPaul Beesley 907969747eSSandrine Bailleux- Ensure that all CI automated tests pass. Failures should be fixed. They might 917969747eSSandrine Bailleux block a patch, depending on how critical they are. 927969747eSSandrine Bailleux 9340d553cfSPaul BeesleySubmitting Changes 94*a092825dSJayanth Dodderi Chidanand================== 9540d553cfSPaul Beesley 9640d553cfSPaul Beesley- Submit your changes for review at https://review.trustedfirmware.org 9740d553cfSPaul Beesley targeting the ``integration`` branch. 9840d553cfSPaul Beesley 997969747eSSandrine Bailleux- Add reviewers for your patch: 1007969747eSSandrine Bailleux 1017969747eSSandrine Bailleux - At least one code owner for each module modified by the patch. See the list 1027969747eSSandrine Bailleux of modules and their :ref:`code owners`. 1037969747eSSandrine Bailleux 1047969747eSSandrine Bailleux - At least one maintainer. See the list of :ref:`maintainers`. 1057969747eSSandrine Bailleux 1067969747eSSandrine Bailleux - If some module has no code owner, try to identify a suitable (non-code 1077969747eSSandrine Bailleux owner) reviewer. Running ``git blame`` on the module's source code can 1087969747eSSandrine Bailleux help, as it shows who has been working the most recently on this area of 1097969747eSSandrine Bailleux the code. 1107969747eSSandrine Bailleux 1117969747eSSandrine Bailleux Alternatively, if it is impractical to identify such a reviewer, you might 1127969747eSSandrine Bailleux send an email to the `TF-A mailing list`_ to broadcast your review request 1137969747eSSandrine Bailleux to the community. 1147969747eSSandrine Bailleux 1157969747eSSandrine Bailleux Note that self-reviewing a patch is prohibited, even if the patch author is 1167969747eSSandrine Bailleux the only code owner of a module modified by the patch. Getting a second pair 1177969747eSSandrine Bailleux of eyes on the code is essential to keep up with the quality standards the 1187969747eSSandrine Bailleux project aspires to. 1197969747eSSandrine Bailleux 1207969747eSSandrine Bailleux- The changes will then undergo further review by the designated people. Any 1217969747eSSandrine Bailleux review comments will be made directly on your patch. This may require you to 1227969747eSSandrine Bailleux do some rework. For controversial changes, the discussion might be moved to 1237969747eSSandrine Bailleux the `TF-A mailing list`_ to involve more of the community. 12440d553cfSPaul Beesley 12540d553cfSPaul Beesley Refer to the `Gerrit Uploading Changes documentation`_ for more details. 12640d553cfSPaul Beesley 1277969747eSSandrine Bailleux- The patch submission rules are the following. For a patch to be approved 1287969747eSSandrine Bailleux and merged in the tree, it must get: 1297969747eSSandrine Bailleux 1307969747eSSandrine Bailleux - One ``Code-Owner-Review+1`` for each of the modules modified by the patch. 1317969747eSSandrine Bailleux - A ``Maintainer-Review+1``. 1327969747eSSandrine Bailleux 1337969747eSSandrine Bailleux In the case where a code owner could not be found for a given module, 1347969747eSSandrine Bailleux ``Code-Owner-Review+1`` is substituted by ``Code-Review+1``. 1357969747eSSandrine Bailleux 1367969747eSSandrine Bailleux In addition to these various code review labels, the patch must also get a 1377969747eSSandrine Bailleux ``Verified+1``. This is usually set by the Continuous Integration (CI) bot 1387969747eSSandrine Bailleux when all automated tests passed on the patch. Sometimes, some of these 1397969747eSSandrine Bailleux automated tests may fail for reasons unrelated to the patch. In this case, 1407969747eSSandrine Bailleux the maintainers might (after analysis of the failures) override the CI bot 1417969747eSSandrine Bailleux score to certify that the patch has been correctly tested. 1427969747eSSandrine Bailleux 1437969747eSSandrine Bailleux In the event where the CI system lacks proper tests for a patch, the patch 1447969747eSSandrine Bailleux author or a reviewer might agree to perform additional manual tests 1457969747eSSandrine Bailleux in their review and the reviewer incorporates the review of the additional 1467969747eSSandrine Bailleux testing in the ``Code-Review+1`` or ``Code-Owner-Review+1`` as applicable to 1477969747eSSandrine Bailleux attest that the patch works as expected. Where possible additional tests should 1487969747eSSandrine Bailleux be added to the CI system as a follow up task. For example, for a 1497969747eSSandrine Bailleux platform-dependent patch where the said platform is not available in the CI 1507969747eSSandrine Bailleux system's board farm. 1517969747eSSandrine Bailleux 15234760951SPaul Beesley- When the changes are accepted, the :ref:`maintainers` will integrate them. 15340d553cfSPaul Beesley 15434760951SPaul Beesley - Typically, the :ref:`maintainers` will merge the changes into the 15540d553cfSPaul Beesley ``integration`` branch. 1567969747eSSandrine Bailleux 15740d553cfSPaul Beesley - If the changes are not based on a sufficiently-recent commit, or if they 15834760951SPaul Beesley cannot be automatically rebased, then the :ref:`maintainers` may rebase it 1593d28b0a4SSandrine Bailleux on the ``integration`` branch or ask you to do so. 1607969747eSSandrine Bailleux 16140d553cfSPaul Beesley - After final integration testing, the changes will make their way into the 1623d28b0a4SSandrine Bailleux ``master`` branch. If a problem is found during integration, the 1633d28b0a4SSandrine Bailleux :ref:`maintainers` will request your help to solve the issue. They may 1643d28b0a4SSandrine Bailleux revert your patches and ask you to resubmit a reworked version of them or 1653d28b0a4SSandrine Bailleux they may ask you to provide a fix-up patch. 16640d553cfSPaul Beesley 167*a092825dSJayanth Dodderi ChidanandAdd CI Configurations 168*a092825dSJayanth Dodderi Chidanand===================== 1696c3d92e3SJayanth Dodderi Chidanand 1706c3d92e3SJayanth Dodderi Chidanand- TF-A uses Jenkins tool for Continuous Integration and testing activities. 1716c3d92e3SJayanth Dodderi Chidanand Various CI Jobs are deployed which run tests on every patch before being 1726c3d92e3SJayanth Dodderi Chidanand merged. So each of your patches go through a series of checks before they 173*a092825dSJayanth Dodderi Chidanand get merged on to the master branch. Kindly ensure, that everytime you add 174*a092825dSJayanth Dodderi Chidanand new files under your platform, they are covered under the following two sections: 175*a092825dSJayanth Dodderi Chidanand 176*a092825dSJayanth Dodderi ChidanandCoverity Scan 177*a092825dSJayanth Dodderi Chidanand------------- 1786c3d92e3SJayanth Dodderi Chidanand 1796c3d92e3SJayanth Dodderi Chidanand- ``Coverity Scan analysis`` is one of the tests we perform on our source code 1806c3d92e3SJayanth Dodderi Chidanand at regular intervals. We maintain a build script ``tf-cov-make`` which contains the 1816c3d92e3SJayanth Dodderi Chidanand build configurations of various platforms in order to cover the entire source 1826c3d92e3SJayanth Dodderi Chidanand code being analysed by Coverity. 1836c3d92e3SJayanth Dodderi Chidanand 1846c3d92e3SJayanth Dodderi Chidanand- When you submit your patches for review containing new source files, please 1856c3d92e3SJayanth Dodderi Chidanand ensure to include them for the ``Coverity Scan analysis`` by adding the 1866c3d92e3SJayanth Dodderi Chidanand respective build configurations in the ``tf-cov-make`` build script. 1876c3d92e3SJayanth Dodderi Chidanand 1886c3d92e3SJayanth Dodderi Chidanand- In this section you find the details on how to append your new build 189*a092825dSJayanth Dodderi Chidanand configurations for Coverity scan analysis illustrated with examples: 1906c3d92e3SJayanth Dodderi Chidanand 1916c3d92e3SJayanth Dodderi Chidanand#. We maintain a separate repository named `tf-a-ci-scripts repository`_ 1926c3d92e3SJayanth Dodderi Chidanand for placing all the test scripts which will be executed by the CI Jobs. 1936c3d92e3SJayanth Dodderi Chidanand 1946c3d92e3SJayanth Dodderi Chidanand#. In this repository, ``tf-cov-make`` script is located at 1956c3d92e3SJayanth Dodderi Chidanand ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make`` 1966c3d92e3SJayanth Dodderi Chidanand 1976c3d92e3SJayanth Dodderi Chidanand#. Edit `tf-cov-make`_ script by appending all the possible build configurations with 1986c3d92e3SJayanth Dodderi Chidanand the specific ``build-flags`` relevant to your platform, so that newly added 1996c3d92e3SJayanth Dodderi Chidanand source files get built and analysed by Coverity. 2006c3d92e3SJayanth Dodderi Chidanand 2016c3d92e3SJayanth Dodderi Chidanand#. For better understanding follow the below specified examples listed in the 2026c3d92e3SJayanth Dodderi Chidanand ``tf-cov-make`` script. 2036c3d92e3SJayanth Dodderi Chidanand 204d0bbe815SJayanth Dodderi Chidanand.. code:: shell 2056c3d92e3SJayanth Dodderi Chidanand 2066c3d92e3SJayanth Dodderi Chidanand Example 1: 2076c3d92e3SJayanth Dodderi Chidanand #Intel 2086c3d92e3SJayanth Dodderi Chidanand make PLAT=stratix10 $(common_flags) all 2096c3d92e3SJayanth Dodderi Chidanand make PLAT=agilex $(common_flags) all 2106c3d92e3SJayanth Dodderi Chidanand 2116c3d92e3SJayanth Dodderi Chidanand- In the above example there are two different SoCs ``stratix`` and ``agilex`` 2126c3d92e3SJayanth Dodderi Chidanand under the Intel platform and the build configurations has been added suitably 2136c3d92e3SJayanth Dodderi Chidanand to include most of their source files. 2146c3d92e3SJayanth Dodderi Chidanand 215d0bbe815SJayanth Dodderi Chidanand.. code:: shell 2166c3d92e3SJayanth Dodderi Chidanand 2176c3d92e3SJayanth Dodderi Chidanand Example 2: 2186c3d92e3SJayanth Dodderi Chidanand #Hikey 2196c3d92e3SJayanth Dodderi Chidanand make PLAT=hikey $(common_flags) ${TBB_OPTIONS} ENABLE_PMF=1 all 2206c3d92e3SJayanth Dodderi Chidanand make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all 2216c3d92e3SJayanth Dodderi Chidanand make PLAT=poplar $(common_flags) all 2226c3d92e3SJayanth Dodderi Chidanand 2236c3d92e3SJayanth Dodderi Chidanand- In this case for ``Hikey`` boards additional ``build-flags`` has been included 2246c3d92e3SJayanth Dodderi Chidanand along with the ``commom_flags`` to cover most of the files relevant to it. 2256c3d92e3SJayanth Dodderi Chidanand 2266c3d92e3SJayanth Dodderi Chidanand- Similar to this you can still find many other different build configurations 2276c3d92e3SJayanth Dodderi Chidanand of various other platforms listed in the ``tf-cov-make`` script. Kindly refer 2286c3d92e3SJayanth Dodderi Chidanand them and append your build configurations respectively. 2296c3d92e3SJayanth Dodderi Chidanand 230*a092825dSJayanth Dodderi ChidanandTest Build Configuration (``tf-l1-build-plat``) 231*a092825dSJayanth Dodderi Chidanand----------------------------------------------- 232*a092825dSJayanth Dodderi Chidanand 233*a092825dSJayanth Dodderi Chidanand- Coverity Scan analysis, runs on a daily basis and will not be triggered for 234*a092825dSJayanth Dodderi Chidanand every individual trusted-firmware patch. 235*a092825dSJayanth Dodderi Chidanand 236*a092825dSJayanth Dodderi Chidanand- Considering this, we have other distinguished CI jobs which run a set of test 237*a092825dSJayanth Dodderi Chidanand configurations on every patch, before they are being passed to ``Coverity scan analysis``. 238*a092825dSJayanth Dodderi Chidanand 239*a092825dSJayanth Dodderi Chidanand- ``tf-l1-build-plat`` is the test group, which holds the test configurations 240*a092825dSJayanth Dodderi Chidanand to build all the platforms. So be kind enough to verify that your newly added 241*a092825dSJayanth Dodderi Chidanand files are built as part of one of the existing platform configurations present 242*a092825dSJayanth Dodderi Chidanand in ``tf-l1-build-plat`` test group. 243*a092825dSJayanth Dodderi Chidanand 244*a092825dSJayanth Dodderi Chidanand- In this section you find the details on how to add the appropriate files, 245*a092825dSJayanth Dodderi Chidanand needed to build your newly introduced platform as part of ``tf-l1-build-plat`` 246*a092825dSJayanth Dodderi Chidanand test group, illustrated with an example: 247*a092825dSJayanth Dodderi Chidanand 248*a092825dSJayanth Dodderi Chidanand- Lets consider ``Hikey`` platform: 249*a092825dSJayanth Dodderi Chidanand In the `tf-a-ci-scripts repository`_ we need to add a build configuration file ``hikey-default`` 250*a092825dSJayanth Dodderi Chidanand under tf_config folder, ``tf_config/hikey-default`` listing all the build parameters 251*a092825dSJayanth Dodderi Chidanand relevant to it. 252*a092825dSJayanth Dodderi Chidanand 253*a092825dSJayanth Dodderi Chidanand.. code:: shell 254*a092825dSJayanth Dodderi Chidanand 255*a092825dSJayanth Dodderi Chidanand #Hikey Build Parameters 256*a092825dSJayanth Dodderi Chidanand CROSS_COMPILE=aarch64-none-elf- 257*a092825dSJayanth Dodderi Chidanand PLAT=hikey 258*a092825dSJayanth Dodderi Chidanand 259*a092825dSJayanth Dodderi Chidanand- Further a test-configuration file ``hikey-default:nil`` need to be added under the 260*a092825dSJayanth Dodderi Chidanand test group, ``tf-l1-build-plat`` located at ``tf-a-ci-scripts/group/tf-l1-build-plat``, 261*a092825dSJayanth Dodderi Chidanand to allow the platform to be built as part of this group. 262*a092825dSJayanth Dodderi Chidanand 263*a092825dSJayanth Dodderi Chidanand.. code:: shell 264*a092825dSJayanth Dodderi Chidanand 265*a092825dSJayanth Dodderi Chidanand # 266*a092825dSJayanth Dodderi Chidanand # Copyright (c) 2019-2022 Arm Limited. All rights reserved. 267*a092825dSJayanth Dodderi Chidanand # 268*a092825dSJayanth Dodderi Chidanand # SPDX-License-Identifier: BSD-3-Clause 269*a092825dSJayanth Dodderi Chidanand # 270*a092825dSJayanth Dodderi Chidanand 271*a092825dSJayanth Dodderi Chidanand- As illustrated above, you need to add the similar files supporting your platform. 272*a092825dSJayanth Dodderi Chidanand 27340d553cfSPaul BeesleyBinary Components 274*a092825dSJayanth Dodderi Chidanand================= 27540d553cfSPaul Beesley 27640d553cfSPaul Beesley- Platforms may depend on binary components submitted to the `Trusted Firmware 27740d553cfSPaul Beesley binary repository`_ if they require code that the contributor is unable or 27840d553cfSPaul Beesley unwilling to open-source. This should be used as a rare exception. 27940d553cfSPaul Beesley- All binary components must follow the contribution guidelines (in particular 28040d553cfSPaul Beesley licensing rules) outlined in the `readme.rst <tf-binaries-readme_>`_ file of 28140d553cfSPaul Beesley the binary repository. 28240d553cfSPaul Beesley- Binary components must be restricted to only the specific functionality that 28340d553cfSPaul Beesley cannot be open-sourced and must be linked into a larger open-source platform 28440d553cfSPaul Beesley port. The majority of the platform port must still be implemented in open 28540d553cfSPaul Beesley source. Platform ports that are merely a thin wrapper around a binary 28640d553cfSPaul Beesley component that contains all the actual code will not be accepted. 28740d553cfSPaul Beesley- Only platform port code (i.e. in the ``plat/<vendor>`` directory) may rely on 28840d553cfSPaul Beesley binary components. Generic code must always be fully open-source. 28940d553cfSPaul Beesley 29040d553cfSPaul Beesley-------------- 29140d553cfSPaul Beesley 292*a092825dSJayanth Dodderi Chidanand*Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved.* 29340d553cfSPaul Beesley 29440d553cfSPaul Beesley.. _developer.trustedfirmware.org: https://developer.trustedfirmware.org 2953d28b0a4SSandrine Bailleux.. _review.trustedfirmware.org: https://review.trustedfirmware.org 296f6ad51c8SJohn Tsichritzis.. _Trusted Firmware-A: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git 29740d553cfSPaul Beesley.. _Git guidelines: http://git-scm.com/book/ch5-2.html 29840d553cfSPaul Beesley.. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html 2993d28b0a4SSandrine Bailleux.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io 30040d553cfSPaul Beesley.. _Trusted Firmware binary repository: https://review.trustedfirmware.org/admin/repos/tf-binaries 30140d553cfSPaul Beesley.. _tf-binaries-readme: https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst 3023d28b0a4SSandrine Bailleux.. _TF-A mailing list: https://lists.trustedfirmware.org/mailman/listinfo/tf-a 3036c3d92e3SJayanth Dodderi Chidanand.. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/ 3046c3d92e3SJayanth Dodderi Chidanand.. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make 305