xref: /rk3399_ARM-atf/docs/process/contributing.rst (revision 7d3b5193723ef1928a9108739b0193eecd962f22)
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
29*7d3b5193SChris Kay-  Ensure commits adhere to the the project's :ref:`Commit Style`.
30*7d3b5193SChris 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
9440d553cfSPaul Beesley------------------
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
1676c3d92e3SJayanth Dodderi ChidanandAdd Build Configurations
1686c3d92e3SJayanth 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
1736c3d92e3SJayanth Dodderi Chidanand   get merged on to the master branch.
1746c3d92e3SJayanth Dodderi Chidanand
1756c3d92e3SJayanth Dodderi Chidanand-  ``Coverity Scan analysis`` is one of the tests we perform on our source code
1766c3d92e3SJayanth Dodderi Chidanand   at regular intervals. We maintain a build script ``tf-cov-make`` which contains the
1776c3d92e3SJayanth Dodderi Chidanand   build configurations of various platforms in order to cover the entire source
1786c3d92e3SJayanth Dodderi Chidanand   code being analysed by Coverity.
1796c3d92e3SJayanth Dodderi Chidanand
1806c3d92e3SJayanth Dodderi Chidanand-  When you submit your patches for review containing new source files, please
1816c3d92e3SJayanth Dodderi Chidanand   ensure to include them for the ``Coverity Scan analysis`` by adding the
1826c3d92e3SJayanth Dodderi Chidanand   respective build configurations in the ``tf-cov-make`` build script.
1836c3d92e3SJayanth Dodderi Chidanand
1846c3d92e3SJayanth Dodderi Chidanand-  In this section you find the details on how to append your new build
1856c3d92e3SJayanth Dodderi Chidanand   configurations for Coverity Scan analysis:
1866c3d92e3SJayanth Dodderi Chidanand
1876c3d92e3SJayanth Dodderi Chidanand#. We maintain a separate repository named `tf-a-ci-scripts repository`_
1886c3d92e3SJayanth Dodderi Chidanand   for placing all the test scripts which will be executed by the CI Jobs.
1896c3d92e3SJayanth Dodderi Chidanand
1906c3d92e3SJayanth Dodderi Chidanand#. In this repository, ``tf-cov-make`` script is located at
1916c3d92e3SJayanth Dodderi Chidanand   ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make``
1926c3d92e3SJayanth Dodderi Chidanand
1936c3d92e3SJayanth Dodderi Chidanand#. Edit `tf-cov-make`_ script by appending all the possible build configurations with
1946c3d92e3SJayanth Dodderi Chidanand   the specific ``build-flags`` relevant to your platform, so that newly added
1956c3d92e3SJayanth Dodderi Chidanand   source files get built and analysed by Coverity.
1966c3d92e3SJayanth Dodderi Chidanand
1976c3d92e3SJayanth Dodderi Chidanand#. For better understanding follow the below specified examples listed in the
1986c3d92e3SJayanth Dodderi Chidanand   ``tf-cov-make`` script.
1996c3d92e3SJayanth Dodderi Chidanand
200d0bbe815SJayanth Dodderi Chidanand.. code:: shell
2016c3d92e3SJayanth Dodderi Chidanand
2026c3d92e3SJayanth Dodderi Chidanand    Example 1:
2036c3d92e3SJayanth Dodderi Chidanand    #Intel
2046c3d92e3SJayanth Dodderi Chidanand    make PLAT=stratix10 $(common_flags) all
2056c3d92e3SJayanth Dodderi Chidanand    make PLAT=agilex $(common_flags) all
2066c3d92e3SJayanth Dodderi Chidanand
2076c3d92e3SJayanth Dodderi Chidanand-  In the above example there are two different SoCs ``stratix`` and ``agilex``
2086c3d92e3SJayanth Dodderi Chidanand   under the Intel platform and the build configurations has been added suitably
2096c3d92e3SJayanth Dodderi Chidanand   to include most of their source files.
2106c3d92e3SJayanth Dodderi Chidanand
211d0bbe815SJayanth Dodderi Chidanand.. code:: shell
2126c3d92e3SJayanth Dodderi Chidanand
2136c3d92e3SJayanth Dodderi Chidanand    Example 2:
2146c3d92e3SJayanth Dodderi Chidanand    #Hikey
2156c3d92e3SJayanth Dodderi Chidanand    make PLAT=hikey $(common_flags) ${TBB_OPTIONS} ENABLE_PMF=1 all
2166c3d92e3SJayanth Dodderi Chidanand    make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all
2176c3d92e3SJayanth Dodderi Chidanand    make PLAT=poplar $(common_flags) all
2186c3d92e3SJayanth Dodderi Chidanand
2196c3d92e3SJayanth Dodderi Chidanand-  In this case for ``Hikey`` boards additional ``build-flags`` has been included
2206c3d92e3SJayanth Dodderi Chidanand   along with the ``commom_flags`` to cover most of the files relevant to it.
2216c3d92e3SJayanth Dodderi Chidanand
2226c3d92e3SJayanth Dodderi Chidanand-  Similar to this you can still find many other different build configurations
2236c3d92e3SJayanth Dodderi Chidanand   of various other platforms listed in the ``tf-cov-make`` script. Kindly refer
2246c3d92e3SJayanth Dodderi Chidanand   them and append your build configurations respectively.
2256c3d92e3SJayanth Dodderi Chidanand
22640d553cfSPaul BeesleyBinary Components
22740d553cfSPaul Beesley-----------------
22840d553cfSPaul Beesley
22940d553cfSPaul Beesley-  Platforms may depend on binary components submitted to the `Trusted Firmware
23040d553cfSPaul Beesley   binary repository`_ if they require code that the contributor is unable or
23140d553cfSPaul Beesley   unwilling to open-source. This should be used as a rare exception.
23240d553cfSPaul Beesley-  All binary components must follow the contribution guidelines (in particular
23340d553cfSPaul Beesley   licensing rules) outlined in the `readme.rst <tf-binaries-readme_>`_ file of
23440d553cfSPaul Beesley   the binary repository.
23540d553cfSPaul Beesley-  Binary components must be restricted to only the specific functionality that
23640d553cfSPaul Beesley   cannot be open-sourced and must be linked into a larger open-source platform
23740d553cfSPaul Beesley   port. The majority of the platform port must still be implemented in open
23840d553cfSPaul Beesley   source. Platform ports that are merely a thin wrapper around a binary
23940d553cfSPaul Beesley   component that contains all the actual code will not be accepted.
24040d553cfSPaul Beesley-  Only platform port code (i.e. in the ``plat/<vendor>`` directory) may rely on
24140d553cfSPaul Beesley   binary components. Generic code must always be fully open-source.
24240d553cfSPaul Beesley
24340d553cfSPaul Beesley--------------
24440d553cfSPaul Beesley
2456c3d92e3SJayanth Dodderi Chidanand*Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved.*
24640d553cfSPaul Beesley
24740d553cfSPaul Beesley.. _developer.trustedfirmware.org: https://developer.trustedfirmware.org
2483d28b0a4SSandrine Bailleux.. _review.trustedfirmware.org: https://review.trustedfirmware.org
249f6ad51c8SJohn Tsichritzis.. _Trusted Firmware-A: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
25040d553cfSPaul Beesley.. _Git guidelines: http://git-scm.com/book/ch5-2.html
25140d553cfSPaul Beesley.. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html
2523d28b0a4SSandrine Bailleux.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io
25340d553cfSPaul Beesley.. _Trusted Firmware binary repository: https://review.trustedfirmware.org/admin/repos/tf-binaries
25440d553cfSPaul Beesley.. _tf-binaries-readme: https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst
2553d28b0a4SSandrine Bailleux.. _TF-A mailing list: https://lists.trustedfirmware.org/mailman/listinfo/tf-a
2566c3d92e3SJayanth Dodderi Chidanand.. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/
2576c3d92e3SJayanth Dodderi Chidanand.. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make
258