kernel-dev-maint-appx.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  3. [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
  4. <appendix id='kernel-dev-maint-appx'>
  5. <title>Kernel Maintenance</title>
  6. <section id='tree-construction'>
  7. <title>Tree Construction</title>
  8. <para>
  9. This section describes construction of the Yocto Project kernel source repositories
  10. as accomplished by the Yocto Project team to create kernel repositories.
  11. These kernel repositories are found under the heading "Yocto Linux Kernel" at
  12. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'>&YOCTO_GIT_URL;/cgit.cgi</ulink>
  13. and can be shipped as part of a Yocto Project release.
  14. The team creates these repositories by
  15. compiling and executing the set of feature descriptions for every BSP
  16. and feature in the product.
  17. Those feature descriptions list all necessary patches,
  18. configuration, branching, tagging and feature divisions found in a kernel.
  19. Thus, the Yocto Project kernel repository (or tree) is built.
  20. </para>
  21. <para>
  22. The existence of this tree allows you to access and clone a particular
  23. Yocto Project kernel repository and use it to build images based on their configurations
  24. and features.
  25. </para>
  26. <para>
  27. You can find the files used to describe all the valid features and BSPs
  28. in the Yocto Project kernel in any clone of the Yocto Project kernel source repository
  29. Git tree.
  30. For example, the following command clones the Yocto Project baseline kernel that
  31. branched off of <filename>linux.org</filename> version 3.4:
  32. <literallayout class='monospaced'>
  33. $ git clone git://git.yoctoproject.org/linux-yocto-3.4
  34. </literallayout>
  35. For another example of how to set up a local Git repository of the Yocto Project
  36. kernel files, see the
  37. "<ulink url='&YOCTO_DOCS_DEV_URL;#local-kernel-files'>Yocto Project Kernel</ulink>" bulleted
  38. item in the Yocto Project Development Manual.
  39. </para>
  40. <para>
  41. Once you have cloned the kernel Git repository on your local machine, you can
  42. switch to the <filename>meta</filename> branch within the repository.
  43. Here is an example that assumes the local Git repository for the kernel is in
  44. a top-level directory named <filename>linux-yocto-3.4</filename>:
  45. <literallayout class='monospaced'>
  46. $ cd linux-yocto-3.4
  47. $ git checkout -b meta origin/meta
  48. </literallayout>
  49. Once you have checked out and switched to the <filename>meta</filename> branch,
  50. you can see a snapshot of all the kernel configuration and feature descriptions that are
  51. used to build that particular kernel repository.
  52. These descriptions are in the form of <filename>.scc</filename> files.
  53. </para>
  54. <para>
  55. You should realize, however, that browsing your local kernel repository
  56. for feature descriptions and patches is not an effective way to determine what is in a
  57. particular kernel branch.
  58. Instead, you should use Git directly to discover the changes in a branch.
  59. Using Git is an efficient and flexible way to inspect changes to the kernel.
  60. <note>
  61. Ground up reconstruction of the complete kernel tree is an action only taken by the
  62. Yocto Project team during an active development cycle.
  63. When you create a clone of the kernel Git repository, you are simply making it
  64. efficiently available for building and development.
  65. </note>
  66. </para>
  67. <para>
  68. The following steps describe what happens when the Yocto Project Team constructs
  69. the Yocto Project kernel source Git repository (or tree) found at
  70. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink> given the
  71. introduction of a new top-level kernel feature or BSP.
  72. These are the actions that effectively create the tree
  73. that includes the new feature, patch or BSP:
  74. <orderedlist>
  75. <listitem><para>A top-level kernel feature is passed to the kernel build subsystem.
  76. Normally, this feature is a BSP for a particular kernel type.</para></listitem>
  77. <listitem><para>The file that describes the top-level feature is located by searching
  78. these system directories:
  79. <itemizedlist>
  80. <listitem><para>The in-tree kernel-cache directories, which are located
  81. in <filename>meta/cfg/kernel-cache</filename></para></listitem>
  82. <listitem><para>Areas pointed to by <filename>SRC_URI</filename> statements
  83. found in recipes</para></listitem>
  84. </itemizedlist>
  85. For a typical build, the target of the search is a
  86. feature description in an <filename>.scc</filename> file
  87. whose name follows this format:
  88. <literallayout class='monospaced'>
  89. &lt;bsp_name&gt;-&lt;kernel_type&gt;.scc
  90. </literallayout>
  91. </para></listitem>
  92. <listitem><para>Once located, the feature description is either compiled into a simple script
  93. of actions, or into an existing equivalent script that is already part of the
  94. shipped kernel.</para></listitem>
  95. <listitem><para>Extra features are appended to the top-level feature description.
  96. These features can come from the
  97. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
  98. variable in recipes.</para></listitem>
  99. <listitem><para>Each extra feature is located, compiled and appended to the script
  100. as described in step three.</para></listitem>
  101. <listitem><para>The script is executed to produce a series of <filename>meta-*</filename>
  102. directories.
  103. These directories are descriptions of all the branches, tags, patches and configurations that
  104. need to be applied to the base Git repository to completely create the
  105. source (build) branch for the new BSP or feature.</para></listitem>
  106. <listitem><para>The base repository is cloned, and the actions
  107. listed in the <filename>meta-*</filename> directories are applied to the
  108. tree.</para></listitem>
  109. <listitem><para>The Git repository is left with the desired branch checked out and any
  110. required branching, patching and tagging has been performed.</para></listitem>
  111. </orderedlist>
  112. </para>
  113. <para>
  114. The kernel tree is now ready for developer consumption to be locally cloned,
  115. configured, and built into a Yocto Project kernel specific to some target hardware.
  116. <note><para>The generated <filename>meta-*</filename> directories add to the kernel
  117. as shipped with the Yocto Project release.
  118. Any add-ons and configuration data are applied to the end of an existing branch.
  119. The full repository generation that is found in the
  120. official Yocto Project kernel repositories at
  121. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'>http://git.yoctoproject.org/cgit.cgi</ulink>
  122. is the combination of all supported boards and configurations.</para>
  123. <para>The technique the Yocto Project team uses is flexible and allows for seamless
  124. blending of an immutable history with additional patches specific to a
  125. deployment.
  126. Any additions to the kernel become an integrated part of the branches.</para>
  127. </note>
  128. </para>
  129. </section>
  130. <section id='build-strategy'>
  131. <title>Build Strategy</title>
  132. <!--
  133. <para>
  134. <emphasis>AR - Darrren Hart:</emphasis> Some parts of this section
  135. need to be in the
  136. "<link linkend='using-an-iterative-development-process'>Using an Iterative Development Process</link>"
  137. section.
  138. Darren needs to figure out which parts and identify them.
  139. </para>
  140. -->
  141. <para>
  142. Once a local Git repository of the Yocto Project kernel exists on a development system,
  143. you can consider the compilation phase of kernel development - building a kernel image.
  144. Some prerequisites exist that are validated by the build process before compilation
  145. starts:
  146. </para>
  147. <itemizedlist>
  148. <listitem><para>The
  149. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> points
  150. to the kernel Git repository.</para></listitem>
  151. <listitem><para>A BSP build branch exists.
  152. This branch has the following form:
  153. <literallayout class='monospaced'>
  154. &lt;kernel_type&gt;/&lt;bsp_name&gt;
  155. </literallayout></para></listitem>
  156. </itemizedlist>
  157. <para>
  158. The OpenEmbedded build system makes sure these conditions exist before attempting compilation.
  159. Other means, however, do exist, such as as bootstrapping a BSP.
  160. </para>
  161. <para>
  162. Before building a kernel, the build process verifies the tree
  163. and configures the kernel by processing all of the
  164. configuration "fragments" specified by feature descriptions in the <filename>.scc</filename>
  165. files.
  166. As the features are compiled, associated kernel configuration fragments are noted
  167. and recorded in the <filename>meta-*</filename> series of directories in their compilation order.
  168. The fragments are migrated, pre-processed and passed to the Linux Kernel
  169. Configuration subsystem (<filename>lkc</filename>) as raw input in the form
  170. of a <filename>.config</filename> file.
  171. The <filename>lkc</filename> uses its own internal dependency constraints to do the final
  172. processing of that information and generates the final <filename>.config</filename> file
  173. that is used during compilation.
  174. </para>
  175. <para>
  176. Using the board's architecture and other relevant values from the board's template,
  177. kernel compilation is started and a kernel image is produced.
  178. </para>
  179. <para>
  180. The other thing that you notice once you configure a kernel is that
  181. the build process generates a build tree that is separate from your kernel's local Git
  182. source repository tree.
  183. This build tree has a name that uses the following form, where
  184. <filename>${MACHINE}</filename> is the metadata name of the machine (BSP) and "kernel_type" is one
  185. of the Yocto Project supported kernel types (e.g. "standard"):
  186. <literallayout class='monospaced'>
  187. linux-${MACHINE}-&lt;kernel_type&gt;-build
  188. </literallayout>
  189. </para>
  190. <para>
  191. The existing support in the <filename>kernel.org</filename> tree achieves this
  192. default functionality.
  193. </para>
  194. <para>
  195. This behavior means that all the generated files for a particular machine or BSP are now in
  196. the build tree directory.
  197. The files include the final <filename>.config</filename> file, all the <filename>.o</filename>
  198. files, the <filename>.a</filename> files, and so forth.
  199. Since each machine or BSP has its own separate
  200. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>
  201. in its own separate branch
  202. of the Git repository, you can easily switch between different builds.
  203. </para>
  204. </section>
  205. </appendix>
  206. <!--
  207. vim: expandtab tw=80 ts=4
  208. -->