kernel-dev-intro.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. <!--SPDX-License-Identifier: CC-BY-2.0-UK-->
  5. <chapter id='kernel-dev-intro'>
  6. <title>Introduction</title>
  7. <section id='kernel-dev-overview'>
  8. <title>Overview</title>
  9. <para>
  10. Regardless of how you intend to make use of the Yocto Project,
  11. chances are you will work with the Linux kernel.
  12. This manual describes how to set up your build host to support
  13. kernel development, introduces the kernel development process,
  14. provides background information on the Yocto Linux kernel
  15. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>,
  16. describes common tasks you can perform using the kernel tools,
  17. shows you how to use the kernel Metadata needed to work with
  18. the kernel inside the Yocto Project, and provides insight into how
  19. the Yocto Project team develops and maintains Yocto Linux kernel
  20. Git repositories and Metadata.
  21. </para>
  22. <para>
  23. Each Yocto Project release has a set of Yocto Linux kernel recipes,
  24. whose Git repositories you can view in the Yocto
  25. <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink> under
  26. the "Yocto Linux Kernel" heading.
  27. New recipes for the release track the latest Linux kernel
  28. upstream developments from
  29. <ulink url='http://www.kernel.org'></ulink> and introduce
  30. newly-supported platforms.
  31. Previous recipes in the release are refreshed and supported for at
  32. least one additional Yocto Project release.
  33. As they align, these previous releases are updated to include the
  34. latest from the Long Term Support Initiative (LTSI) project.
  35. You can learn more about Yocto Linux kernels and LTSI in the
  36. "<link linkend='kernel-big-picture'>Yocto Project Kernel Development and Maintenance</link>"
  37. section.
  38. </para>
  39. <para>
  40. Also included is a Yocto Linux kernel development recipe
  41. (<filename>linux-yocto-dev.bb</filename>) should you want to work
  42. with the very latest in upstream Yocto Linux kernel development and
  43. kernel Metadata development.
  44. <note>
  45. For more on Yocto Linux kernels, see the
  46. "<link linkend='kernel-big-picture'>Yocto Project Kernel Development and Maintenance</link>
  47. section.
  48. </note>
  49. </para>
  50. <para>
  51. The Yocto Project also provides a powerful set of kernel
  52. tools for managing Yocto Linux kernel sources and configuration data.
  53. You can use these tools to make a single configuration change,
  54. apply multiple patches, or work with your own kernel sources.
  55. </para>
  56. <para>
  57. In particular, the kernel tools allow you to generate configuration
  58. fragments that specify only what you must, and nothing more.
  59. Configuration fragments only need to contain the highest level
  60. visible <filename>CONFIG</filename> options as presented by the
  61. Yocto Linux kernel <filename>menuconfig</filename> system.
  62. Contrast this against a complete Yocto Linux kernel
  63. <filename>.config</filename> file, which includes all the automatically
  64. selected <filename>CONFIG</filename> options.
  65. This efficiency reduces your maintenance effort and allows you
  66. to further separate your configuration in ways that make sense for
  67. your project.
  68. A common split separates policy and hardware.
  69. For example, all your kernels might support the
  70. <filename>proc</filename> and <filename>sys</filename> filesystems,
  71. but only specific boards require sound, USB, or specific drivers.
  72. Specifying these configurations individually allows you to aggregate
  73. them together as needed, but maintains them in only one place.
  74. Similar logic applies to separating source changes.
  75. </para>
  76. <para>
  77. If you do not maintain your own kernel sources and need to make
  78. only minimal changes to the sources, the released recipes provide a
  79. vetted base upon which to layer your changes.
  80. Doing so allows you to benefit from the continual kernel
  81. integration and testing performed during development of the
  82. Yocto Project.
  83. </para>
  84. <para>
  85. If, instead, you have a very specific Linux kernel source tree
  86. and are unable to align with one of the official Yocto Linux kernel
  87. recipes, an alternative exists by which you can use the Yocto
  88. Project Linux kernel tools with your own kernel sources.
  89. </para>
  90. <para>
  91. The remainder of this manual provides instructions for completing
  92. specific Linux kernel development tasks.
  93. These instructions assume you are comfortable working with
  94. <ulink url='http://openembedded.org/wiki/Bitbake'>BitBake</ulink>
  95. recipes and basic open-source development tools.
  96. Understanding these concepts will facilitate the process of working
  97. with the kernel recipes.
  98. If you find you need some additional background, please be sure to
  99. review and understand the following documentation:
  100. <itemizedlist>
  101. <listitem><para>
  102. <ulink url='&YOCTO_DOCS_BRIEF_URL;'>Yocto Project Quick Build</ulink>
  103. document.
  104. </para></listitem>
  105. <listitem><para>
  106. <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>.
  107. </para></listitem>
  108. <listitem><para>
  109. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  110. as described in the Yocto Project Application Development and
  111. the Extensible Software Development Kit (eSDK) manual.
  112. </para></listitem>
  113. <listitem><para>
  114. The
  115. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  116. section in the Yocto Project Development Tasks Manual.
  117. </para></listitem>
  118. <listitem><para>
  119. The
  120. "<link linkend='kernel-modification-workflow'>Kernel Modification Workflow</link>"
  121. section.
  122. </para></listitem>
  123. </itemizedlist>
  124. </para>
  125. </section>
  126. <section id='kernel-modification-workflow'>
  127. <title>Kernel Modification Workflow</title>
  128. <para>
  129. Kernel modification involves changing the Yocto Project kernel,
  130. which could involve changing configuration options as well as adding
  131. new kernel recipes.
  132. Configuration changes can be added in the form of configuration
  133. fragments, while recipe modification comes through the kernel's
  134. <filename>recipes-kernel</filename> area in a kernel layer you create.
  135. </para>
  136. <para>
  137. This section presents a high-level overview of the Yocto Project
  138. kernel modification workflow.
  139. The illustration and accompanying list provide general information
  140. and references for further information.
  141. <imagedata fileref="figures/kernel-dev-flow.png"
  142. width="9in" depth="5in" align="center" scalefit="1" />
  143. </para>
  144. <para>
  145. <orderedlist>
  146. <listitem><para>
  147. <emphasis>Set up Your Host Development System to Support
  148. Development Using the Yocto Project</emphasis>:
  149. See the
  150. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-start'>Setting Up the Development Host to Use the Yocto Project</ulink>"
  151. section in the Yocto Project Development Tasks Manual for
  152. options on how to get a build host ready to use the Yocto
  153. Project.
  154. </para></listitem>
  155. <listitem><para>
  156. <emphasis>Set Up Your Host Development System for Kernel Development:</emphasis>
  157. It is recommended that you use <filename>devtool</filename>
  158. and an extensible SDK for kernel development.
  159. Alternatively, you can use traditional kernel development
  160. methods with the Yocto Project.
  161. Either way, there are steps you need to take to get the
  162. development environment ready.</para>
  163. <para>Using <filename>devtool</filename> and the eSDK requires
  164. that you have a clean build of the image and that you are
  165. set up with the appropriate eSDK.
  166. For more information, see the
  167. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>"
  168. section.</para>
  169. <para>Using traditional kernel development requires that you
  170. have the kernel source available in an isolated local Git
  171. repository.
  172. For more information, see the
  173. "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
  174. section.
  175. </para></listitem>
  176. <listitem><para>
  177. <emphasis>Make Changes to the Kernel Source Code if
  178. applicable:</emphasis>
  179. Modifying the kernel does not always mean directly
  180. changing source files.
  181. However, if you have to do this, you make the changes to the
  182. files in the eSDK's Build Directory if you are using
  183. <filename>devtool</filename>.
  184. For more information, see the
  185. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  186. section.</para>
  187. <para>If you are using traditional kernel development, you
  188. edit the source files in the kernel's local Git repository.
  189. For more information, see the
  190. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  191. section.
  192. </para></listitem>
  193. <listitem><para>
  194. <emphasis>Make Kernel Configuration Changes if
  195. Applicable:</emphasis>
  196. If your situation calls for changing the kernel's
  197. configuration, you can use
  198. <link linkend='using-menuconfig'><filename>menuconfig</filename></link>,
  199. which allows you to interactively develop and test the
  200. configuration changes you are making to the kernel.
  201. Saving changes you make with <filename>menuconfig</filename>
  202. updates the kernel's <filename>.config</filename> file.
  203. <note><title>Warning</title>
  204. Try to resist the temptation to directly edit an
  205. existing <filename>.config</filename> file, which is
  206. found in the Build Directory among the source code
  207. used for the build.
  208. Doing so, can produce unexpected results when the
  209. OpenEmbedded build system regenerates the configuration
  210. file.
  211. </note>
  212. Once you are satisfied with the configuration
  213. changes made using <filename>menuconfig</filename>
  214. and you have saved them, you can directly compare the
  215. resulting <filename>.config</filename> file against an
  216. existing original and gather those changes into a
  217. <link linkend='creating-config-fragments'>configuration fragment file</link>
  218. to be referenced from within the kernel's
  219. <filename>.bbappend</filename> file.</para>
  220. <para>Additionally, if you are working in a BSP layer
  221. and need to modify the BSP's kernel's configuration,
  222. you can use <filename>menuconfig</filename>.
  223. </para></listitem>
  224. <listitem><para>
  225. <emphasis>Rebuild the Kernel Image With Your Changes:</emphasis>
  226. Rebuilding the kernel image applies your changes.
  227. Depending on your target hardware, you can verify your changes
  228. on actual hardware or perhaps QEMU.
  229. </para></listitem>
  230. </orderedlist>
  231. The remainder of this developer's guide covers common tasks typically
  232. used during kernel development, advanced Metadata usage, and Yocto Linux
  233. kernel maintenance concepts.
  234. </para>
  235. </section>
  236. </chapter>
  237. <!--
  238. vim: expandtab tw=80 ts=4
  239. -->