usingpoky.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. following 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. At the core of Poky is the bitbake task executor together with various types of
  14. configuration files. This section gives an overview of bitbake and the
  15. configuration files, in particular what they are used for, and how they
  16. interact.
  17. </para>
  18. <para>
  19. Bitbake handles the parsing and execution of the data
  20. files. The data itself is of various types; recipes which give
  21. details about particular pieces of software, class data which is an
  22. abstraction of common build information (e.g. how to build a Linux kernel)
  23. and configuration data for machines, policy decisions, etc., which acts as
  24. a glue and binds everything together. Bitbake knows how to combine multiple
  25. data sources together, each data source being referred to as a <link
  26. linkend='usingpoky-changes-layers'>'layer'</link>.
  27. </para>
  28. <para>
  29. The <link linkend='ref-structure'>directory structure walkthrough</link>
  30. section gives details on the meaning of specific directories but some
  31. brief details on the core components follows:
  32. </para>
  33. <section id='usingpoky-components-bitbake'>
  34. <title>Bitbake</title>
  35. <para>
  36. Bitbake is the tool at the heart of Poky and is responsible
  37. for parsing the metadata, generating a list of tasks from it
  38. and then executing them. To see a list of the options it
  39. supports look at <command>bitbake --help</command>.
  40. </para>
  41. <para>
  42. The most common usage is <command>bitbake packagename</command> where
  43. packagename is the name of the package you wish to build
  44. (from now on called the target). This often equates to the first part of a .bb
  45. filename, so to run the <filename>matchbox-desktop_1.2.3.bb</filename> file, you
  46. might type <command>bitbake matchbox-desktop</command>.
  47. Several different versions of matchbox-desktop might exist and
  48. bitbake will choose the one selected by the distribution configuration
  49. (more details about how bitbake chooses between different versions
  50. and providers is available in the <link linkend='ref-bitbake-providers'>
  51. 'Preferences and Providers' section</link>). Bitbake will also try to execute any
  52. dependent tasks first so before building matchbox-desktop it
  53. would build a cross compiler and glibc if not already built.
  54. </para>
  55. </section>
  56. <section id='usingpoky-components-metadata'>
  57. <title>Metadata (Recipes)</title>
  58. <para>
  59. The .bb files are usually referred to as 'recipes'. In general, a
  60. recipe contains information about a single piece of software such
  61. as where to download the source, any patches that are needed,
  62. any special configuration options, how to compile the source files
  63. and how to package the compiled output.
  64. </para>
  65. <para>
  66. 'package' can also be used to describe recipes but since the same
  67. word is used for the packaged output from Poky (i.e. .ipk or .deb
  68. files), this document will avoid it.
  69. </para>
  70. </section>
  71. <section id='usingpoky-components-classes'>
  72. <title>Classes</title>
  73. <para>
  74. Class (.bbclass) files contain information which is useful to share
  75. between metadata files. An example is the autotools class which contains
  76. the common settings that any application using autotools would use. The
  77. <link linkend='ref-classes'>classes reference section</link> gives details
  78. on common classes and how to use them.
  79. </para>
  80. </section>
  81. <section id='usingpoky-components-configuration'>
  82. <title>Configuration</title>
  83. <para>
  84. The configuration (.conf) files define various configuration variables
  85. which govern what Poky does. These are split into several areas, such
  86. as machine configuration options, distribution configuration options,
  87. compiler tuning options, general common configuration and user
  88. configuration (local.conf).
  89. </para>
  90. </section>
  91. </section>
  92. <section id='usingpoky-build'>
  93. <title>Running a Build</title>
  94. <para>
  95. First the Poky build environment needs to be set up using the following command:
  96. </para>
  97. <para>
  98. <literallayout class='monospaced'>
  99. $ source poky-init-build-env [build_dir]
  100. </literallayout>
  101. </para>
  102. <para>
  103. The build_dir is the dir containing all the building object files. The default
  104. build dir is poky-dir/build. Multiple build_dir can be used for different targets.
  105. For example, ~/build/x86 for qemux86 target, and ~/build/arm for qemuarm target.
  106. Please refer to <link linkend="structure-core-script">poky-init-build-env</link>
  107. for detail info
  108. </para>
  109. <para>
  110. Once the Poky build environment is set up, a target can now be built using:
  111. </para>
  112. <para>
  113. <literallayout class='monospaced'>
  114. $ bitbake &lt;target&gt;
  115. $ bitbake qemu-native
  116. </literallayout>
  117. </para>
  118. <para>
  119. The target is the name of the recipe you want to build. Common targets are the
  120. images (in <filename class="directory">meta/packages/images/</filename>)
  121. or the name of a recipe for a specific piece of software like
  122. <application>busybox</application>. More details about the standard images
  123. are available in the <link linkend='ref-images'>image reference section</link>.
  124. The qemu-native target will build the poky customized qemu, and will be used
  125. by runqemu script later.
  126. </para>
  127. </section>
  128. <section id='usingpoky-install'>
  129. <title>Installing and Using the Result</title>
  130. <para>
  131. Once an image has been built it often needs to be installed. The images/kernels built
  132. by Poky are placed in the <filename class="directory">tmp/deploy/images</filename>
  133. directory. Running qemux86 and qemuarm images is covered in the <link
  134. linkend='intro-quickstart-qemu'>Running an Image</link> section. See your
  135. board/machine documentation for information about how to install these images.
  136. </para>
  137. </section>
  138. <section id='usingpoky-debugging'>
  139. <title>Debugging Build Failures</title>
  140. <para>
  141. The exact method for debugging Poky depends on the nature of the
  142. bug(s) and which part of the system they might be from. Standard
  143. debugging practises such as comparing to the last
  144. known working version and examining the changes, reapplying the
  145. changes in steps to identify the one causing the problem etc. are
  146. valid for Poky just like any other system. It's impossible to detail
  147. every possible potential failure here but there are some general
  148. tips to aid debugging:
  149. </para>
  150. <section id='usingpoky-debugging-taskfailures'>
  151. <title>Task Failures</title>
  152. <para>The log file for shell tasks is available in <filename>${WORKDIR}/temp/log.do_taskname.pid</filename>.
  153. For the compile task of busybox 1.01 on the ARM spitz machine, this
  154. might be <filename>tmp/work/armv5te-poky-linux-gnueabi/busybox-1.01/temp/log.do_compile.1234</filename>
  155. for example. To see what bitbake ran to generate that log, look at the <filename>run.do_taskname.pid </filename>
  156. file in the same directory.
  157. </para>
  158. <para>The output from python tasks is sent directly to the console at present.</para>
  159. </section>
  160. <section id='usingpoky-debugging-taskrunning'>
  161. <title>Running specific tasks</title>
  162. <para> Any given package consists of a set of tasks, in most
  163. cases the series is fetch, unpack, patch, configure,
  164. compile, install, package, package_write and build. The
  165. default task is "build" and any tasks this depends on are
  166. built first hence the standard bitbake behaviour. There are
  167. some tasks such as devshell which are not part of the
  168. default build chain. If you wish to run such a task you can
  169. use the "-c" option to bitbake e.g. <command>bitbake
  170. matchbox-desktop -c devshell</command>.
  171. </para>
  172. <para>
  173. If you wish to rerun a task you can use the force option
  174. "-f". A typical usage session might look like: </para>
  175. <para>
  176. <literallayout class='monospaced'>
  177. % bitbake matchbox-desktop
  178. [change some source in the WORKDIR for example]
  179. % bitbake matchbox-desktop -c compile -f
  180. % bitbake matchbox-desktop</literallayout>
  181. </para>
  182. <para>
  183. which would build matchbox-desktop, then recompile it. The
  184. final command reruns all tasks after the compile (basically
  185. the packaging tasks) since bitbake will notice that the
  186. compile has been rerun and hence the other tasks also need
  187. to run again.
  188. </para>
  189. <para>
  190. You can view a list of tasks in a given package by running
  191. the listtasks task e.g. <command>bitbake matchbox-desktop -c
  192. listtasks</command>, and the result is in file ${WORKDIR}/temp/log.do_listtasks.pid.
  193. </para>
  194. </section>
  195. <section id='usingpoky-debugging-dependencies'>
  196. <title>Dependency Graphs</title>
  197. <para>
  198. Sometimes it can be hard to see why bitbake wants to build
  199. some other packages before a given package you've specified.
  200. <command>bitbake -g targetname</command> will create
  201. <filename>depends.dot</filename> and
  202. <filename>task-depends.dot</filename> files in the current
  203. directory. They show
  204. which packages and tasks depend on which other packages and
  205. tasks and are useful for debugging purposes.
  206. <command>"bitbake -g -u depexp targetname"</command> will show result
  207. in more human-readable GUI style.
  208. </para>
  209. </section>
  210. <section id='usingpoky-debugging-bitbake'>
  211. <title>General Bitbake Problems</title>
  212. <para>
  213. Debug output from bitbake can be seen with the "-D" option.
  214. The debug output gives more information about what bitbake
  215. is doing and/or why. Each -D option increases the logging
  216. level, the most common usage being "-DDD".
  217. </para>
  218. <para>
  219. The output from <command>bitbake -DDD -v targetname</command> can reveal why
  220. a certain version of a package might be chosen, why bitbake
  221. picked a certain provider or help in other situations where
  222. bitbake does something you're not expecting.
  223. </para>
  224. </section>
  225. <section id='usingpoky-debugging-buildfile'>
  226. <title>Building with no dependencies</title>
  227. <para>
  228. If you really want to build a specific .bb file, you can use
  229. the form <command>bitbake -b somepath/somefile.bb</command>. Note that this
  230. will not check the dependencies so this option should only
  231. be used when you know its dependencies already exist. You
  232. can specify fragments of the filename and bitbake will see
  233. if it can find a unique match.
  234. </para>
  235. </section>
  236. <section id='usingpoky-debugging-variables'>
  237. <title>Variables</title>
  238. <para>
  239. The "-e" option will dump the resulting environment for
  240. either the configuration (no package specified) or for a
  241. specific package when specified with the "-b" option.
  242. </para>
  243. </section>
  244. <section id='usingpoky-debugging-others'>
  245. <title>Other Tips</title>
  246. <tip>
  247. <para>When adding new packages it is worth keeping an eye open for bad
  248. things creeping into compiler commandlines such as references to local
  249. system files (<filename>/usr/lib/</filename> or <filename>/usr/include/</filename> etc.).
  250. </para>
  251. </tip>
  252. <tip>
  253. <para>
  254. If you want to remove the psplash boot splashscreen, add "psplash=false"
  255. to the kernel commandline and psplash won't load allowing you to see
  256. the console. It's also possible to switch out of the splashscreen by
  257. switching virtual console (Fn+Left or Fn+Right on a Zaurus).
  258. </para>
  259. </tip>
  260. </section>
  261. </section>
  262. </chapter>
  263. <!--
  264. vim: expandtab tw=80 ts=4
  265. -->