kernel-dev-intro.xml 13 KB

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