18aa05055SPaul BeesleyContributor's Guide 28aa05055SPaul Beesley=================== 340d553cfSPaul Beesley 440d553cfSPaul BeesleyGetting Started 540d553cfSPaul Beesley--------------- 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 2740d553cfSPaul Beesley-------------- 2840d553cfSPaul Beesley 2940d553cfSPaul Beesley- Make commits of logical units. See these general `Git guidelines`_ for 3040d553cfSPaul Beesley contributing to a project. 31e256cc63SSandrine Bailleux 32d97bade1SChris Kay- Ensure your commit messages comply with the `Conventional Commits`_ 33d97bade1SChris Kay specification: 34d97bade1SChris Kay 35d97bade1SChris Kay .. code:: 36d97bade1SChris Kay 37d97bade1SChris Kay <type>[optional scope]: <description> 38d97bade1SChris Kay 39d97bade1SChris Kay [optional body] 40d97bade1SChris Kay 41d97bade1SChris Kay [optional footer(s)] 42d97bade1SChris Kay 43d97bade1SChris Kay You can use the tooling installed by the optional steps in the 44d97bade1SChris Kay :ref:`prerequisites <Prerequisites>` guide to validate this locally. 45d97bade1SChris Kay 4640d553cfSPaul Beesley- Keep the commits on topic. If you need to fix another bug or make another 47a88b3c29SSandrine Bailleux enhancement, please address it on a separate topic branch. 48e256cc63SSandrine Bailleux 497969747eSSandrine Bailleux- Split the patch in manageable units. Small patches are usually easier to 507969747eSSandrine Bailleux review so this will speed up the review process. 517969747eSSandrine Bailleux 5240d553cfSPaul Beesley- Avoid long commit series. If you do have a long series, consider whether 5340d553cfSPaul Beesley some commits should be squashed together or addressed in a separate topic. 54e256cc63SSandrine Bailleux 557969747eSSandrine Bailleux- Ensure that each commit in the series has at least one ``Signed-off-by:`` 567969747eSSandrine Bailleux line, using your real name and email address. The names in the 577969747eSSandrine Bailleux ``Signed-off-by:`` and ``Commit:`` lines must match. By adding this line the 587969747eSSandrine Bailleux contributor certifies the contribution is made under the terms of the 597969747eSSandrine Bailleux :download:`Developer Certificate of Origin <../../dco.txt>`. 607969747eSSandrine Bailleux 617969747eSSandrine Bailleux There might be multiple ``Signed-off-by:`` lines, depending on the history 627969747eSSandrine Bailleux of the patch. 637969747eSSandrine Bailleux 647969747eSSandrine Bailleux More details may be found in the `Gerrit Signed-off-by Lines guidelines`_. 657969747eSSandrine Bailleux 667969747eSSandrine Bailleux- Ensure that each commit also has a unique ``Change-Id:`` line. If you have 677969747eSSandrine Bailleux cloned the repository with the "`Clone with commit-msg hook`" clone method 687969747eSSandrine Bailleux (following the :ref:`Prerequisites` document), this should already be the 697969747eSSandrine Bailleux case. 707969747eSSandrine Bailleux 717969747eSSandrine Bailleux More details may be found in the `Gerrit Change-Ids documentation`_. 727969747eSSandrine Bailleux 737969747eSSandrine Bailleux- Write informative and comprehensive commit messages. A good commit message 747969747eSSandrine Bailleux provides all the background information needed for reviewers to understand 757969747eSSandrine Bailleux the intent and rationale of the patch. This information is also useful for 767969747eSSandrine Bailleux future reference. 777969747eSSandrine Bailleux 787969747eSSandrine Bailleux For example: 797969747eSSandrine Bailleux 807969747eSSandrine Bailleux - What does the patch do? 817969747eSSandrine Bailleux - What motivated it? 827969747eSSandrine Bailleux - What impact does it have? 837969747eSSandrine Bailleux - How was it tested? 847969747eSSandrine Bailleux - Have alternatives been considered? Why did you choose this approach over 857969747eSSandrine Bailleux another one? 867969747eSSandrine Bailleux - If it fixes an `issue`_, include a reference. 877969747eSSandrine Bailleux 887969747eSSandrine Bailleux- Follow the :ref:`Coding Style` and :ref:`Coding Guidelines`. 897969747eSSandrine Bailleux 907969747eSSandrine Bailleux - Use the checkpatch.pl script provided with the Linux source tree. A 917969747eSSandrine Bailleux Makefile target is provided for convenience, see :ref:`this 927969747eSSandrine Bailleux section<automatic-compliance-checking>` for more details. 93e256cc63SSandrine Bailleux 9440d553cfSPaul Beesley- Where appropriate, please update the documentation. 9540d553cfSPaul Beesley 96e256cc63SSandrine Bailleux - Consider whether the :ref:`Porting Guide`, :ref:`Firmware Design` document 97e256cc63SSandrine Bailleux or other in-source documentation needs updating. 98e256cc63SSandrine Bailleux 99e256cc63SSandrine Bailleux - If you are submitting new files that you intend to be the code owner for 100e256cc63SSandrine Bailleux (for example, a new platform port), then also update the 101e256cc63SSandrine Bailleux :ref:`code owners` file. 102e256cc63SSandrine Bailleux 103e256cc63SSandrine Bailleux - For topics with multiple commits, you should make all documentation changes 104e256cc63SSandrine Bailleux (and nothing else) in the last commit of the series. Otherwise, include 105e256cc63SSandrine Bailleux the documentation changes within the single commit. 106e256cc63SSandrine Bailleux 1071f19411aSSandrine Bailleux.. _copyright-license-guidance: 1081f19411aSSandrine Bailleux 10940d553cfSPaul Beesley- Ensure that each changed file has the correct copyright and license 110e256cc63SSandrine Bailleux information. Files that entirely consist of contributions to this project 111e256cc63SSandrine Bailleux should have a copyright notice and BSD-3-Clause SPDX license identifier of 112e256cc63SSandrine Bailleux the form as shown in :ref:`license`. Files that contain changes to imported 113e256cc63SSandrine Bailleux Third Party IP files should retain their original copyright and license 114e256cc63SSandrine Bailleux notices. 115e256cc63SSandrine Bailleux 116e256cc63SSandrine Bailleux For significant contributions you may add your own copyright notice in the 117e256cc63SSandrine Bailleux following format: 11840d553cfSPaul Beesley 11940d553cfSPaul Beesley :: 12040d553cfSPaul Beesley 12140d553cfSPaul Beesley Portions copyright (c) [XXXX-]YYYY, <OWNER>. All rights reserved. 12240d553cfSPaul Beesley 123e256cc63SSandrine Bailleux where XXXX is the year of first contribution (if different to YYYY) and YYYY 124e256cc63SSandrine Bailleux is the year of most recent contribution. <OWNER> is your name or your company 125e256cc63SSandrine Bailleux name. 12640d553cfSPaul Beesley 1277969747eSSandrine Bailleux- Ensure that each patch in the patch series compiles in all supported 1287969747eSSandrine Bailleux configurations. Patches which do not compile will not be merged. 1297969747eSSandrine Bailleux 13040d553cfSPaul Beesley- Please test your changes. As a minimum, ensure that Linux boots on the 13143f35ef5SPaul Beesley Foundation FVP. See :ref:`Arm Fixed Virtual Platforms (FVP)` for more 13243f35ef5SPaul Beesley information. For more extensive testing, consider running the `TF-A Tests`_ 13343f35ef5SPaul Beesley against your patches. 13440d553cfSPaul Beesley 1357969747eSSandrine Bailleux- Ensure that all CI automated tests pass. Failures should be fixed. They might 1367969747eSSandrine Bailleux block a patch, depending on how critical they are. 1377969747eSSandrine Bailleux 13840d553cfSPaul BeesleySubmitting Changes 13940d553cfSPaul Beesley------------------ 14040d553cfSPaul Beesley 14140d553cfSPaul Beesley- Submit your changes for review at https://review.trustedfirmware.org 14240d553cfSPaul Beesley targeting the ``integration`` branch. 14340d553cfSPaul Beesley 1447969747eSSandrine Bailleux- Add reviewers for your patch: 1457969747eSSandrine Bailleux 1467969747eSSandrine Bailleux - At least one code owner for each module modified by the patch. See the list 1477969747eSSandrine Bailleux of modules and their :ref:`code owners`. 1487969747eSSandrine Bailleux 1497969747eSSandrine Bailleux - At least one maintainer. See the list of :ref:`maintainers`. 1507969747eSSandrine Bailleux 1517969747eSSandrine Bailleux - If some module has no code owner, try to identify a suitable (non-code 1527969747eSSandrine Bailleux owner) reviewer. Running ``git blame`` on the module's source code can 1537969747eSSandrine Bailleux help, as it shows who has been working the most recently on this area of 1547969747eSSandrine Bailleux the code. 1557969747eSSandrine Bailleux 1567969747eSSandrine Bailleux Alternatively, if it is impractical to identify such a reviewer, you might 1577969747eSSandrine Bailleux send an email to the `TF-A mailing list`_ to broadcast your review request 1587969747eSSandrine Bailleux to the community. 1597969747eSSandrine Bailleux 1607969747eSSandrine Bailleux Note that self-reviewing a patch is prohibited, even if the patch author is 1617969747eSSandrine Bailleux the only code owner of a module modified by the patch. Getting a second pair 1627969747eSSandrine Bailleux of eyes on the code is essential to keep up with the quality standards the 1637969747eSSandrine Bailleux project aspires to. 1647969747eSSandrine Bailleux 1657969747eSSandrine Bailleux- The changes will then undergo further review by the designated people. Any 1667969747eSSandrine Bailleux review comments will be made directly on your patch. This may require you to 1677969747eSSandrine Bailleux do some rework. For controversial changes, the discussion might be moved to 1687969747eSSandrine Bailleux the `TF-A mailing list`_ to involve more of the community. 16940d553cfSPaul Beesley 17040d553cfSPaul Beesley Refer to the `Gerrit Uploading Changes documentation`_ for more details. 17140d553cfSPaul Beesley 1727969747eSSandrine Bailleux- The patch submission rules are the following. For a patch to be approved 1737969747eSSandrine Bailleux and merged in the tree, it must get: 1747969747eSSandrine Bailleux 1757969747eSSandrine Bailleux - One ``Code-Owner-Review+1`` for each of the modules modified by the patch. 1767969747eSSandrine Bailleux - A ``Maintainer-Review+1``. 1777969747eSSandrine Bailleux 1787969747eSSandrine Bailleux In the case where a code owner could not be found for a given module, 1797969747eSSandrine Bailleux ``Code-Owner-Review+1`` is substituted by ``Code-Review+1``. 1807969747eSSandrine Bailleux 1817969747eSSandrine Bailleux In addition to these various code review labels, the patch must also get a 1827969747eSSandrine Bailleux ``Verified+1``. This is usually set by the Continuous Integration (CI) bot 1837969747eSSandrine Bailleux when all automated tests passed on the patch. Sometimes, some of these 1847969747eSSandrine Bailleux automated tests may fail for reasons unrelated to the patch. In this case, 1857969747eSSandrine Bailleux the maintainers might (after analysis of the failures) override the CI bot 1867969747eSSandrine Bailleux score to certify that the patch has been correctly tested. 1877969747eSSandrine Bailleux 1887969747eSSandrine Bailleux In the event where the CI system lacks proper tests for a patch, the patch 1897969747eSSandrine Bailleux author or a reviewer might agree to perform additional manual tests 1907969747eSSandrine Bailleux in their review and the reviewer incorporates the review of the additional 1917969747eSSandrine Bailleux testing in the ``Code-Review+1`` or ``Code-Owner-Review+1`` as applicable to 1927969747eSSandrine Bailleux attest that the patch works as expected. Where possible additional tests should 1937969747eSSandrine Bailleux be added to the CI system as a follow up task. For example, for a 1947969747eSSandrine Bailleux platform-dependent patch where the said platform is not available in the CI 1957969747eSSandrine Bailleux system's board farm. 1967969747eSSandrine Bailleux 19734760951SPaul Beesley- When the changes are accepted, the :ref:`maintainers` will integrate them. 19840d553cfSPaul Beesley 19934760951SPaul Beesley - Typically, the :ref:`maintainers` will merge the changes into the 20040d553cfSPaul Beesley ``integration`` branch. 2017969747eSSandrine Bailleux 20240d553cfSPaul Beesley - If the changes are not based on a sufficiently-recent commit, or if they 20334760951SPaul Beesley cannot be automatically rebased, then the :ref:`maintainers` may rebase it 2043d28b0a4SSandrine Bailleux on the ``integration`` branch or ask you to do so. 2057969747eSSandrine Bailleux 20640d553cfSPaul Beesley - After final integration testing, the changes will make their way into the 2073d28b0a4SSandrine Bailleux ``master`` branch. If a problem is found during integration, the 2083d28b0a4SSandrine Bailleux :ref:`maintainers` will request your help to solve the issue. They may 2093d28b0a4SSandrine Bailleux revert your patches and ask you to resubmit a reworked version of them or 2103d28b0a4SSandrine Bailleux they may ask you to provide a fix-up patch. 21140d553cfSPaul Beesley 2126c3d92e3SJayanth Dodderi ChidanandAdd Build Configurations 2136c3d92e3SJayanth Dodderi Chidanand------------------------ 2146c3d92e3SJayanth Dodderi Chidanand 2156c3d92e3SJayanth Dodderi Chidanand- TF-A uses Jenkins tool for Continuous Integration and testing activities. 2166c3d92e3SJayanth Dodderi Chidanand Various CI Jobs are deployed which run tests on every patch before being 2176c3d92e3SJayanth Dodderi Chidanand merged. So each of your patches go through a series of checks before they 2186c3d92e3SJayanth Dodderi Chidanand get merged on to the master branch. 2196c3d92e3SJayanth Dodderi Chidanand 2206c3d92e3SJayanth Dodderi Chidanand- ``Coverity Scan analysis`` is one of the tests we perform on our source code 2216c3d92e3SJayanth Dodderi Chidanand at regular intervals. We maintain a build script ``tf-cov-make`` which contains the 2226c3d92e3SJayanth Dodderi Chidanand build configurations of various platforms in order to cover the entire source 2236c3d92e3SJayanth Dodderi Chidanand code being analysed by Coverity. 2246c3d92e3SJayanth Dodderi Chidanand 2256c3d92e3SJayanth Dodderi Chidanand- When you submit your patches for review containing new source files, please 2266c3d92e3SJayanth Dodderi Chidanand ensure to include them for the ``Coverity Scan analysis`` by adding the 2276c3d92e3SJayanth Dodderi Chidanand respective build configurations in the ``tf-cov-make`` build script. 2286c3d92e3SJayanth Dodderi Chidanand 2296c3d92e3SJayanth Dodderi Chidanand- In this section you find the details on how to append your new build 2306c3d92e3SJayanth Dodderi Chidanand configurations for Coverity Scan analysis: 2316c3d92e3SJayanth Dodderi Chidanand 2326c3d92e3SJayanth Dodderi Chidanand#. We maintain a separate repository named `tf-a-ci-scripts repository`_ 2336c3d92e3SJayanth Dodderi Chidanand for placing all the test scripts which will be executed by the CI Jobs. 2346c3d92e3SJayanth Dodderi Chidanand 2356c3d92e3SJayanth Dodderi Chidanand#. In this repository, ``tf-cov-make`` script is located at 2366c3d92e3SJayanth Dodderi Chidanand ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make`` 2376c3d92e3SJayanth Dodderi Chidanand 2386c3d92e3SJayanth Dodderi Chidanand#. Edit `tf-cov-make`_ script by appending all the possible build configurations with 2396c3d92e3SJayanth Dodderi Chidanand the specific ``build-flags`` relevant to your platform, so that newly added 2406c3d92e3SJayanth Dodderi Chidanand source files get built and analysed by Coverity. 2416c3d92e3SJayanth Dodderi Chidanand 2426c3d92e3SJayanth Dodderi Chidanand#. For better understanding follow the below specified examples listed in the 2436c3d92e3SJayanth Dodderi Chidanand ``tf-cov-make`` script. 2446c3d92e3SJayanth Dodderi Chidanand 245*d0bbe815SJayanth Dodderi Chidanand.. code:: shell 2466c3d92e3SJayanth Dodderi Chidanand 2476c3d92e3SJayanth Dodderi Chidanand Example 1: 2486c3d92e3SJayanth Dodderi Chidanand #Intel 2496c3d92e3SJayanth Dodderi Chidanand make PLAT=stratix10 $(common_flags) all 2506c3d92e3SJayanth Dodderi Chidanand make PLAT=agilex $(common_flags) all 2516c3d92e3SJayanth Dodderi Chidanand 2526c3d92e3SJayanth Dodderi Chidanand- In the above example there are two different SoCs ``stratix`` and ``agilex`` 2536c3d92e3SJayanth Dodderi Chidanand under the Intel platform and the build configurations has been added suitably 2546c3d92e3SJayanth Dodderi Chidanand to include most of their source files. 2556c3d92e3SJayanth Dodderi Chidanand 256*d0bbe815SJayanth Dodderi Chidanand.. code:: shell 2576c3d92e3SJayanth Dodderi Chidanand 2586c3d92e3SJayanth Dodderi Chidanand Example 2: 2596c3d92e3SJayanth Dodderi Chidanand #Hikey 2606c3d92e3SJayanth Dodderi Chidanand make PLAT=hikey $(common_flags) ${TBB_OPTIONS} ENABLE_PMF=1 all 2616c3d92e3SJayanth Dodderi Chidanand make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all 2626c3d92e3SJayanth Dodderi Chidanand make PLAT=poplar $(common_flags) all 2636c3d92e3SJayanth Dodderi Chidanand 2646c3d92e3SJayanth Dodderi Chidanand- In this case for ``Hikey`` boards additional ``build-flags`` has been included 2656c3d92e3SJayanth Dodderi Chidanand along with the ``commom_flags`` to cover most of the files relevant to it. 2666c3d92e3SJayanth Dodderi Chidanand 2676c3d92e3SJayanth Dodderi Chidanand- Similar to this you can still find many other different build configurations 2686c3d92e3SJayanth Dodderi Chidanand of various other platforms listed in the ``tf-cov-make`` script. Kindly refer 2696c3d92e3SJayanth Dodderi Chidanand them and append your build configurations respectively. 2706c3d92e3SJayanth Dodderi Chidanand 27140d553cfSPaul BeesleyBinary Components 27240d553cfSPaul Beesley----------------- 27340d553cfSPaul Beesley 27440d553cfSPaul Beesley- Platforms may depend on binary components submitted to the `Trusted Firmware 27540d553cfSPaul Beesley binary repository`_ if they require code that the contributor is unable or 27640d553cfSPaul Beesley unwilling to open-source. This should be used as a rare exception. 27740d553cfSPaul Beesley- All binary components must follow the contribution guidelines (in particular 27840d553cfSPaul Beesley licensing rules) outlined in the `readme.rst <tf-binaries-readme_>`_ file of 27940d553cfSPaul Beesley the binary repository. 28040d553cfSPaul Beesley- Binary components must be restricted to only the specific functionality that 28140d553cfSPaul Beesley cannot be open-sourced and must be linked into a larger open-source platform 28240d553cfSPaul Beesley port. The majority of the platform port must still be implemented in open 28340d553cfSPaul Beesley source. Platform ports that are merely a thin wrapper around a binary 28440d553cfSPaul Beesley component that contains all the actual code will not be accepted. 28540d553cfSPaul Beesley- Only platform port code (i.e. in the ``plat/<vendor>`` directory) may rely on 28640d553cfSPaul Beesley binary components. Generic code must always be fully open-source. 28740d553cfSPaul Beesley 28840d553cfSPaul Beesley-------------- 28940d553cfSPaul Beesley 2906c3d92e3SJayanth Dodderi Chidanand*Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved.* 29140d553cfSPaul Beesley 292d97bade1SChris Kay.. _Conventional Commits: https://www.conventionalcommits.org/en/v1.0.0 29340d553cfSPaul Beesley.. _developer.trustedfirmware.org: https://developer.trustedfirmware.org 2943d28b0a4SSandrine Bailleux.. _review.trustedfirmware.org: https://review.trustedfirmware.org 29540d553cfSPaul Beesley.. _issue: https://developer.trustedfirmware.org/project/board/1/ 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 29940d553cfSPaul Beesley.. _Gerrit Signed-off-by Lines guidelines: https://review.trustedfirmware.org/Documentation/user-signedoffby.html 30040d553cfSPaul Beesley.. _Gerrit Change-Ids documentation: https://review.trustedfirmware.org/Documentation/user-changeid.html 3013d28b0a4SSandrine Bailleux.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io 30240d553cfSPaul Beesley.. _Trusted Firmware binary repository: https://review.trustedfirmware.org/admin/repos/tf-binaries 30340d553cfSPaul Beesley.. _tf-binaries-readme: https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst 3043d28b0a4SSandrine Bailleux.. _TF-A mailing list: https://lists.trustedfirmware.org/mailman/listinfo/tf-a 3056c3d92e3SJayanth Dodderi Chidanand.. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/ 3066c3d92e3SJayanth Dodderi Chidanand.. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make 307