intro.rst 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ************
  3. Introduction
  4. ************
  5. Overview
  6. ========
  7. Regardless of how you intend to make use of the Yocto Project, chances
  8. are you will work with the Linux kernel. This manual describes how to
  9. set up your build host to support kernel development, introduces the
  10. kernel development process, provides background information on the Yocto
  11. Linux kernel :term:`Metadata`, describes
  12. common tasks you can perform using the kernel tools, shows you how to
  13. use the kernel Metadata needed to work with the kernel inside the Yocto
  14. Project, and provides insight into how the Yocto Project team develops
  15. and maintains Yocto Linux kernel Git repositories and Metadata.
  16. Each Yocto Project release has a set of Yocto Linux kernel recipes,
  17. whose Git repositories you can view in the Yocto
  18. :yocto_git:`Source Repositories <>` under the "Yocto Linux Kernel"
  19. heading. New recipes for the release track the latest Linux kernel
  20. upstream developments from https://www.kernel.org and introduce
  21. newly-supported platforms. Previous recipes in the release are refreshed
  22. and supported for at least one additional Yocto Project release. As they
  23. align, these previous releases are updated to include the latest from
  24. the Long Term Support Initiative (LTSI) project. You can learn more
  25. about Yocto Linux kernels and LTSI in the
  26. ":ref:`kernel-dev/concepts-appx:yocto project kernel development and maintenance`" section.
  27. Also included is a Yocto Linux kernel development recipe
  28. (``linux-yocto-dev.bb``) should you want to work with the very latest in
  29. upstream Yocto Linux kernel development and kernel Metadata development.
  30. .. note::
  31. For more on Yocto Linux kernels, see the
  32. ":ref:`kernel-dev/concepts-appx:yocto project kernel development and maintenance`"
  33. section.
  34. The Yocto Project also provides a powerful set of kernel tools for
  35. managing Yocto Linux kernel sources and configuration data. You can use
  36. these tools to make a single configuration change, apply multiple
  37. patches, or work with your own kernel sources.
  38. In particular, the kernel tools allow you to generate configuration
  39. fragments that specify only what you must, and nothing more.
  40. Configuration fragments only need to contain the highest level visible
  41. ``CONFIG`` options as presented by the Yocto Linux kernel ``menuconfig``
  42. system. Contrast this against a complete Yocto Linux kernel ``.config``
  43. file, which includes all the automatically selected ``CONFIG`` options.
  44. This efficiency reduces your maintenance effort and allows you to
  45. further separate your configuration in ways that make sense for your
  46. project. A common split separates policy and hardware. For example, all
  47. your kernels might support the ``proc`` and ``sys`` filesystems, but
  48. only specific boards require sound, USB, or specific drivers. Specifying
  49. these configurations individually allows you to aggregate them together
  50. as needed, but maintains them in only one place. Similar logic applies
  51. to separating source changes.
  52. If you do not maintain your own kernel sources and need to make only
  53. minimal changes to the sources, the released recipes provide a vetted
  54. base upon which to layer your changes. Doing so allows you to benefit
  55. from the continual kernel integration and testing performed during
  56. development of the Yocto Project.
  57. If, instead, you have a very specific Linux kernel source tree and are
  58. unable to align with one of the official Yocto Linux kernel recipes,
  59. you have a way to use the Yocto Project Linux kernel tools with your
  60. own kernel sources.
  61. The remainder of this manual provides instructions for completing
  62. specific Linux kernel development tasks. These instructions assume you
  63. are comfortable working with :oe_wiki:`BitBake </Bitbake>` recipes and basic
  64. open-source development tools. Understanding these concepts will
  65. facilitate the process of working with the kernel recipes. If you find
  66. you need some additional background, please be sure to review and
  67. understand the following documentation:
  68. - :doc:`/brief-yoctoprojectqs/index` document.
  69. - :doc:`/overview-manual/index`.
  70. - :ref:`devtool
  71. workflow <sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow>`
  72. as described in the Yocto Project Application Development and the
  73. Extensible Software Development Kit (eSDK) manual.
  74. - The ":ref:`dev-manual/layers:understanding and creating layers`"
  75. section in the Yocto Project Development Tasks Manual.
  76. - The ":ref:`kernel-dev/intro:kernel modification workflow`" section.
  77. Kernel Modification Workflow
  78. ============================
  79. Kernel modification involves changing the Yocto Project kernel, which
  80. could involve changing configuration options as well as adding new
  81. kernel recipes. Configuration changes can be added in the form of
  82. configuration fragments, while recipe modification comes through the
  83. kernel's ``recipes-kernel`` area in a kernel layer you create.
  84. This section presents a high-level overview of the Yocto Project kernel
  85. modification workflow. The illustration and accompanying list provide
  86. general information and references for further information.
  87. .. image:: figures/kernel-dev-flow.png
  88. :width: 100%
  89. #. *Set up Your Host Development System to Support Development Using the
  90. Yocto Project*: See the ":doc:`/dev-manual/start`" section in
  91. the Yocto Project Development Tasks Manual for options on how to get
  92. a build host ready to use the Yocto Project.
  93. #. *Set Up Your Host Development System for Kernel Development:* It is
  94. recommended that you use ``devtool`` for kernel
  95. development. Alternatively, you can use traditional kernel
  96. development methods with the Yocto Project. Either way, there are
  97. steps you need to take to get the development environment ready.
  98. Using ``devtool`` requires that you have a clean build
  99. of the image. For
  100. more information, see the
  101. ":ref:`kernel-dev/common:getting ready to develop using ``devtool```"
  102. section.
  103. Using traditional kernel development requires that you have the
  104. kernel source available in an isolated local Git repository. For more
  105. information, see the
  106. ":ref:`kernel-dev/common:getting ready for traditional kernel development`"
  107. section.
  108. #. *Make Changes to the Kernel Source Code if applicable:* Modifying the
  109. kernel does not always mean directly changing source files. However,
  110. if you have to do this, you make the changes to the files in the
  111. Yocto's :term:`Build Directory` if you are using ``devtool``. For more
  112. information, see the
  113. ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`"
  114. section.
  115. If you are using traditional kernel development, you edit the source
  116. files in the kernel's local Git repository. For more information, see the
  117. ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`"
  118. section.
  119. #. *Make Kernel Configuration Changes if Applicable:* If your situation
  120. calls for changing the kernel's configuration, you can use
  121. :ref:`menuconfig <kernel-dev/common:using \`\`menuconfig\`\`>`,
  122. which allows you to
  123. interactively develop and test the configuration changes you are
  124. making to the kernel. Saving changes you make with ``menuconfig``
  125. updates the kernel's ``.config`` file.
  126. .. note::
  127. Try to resist the temptation to directly edit an existing ``.config``
  128. file, which is found in the :term:`Build Directory` among the source code
  129. used for the build. Doing so, can produce unexpected results when
  130. the OpenEmbedded build system regenerates the configuration file.
  131. Once you are satisfied with the configuration changes made using
  132. ``menuconfig`` and you have saved them, you can directly compare the
  133. resulting ``.config`` file against an existing original and gather
  134. those changes into a
  135. :ref:`configuration fragment file <kernel-dev/common:creating configuration fragments>` to be
  136. referenced from within the kernel's ``.bbappend`` file.
  137. Additionally, if you are working in a BSP layer and need to modify
  138. the BSP's kernel's configuration, you can use ``menuconfig``.
  139. #. *Rebuild the Kernel Image With Your Changes:* Rebuilding the kernel
  140. image applies your changes. Depending on your target hardware, you
  141. can verify your changes on actual hardware or perhaps QEMU.
  142. The remainder of this developer's guide covers common tasks typically
  143. used during kernel development, advanced Metadata usage, and Yocto Linux
  144. kernel maintenance concepts.