kernel-dev-intro.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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_QS_URL;'>Yocto Project Quick Start</ulink>
  102. </para></listitem>
  103. <listitem><para>
  104. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename> workflow</ulink>
  105. as described in the Yocto Project Software Development Kit
  106. (SDK) Developer's Guide.
  107. </para></listitem>
  108. <listitem><para>
  109. The
  110. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  111. section in the Yocto Project Development Tasks Manual.
  112. </para></listitem>
  113. <listitem><para>
  114. The
  115. "<link linkend='kernel-modification-workflow'>Kernel Modification Workflow</link>"
  116. section.
  117. </para></listitem>
  118. </itemizedlist>
  119. </para>
  120. <para>
  121. Finally, while this document focuses on the manual creation of
  122. recipes, patches, and configuration files, the Yocto Project
  123. Board Support Package (BSP) tools are available to automate
  124. this process with existing content and work well to create the
  125. initial framework and boilerplate code.
  126. For details on these tools, see the
  127. "<ulink url='&YOCTO_DOCS_BSP_URL;#using-the-yocto-projects-bsp-tools'>Using the Yocto Project's BSP Tools</ulink>"
  128. section in the Yocto Project Board Support Package (BSP) Developer's
  129. Guide.
  130. </para>
  131. </section>
  132. <section id='kernel-modification-workflow'>
  133. <title>Kernel Modification Workflow</title>
  134. <para>
  135. Kernel modification involves changing the Yocto Project kernel,
  136. which could involve changing configuration options as well as adding
  137. new kernel recipes.
  138. Configuration changes can be added in the form of configuration
  139. fragments, while recipe modification comes through the kernel's
  140. <filename>recipes-kernel</filename> area in a kernel layer you create.
  141. </para>
  142. <para>
  143. This section presents a high-level overview of the Yocto Project
  144. kernel modification workflow.
  145. The illustration and accompanying list provide general information
  146. and references for further information.
  147. <imagedata fileref="figures/kernel-dev-flow.png"
  148. width="9in" depth="5in" align="center" scalefit="1" />
  149. </para>
  150. <para>
  151. <orderedlist>
  152. <listitem><para>
  153. <emphasis>Set Up Your Host Development System to Support
  154. Development Using the Yocto Project:</emphasis>
  155. See the
  156. "<ulink url='&YOCTO_DOCS_QS_URL;#yp-resources'>Setting Up to Use the Yocto Project</ulink>"
  157. section in the Yocto Project Quick Start for options on how
  158. to get a build host ready to use the Yocto Project.
  159. </para></listitem>
  160. <listitem><para>
  161. <emphasis>Set Up Your Host Development System for Kernel Development:</emphasis>
  162. It is recommended that you use <filename>devtool</filename>
  163. and an extensible SDK for kernel development.
  164. Alternatively, you can use traditional kernel development
  165. methods with the Yocto Project.
  166. Either way, there are steps you need to take to get the
  167. development environment ready.</para>
  168. <para>Using <filename>devtool</filename> and the eSDK requires
  169. that you have a clean build of the image and that you are
  170. set up with the appropriate eSDK.
  171. For more information, see the
  172. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>"
  173. section.</para>
  174. <para>Using traditional kernel development requires that you
  175. have the kernel source available in an isolated local Git
  176. repository.
  177. For more information, see the
  178. "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
  179. section.
  180. </para></listitem>
  181. <listitem><para>
  182. <emphasis>Make Changes to the Kernel Source Code if
  183. applicable:</emphasis>
  184. Modifying the kernel does not always mean directly
  185. changing source files.
  186. However, if you have to do this, you make the changes to the
  187. files in the eSDK's Build Directory if you are using
  188. <filename>devtool</filename>.
  189. For more information, see the
  190. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  191. section.</para>
  192. <para>If you are using traditional kernel development, you
  193. edit the source files in the kernel's local Git repository.
  194. For more information, see the
  195. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  196. section.
  197. </para></listitem>
  198. <listitem><para>
  199. <emphasis>Make Kernel Configuration Changes if
  200. Applicable:</emphasis>
  201. If your situation calls for changing the kernel's
  202. configuration, you can use
  203. <link linkend='using-menuconfig'><filename>menuconfig</filename></link>,
  204. which allows you to interactively develop and test the
  205. configuration changes you are making to the kernel.
  206. Saving changes you make with <filename>menuconfig</filename>
  207. updates the kernel's <filename>.config</filename> file.
  208. <note><title>Warning</title>
  209. Try to resist the temptation to directly edit an
  210. existing <filename>.config</filename> file, which is
  211. found in the Build Directory among the source code
  212. used for the build.
  213. Doing so, can produce unexpected results when the
  214. OpenEmbedded build system regenerates the configuration
  215. file.
  216. </note>
  217. Once you are satisfied with the configuration
  218. changes made using <filename>menuconfig</filename>
  219. and you have saved them, you can directly compare the
  220. resulting <filename>.config</filename> file against an
  221. existing original and gather those changes into a
  222. <link linkend='creating-config-fragments'>configuration fragment file</link>
  223. to be referenced from within the kernel's
  224. <filename>.bbappend</filename> file.</para>
  225. <para>Additionally, if you are working in a BSP layer
  226. and need to modify the BSP's kernel's configuration,
  227. you can use the
  228. <ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'><filename>yocto-kernel</filename></ulink>
  229. script as well as <filename>menuconfig</filename>.
  230. The <filename>yocto-kernel</filename> script lets
  231. you interactively set up kernel configurations.
  232. </para></listitem>
  233. <listitem><para>
  234. <emphasis>Rebuild the Kernel Image With Your Changes:</emphasis>
  235. Rebuilding the kernel image applies your changes.
  236. Depending on your target hardware, you can verify your changes
  237. on actual hardware or perhaps QEMU.
  238. </para></listitem>
  239. </orderedlist>
  240. The remainder of this developer's guide covers common tasks typically
  241. used during kernel development, advanced Metadata usage, and Yocto Linux
  242. kernel maintenance concepts.
  243. </para>
  244. </section>
  245. </chapter>
  246. <!--
  247. vim: expandtab tw=80 ts=4
  248. -->