usingpoky.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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-collections'>'collection'</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 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 setup using the following command:
  96. </para>
  97. <para>
  98. <literallayout class='monospaced'>
  99. $ source poky-init-build-env
  100. </literallayout>
  101. </para>
  102. <para>
  103. Once the Poky build environment is setup, a target can now be built using:
  104. </para>
  105. <para>
  106. <literallayout class='monospaced'>
  107. $ bitbake &lt;target&gt;
  108. </literallayout>
  109. </para>
  110. <para>
  111. The target is the name of the recipe you want to build. Common targets are the
  112. images (in <filename class="directory">meta/packages/images/</filename>)
  113. or the name of a recipe for a specific piece of software like
  114. <application>busybox</application>. More details about the standard images
  115. are available in the <link linkend='ref-images'>image reference section</link>.
  116. </para>
  117. </section>
  118. <section id='usingpoky-install'>
  119. <title>Installing and Using the Result</title>
  120. <para>
  121. Once an image has been built it often needs to be installed. The images/kernels built
  122. by Poky are placed in the <filename class="directory">tmp/deploy/images</filename>
  123. directory. Running qemux86 and qemuarm images is covered in the <link
  124. linkend='intro-quickstart-qemu'>Running an Image</link> section. See your
  125. board/machine documentation for information about how to install these images.
  126. </para>
  127. <section id='usingpoky-install-usbnetworking'>
  128. <title>USB Networking</title>
  129. <para>
  130. Devices commonly have USB connectivity. To connect to the usbnet interface, on
  131. the host machine run:
  132. </para>
  133. <para>
  134. <programlisting>
  135. modprobe usbnet
  136. ifconfig usb0 192.168.0.200
  137. route add 192.168.0.202 usb0
  138. </programlisting>
  139. </para>
  140. </section>
  141. <section id='usingpoky-install-qemu-networking'>
  142. <title>QEMU/USB networking with IP masquerading</title>
  143. <para>
  144. On Ubuntu, Debian or similar distributions you can have the network automatically
  145. configured. You can also enable masquerading between the QEMU system and the rest
  146. of your network. To do this you need to edit <filename>/etc/network/interfaces</filename> to include:
  147. </para>
  148. <para><programlisting>
  149. allow-hotplug tap0
  150. iface tap0 inet static
  151. address 192.168.7.200
  152. netmask 255.255.255.0
  153. network 192.168.7.0
  154. post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
  155. post-up echo 1 > /proc/sys/net/ipv4/ip_forward
  156. post-up iptables -P FORWARD ACCEPT
  157. </programlisting>
  158. </para>
  159. <para>
  160. This ensures the tap0 interface will be up everytime you run QEMU
  161. and it will have network/internet access.
  162. </para>
  163. <para>
  164. Under emulation there are two steps to configure for internet access
  165. via tap0. The first step is to configure routing:
  166. </para>
  167. <para><programlisting>
  168. route add default gw 192.168.7.200 tap0
  169. </programlisting>
  170. </para>
  171. <para>
  172. The second is to configure name resolution which is configured in the
  173. <filename>/etc/resolv.conf</filename> file. The simplest solution is
  174. to copy it's content from the host machine.
  175. </para>
  176. <para>
  177. USB connections to devices can be setup and automated in a similar way.
  178. First add the following to
  179. <filename>/etc/network/interfaces</filename>:
  180. </para>
  181. <para><programlisting>
  182. allow-hotplug usb0
  183. iface usb0 inet static
  184. address 192.168.0.200
  185. netmask 255.255.255.0
  186. network 192.168.0.0
  187. post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24
  188. post-up echo 1 > /proc/sys/net/ipv4/ip_forward
  189. post-up iptables -P FORWARD ACCEPT
  190. </programlisting>
  191. </para>
  192. <para>
  193. and then to configure routing on the device you would use:
  194. </para>
  195. <para><programlisting>
  196. route add default gw 192.168.0.202 usb0
  197. </programlisting>
  198. </para>
  199. </section>
  200. </section>
  201. <section id='usingpoky-debugging'>
  202. <title>Debugging Build Failures</title>
  203. <para>
  204. The exact method for debugging Poky depends on the nature of the
  205. bug(s) and which part of the system they might be from. Standard
  206. debugging practises such as comparing to the last
  207. known working version and examining the changes, reapplying the
  208. changes in steps to identify the one causing the problem etc. are
  209. valid for Poky just like any other system. Its impossible to detail
  210. every possible potential failure here but there are some general
  211. tips to aid debugging:
  212. </para>
  213. <section id='usingpoky-debugging-taskfailures'>
  214. <title>Task Failures</title>
  215. <para>The log file for shell tasks is available in <filename>${WORKDIR}/temp/log.do_taskname.pid</filename>.
  216. For the compile task of busybox 1.01 on the ARM spitz machine, this
  217. might be <filename>tmp/work/armv5te-poky-linux-gnueabi/busybox-1.01/temp/log.do_compile.1234</filename>
  218. for example. To see what bitbake ran to generate that log, look at the <filename>run.do_taskname.pid </filename>
  219. file in the same directory.
  220. </para>
  221. <para>The output from python tasks is sent directly to the console at present.</para>
  222. </section>
  223. <section id='usingpoky-debugging-taskrunning'>
  224. <title>Running specific tasks</title>
  225. <para> Any given package consists of a set of tasks, in most
  226. cases the series is fetch, unpack, patch, configure,
  227. compile, install, package, package_write and build. The
  228. default task is "build" and any tasks this depends on are
  229. built first hence the standard bitbake behaviour. There are
  230. some tasks such as devshell which are not part of the
  231. default build chain. If you wish to run such a task you can
  232. use the "-c" option to bitbake e.g. <command>bitbake
  233. matchbox-desktop -c devshell</command>.
  234. </para>
  235. <para>
  236. If you wish to rerun a task you can use the force option
  237. "-f". A typical usage session might look like: </para>
  238. <para>
  239. <literallayout class='monospaced'>
  240. % bitbake matchbox-desktop
  241. [change some source in the WORKDIR for example]
  242. % bitbake matchbox-desktop -c compile -f
  243. % bitbake matchbox-desktop</literallayout>
  244. </para>
  245. <para>
  246. which would build matchbox-desktop, then recompile it. The
  247. final command reruns all tasks after the compile (basically
  248. the packaging tasks) since bitbake will notice the the
  249. compile has been rerun and hence the other tasks also need
  250. to run again.
  251. </para>
  252. <para>
  253. You can view a list of tasks in a given package by running
  254. the listtasks task e.g. <command>bitbake matchbox-desktop -c
  255. listtasks</command>.
  256. </para>
  257. </section>
  258. <section id='usingpoky-debugging-dependencies'>
  259. <title>Dependency Graphs</title>
  260. <para>
  261. Sometimes it can be hard to see why bitbake wants to build
  262. some other packages before a given package you've specified.
  263. <command>bitbake -g targetname</command> will create
  264. <filename>depends.dot</filename> and
  265. <filename>task-depends.dot</filename> files in the current
  266. directory. They show
  267. which packages and tasks depend on which other packages and
  268. tasks and are useful for debugging purposes.
  269. </para>
  270. </section>
  271. <section id='usingpoky-debugging-bitbake'>
  272. <title>General Bitbake Problems</title>
  273. <para>
  274. Debug output from bitbake can be seen with the "-D" option.
  275. The debug output gives more information about what bitbake
  276. is doing and/or why. Each -D option increases the logging
  277. level, the most common usage being "-DDD".
  278. </para>
  279. <para>
  280. The output from <command>bitbake -DDD -v targetname</command> can reveal why
  281. a certain version of a package might be chosen, why bitbake
  282. picked a certain provider or help in other situations where
  283. bitbake does something you're not expecting.
  284. </para>
  285. </section>
  286. <section id='usingpoky-debugging-buildfile'>
  287. <title>Building with no dependencies</title>
  288. <para>
  289. If you really want to build a specific .bb file, you can use
  290. the form <command>bitbake -b somepath/somefile.bb</command>. Note that this
  291. will not check the dependencies so this option should only
  292. be used when you know its dependencies already exist. You
  293. can specify fragments of the filename and bitbake will see
  294. if it can find a unique match.
  295. </para>
  296. </section>
  297. <section id='usingpoky-debugging-variables'>
  298. <title>Variables</title>
  299. <para>
  300. The "-e" option will dump the resulting environment for
  301. either the configuration (no package specified) or for a
  302. specific package when specified with the "-b" option.
  303. </para>
  304. </section>
  305. <section id='usingpoky-debugging-others'>
  306. <title>Other Tips</title>
  307. <tip>
  308. <para>When adding new packages it is worth keeping an eye open for bad
  309. things creeping into compiler commandlines such as references to local
  310. system files (<filename>/usr/lib/</filename> or <filename>/usr/include/</filename> etc.).
  311. </para>
  312. </tip>
  313. <tip>
  314. <para>
  315. If you want to remove the psplash boot splashscreen, add "psplash=false"
  316. to the kernel commandline and psplash won't load allowing you to see
  317. the console. It's also possible to switch out of the splashscreen by
  318. switching virtual console (Fn+Left or Fn+Right on a Zaurus).
  319. </para>
  320. </tip>
  321. </section>
  322. </section>
  323. </chapter>
  324. <!--
  325. vim: expandtab tw=80 ts=4
  326. -->