contributing.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. Contributor's Guide
  2. *******************
  3. Getting Started
  4. ===============
  5. - Make sure you have a Github account and you are logged on to
  6. `review.trustedfirmware.org`_.
  7. Also make sure that you have registered your full name and email address in
  8. your `review.trustedfirmware.org`_ profile. Otherwise, the Gerrit server
  9. might reject patches you attempt to post for review.
  10. - If you plan to contribute a major piece of work, it is usually a good idea to
  11. start a discussion around it on the `TF-A mailing list`_. This gives everyone
  12. visibility of what is coming up, you might learn that somebody else is
  13. already working on something similar or the community might be able to
  14. provide some early input to help shaping the design of the feature.
  15. If you intend to include Third Party IP in your contribution, please mention
  16. it explicitly in the email thread and ensure that the changes that include
  17. Third Party IP are made in a separate patch (or patch series).
  18. - Clone the Trusted Firmware-A source code on your own machine as described in
  19. :ref:`prerequisites_get_source`.
  20. - Create a local topic branch based on the Trusted Firmware-A ``master``
  21. branch.
  22. Making Changes
  23. ==============
  24. - Ensure commits adhere to the project's :ref:`Commit Style`.
  25. - Make commits of logical units. See these general `Git guidelines`_ for
  26. contributing to a project.
  27. - Keep the commits on topic. If you need to fix another bug or make another
  28. enhancement, please address it on a separate topic branch.
  29. - Split the patch in manageable units. Small patches are usually easier to
  30. review so this will speed up the review process.
  31. - Avoid long commit series. If you do have a long series, consider whether
  32. some commits should be squashed together or addressed in a separate topic.
  33. - Follow the :ref:`Coding Style` and :ref:`Coding Guidelines`.
  34. - Use the checkpatch.pl script provided with the Linux source tree. A
  35. Makefile target is provided for convenience, see :ref:`this
  36. section<automatic-compliance-checking>` for more details.
  37. - Where appropriate, please update the documentation.
  38. - Consider whether the :ref:`Porting Guide`, :ref:`Firmware Design` document
  39. or other in-source documentation needs updating.
  40. - If you are submitting new files that you intend to be the code owner for
  41. (for example, a new platform port), then also update the
  42. :ref:`code owners` file.
  43. - For topics with multiple commits, you should make all documentation changes
  44. (and nothing else) in the last commit of the series. Otherwise, include
  45. the documentation changes within the single commit.
  46. .. _copyright-license-guidance:
  47. - Ensure that each changed file has the correct copyright and license
  48. information. Files that entirely consist of contributions to this project
  49. should have a copyright notice and BSD-3-Clause SPDX license identifier of
  50. the form as shown in :ref:`license`. Files that contain changes to imported
  51. Third Party IP files should retain their original copyright and license
  52. notices.
  53. For significant contributions you may add your own copyright notice in the
  54. following format:
  55. ::
  56. Portions copyright (c) [XXXX-]YYYY, <OWNER>. All rights reserved.
  57. where XXXX is the year of first contribution (if different to YYYY) and YYYY
  58. is the year of most recent contribution. <OWNER> is your name or your company
  59. name.
  60. - Ensure that each patch in the patch series compiles in all supported
  61. configurations. Patches which do not compile will not be merged.
  62. - Please test your changes. As a minimum, ensure that Linux boots on the
  63. Foundation FVP. See :ref:`Arm Fixed Virtual Platforms (FVP)` for more
  64. information. For more extensive testing, consider running the `TF-A Tests`_
  65. against your patches.
  66. - Ensure that all CI automated tests pass. Failures should be fixed. They might
  67. block a patch, depending on how critical they are.
  68. Submitting Changes
  69. ==================
  70. .. note::
  71. Please follow the `How to Contribute Code`_ section of the OpenCI
  72. documentation for general instructions on setting up Gerrit and posting
  73. patches there. The rest of this section provides details about patch
  74. submission rules specifically for the TF-A project.
  75. - Submit your changes for review using the ``git review`` command.
  76. This will automatically rebase them onto the upstream ``integration`` branch,
  77. as required by TF-A's patch submission process.
  78. - From the Gerrit web UI, add reviewers for your patch:
  79. - At least one code owner for each module modified by the patch. See the
  80. list of modules and their :ref:`code owners`.
  81. - At least one maintainer. See the list of :ref:`maintainers`.
  82. - If some module has no code owner, try to identify a suitable (non-code
  83. owner) reviewer. Running ``git blame`` on the module's source code can
  84. help, as it shows who has been working the most recently on this area of
  85. the code.
  86. Alternatively, if it is impractical to identify such a reviewer, you might
  87. send an email to the `TF-A mailing list`_ to broadcast your review request
  88. to the community.
  89. Note that self-reviewing a patch is prohibited, even if the patch author is
  90. the only code owner of a module modified by the patch. Getting a second pair
  91. of eyes on the code is essential to keep up with the quality standards the
  92. project aspires to.
  93. - The changes will then undergo further review by the designated people. Any
  94. review comments will be made directly on your patch. This may require you to
  95. do some rework. For controversial changes, the discussion might be moved to
  96. the `TF-A mailing list`_ to involve more of the community.
  97. Refer to the `Gerrit Uploading Changes documentation`_ for more details.
  98. - The patch submission rules are the following. For a patch to be approved
  99. and merged in the tree, it must get:
  100. - One ``Code-Owner-Review+1`` for each of the modules modified by the patch.
  101. - A ``Maintainer-Review+1``.
  102. In the case where a code owner could not be found for a given module,
  103. ``Code-Owner-Review+1`` is substituted by ``Code-Review+1``.
  104. In addition to these various code review labels, the patch must also get a
  105. ``Verified+1``. This is usually set by the Continuous Integration (CI) bot
  106. when all automated tests passed on the patch. Sometimes, some of these
  107. automated tests may fail for reasons unrelated to the patch. In this case,
  108. the maintainers might (after analysis of the failures) override the CI bot
  109. score to certify that the patch has been correctly tested.
  110. In the event where the CI system lacks proper tests for a patch, the patch
  111. author or a reviewer might agree to perform additional manual tests
  112. in their review and the reviewer incorporates the review of the additional
  113. testing in the ``Code-Review+1`` or ``Code-Owner-Review+1`` as applicable to
  114. attest that the patch works as expected. Where possible additional tests should
  115. be added to the CI system as a follow up task. For example, for a
  116. platform-dependent patch where the said platform is not available in the CI
  117. system's board farm.
  118. - When the changes are accepted, the :ref:`maintainers` will integrate them.
  119. - Typically, the :ref:`maintainers` will merge the changes into the
  120. ``integration`` branch.
  121. - If the changes are not based on a sufficiently-recent commit, or if they
  122. cannot be automatically rebased, then the :ref:`maintainers` may rebase it
  123. on the ``integration`` branch or ask you to do so.
  124. - After final integration testing, the changes will make their way into the
  125. ``master`` branch. If a problem is found during integration, the
  126. :ref:`maintainers` will request your help to solve the issue. They may
  127. revert your patches and ask you to resubmit a reworked version of them or
  128. they may ask you to provide a fix-up patch.
  129. Add CI Configurations
  130. =====================
  131. TF-A uses Jenkins for Continuous Integration and testing activities. Various CI
  132. jobs are deployed to run tests on every patch before being merged. Each of your
  133. patches go through a series of checks before they get merged on to the master
  134. branch. Kindly ensure that every time you add new files under your platform,
  135. they are covered by the following two sections.
  136. Coverity Scan
  137. -------------
  138. The TF-A project makes use of `Coverity Scan` for static analysis, a service
  139. offered by Synopsys for open-source projects. This tool is able to find defects
  140. and vulnerabilities in a code base, such as dereferences of NULL pointers, use
  141. of uninitialized data, control flow issues and many other things.
  142. The TF-A source code is submitted daily to this service for analysis. Results of
  143. the latest and previous scans, as well as the complete list of defects it
  144. detected, are accessible online from
  145. https://scan.coverity.com/projects/arm-software-arm-trusted-firmware.
  146. The `tf-a-ci-scripts repository`_ contains scripts to run the Coverity Scan
  147. tools on the integration branch of the TF-A code base and make them available on
  148. https://scan.coverity.com. These scripts get executed daily by the
  149. `tf-a-coverity Jenkins job`_.
  150. In order to maintain a high level of coverage, including on newly introduced
  151. code, it is important to maintain the appropriate TF-A CI scripts. Details of
  152. when to update these scripts and how to do so follow.
  153. We maintain a build script - ``tf-cov-make`` - which contains the build
  154. configurations of various platforms in order to cover the entire source code
  155. being analysed by Coverity.
  156. When you submit your patches for review, and if they contain new source files,
  157. `TF-A CI static checks job`_ might report that these files are not covered. In
  158. this case, the job's console output will show the following error message::
  159. ****** Newly added files detection check for Coverity Scan analysis on patch(es) ******
  160. Result : FAILURE
  161. New source files have been identified in your patch..
  162. some/dir/file.c
  163. please ensure to include them for the ``Coverity Scan analysis`` by adding
  164. the respective build configurations in the ``tf-cov-make`` build script.
  165. In this section you find the details on how to append your new build
  166. configurations for Coverity scan analysis illustrated with examples:
  167. #. We maintain a separate repository named `tf-a-ci-scripts repository`_
  168. for placing all the test scripts which will be executed by the CI Jobs.
  169. #. In this repository, ``tf-cov-make`` script is located at
  170. ``tf-a-ci-scripts/script/tf-coverity/tf-cov-make``
  171. #. Edit the `tf-cov-make`_ script by appending all the possible build
  172. configurations with the specific build flags relevant to your platform, so
  173. that newly added source files get built and analysed by Coverity.
  174. #. For better understanding follow the below specified examples listed in the
  175. ``tf-cov-make`` script.
  176. .. code:: shell
  177. Example 1:
  178. #Intel
  179. make PLAT=stratix10 $(common_flags) all
  180. make PLAT=agilex $(common_flags) all
  181. - In the above example there are two different SoCs ``stratix`` and ``agilex``
  182. under the Intel platform and the build configurations has been added suitably
  183. to include most of their source files.
  184. .. code:: shell
  185. Example 2:
  186. #Hikey
  187. make PLAT=hikey $(common_flags) ${TBB_OPTIONS} ENABLE_PMF=1 all
  188. make PLAT=hikey960 $(common_flags) ${TBB_OPTIONS} all
  189. make PLAT=poplar $(common_flags) all
  190. - In this case for ``Hikey`` boards additional build flags have been included
  191. along with the ``common_flags`` to cover most of the files relevant to it.
  192. - Similar to this you can still find many other different build configurations
  193. of various other platforms listed in the ``tf-cov-make`` script. Kindly refer
  194. them and append your build configurations respectively.
  195. Test Build Configurations
  196. -------------------------
  197. We have CI jobs which run a set of test configurations on every TF-A patch
  198. before they get merged upstream.
  199. At the bare minimum, TF-A code should build without any errors for every
  200. supported platform - and every feature of this platform. To make sure this is
  201. the case, we maintain a set of build tests. ``tf-l1-build-plat`` is the test
  202. group which holds all build tests for all platforms. So be kind enough to
  203. verify that your newly added files are covered by such a build test.
  204. If this is not the case, please follow the instructions below to add the
  205. appropriate files. We will illustrate this with an example for the ``Hikey``
  206. platform.
  207. - In the `tf-a-ci-scripts repository`_ we need to add a build configuration file
  208. ``hikey-default`` under ``tf_config/`` folder. ``tf_config/hikey-default``
  209. must list all the build parameters relevant to it.
  210. .. code:: shell
  211. # Hikey Build Parameters
  212. CROSS_COMPILE=aarch64-none-elf-
  213. PLAT=hikey
  214. - Further another file, ``hikey-default:nil``, needs to be added under
  215. ``group/tf-l1-build-plat/`` folder to allow the platform to be built as part
  216. of this test group. ``group/tf-l1-build-plat/hikey-default:nil`` file just
  217. needs to exist but does not contain anything meaningful, apart from a
  218. mandatory copyright notice:
  219. .. code:: shell
  220. #
  221. # Copyright (c) 2019-2022 Arm Limited. All rights reserved.
  222. #
  223. # SPDX-License-Identifier: BSD-3-Clause
  224. #
  225. - As illustrated above, you need to add similar files supporting your platform.
  226. For a more elaborate explanation of the TF-A CI scripts internals, including how
  227. to add more complex tests beyond a simple build test, please refer to the `TF-A
  228. CI scripts overview`_ section of the OpenCI documentation.
  229. Binary Components
  230. =================
  231. - Platforms may depend on binary components submitted to the `Trusted Firmware
  232. binary repository`_ if they require code that the contributor is unable or
  233. unwilling to open-source. This should be used as a rare exception.
  234. - All binary components must follow the contribution guidelines (in particular
  235. licensing rules) outlined in the `readme.rst <tf-binaries-readme_>`_ file of
  236. the binary repository.
  237. - Binary components must be restricted to only the specific functionality that
  238. cannot be open-sourced and must be linked into a larger open-source platform
  239. port. The majority of the platform port must still be implemented in open
  240. source. Platform ports that are merely a thin wrapper around a binary
  241. component that contains all the actual code will not be accepted.
  242. - Only platform port code (i.e. in the ``plat/<vendor>`` directory) may rely on
  243. binary components. Generic code must always be fully open-source.
  244. --------------
  245. *Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.*
  246. .. _review.trustedfirmware.org: https://review.trustedfirmware.org
  247. .. _Git guidelines: http://git-scm.com/book/ch5-2.html
  248. .. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html
  249. .. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io
  250. .. _Trusted Firmware binary repository: https://review.trustedfirmware.org/admin/repos/tf-binaries
  251. .. _tf-binaries-readme: https://git.trustedfirmware.org/tf-binaries.git/tree/readme.rst
  252. .. _TF-A mailing list: https://lists.trustedfirmware.org/mailman3/lists/tf-a.lists.trustedfirmware.org/
  253. .. _tf-a-ci-scripts repository: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/
  254. .. _tf-cov-make: https://git.trustedfirmware.org/ci/tf-a-ci-scripts.git/tree/script/tf-coverity/tf-cov-make
  255. .. _How to Contribute Code: https://tf-ci-users-guide.readthedocs.io/en/latest/#how-to-contribute-code
  256. .. _TF-A CI scripts overview: https://tf-ci-users-guide.readthedocs.io/en/latest/#tf-a-ci-scripts-overview
  257. .. _tf-a-coverity Jenkins job: https://ci.trustedfirmware.org/job/tf-a-coverity/
  258. .. _TF-A CI static checks job: https://ci.trustedfirmware.org/job/tf-a-static-checks/