usingpoky.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <chapter id='usingpoky'>
  4. <title>Using Poky</title>
  5. <para>
  6. This section gives an overview of the components that make up Poky
  7. followed by information about running poky builds and dealing with any
  8. problems that may arise.
  9. </para>
  10. <section id='usingpoky-components'>
  11. <title>Poky Overview</title>
  12. <para>
  13. The BitBake task executor together with various types of configuration files form the core of Poky.
  14. This section overviews the BitBake task executor and the
  15. configuration files by describing what they are used for and they they interact.
  16. </para>
  17. <para>
  18. BitBake handles the parsing and execution of the data files.
  19. The data itself is of various types:
  20. <itemizedlist>
  21. <listitem><para>Recipes: Provides details about particular pieces of software</para></listitem>
  22. <listitem><para>Class Data: An abstraction of common build information (e.g. how to build a
  23. Linux kernel).</para></listitem>
  24. <listitem><para>Configuration Data: Defines machine-specific settings, policy decisions, etc.
  25. Configuration data acts a the glue to bind everything together.</para></listitem>
  26. </itemizedlist>
  27. </para>
  28. <para>
  29. BitBake knows how to combine multiple data sources together and refers to each data source
  30. as a <link linkend='usingpoky-changes-layers'>'layer'</link>.
  31. </para>
  32. <para>
  33. Following are some brief details on these core components.
  34. For more detailed information on these components see the
  35. <link linkend='ref-structure'>'Reference: Directory Structure'</link>
  36. appendix.
  37. </para>
  38. <section id='usingpoky-components-bitbake'>
  39. <title>BitBake</title>
  40. <para>
  41. BitBake is the tool at the heart of Poky and is responsible
  42. for parsing the metadata, generating a list of tasks from it
  43. and then executing them. To see a list of the options BitBake
  44. supports look at 'bitbake --help'.
  45. </para>
  46. <para>
  47. The most common usage for BitBake is <filename>bitbake &lt;packagename&gt;</filename>, where
  48. packagename is the name of the package you want to build (referred to as the 'target'
  49. in this manual).
  50. The target often equates to the first part of a <filename>.bb</filename> filename.
  51. So, to run the <filename>matchbox-desktop_1.2.3.bb</filename> file, you
  52. might type the following:
  53. <literallayout class='monospaced'>
  54. $ bitbake matchbox-desktop
  55. </literallayout>
  56. Several different versions of <filename>matchbox-desktop</filename> might exist.
  57. BitBake chooses the one selected by the distribution configuration.
  58. You can get more details about how BitBake chooses between different versions
  59. and providers in the <link linkend='ref-bitbake-providers'>
  60. 'Preferences and Providers'</link> section.
  61. </para>
  62. <para>
  63. BitBake also tries to execute any dependent tasks first.
  64. So for example, before building <filename>matchbox-desktop</filename> BitBake
  65. would build a cross compiler and glibc if they had not already been built.
  66. </para>
  67. <para>
  68. A useful BitBake option to consider is the <filename>-k</filename> or
  69. <filename>&dash;&dash;continue</filename> option.
  70. This option instructs BitBake to try and continue processing the job as much
  71. as possible even after encountering an error. When an error occurs the target that
  72. failed and those that depend on it cannot be remade. However, when you use this
  73. option other dependencies can still be processed.
  74. </para>
  75. </section>
  76. <section id='usingpoky-components-metadata'>
  77. <title>Metadata (Recipes)</title>
  78. <para>
  79. The <filename>.bb</filename> files are usually referred to as 'recipes'.
  80. In general, a recipe contains information about a single piece of software such
  81. as from where to download the source patches (if any are needed), which special
  82. configuration options to apply, how to compile the source files, and how to
  83. package the compiled output.
  84. </para>
  85. <para>
  86. The term 'package' can also be used to describe recipes.
  87. However, since the same word is used for the packaged output from Poky (i.e. .ipk or .deb
  88. files), this document avoids it.
  89. </para>
  90. </section>
  91. <section id='usingpoky-components-classes'>
  92. <title>Classes</title>
  93. <para>
  94. Class files (<filename>.bbclass</filename>) contain information that is useful to share
  95. between metadata files.
  96. An example is the autotools class, which contains
  97. common settings for any application that autotools uses.
  98. The <link linkend='ref-classes'>Reference: Classes</link> appendix provides details
  99. about common classes and how to use them.
  100. </para>
  101. </section>
  102. <section id='usingpoky-components-configuration'>
  103. <title>Configuration</title>
  104. <para>
  105. The configuration files (<filename>.conf</filename>) define various configuration variables
  106. that govern what Poky does.
  107. These files are split into several areas that define machine configuration options,
  108. distribution configuration options, compiler tuning options, general common configuration
  109. options and user configuration options (<filename>local.conf</filename>).
  110. </para>
  111. </section>
  112. </section>
  113. <section id='usingpoky-build'>
  114. <title>Running a Build</title>
  115. <para>
  116. First the Poky build environment needs to be set up using the following command:
  117. </para>
  118. <para>
  119. <literallayout class='monospaced'>
  120. $ source poky-init-build-env [build_dir]
  121. </literallayout>
  122. </para>
  123. <para>
  124. The build_dir is the dir containing all the build's object files. The default
  125. build dir is poky-dir/build. A different build_dir can be used for each of the targets.
  126. For example, ~/build/x86 for a qemux86 target, and ~/build/arm for a qemuarm target.
  127. Please refer to <link linkend="structure-core-script">poky-init-build-env</link>
  128. for more detailed information.
  129. </para>
  130. <para>
  131. Once the Poky build environment is set up, a target can be built using:
  132. </para>
  133. <para>
  134. <literallayout class='monospaced'>
  135. $ bitbake &lt;target&gt;
  136. </literallayout>
  137. </para>
  138. <para>
  139. The target is the name of the recipe you want to build.
  140. Common targets are the images in <filename>meta/recipes-core/images</filename>,
  141. <filename>/meta/recipes-sato/images</filename>, etc.
  142. Or, the target can be the name of a recipe for a specific piece of software such as
  143. <application>busybox</application>.
  144. For more details about the standard images available, see the
  145. <link linkend="ref-images">'Reference: Images'</link> appendix.
  146. </para>
  147. <note>
  148. Building an image without GNU Public License Version 3 (GPLv3) components is
  149. only supported for minimal and base images.
  150. See <link linkend='ref-images'>'Reference: Images'</link> for more information.
  151. </note>
  152. <note>
  153. When building an image using GPL components you need to maintain your original
  154. settings and not switch back and forth applying different versions of the GNU
  155. Public License. If you rebuild using different versions of GPL you can get
  156. dependency errors due to some components not being rebuilt.
  157. </note>
  158. </section>
  159. <section id='usingpoky-install'>
  160. <title>Installing and Using the Result</title>
  161. <para>
  162. Once an image has been built it often needs to be installed.
  163. The images/kernels built by Poky are placed in the
  164. <filename class="directory">tmp/deploy/images</filename> directory.
  165. Running qemux86 and qemuarm images is described in the
  166. 'Using Pre-Built Binaries and QEMU' section of the Yocto Project Quick Start.
  167. See <ulink url="http://www.yoctoproject.org//docs/yocto-quick-start/yocto-project-qs.html"/>
  168. for the guide.
  169. For information about how to install these images, see the documentation for your
  170. particular board/machine.
  171. </para>
  172. </section>
  173. <section id='usingpoky-debugging'>
  174. <title>Debugging Build Failures</title>
  175. <para>
  176. The exact method for debugging Poky depends on the nature of the
  177. problem and on the system's area from which the bug originates.
  178. Standard debugging practices such as comparison against the last
  179. known working version with examination of the changes and the re-application of steps
  180. to identify the one causing the problem are
  181. valid for Poky just as they are for any other system.
  182. Even though it is impossible to detail every possible potential failure,
  183. here are some general tips to aid in debugging:
  184. </para>
  185. <section id='usingpoky-debugging-taskfailures'>
  186. <title>Task Failures</title>
  187. <para>The log file for shell tasks is available in <filename>${WORKDIR}/temp/log.do_taskname.pid</filename>.
  188. For example, the "compile" task of busybox 1.01 on the ARM spitz machine might be
  189. <filename>tmp/work/armv5te-poky-linux-gnueabi/busybox-1.01/temp/log.do_compile.1234</filename>.
  190. To see what BitBake runs to generate that log, look at the corresponding
  191. <filename>run.do_taskname.pid </filename> file located in the same directory.
  192. </para>
  193. <para>
  194. Presently, the output from python tasks is sent directly to the console.
  195. </para>
  196. </section>
  197. <section id='usingpoky-debugging-taskrunning'>
  198. <title>Running Specific Tasks</title>
  199. <para>
  200. Any given package consists of a set of tasks.
  201. In most cases the series is: fetch, unpack, patch, configure,
  202. compile, install, package, package_write and build.
  203. The default task is "build" and any tasks on which it depends build first - hence,
  204. the standard BitBake behaviour.
  205. Some tasks exist, such as devshell, that are not part of the default build chain.
  206. If you wish to run a task that is not part of the default build chain you can use the
  207. "-c" option in BitBake as follows:
  208. <literallayout class='monospaced'>
  209. $ bitbake matchbox-desktop -c devshell
  210. </literallayout>
  211. </para>
  212. <para>
  213. If you wish to rerun a task use the force option "-f".
  214. For example, the following sequence forces recompilation after changing files in the
  215. working directory.
  216. </para>
  217. <para>
  218. <literallayout class='monospaced'>
  219. $ bitbake matchbox-desktop
  220. [make some changes to the source code in the WORKDIR]
  221. $ bitbake matchbox-desktop -c compile -f
  222. $ bitbake matchbox-desktop
  223. </literallayout>
  224. </para>
  225. <para>
  226. This sequence first builds <filename>matchbox-desktop</filename> and then recompiles it.
  227. The last command reruns all tasks, basically the packaging tasks, after the compile.
  228. BitBake recognizes that the "compile" task was rerun and therefore understands that the other
  229. tasks also need to be run again.
  230. </para>
  231. <para>
  232. You can view a list of tasks in a given package by running the "listtasks" task.
  233. For example:
  234. <literallayout class='monospaced'>
  235. $ bitbake matchbox-desktop -c
  236. </literallayout>
  237. The results are in the file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
  238. </para>
  239. </section>
  240. <section id='usingpoky-debugging-dependencies'>
  241. <title>Dependency Graphs</title>
  242. <para>
  243. Sometimes it can be hard to see why BitBake wants to build some other packages before a given
  244. package you've specified.
  245. The <filename>bitbake -g targetname</filename> command creates the <filename>depends.dot</filename> and
  246. <filename>task-depends.dot</filename> files in the current directory.
  247. These files show the package and task dependencies and are useful for debugging problems.
  248. You can use the <filename>bitbake -g -u depexp targetname</filename> command to display the results
  249. in a more human-readable form.
  250. </para>
  251. </section>
  252. <section id='usingpoky-debugging-bitbake'>
  253. <title>General BitBake Problems</title>
  254. <para>
  255. You can see debug output from BitBake by using the "-D" option.
  256. The debug output gives more information about what BitBake
  257. is doing and the reason behind it.
  258. Each "-D" option you use increases the logging level.
  259. The most common usage is <filename>-DDD</filename>.
  260. </para>
  261. <para>
  262. The output from <filename>bitbake -DDD -v targetname</filename> can reveal why
  263. BitBake chose a certain version of a package or why BitBake
  264. picked a certain provider.
  265. This command could also help you in a situation where you think BitBake did something
  266. unexpected.
  267. </para>
  268. </section>
  269. <section id='usingpoky-debugging-buildfile'>
  270. <title>Building with No Dependencies</title>
  271. <para>
  272. If you really want to build a specific <filename>.bb</filename> file, you can use
  273. the command form <filename>bitbake -b somepath/somefile.bb</filename>.
  274. This command form does not check for dependencies so you should use it
  275. only when you know its dependencies already exist.
  276. You can also specify fragments of the filename and BitBake checks for a unique match.
  277. </para>
  278. </section>
  279. <section id='usingpoky-debugging-variables'>
  280. <title>Variables</title>
  281. <para>
  282. The "-e" option dumps the resulting environment for
  283. either the configuration (no package specified) or for a
  284. specific package when specified with the "-b" option.
  285. </para>
  286. </section>
  287. <section id='usingpoky-debugging-others'>
  288. <title>Other Tips</title>
  289. <tip>
  290. <para>
  291. When adding new packages it is worth watching for undesireable items making their way
  292. into compiler command lines.
  293. For example, you do not want references to local system files like
  294. <filename>/usr/lib/</filename> or <filename>/usr/include/</filename>.
  295. </para>
  296. </tip>
  297. <tip>
  298. <para>
  299. If you want to remove the psplash boot splashscreen, add "psplash=false"
  300. to the kernel command line.
  301. Doing so prevents psplash from loading thus allowing you to see the console.
  302. It is also possible to switch out of the splashscreen by
  303. switching the virtual console (e.g. Fn+Left or Fn+Right on a Zaurus).
  304. </para>
  305. </tip>
  306. </section>
  307. </section>
  308. </chapter>
  309. <!--
  310. vim: expandtab tw=80 ts=4
  311. -->