maint-appx.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ******************
  3. Kernel Maintenance
  4. ******************
  5. Tree Construction
  6. =================
  7. This section describes construction of the Yocto Project kernel source
  8. repositories as accomplished by the Yocto Project team to create Yocto
  9. Linux kernel repositories. These kernel repositories are found under the
  10. heading "Yocto Linux Kernel" at :yocto_git:`/` and
  11. are shipped as part of a Yocto Project release. The team creates these
  12. repositories by compiling and executing the set of feature descriptions
  13. for every BSP and feature in the product. Those feature descriptions
  14. list all necessary patches, configurations, branches, tags, and feature
  15. divisions found in a Yocto Linux kernel. Thus, the Yocto Project Linux
  16. kernel repository (or tree) and accompanying Metadata in the
  17. ``yocto-kernel-cache`` are built.
  18. The existence of these repositories allow you to access and clone a
  19. particular Yocto Project Linux kernel repository and use it to build
  20. images based on their configurations and features.
  21. You can find the files used to describe all the valid features and BSPs
  22. in the Yocto Project Linux kernel in any clone of the Yocto Project
  23. Linux kernel source repository and ``yocto-kernel-cache`` Git trees. For
  24. example, the following commands clone the Yocto Project baseline Linux
  25. kernel that branches off ``linux.org`` version 4.12 and the
  26. ``yocto-kernel-cache``, which contains stores of kernel Metadata::
  27. $ git clone git://git.yoctoproject.org/linux-yocto-4.12
  28. $ git clone git://git.yoctoproject.org/linux-kernel-cache
  29. For more information on
  30. how to set up a local Git repository of the Yocto Project Linux kernel
  31. files, see the
  32. ":ref:`kernel-dev/common:preparing the build host to work on the kernel`"
  33. section.
  34. Once you have cloned the kernel Git repository and the cache of Metadata
  35. on your local machine, you can discover the branches that are available
  36. in the repository using the following Git command::
  37. $ git branch -a
  38. Checking out a branch allows you to work with a particular Yocto Linux
  39. kernel. For example, the following commands check out the
  40. "standard/beagleboard" branch of the Yocto Linux kernel repository and
  41. the "yocto-4.12" branch of the ``yocto-kernel-cache`` repository::
  42. $ cd ~/linux-yocto-4.12
  43. $ git checkout -b my-kernel-4.12 remotes/origin/standard/beagleboard
  44. $ cd ~/linux-kernel-cache
  45. $ git checkout -b my-4.12-metadata remotes/origin/yocto-4.12
  46. .. note::
  47. Branches in the ``yocto-kernel-cache`` repository correspond to Yocto Linux
  48. kernel versions (e.g. "yocto-4.12", "yocto-4.10", "yocto-4.9", and so forth).
  49. Once you have checked out and switched to appropriate branches, you can
  50. see a snapshot of all the kernel source files used to build that
  51. particular Yocto Linux kernel for a particular board.
  52. To see the features and configurations for a particular Yocto Linux
  53. kernel, you need to examine the ``yocto-kernel-cache`` Git repository.
  54. As mentioned, branches in the ``yocto-kernel-cache`` repository
  55. correspond to Yocto Linux kernel versions (e.g. ``yocto-4.12``).
  56. Branches contain descriptions in the form of ``.scc`` and ``.cfg``
  57. files.
  58. You should realize, however, that browsing your local
  59. ``yocto-kernel-cache`` repository for feature descriptions and patches
  60. is not an effective way to determine what is in a particular kernel
  61. branch. Instead, you should use Git directly to discover the changes in
  62. a branch. Using Git is an efficient and flexible way to inspect changes
  63. to the kernel.
  64. .. note::
  65. Ground up reconstruction of the complete kernel tree is an action
  66. only taken by the Yocto Project team during an active development
  67. cycle. When you create a clone of the kernel Git repository, you are
  68. simply making it efficiently available for building and development.
  69. The following steps describe what happens when the Yocto Project Team
  70. constructs the Yocto Project kernel source Git repository (or tree)
  71. found at :yocto_git:`/` given the introduction of a new
  72. top-level kernel feature or BSP. The following actions effectively
  73. provide the Metadata and create the tree that includes the new feature,
  74. patch, or BSP:
  75. #. *Pass Feature to the OpenEmbedded Build System:* A top-level kernel
  76. feature is passed to the kernel build subsystem. Normally, this
  77. feature is a BSP for a particular kernel type.
  78. #. *Locate Feature:* The file that describes the top-level feature is
  79. located by searching these system directories:
  80. - The in-tree kernel-cache directories, which are located in the
  81. :yocto_git:`yocto-kernel-cache </yocto-kernel-cache/tree/bsp>`
  82. repository organized under the "Yocto Linux Kernel" heading in the
  83. :yocto_git:`Yocto Project Source Repositories <>`.
  84. - Areas pointed to by :term:`SRC_URI` statements found in kernel recipes.
  85. For a typical build, the target of the search is a feature
  86. description in an ``.scc`` file whose name follows this format (e.g.
  87. ``beaglebone-standard.scc`` and ``beaglebone-preempt-rt.scc``)::
  88. bsp_root_name-kernel_type.scc
  89. #. *Expand Feature:* Once located, the feature description is either
  90. expanded into a simple script of actions, or into an existing
  91. equivalent script that is already part of the shipped kernel.
  92. #. *Append Extra Features:* Extra features are appended to the top-level
  93. feature description. These features can come from the
  94. :term:`KERNEL_FEATURES`
  95. variable in recipes.
  96. #. *Locate, Expand, and Append Each Feature:* Each extra feature is
  97. located, expanded and appended to the script as described in step
  98. three.
  99. #. *Execute the Script:* The script is executed to produce files
  100. ``.scc`` and ``.cfg`` files in appropriate directories of the
  101. ``yocto-kernel-cache`` repository. These files are descriptions of
  102. all the branches, tags, patches and configurations that need to be
  103. applied to the base Git repository to completely create the source
  104. (build) branch for the new BSP or feature.
  105. #. *Clone Base Repository:* The base repository is cloned, and the
  106. actions listed in the ``yocto-kernel-cache`` directories are applied
  107. to the tree.
  108. #. *Perform Cleanup:* The Git repositories are left with the desired
  109. branches checked out and any required branching, patching and tagging
  110. has been performed.
  111. The kernel tree and cache are ready for developer consumption to be
  112. locally cloned, configured, and built into a Yocto Project kernel
  113. specific to some target hardware.
  114. .. note::
  115. - The generated ``yocto-kernel-cache`` repository adds to the kernel
  116. as shipped with the Yocto Project release. Any add-ons and
  117. configuration data are applied to the end of an existing branch.
  118. The full repository generation that is found in the official Yocto
  119. Project kernel repositories at :yocto_git:`/` is the
  120. combination of all supported boards and configurations.
  121. - The technique the Yocto Project team uses is flexible and allows
  122. for seamless blending of an immutable history with additional
  123. patches specific to a deployment. Any additions to the kernel
  124. become an integrated part of the branches.
  125. - The full kernel tree that you see on :yocto_git:`/` is
  126. generated through repeating the above steps for all valid BSPs.
  127. The end result is a branched, clean history tree that makes up the
  128. kernel for a given release. You can see the script (``kgit-scc``)
  129. responsible for this in the
  130. :yocto_git:`yocto-kernel-tools </yocto-kernel-tools/tree/tools>`
  131. repository.
  132. - The steps used to construct the full kernel tree are the same
  133. steps that BitBake uses when it builds a kernel image.
  134. Build Strategy
  135. ==============
  136. Once you have cloned a Yocto Linux kernel repository and the cache
  137. repository (``yocto-kernel-cache``) onto your development system, you
  138. can consider the compilation phase of kernel development, which is
  139. building a kernel image. Some prerequisites are validated by
  140. the build process before compilation starts:
  141. - The :term:`SRC_URI` points to the
  142. kernel Git repository.
  143. - A BSP build branch with Metadata exists in the ``yocto-kernel-cache``
  144. repository. The branch is based on the Yocto Linux kernel version and
  145. has configurations and features grouped under the
  146. ``yocto-kernel-cache/bsp`` directory. For example, features and
  147. configurations for the BeagleBone Board assuming a
  148. ``linux-yocto_4.12`` kernel reside in the following area of the
  149. ``yocto-kernel-cache`` repository: yocto-kernel-cache/bsp/beaglebone
  150. .. note::
  151. In the previous example, the "yocto-4.12" branch is checked out in
  152. the ``yocto-kernel-cache`` repository.
  153. The OpenEmbedded build system makes sure these conditions are satisfied before
  154. attempting compilation. Other means, however, do exist, such as
  155. bootstrapping a BSP.
  156. Before building a kernel, the build process verifies the tree and
  157. configures the kernel by processing all of the configuration "fragments"
  158. specified by feature descriptions in the ``.scc`` files. As the features
  159. are compiled, associated kernel configuration fragments are noted and
  160. recorded in the series of directories in their compilation order. The
  161. fragments are migrated, pre-processed and passed to the Linux Kernel
  162. Configuration subsystem (``lkc``) as raw input in the form of a
  163. ``.config`` file. The ``lkc`` uses its own internal dependency
  164. constraints to do the final processing of that information and generates
  165. the final ``.config`` file that is used during compilation.
  166. Using the board's architecture and other relevant values from the
  167. board's template, kernel compilation is started and a kernel image is
  168. produced.
  169. The other thing that you notice once you configure a kernel is that the
  170. build process generates a build tree that is separate from your kernel's
  171. local Git source repository tree. This build tree has a name that uses
  172. the following form, where ``${MACHINE}`` is the metadata name of the
  173. machine (BSP) and "kernel_type" is one of the Yocto Project supported
  174. kernel types (e.g. "standard")::
  175. linux-${MACHINE}-kernel_type-build
  176. The existing support in the ``kernel.org`` tree achieves this default
  177. functionality.
  178. This behavior means that all the generated files for a particular
  179. machine or BSP are now in the build tree directory. The files include
  180. the final ``.config`` file, all the ``.o`` files, the ``.a`` files, and
  181. so forth. Since each machine or BSP has its own separate
  182. :term:`Build Directory` in its own separate branch of the Git repository,
  183. you can easily switch between different builds.