kernel-dev-intro.rst 8.5 KB

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