blob: 13d9ad6ab758bbea2ada9e53caa84ad70328a83f [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001<!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
5<chapter id='usingpoky'>
6<title>Using the Yocto Project</title>
7
8 <para>
9 This chapter describes common usage for the Yocto Project.
10 The information is introductory in nature as other manuals in the Yocto Project
11 documentation set provide more details on how to use the Yocto Project.
12 </para>
13
14<section id='usingpoky-build'>
15 <title>Running a Build</title>
16
17 <para>
18 This section provides a summary of the build process and provides information
19 for less obvious aspects of the build process.
20 For general information on how to build an image using the OpenEmbedded build
21 system, see the
22 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
23 section of the Yocto Project Quick Start.
24 </para>
25
26 <section id='build-overview'>
27 <title>Build Overview</title>
28
29 <para>
30 In the development environment you will need to build an image whenever you change hardware
31 support, add or change system libraries, or add or change services that have dependencies.
32 </para>
33
34 <mediaobject>
35 <imageobject>
36 <imagedata fileref="figures/building-an-image.png" format="PNG" align='center' scalefit='1'/>
37 </imageobject>
38 <caption>
39 <para>Building an Image</para>
40 </caption>
41 </mediaobject>
42
43 <para>
44 The first thing you need to do is set up the OpenEmbedded build
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 environment by sourcing the environment setup script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 (i.e.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047 <link linkend='structure-core-script'><filename>&OE_INIT_FILE;</filename></link>).
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 Here is an example:
49 <literallayout class='monospaced'>
50 $ source &OE_INIT_FILE; [<replaceable>build_dir</replaceable>]
51 </literallayout>
52 </para>
53
54 <para>
55 The <replaceable>build_dir</replaceable> argument is optional and specifies the directory the
56 OpenEmbedded build system uses for the build -
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057 the
58 <link linkend='build-directory'>Build Directory</link>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 If you do not specify a Build Directory, it defaults to a directory
60 named <filename>build</filename> in your current working directory.
61 A common practice is to use a different Build Directory for different targets.
62 For example, <filename>~/build/x86</filename> for a <filename>qemux86</filename>
63 target, and <filename>~/build/arm</filename> for a <filename>qemuarm</filename> target.
64 </para>
65
66 <para>
67 Once the build environment is set up, you can build a target using:
68 <literallayout class='monospaced'>
69 $ bitbake <replaceable>target</replaceable>
70 </literallayout>
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 <note>
72 <para>
73 If you experience a build error due to resources
74 temporarily being unavailable and it appears you
75 should not be having this issue, it might be due
76 to the combination of a 4.3+ Linux kernel and
77 <filename>systemd</filename> version 228+
78 (i.e. see this
79 <ulink url='http://unix.stackexchange.com/questions/253903/creating-threads-fails-with-resource-temporarily-unavailable-with-4-3-kernel'>link</ulink>
80 for information).
81 </para>
82
83 <para>
84 To work around this issue, you can try either
85 of the following:
86 <itemizedlist>
87 <listitem><para>
88 Try the build again.
89 </para></listitem>
90 <listitem><para>
91 Modify the "DefaultTasksMax"
92 <filename>systemd</filename> parameter
93 by uncommenting it and setting it to
94 "infinity".
95 You can find this parameter in the
96 <filename>system.conf</filename> file
97 located in
98 <filename>/etc/systemd</filename>
99 on most systems.
100 </para></listitem>
101 </itemizedlist>
102 </para>
103 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104 </para>
105
106 <para>
107 The <replaceable>target</replaceable> is the name of the recipe you want to build.
108 Common targets are the images in <filename>meta/recipes-core/images</filename>,
109 <filename>meta/recipes-sato/images</filename>, etc. all found in the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500110 <link linkend='source-directory'>Source Directory</link>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 Or, the target can be the name of a recipe for a specific piece of software such as
112 BusyBox.
113 For more details about the images the OpenEmbedded build system supports, see the
114 "<link linkend="ref-images">Images</link>" chapter.
115 </para>
116
117 <note>
118 Building an image without GNU General Public License Version
119 3 (GPLv3), or similarly licensed, components is supported for
120 only minimal and base images.
121 See the "<link linkend='ref-images'>Images</link>" chapter for more information.
122 </note>
123 </section>
124
125 <section id='building-an-image-using-gpl-components'>
126 <title>Building an Image Using GPL Components</title>
127
128 <para>
129 When building an image using GPL components, you need to maintain your original
130 settings and not switch back and forth applying different versions of the GNU
131 General Public License.
132 If you rebuild using different versions of GPL, dependency errors might occur
133 due to some components not being rebuilt.
134 </para>
135 </section>
136</section>
137
138<section id='usingpoky-install'>
139 <title>Installing and Using the Result</title>
140
141 <para>
142 Once an image has been built, it often needs to be installed.
143 The images and kernels built by the OpenEmbedded build system are placed in the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500144 <link linkend='build-directory'>Build Directory</link> in
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145 <filename class="directory">tmp/deploy/images</filename>.
146 For information on how to run pre-built images such as <filename>qemux86</filename>
147 and <filename>qemuarm</filename>, see the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500148 <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink>
149 manual.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 For information about how to install these images, see the documentation for your
151 particular board or machine.
152 </para>
153</section>
154
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600155<section id='usingpoky-debugging-tools-and-techniques'>
156 <title>Debugging Tools and Techniques</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
158 <para>
159 The exact method for debugging build failures depends on the nature of
160 the problem and on the system's area from which the bug originates.
161 Standard debugging practices such as comparison against the last
162 known working version with examination of the changes and the
163 re-application of steps to identify the one causing the problem are
164 valid for the Yocto Project just as they are for any other system.
165 Even though it is impossible to detail every possible potential failure,
166 this section provides some general tips to aid in debugging.
167 </para>
168
169 <para>
170 A useful feature for debugging is the error reporting tool.
171 Configuring the Yocto Project to use this tool causes the
172 OpenEmbedded build system to produce error reporting commands as
173 part of the console output.
174 You can enter the commands after the build completes
175 to log error information
176 into a common database, that can help you figure out what might be
177 going wrong.
178 For information on how to enable and use this feature, see the
179 "<ulink url='&YOCTO_DOCS_DEV_URL;#using-the-error-reporting-tool'>Using the Error Reporting Tool</ulink>"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500180 section in the Yocto Project Development Tasks Manual.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181 </para>
182
183 <para>
184 For discussions on debugging, see the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500185 "<ulink url='&YOCTO_DOCS_DEV_URL;#platdev-gdb-remotedebug'>Debugging With the GNU Project Debugger (GDB) Remotely</ulink>" section
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500186 in the Yocto Project Development Tasks Manual
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500187 and the
188 "<ulink url='&YOCTO_DOCS_SDK_URL;#adt-eclipse'>Working within Eclipse</ulink>"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500189 section in the Yocto Project Application Development and the
190 Extensible Software Development Kit (eSDK) manual.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191 </para>
192
193 <note>
194 The remainder of this section presents many examples of the
195 <filename>bitbake</filename> command.
196 You can learn about BitBake by reading the
197 <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink>.
198 </note>
199
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600200 <section id='usingpoky-debugging-viewing-logs-from-failed-tasks'>
201 <title>Viewing Logs from Failed Tasks</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600203 <para>
204 You can find the log for a task in the file
205 <filename>${</filename><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link><filename>}/temp/log.do_</filename><replaceable>taskname</replaceable>.
206 For example, the log for the
207 <link linkend='ref-tasks-compile'><filename>do_compile</filename></link>
208 task of the QEMU minimal image for the x86 machine
209 (<filename>qemux86</filename>) might be in
210 <filename>tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile</filename>.
211 To see the commands
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500212 <link linkend='bitbake-term'>BitBake</link> ran
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600213 to generate a log, look at the corresponding
214 <filename>run.do_</filename><replaceable>taskname</replaceable>
215 file in the same directory.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500216 </para>
217
218 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600219 <filename>log.do_</filename><replaceable>taskname</replaceable> and
220 <filename>run.do_</filename><replaceable>taskname</replaceable>
221 are actually symbolic links to
222 <filename>log.do_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>
223 and
224 <filename>log.run_</filename><replaceable>taskname</replaceable><filename>.</filename><replaceable>pid</replaceable>,
225 where <replaceable>pid</replaceable> is the PID the task had when
226 it ran.
227 The symlinks always point to the files corresponding to the most
228 recent run.
229 </para>
230 </section>
231
232 <section id='usingpoky-debugging-viewing-variable-values'>
233 <title>Viewing Variable Values</title>
234 <para>
235 BitBake's <filename>-e</filename> option is used to display
236 variable values after parsing.
237 The following command displays the variable values after the
238 configuration files (i.e. <filename>local.conf</filename>,
239 <filename>bblayers.conf</filename>,
240 <filename>bitbake.conf</filename> and so forth) have been
241 parsed:
242 <literallayout class='monospaced'>
243 $ bitbake -e
244 </literallayout>
245 The following command displays variable values after a specific
246 recipe has been parsed.
247 The variables include those from the configuration as well:
248 <literallayout class='monospaced'>
249 $ bitbake -e recipename
250 </literallayout>
251 <note><para>
252 Each recipe has its own private set of variables (datastore).
253 Internally, after parsing the configuration, a copy of the
254 resulting datastore is made prior to parsing each recipe.
255 This copying implies that variables set in one recipe will
256 not be visible to other recipes.</para>
257
258 <para>Likewise, each task within a recipe gets a private
259 datastore based on the recipe datastore, which means that
260 variables set within one task will not be visible to
261 other tasks.</para>
262 </note>
263 </para>
264
265 <para>
266 In the output of <filename>bitbake -e</filename>, each variable is
267 preceded by a description of how the variable got its value,
268 including temporary values that were later overriden.
269 This description also includes variable flags (varflags) set on
270 the variable.
271 The output can be very helpful during debugging.
272 </para>
273
274 <para>
275 Variables that are exported to the environment are preceded by
276 <filename>export</filename> in the output of
277 <filename>bitbake -e</filename>.
278 See the following example:
279 <literallayout class='monospaced'>
280 export CC="i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/ulf/poky/build/tmp/sysroots/qemux86"
281 </literallayout>
282 </para>
283
284 <para>
285 In addition to variable values, the output of the
286 <filename>bitbake -e</filename> and
287 <filename>bitbake -e</filename>&nbsp;<replaceable>recipe</replaceable>
288 commands includes the following information:
289 <itemizedlist>
290 <listitem><para>
291 The output starts with a tree listing all configuration
292 files and classes included globally, recursively listing
293 the files they include or inherit in turn.
294 Much of the behavior of the OpenEmbedded build system
295 (including the behavior of the
296 <link linkend='normal-recipe-build-tasks'>normal recipe build tasks</link>)
297 is implemented in the
298 <link linkend='ref-classes-base'><filename>base</filename></link>
299 class and the classes it inherits, rather than being built
300 into BitBake itself.
301 </para></listitem>
302 <listitem><para>
303 After the variable values, all functions appear in the
304 output.
305 For shell functions, variables referenced within the
306 function body are expanded.
307 If a function has been modified using overrides or
308 using override-style operators like
309 <filename>_append</filename> and
310 <filename>_prepend</filename>, then the final assembled
311 function body appears in the output.
312 </para></listitem>
313 </itemizedlist>
314 </para>
315 </section>
316
317 <section id='viewing-package-information-with-oe-pkgdata-util'>
318 <title>Viewing Package Information with <filename>oe-pkgdata-util</filename></title>
319
320 <para>
321 You can use the <filename>oe-pkgdata-util</filename> command-line
322 utility to query
323 <link linkend='var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></link>
324 and display various package-related information.
325 When you use the utility, you must use it to view information
326 on packages that have already been built.
327 </para>
328
329 <para>
330 Following are a few of the available
331 <filename>oe-pkgdata-util</filename> subcommands.
332 <note>
333 You can use the standard * and ? globbing wildcards as part of
334 package names and paths.
335 </note>
336 <itemizedlist>
337 <listitem><para>
338 <filename>oe-pkgdata-util list-pkgs [</filename><replaceable>pattern</replaceable><filename>]</filename>:
339 Lists all packages that have been built, optionally
340 limiting the match to packages that match
341 <replaceable>pattern</replaceable>.
342 </para></listitem>
343 <listitem><para>
344 <filename>oe-pkgdata-util list-pkg-files&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
345 Lists the files and directories contained in the given
346 packages.
347 <note>
348 <para>
349 A different way to view the contents of a package is
350 to look at the
351 <filename>${</filename><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link><filename>}/packages-split</filename>
352 directory of the recipe that generates the
353 package.
354 This directory is created by the
355 <link linkend='ref-tasks-package'><filename>do_package</filename></link>
356 task and has one subdirectory for each package the
357 recipe generates, which contains the files stored in
358 that package.</para>
359 <para>
360 If you want to inspect the
361 <filename>${WORKDIR}/packages-split</filename>
362 directory, make sure that
363 <link linkend='ref-classes-rm-work'><filename>rm_work</filename></link>
364 is not enabled when you build the recipe.
365 </para>
366 </note>
367 </para></listitem>
368 <listitem><para>
369 <filename>oe-pkgdata-util find-path&nbsp;</filename><replaceable>path</replaceable><filename>&nbsp;...</filename>:
370 Lists the names of the packages that contain the given
371 paths.
372 For example, the following tells us that
373 <filename>/usr/share/man/man1/make.1</filename>
374 is contained in the <filename>make-doc</filename>
375 package:
376 <literallayout class='monospaced'>
377 $ oe-pkgdata-util find-path /usr/share/man/man1/make.1
378 make-doc: /usr/share/man/man1/make.1
379 </literallayout>
380 </para></listitem>
381 <listitem><para>
382 <filename>oe-pkgdata-util lookup-recipe&nbsp;</filename><replaceable>package</replaceable><filename>&nbsp;...</filename>:
383 Lists the name of the recipes that
384 produce the given packages.
385 </para></listitem>
386 </itemizedlist>
387 </para>
388
389 <para>
390 For more information on the <filename>oe-pkgdata-util</filename>
391 command, use the help facility:
392 <literallayout class='monospaced'>
393 $ oe-pkgdata-util &dash;&dash;help
394 $ oe-pkgdata-util <replaceable>subcommand</replaceable> --help
395 </literallayout>
396 </para>
397 </section>
398
399 <section id='usingpoky-viewing-dependencies-between-recipes-and-tasks'>
400 <title>Viewing Dependencies Between Recipes and Tasks</title>
401
402 <para>
403 Sometimes it can be hard to see why BitBake wants to build other
404 recipes before the one you have specified.
405 Dependency information can help you understand why a recipe is
406 built.
407 </para>
408
409 <para>
410 To generate dependency information for a recipe, run the following
411 command:
412 <literallayout class='monospaced'>
413 $ bitbake -g <replaceable>recipename</replaceable>
414 </literallayout>
415 This command writes the following files in the current directory:
416 <itemizedlist>
417 <listitem><para>
418 <filename>pn-buildlist</filename>: A list of
419 recipes/targets involved in building
420 <replaceable>recipename</replaceable>.
421 "Involved" here means that at least one task from the
422 recipe needs to run when building
423 <replaceable>recipename</replaceable> from scratch.
424 Targets that are in
425 <link linkend='var-ASSUME_PROVIDED'><filename>ASSUME_PROVIDED</filename></link>
426 are not listed.
427 </para></listitem>
428 <listitem><para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600429 <filename>task-depends.dot</filename>: A graph showing
430 dependencies between tasks.
431 </para></listitem>
432 </itemizedlist>
433 </para>
434
435 <para>
436 The graphs are in
437 <ulink url='https://en.wikipedia.org/wiki/DOT_%28graph_description_language%29'>DOT</ulink>
438 format and can be converted to images (e.g. using the
439 <filename>dot</filename> tool from
440 <ulink url='http://www.graphviz.org/'>Graphviz</ulink>).
441 <note><title>Notes</title>
442 <itemizedlist>
443 <listitem><para>
444 DOT files use a plain text format.
445 The graphs generated using the
446 <filename>bitbake -g</filename> command are often so
447 large as to be difficult to read without special
448 pruning (e.g. with Bitbake's
449 <filename>-I</filename> option) and processing.
450 Despite the form and size of the graphs, the
451 corresponding <filename>.dot</filename> files can still
452 be possible to read and provide useful information.
453 </para>
454
455 <para>As an example, the
456 <filename>task-depends.dot</filename> file contains
457 lines such as the following:
458 <literallayout class='monospaced'>
459 "libxslt.do_configure" -> "libxml2.do_populate_sysroot"
460 </literallayout>
461 The above example line reveals that the
462 <link linkend='ref-tasks-configure'><filename>do_configure</filename></link>
463 task in <filename>libxslt</filename> depends on the
464 <link linkend='ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></link>
465 task in <filename>libxml2</filename>, which is a normal
466 <link linkend='var-DEPENDS'><filename>DEPENDS</filename></link>
467 dependency between the two recipes.
468 </para></listitem>
469 <listitem><para>
470 For an example of how <filename>.dot</filename> files
471 can be processed, see the
472 <filename>scripts/contrib/graph-tool</filename> Python
473 script, which finds and displays paths between graph
474 nodes.
475 </para></listitem>
476 </itemizedlist>
477 </note>
478 </para>
479
480 <para>
481 You can use a different method to view dependency information
482 by using the following command:
483 <literallayout class='monospaced'>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500484 $ bitbake -g -u taskexp <replaceable>recipename</replaceable>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600485 </literallayout>
486 This command displays a GUI window from which you can view
487 build-time and runtime dependencies for the recipes involved in
488 building <replaceable>recipename</replaceable>.
489 </para>
490 </section>
491
492 <section id='usingpoky-viewing-task-variable-dependencies'>
493 <title>Viewing Task Variable Dependencies</title>
494
495 <para>
496 As mentioned in the
497 "<ulink url='&YOCTO_DOCS_BB_URL;#checksums'>Checksums (Signatures)</ulink>"
498 section of the BitBake User Manual, BitBake tries to automatically
499 determine what variables a task depends on so that it can rerun
500 the task if any values of the variables change.
501 This determination is usually reliable.
502 However, if you do things like construct variable names at runtime,
503 then you might have to manually declare dependencies on those
504 variables using <filename>vardeps</filename> as described in the
505 "<ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'>Variable Flags</ulink>"
506 section of the BitBake User Manual.
507 </para>
508
509 <para>
510 If you are unsure whether a variable dependency is being picked up
511 automatically for a given task, you can list the variable
512 dependencies BitBake has determined by doing the following:
513 <orderedlist>
514 <listitem><para>
515 Build the recipe containing the task:
516 <literallayout class='monospaced'>
517 $ bitbake <replaceable>recipename</replaceable>
518 </literallayout>
519 </para></listitem>
520 <listitem><para>
521 Inside the
522 <link linkend='var-STAMPS_DIR'><filename>STAMPS_DIR</filename></link>
523 directory, find the signature data
524 (<filename>sigdata</filename>) file that corresponds to the
525 task.
526 The <filename>sigdata</filename> files contain a pickled
527 Python database of all the metadata that went into creating
528 the input checksum for the task.
529 As an example, for the
530 <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link>
531 task of the <filename>db</filename> recipe, the
532 <filename>sigdata</filename> file might be found in the
533 following location:
534 <literallayout class='monospaced'>
535 ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
536 </literallayout>
537 For tasks that are accelerated through the shared state
538 (<link linkend='shared-state-cache'>sstate</link>)
539 cache, an additional <filename>siginfo</filename> file is
540 written into
541 <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link>
542 along with the cached task output.
543 The <filename>siginfo</filename> files contain exactly the
544 same information as <filename>sigdata</filename> files.
545 </para></listitem>
546 <listitem><para>
547 Run <filename>bitbake-dumpsig</filename> on the
548 <filename>sigdata</filename> or
549 <filename>siginfo</filename> file.
550 Here is an example:
551 <literallayout class='monospaced'>
552 $ bitbake-dumpsig ${BUILDDIR}/tmp/stamps/i586-poky-linux/db/6.0.30-r1.do_fetch.sigdata.7c048c18222b16ff0bcee2000ef648b1
553 </literallayout>
554 In the output of the above command, you will find a line
555 like the following, which lists all the (inferred) variable
556 dependencies for the task.
557 This list also includes indirect dependencies from
558 variables depending on other variables, recursively.
559 <literallayout class='monospaced'>
560 Task dependencies: ['PV', 'SRCREV', 'SRC_URI', 'SRC_URI[md5sum]', 'SRC_URI[sha256sum]', 'base_do_fetch']
561 </literallayout>
562 <note>
563 Functions (e.g. <filename>base_do_fetch</filename>)
564 also count as variable dependencies.
565 These functions in turn depend on the variables they
566 reference.
567 </note>
568 The output of <filename>bitbake-dumpsig</filename> also includes
569 the value each variable had, a list of dependencies for each
570 variable, and
571 <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHBASE_WHITELIST'><filename>BB_HASHBASE_WHITELIST</filename></ulink>
572 information.
573 </para></listitem>
574 </orderedlist>
575 </para>
576
577 <para>
578 There is also a <filename>bitbake-diffsigs</filename> command for
579 comparing two <filename>siginfo</filename> or
580 <filename>sigdata</filename> files.
581 This command can be helpful when trying to figure out what changed
582 between two versions of a task.
583 If you call <filename>bitbake-diffsigs</filename> with just one
584 file, the command behaves like
585 <filename>bitbake-dumpsig</filename>.
586 </para>
587
588 <para>
589 You can also use BitBake to dump out the signature construction
590 information without executing tasks by using either of the
591 following BitBake command-line options:
592 <literallayout class='monospaced'>
593 &dash;&dash;dump-signatures=<replaceable>SIGNATURE_HANDLER</replaceable>
594 -S <replaceable>SIGNATURE_HANDLER</replaceable>
595 </literallayout>
596 <note>
597 Two common values for
598 <replaceable>SIGNATURE_HANDLER</replaceable> are "none" and
599 "printdiff", which dump only the signature or compare the
600 dumped signature with the cached one, respectively.
601 </note>
602 Using BitBake with either of these options causes BitBake to dump
603 out <filename>sigdata</filename> files in the
604 <filename>stamps</filename> directory for every task it would have
605 executed instead of building the specified target package.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500606 </para>
607 </section>
608
609 <section id='usingpoky-debugging-taskrunning'>
610 <title>Running Specific Tasks</title>
611
612 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600613 Any given recipe consists of a set of tasks.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500614 The standard BitBake behavior in most cases is:
615 <filename>do_fetch</filename>,
616 <filename>do_unpack</filename>,
617 <filename>do_patch</filename>, <filename>do_configure</filename>,
618 <filename>do_compile</filename>, <filename>do_install</filename>,
619 <filename>do_package</filename>,
620 <filename>do_package_write_*</filename>, and
621 <filename>do_build</filename>.
622 The default task is <filename>do_build</filename> and any tasks
623 on which it depends build first.
624 Some tasks, such as <filename>do_devshell</filename>, are not part
625 of the default build chain.
626 If you wish to run a task that is not part of the default build
627 chain, you can use the <filename>-c</filename> option in BitBake.
628 Here is an example:
629 <literallayout class='monospaced'>
630 $ bitbake matchbox-desktop -c devshell
631 </literallayout>
632 </para>
633
634 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600635 The <filename>-c</filename> option respects task dependencies,
636 which means that all other tasks (including tasks from other
637 recipes) that the specified task depends on will be run before the
638 task.
639 Even when you manually specify a task to run with
640 <filename>-c</filename>, BitBake will only run the task if it
641 considers it "out of date".
642 See the
643 "<link linkend='stamp-files-and-the-rerunning-of-tasks'>Stamp Files and the Rerunning of Tasks</link>"
644 section for how BitBake determines whether a task is "out of date".
645 </para>
646
647 <para>
648 If you want to force an up-to-date task to be rerun (e.g.
649 because you made manual modifications to the recipe's
650 <link linkend='var-WORKDIR'><filename>WORKDIR</filename></link>
651 that you want to try out), then you can use the
652 <filename>-f</filename> option.
653 <note>
654 The reason <filename>-f</filename> is never required when
655 running the
656 <link linkend='ref-tasks-devshell'><filename>do_devshell</filename></link>
657 task is because the
658 <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink><filename>]</filename>
659 variable flag is already set for the task.
660 </note>
661 The following example shows one way you can use the
662 <filename>-f</filename> option:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500663 <literallayout class='monospaced'>
664 $ bitbake matchbox-desktop
665 .
666 .
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600667 make some changes to the source code in the work directory
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500668 .
669 .
670 $ bitbake matchbox-desktop -c compile -f
671 $ bitbake matchbox-desktop
672 </literallayout>
673 </para>
674
675 <para>
676 This sequence first builds and then recompiles
677 <filename>matchbox-desktop</filename>.
678 The last command reruns all tasks (basically the packaging tasks)
679 after the compile.
680 BitBake recognizes that the <filename>do_compile</filename>
681 task was rerun and therefore understands that the other tasks
682 also need to be run again.
683 </para>
684
685 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600686 Another, shorter way to rerun a task and all
687 <link linkend='normal-recipe-build-tasks'>normal recipe build tasks</link>
688 that depend on it is to use the <filename>-C</filename>
689 option.
690 <note>
691 This option is upper-cased and is separate from the
692 <filename>-c</filename> option, which is lower-cased.
693 </note>
694 Using this option invalidates the given task and then runs the
695 <link linkend='ref-tasks-build'><filename>do_build</filename></link>
696 task, which is the default task if no task is given, and the
697 tasks on which it depends.
698 You could replace the final two commands in the previous example
699 with the following single command:
700 <literallayout class='monospaced'>
701 $ bitbake matchbox-desktop -C compile
702 </literallayout>
703 Internally, the <filename>-f</filename> and
704 <filename>-C</filename> options work by tainting (modifying) the
705 input checksum of the specified task.
706 This tainting indirectly causes the task and its
707 dependent tasks to be rerun through the normal task dependency
708 mechanisms.
709 <note>
710 BitBake explicitly keeps track of which tasks have been
711 tainted in this fashion, and will print warnings such as the
712 following for builds involving such tasks:
713 <literallayout class='monospaced'>
714 WARNING: /home/ulf/poky/meta/recipes-sato/matchbox-desktop/matchbox-desktop_2.1.bb.do_compile is tainted from a forced run
715 </literallayout>
716 The purpose of the warning is to let you know that the work
717 directory and build output might not be in the clean state they
718 would be in for a "normal" build, depending on what actions
719 you took.
720 To get rid of such warnings, you can remove the work directory
721 and rebuild the recipe, as follows:
722 <literallayout class='monospaced'>
723 $ bitbake matchbox-desktop -c clean
724 $ bitbake matchbox-desktop
725 </literallayout>
726 </note>
727 </para>
728
729 <para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500730 You can view a list of tasks in a given package by running the
731 <filename>do_listtasks</filename> task as follows:
732 <literallayout class='monospaced'>
733 $ bitbake matchbox-desktop -c listtasks
734 </literallayout>
735 The results appear as output to the console and are also in the
736 file <filename>${WORKDIR}/temp/log.do_listtasks</filename>.
737 </para>
738 </section>
739
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500740 <section id='usingpoky-debugging-bitbake'>
741 <title>General BitBake Problems</title>
742
743 <para>
744 You can see debug output from BitBake by using the <filename>-D</filename> option.
745 The debug output gives more information about what BitBake
746 is doing and the reason behind it.
747 Each <filename>-D</filename> option you use increases the logging level.
748 The most common usage is <filename>-DDD</filename>.
749 </para>
750
751 <para>
752 The output from <filename>bitbake -DDD -v</filename> <replaceable>targetname</replaceable> can reveal why
753 BitBake chose a certain version of a package or why BitBake
754 picked a certain provider.
755 This command could also help you in a situation where you think BitBake did something
756 unexpected.
757 </para>
758 </section>
759
760 <section id='development-host-system-issues'>
761 <title>Development Host System Issues</title>
762
763 <para>
764 Sometimes issues on the host development system can cause your
765 build to fail.
766 Following are known, host-specific problems.
767 Be sure to always consult the
768 <ulink url='&YOCTO_RELEASE_NOTES;'>Release Notes</ulink>
769 for a look at all release-related issues.
770 <itemizedlist>
771 <listitem><para><emphasis><filename>glibc-initial</filename> fails to build</emphasis>:
772 If your development host system has the unpatched
773 <filename>GNU Make 3.82</filename>,
774 the
775 <link linkend='ref-tasks-install'><filename>do_install</filename></link>
776 task fails for <filename>glibc-initial</filename> during
777 the build.</para>
778 <para>Typically, every distribution that ships
779 <filename>GNU Make 3.82</filename> as
780 the default already has the patched version.
781 However, some distributions, such as Debian, have
782 <filename>GNU Make 3.82</filename> as an option, which
783 is unpatched.
784 You will see this error on these types of distributions.
785 Switch to <filename>GNU Make 3.81</filename> or patch
786 your <filename>make</filename> to solve the problem.
787 </para></listitem>
788 </itemizedlist>
789 </para>
790 </section>
791
792 <section id='usingpoky-debugging-buildfile'>
793 <title>Building with No Dependencies</title>
794 <para>
795 To build a specific recipe (<filename>.bb</filename> file),
796 you can use the following command form:
797 <literallayout class='monospaced'>
798 $ bitbake -b <replaceable>somepath</replaceable>/<replaceable>somerecipe</replaceable>.bb
799 </literallayout>
800 This command form does not check for dependencies.
801 Consequently, you should use it
802 only when you know existing dependencies have been met.
803 <note>
804 You can also specify fragments of the filename.
805 In this case, BitBake checks for a unique match.
806 </note>
807 </para>
808 </section>
809
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500810 <section id='recipe-logging-mechanisms'>
811 <title>Recipe Logging Mechanisms</title>
812 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600813 The Yocto Project provides several logging functions for producing
814 debugging output and reporting errors and warnings.
815 For Python functions, the following logging functions exist.
816 All of these functions log to
817 <filename>${T}/log.do_</filename><replaceable>task</replaceable>,
818 and can also log to standard output (stdout) with the right
819 settings:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500820 <itemizedlist>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600821 <listitem><para>
822 <filename>bb.plain(</filename><replaceable>msg</replaceable><filename>)</filename>:
823 Writes <replaceable>msg</replaceable> as is to the log while
824 also logging to stdout.
825 </para></listitem>
826 <listitem><para>
827 <filename>bb.note(</filename><replaceable>msg</replaceable><filename>)</filename>:
828 Writes "NOTE: <replaceable>msg</replaceable>" to the log.
829 Also logs to stdout if BitBake is called with "-v".
830 </para></listitem>
831 <listitem><para>
832 <filename>bb.debug(</filename><replaceable>level</replaceable><filename>,&nbsp;</filename><replaceable>msg</replaceable><filename>)</filename>:
833 Writes "DEBUG: <replaceable>msg</replaceable>" to the log.
834 Also logs to stdout if the log level is greater than or
835 equal to <replaceable>level</replaceable>.
836 See the
837 "<ulink url='&YOCTO_DOCS_BB_URL;#usage-and-syntax'>-D</ulink>"
838 option in the BitBake User Manual for more information.
839 </para></listitem>
840 <listitem><para>
841 <filename>bb.warn(</filename><replaceable>msg</replaceable><filename>)</filename>:
842 Writes "WARNING: <replaceable>msg</replaceable>" to the log
843 while also logging to stdout.
844 </para></listitem>
845 <listitem><para>
846 <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>:
847 Writes "ERROR: <replaceable>msg</replaceable>" to the log
848 while also logging to stdout.
849 <note>
850 Calling this function does not cause the task to fail.
851 </note>
852 </para></listitem>
853 <listitem><para>
854 <filename>bb.fatal(</filename><replaceable>msg</replaceable><filename>)</filename>:
855 This logging function is similar to
856 <filename>bb.error(</filename><replaceable>msg</replaceable><filename>)</filename>
857 but also causes the calling task to fail.
858 <note>
859 <filename>bb.fatal()</filename> raises an exception,
860 which means you do not need to put a "return"
861 statement after the function.
862 </note>
863 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500864 </itemizedlist>
865 </para>
866
867 <para>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600868 The same logging functions are also available in shell functions,
869 under the names
870 <filename>bbplain</filename>, <filename>bbnote</filename>,
871 <filename>bbdebug</filename>, <filename>bbwarn</filename>,
872 <filename>bberror</filename>, and <filename>bbfatal</filename>.
873 The
874 <link linkend='ref-classes-logging'><filename>logging</filename></link>
875 class implements these functions.
876 See that class in the
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500877 <filename>meta/classes</filename> folder of the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500878 <link linkend='source-directory'>Source Directory</link>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600879 for information.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500880 </para>
881
882 <section id='logging-with-python'>
883 <title>Logging With Python</title>
884 <para>
885 When creating recipes using Python and inserting code that handles build logs,
886 keep in mind the goal is to have informative logs while keeping the console as
887 "silent" as possible.
888 Also, if you want status messages in the log, use the "debug" loglevel.
889 </para>
890
891 <para>
892 Following is an example written in Python.
893 The code handles logging for a function that determines the
894 number of tasks needed to be run.
895 See the
896 "<link linkend='ref-tasks-listtasks'><filename>do_listtasks</filename></link>"
897 section for additional information:
898 <literallayout class='monospaced'>
899 python do_listtasks() {
900 bb.debug(2, "Starting to figure out the task list")
901 if noteworthy_condition:
902 bb.note("There are 47 tasks to run")
903 bb.debug(2, "Got to point xyz")
904 if warning_trigger:
905 bb.warn("Detected warning_trigger, this might be a problem later.")
906 if recoverable_error:
907 bb.error("Hit recoverable_error, you really need to fix this!")
908 if fatal_error:
909 bb.fatal("fatal_error detected, unable to print the task list")
910 bb.plain("The tasks present are abc")
911 bb.debug(2, "Finished figuring out the tasklist")
912 }
913 </literallayout>
914 </para>
915 </section>
916
917 <section id='logging-with-bash'>
918 <title>Logging With Bash</title>
919 <para>
920 When creating recipes using Bash and inserting code that handles build
921 logs, you have the same goals - informative with minimal console output.
922 The syntax you use for recipes written in Bash is similar to that of
923 recipes written in Python described in the previous section.
924 </para>
925
926 <para>
927 Following is an example written in Bash.
928 The code logs the progress of the <filename>do_my_function</filename> function.
929 <literallayout class='monospaced'>
930 do_my_function() {
931 bbdebug 2 "Running do_my_function"
932 if [ exceptional_condition ]; then
933 bbnote "Hit exceptional_condition"
934 fi
935 bbdebug 2 "Got to point xyz"
936 if [ warning_trigger ]; then
937 bbwarn "Detected warning_trigger, this might cause a problem later."
938 fi
939 if [ recoverable_error ]; then
940 bberror "Hit recoverable_error, correcting"
941 fi
942 if [ fatal_error ]; then
943 bbfatal "fatal_error detected"
944 fi
945 bbdebug 2 "Completed do_my_function"
946 }
947 </literallayout>
948 </para>
949 </section>
950 </section>
951
952 <section id='usingpoky-debugging-others'>
953 <title>Other Tips</title>
954
955 <para>
956 Here are some other tips that you might find useful:
957 <itemizedlist>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600958 <listitem><para>
959 When adding new packages, it is worth watching for
960 undesirable items making their way into compiler command
961 lines.
962 For example, you do not want references to local system
963 files like
964 <filename>/usr/lib/</filename> or
965 <filename>/usr/include/</filename>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500966 </para></listitem>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600967 <listitem><para>
968 If you want to remove the <filename>psplash</filename>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500969 boot splashscreen,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600970 add <filename>psplash=false</filename> to the kernel
971 command line.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500972 Doing so prevents <filename>psplash</filename> from loading
973 and thus allows you to see the console.
974 It is also possible to switch out of the splashscreen by
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600975 switching the virtual console (e.g. Fn+Left or Fn+Right
976 on a Zaurus).
977 </para></listitem>
978 <listitem><para>
979 Removing
980 <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link>
981 (usually <filename>tmp/</filename>, within the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500982 <link linkend='build-directory'>Build Directory</link>)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600983 can often fix temporary build issues.
984 Removing <filename>TMPDIR</filename> is usually a
985 relatively cheap operation, because task output will be
986 cached in
987 <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link>
988 (usually <filename>sstate-cache/</filename>, which is
989 also in the Build Directory).
990 <note>
991 Removing <filename>TMPDIR</filename> might be a
992 workaround rather than a fix.
993 Consequently, trying to determine the underlying cause
994 of an issue before removing the directory is a good
995 idea.
996 </note>
997 </para></listitem>
998 <listitem><para>
999 Understanding how a feature is used in practice within
1000 existing recipes can be very helpful.
1001 It is recommended that you configure some method that
1002 allows you to quickly search through files.</para>
1003
1004 <para>Using GNU Grep, you can use the following shell
1005 function to recursively search through common
1006 recipe-related files, skipping binary files,
1007 <filename>.git</filename> directories, and the
1008 Build Directory (assuming its name starts with
1009 "build"):
1010 <literallayout class='monospaced'>
1011 g() {
1012 grep -Ir \
1013 --exclude-dir=.git \
1014 --exclude-dir='build*' \
1015 --include='*.bb*' \
1016 --include='*.inc*' \
1017 --include='*.conf*' \
1018 --include='*.py*' \
1019 "$@"
1020 }
1021 </literallayout>
1022 Following are some usage examples:
1023 <literallayout class='monospaced'>
1024 $ g FOO # Search recursively for "FOO"
1025 $ g -i foo # Search recursively for "foo", ignoring case
1026 $ g -w FOO # Search recursively for "FOO" as a word, ignoring e.g. "FOOBAR"
1027 </literallayout>
1028 If figuring out how some feature works requires a lot of
1029 searching, it might indicate that the documentation should
1030 be extended or improved.
1031 In such cases, consider filing a documentation bug using
1032 the Yocto Project implementation of
1033 <ulink url='https://bugzilla.yoctoproject.org/'>Bugzilla</ulink>.
1034 For general information on how to submit a bug against
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001035 the Yocto Project, see the Yocto Project Bugzilla
1036 <ulink url='&YOCTO_WIKI_URL;/wiki/Bugzilla_Configuration_and_Bug_Tracking'>wiki page</ulink>"
1037 or the
1038 <ulink url='&YOCTO_DOCS_DEV_URL;#submitting-a-defect-against-the-yocto-project'>Submitting a Defect Against the Yocto Project</ulink>"
1039 section, which is in the Yocto Project Development Tasks
1040 Manual.
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001041 <note>
1042 The manuals might not be the right place to document
1043 variables that are purely internal and have a limited
1044 scope (e.g. internal variables used to implement a
1045 single <filename>.bbclass</filename> file).
1046 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001047 </para></listitem>
1048 </itemizedlist>
1049 </para>
1050 </section>
1051</section>
1052
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001053<section id='ref-quick-emulator-qemu'>
1054 <title>Quick EMUlator (QEMU)</title>
1055
1056 <para>
1057 The Yocto Project uses an implementation of the Quick EMUlator (QEMU)
1058 Open Source project as part of the Yocto Project development "tool
1059 set".
1060 </para>
1061
1062 <para>
1063 Within the context of the Yocto Project, QEMU is an
1064 emulator and virtualization machine that allows you to run a complete
1065 image you have built using the Yocto Project as just another task
1066 on your build system.
1067 QEMU is useful for running and testing images and applications on
1068 supported Yocto Project architectures without having actual hardware.
1069 Among other things, the Yocto Project uses QEMU to run automated
1070 Quality Assurance (QA) tests on final images shipped with each
1071 release.
1072 <note>
1073 This implementation is not the same as QEMU in general.
1074 </note>
1075 This section provides a brief reference for the Yocto Project
1076 implementation of QEMU.
1077 </para>
1078
1079 <para>
1080 For official information and documentation on QEMU in general, see the
1081 following references:
1082 <itemizedlist>
1083 <listitem><para>
1084 <emphasis><ulink url='http://wiki.qemu.org/Main_Page'>QEMU Website</ulink>:</emphasis>
1085 The official website for the QEMU Open Source project.
1086 </para></listitem>
1087 <listitem><para>
1088 <emphasis><ulink url='http://wiki.qemu.org/Manual'>Documentation</ulink>:</emphasis>
1089 The QEMU user manual.
1090 </para></listitem>
1091 </itemizedlist>
1092 </para>
1093
1094 <para>
1095 For information on how to use the Yocto Project implementation of
1096 QEMU, see the
1097 "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>"
1098 chapter in the Yocto Project Development Tasks Manual.
1099 </para>
1100
1101 <section id='qemu-availability'>
1102 <title>QEMU Availability</title>
1103
1104 <para>
1105 QEMU is made available with the Yocto Project a number of ways.
1106 One method is to install a Software Development Kit (SDK).
1107 For more information on how to make sure you have
1108 QEMU available, see
1109 "<ulink url='&YOCTO_DOCS_SDK_URL;#the-qemu-emulator'>The QEMU Emulator</ulink>"
1110 section in the Yocto Project Application Development and the
1111 Extensible Software Development Kit (eSDK) manual.
1112 </para>
1113 </section>
1114
1115 <section id='qemu-performance'>
1116 <title>QEMU Performance</title>
1117
1118 <para>
1119 Using QEMU to emulate your hardware can result in speed issues
1120 depending on the target and host architecture mix.
1121 For example, using the <filename>qemux86</filename> image in the
1122 emulator on an Intel-based 32-bit (x86) host machine is fast
1123 because the target and host architectures match.
1124 On the other hand, using the <filename>qemuarm</filename> image
1125 on the same Intel-based host can be slower.
1126 But, you still achieve faithful emulation of ARM-specific issues.
1127 </para>
1128
1129 <para>
1130 To speed things up, the QEMU images support using
1131 <filename>distcc</filename> to call a cross-compiler outside the
1132 emulated system.
1133 If you used <filename>runqemu</filename> to start QEMU, and the
1134 <filename>distccd</filename> application is present on the host
1135 system, any BitBake cross-compiling toolchain available from the
1136 build system is automatically used from within QEMU simply by
1137 calling <filename>distcc</filename>.
1138 You can accomplish this by defining the cross-compiler variable
1139 (e.g. <filename>export CC="distcc"</filename>).
1140 Alternatively, if you are using a suitable SDK image or the
1141 appropriate stand-alone toolchain is present, the toolchain is
1142 also automatically used.
1143 </para>
1144
1145 <note>
1146 Several mechanisms exist that let you connect to the system
1147 running on the QEMU emulator:
1148 <itemizedlist>
1149 <listitem><para>
1150 QEMU provides a framebuffer interface that makes standard
1151 consoles available.
1152 </para></listitem>
1153 <listitem><para>
1154 Generally, headless embedded devices have a serial port.
1155 If so, you can configure the operating system of the
1156 running image to use that port to run a console.
1157 The connection uses standard IP networking.
1158 </para></listitem>
1159 <listitem><para>
1160 SSH servers exist in some QEMU images.
1161 The <filename>core-image-sato</filename> QEMU image has a
1162 Dropbear secure shell (SSH) server that runs with the root
1163 password disabled.
1164 The <filename>core-image-full-cmdline</filename> and
1165 <filename>core-image-lsb</filename> QEMU images
1166 have OpenSSH instead of Dropbear.
1167 Including these SSH servers allow you to use standard
1168 <filename>ssh</filename> and <filename>scp</filename>
1169 commands.
1170 The <filename>core-image-minimal</filename> QEMU image,
1171 however, contains no SSH server.
1172 </para></listitem>
1173 <listitem><para>
1174 You can use a provided, user-space NFS server to boot
1175 the QEMU session using a local copy of the root
1176 filesystem on the host.
1177 In order to make this connection, you must extract a
1178 root filesystem tarball by using the
1179 <filename>runqemu-extract-sdk</filename> command.
1180 After running the command, you must then point the
1181 <filename>runqemu</filename>
1182 script to the extracted directory instead of a root
1183 filesystem image file.
1184 See the
1185 "<ulink url='&YOCTO_DOCS_DEV_URL;#qemu-running-under-a-network-file-system-nfs-server'>Running Under a Network File System (NFS) Server</ulink>"
1186 section in the Yocto Project Development Tasks Manual for
1187 more information.
1188 </para></listitem>
1189 </itemizedlist>
1190 </note>
1191 </section>
1192
1193 <section id='qemu-command-line-syntax'>
1194 <title>QEMU Command-Line Syntax</title>
1195
1196 <para>
1197 The basic <filename>runqemu</filename> command syntax is as
1198 follows:
1199 <literallayout class='monospaced'>
1200 $ runqemu [<replaceable>option</replaceable> ] [...]
1201 </literallayout>
1202 Based on what you provide on the command line,
1203 <filename>runqemu</filename> does a good job of figuring out what
1204 you are trying to do.
1205 For example, by default, QEMU looks for the most recently built
1206 image according to the timestamp when it needs to look for an
1207 image.
1208 Minimally, through the use of options, you must provide either
1209 a machine name, a virtual machine image
1210 (<filename>*wic.vmdk</filename>), or a kernel image
1211 (<filename>*.bin</filename>).
1212 </para>
1213
1214 <para>
1215 Following is the command-line help output for the
1216 <filename>runqemu</filename> command:
1217 <literallayout class='monospaced'>
1218 $ runqemu --help
1219
1220 Usage: you can run this script with any valid combination
1221 of the following environment variables (in any order):
1222 KERNEL - the kernel image file to use
1223 ROOTFS - the rootfs image file or nfsroot directory to use
1224 MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
1225 Simplified QEMU command-line options can be passed with:
1226 nographic - disable video console
1227 serial - enable a serial console on /dev/ttyS0
1228 slirp - enable user networking, no root privileges is required
1229 kvm - enable KVM when running x86/x86_64 (VT-capable CPU required)
1230 kvm-vhost - enable KVM with vhost when running x86/x86_64 (VT-capable CPU required)
1231 publicvnc - enable a VNC server open to all hosts
1232 audio - enable audio
1233 [*/]ovmf* - OVMF firmware file or base name for booting with UEFI
1234 tcpserial=&lt;port&gt; - specify tcp serial port number
1235 biosdir=&lt;dir&gt; - specify custom bios dir
1236 biosfilename=&lt;filename&gt; - specify bios filename
1237 qemuparams=&lt;xyz&gt; - specify custom parameters to QEMU
1238 bootparams=&lt;xyz&gt; - specify custom kernel parameters during boot
1239 help, -h, --help: print this text
1240
1241 Examples:
1242 runqemu
1243 runqemu qemuarm
1244 runqemu tmp/deploy/images/qemuarm
1245 runqemu tmp/deploy/images/qemux86/&lt;qemuboot.conf&gt;
1246 runqemu qemux86-64 core-image-sato ext4
1247 runqemu qemux86-64 wic-image-minimal wic
1248 runqemu path/to/bzImage-qemux86.bin path/to/nfsrootdir/ serial
1249 runqemu qemux86 iso/hddimg/wic.vmdk/wic.qcow2/wic.vdi/ramfs/cpio.gz...
1250 runqemu qemux86 qemuparams="-m 256"
1251 runqemu qemux86 bootparams="psplash=false"
1252 runqemu path/to/&lt;image&gt;-&lt;machine&gt;.wic
1253 runqemu path/to/&lt;image&gt;-&lt;machine&gt;.wic.vmdk
1254 </literallayout>
1255 </para>
1256 </section>
1257
1258 <section id='runqemu-command-line-options'>
1259 <title><filename>runqemu</filename> Command-Line Options</title>
1260
1261 <para>
1262 Following is a description of <filename>runqemu</filename>
1263 options you can provide on the command line:
1264 <note><title>Tip</title>
1265 If you do provide some "illegal" option combination or perhaps
1266 you do not provide enough in the way of options,
1267 <filename>runqemu</filename> provides appropriate error
1268 messaging to help you correct the problem.
1269 </note>
1270 <itemizedlist>
1271 <listitem><para>
1272 <replaceable>QEMUARCH</replaceable>:
1273 The QEMU machine architecture, which must be "qemuarm",
1274 "qemuarm64", "qemumips", "qemumips64", "qemuppc",
1275 "qemux86", or "qemux86-64".
1276 </para></listitem>
1277 <listitem><para>
1278 <filename><replaceable>VM</replaceable></filename>:
1279 The virtual machine image, which must be a
1280 <filename>.wic.vmdk</filename> file.
1281 Use this option when you want to boot a
1282 <filename>.wic.vmdk</filename> image.
1283 The image filename you provide must contain one of the
1284 following strings: "qemux86-64", "qemux86", "qemuarm",
1285 "qemumips64", "qemumips", "qemuppc", or "qemush4".
1286 </para></listitem>
1287 <listitem><para>
1288 <replaceable>ROOTFS</replaceable>:
1289 A root filesystem that has one of the following
1290 filetype extensions: "ext2", "ext3", "ext4", "jffs2",
1291 "nfs", or "btrfs".
1292 If the filename you provide for this option uses “nfs”, it
1293 must provide an explicit root filesystem path.
1294 </para></listitem>
1295 <listitem><para>
1296 <replaceable>KERNEL</replaceable>:
1297 A kernel image, which is a <filename>.bin</filename> file.
1298 When you provide a <filename>.bin</filename> file,
1299 <filename>runqemu</filename> detects it and assumes the
1300 file is a kernel image.
1301 </para></listitem>
1302 <listitem><para>
1303 <replaceable>MACHINE</replaceable>:
1304 The architecture of the QEMU machine, which must be one
1305 of the following: "qemux86", "qemux86-64", "qemuarm",
1306 "qemuarm64", "qemumips", “qemumips64", or "qemuppc".
1307 The <replaceable>MACHINE</replaceable> and
1308 <replaceable>QEMUARCH</replaceable> options are basically
1309 identical.
1310 If you do not provide a <replaceable>MACHINE</replaceable>
1311 option, <filename>runqemu</filename> tries to determine
1312 it based on other options.
1313 </para></listitem>
1314 <listitem><para>
1315 <filename>ramfs</filename>:
1316 Indicates you are booting an initial RAM disk (initramfs)
1317 image, which means the <filename>FSTYPE</filename> is
1318 <filename>cpio.gz</filename>.
1319 </para></listitem>
1320 <listitem><para>
1321 <filename>iso</filename>:
1322 Indicates you are booting an ISO image, which means the
1323 <filename>FSTYPE</filename> is
1324 <filename>.iso</filename>.
1325 </para></listitem>
1326 <listitem><para>
1327 <filename>nographic</filename>:
1328 Disables the video console, which sets the console to
1329 "ttys0".
1330 </para></listitem>
1331 <listitem><para>
1332 <filename>serial</filename>:
1333 Enables a serial console on
1334 <filename>/dev/ttyS0</filename>.
1335 </para></listitem>
1336 <listitem><para>
1337 <filename>biosdir</filename>:
1338 Establishes a custom directory for BIOS, VGA BIOS and
1339 keymaps.
1340 </para></listitem>
1341 <listitem><para>
1342 <filename>biosfilename</filename>:
1343 Establishes a custom BIOS name.
1344 </para></listitem>
1345 <listitem><para>
1346 <filename>qemuparams=\"<replaceable>xyz</replaceable>\"</filename>:
1347 Specifies custom QEMU parameters.
1348 Use this option to pass options other than the simple
1349 "kvm" and "serial" options.
1350 </para></listitem>
1351 <listitem><para><filename>bootparams=\"<replaceable>xyz</replaceable>\"</filename>:
1352 Specifies custom boot parameters for the kernel.
1353 </para></listitem>
1354 <listitem><para>
1355 <filename>audio</filename>:
1356 Enables audio in QEMU.
1357 The <replaceable>MACHINE</replaceable> option must be
1358 either "qemux86" or "qemux86-64" in order for audio to be
1359 enabled.
1360 Additionally, the <filename>snd_intel8x0</filename>
1361 or <filename>snd_ens1370</filename> driver must be
1362 installed in linux guest.
1363 </para></listitem>
1364 <listitem><para>
1365 <filename>slirp</filename>:
1366 Enables "slirp" networking, which is a different way
1367 of networking that does not need root access
1368 but also is not as easy to use or comprehensive
1369 as the default.
1370 </para></listitem>
1371 <listitem><para id='kvm-cond'>
1372 <filename>kvm</filename>:
1373 Enables KVM when running "qemux86" or "qemux86-64"
1374 QEMU architectures.
1375 For KVM to work, all the following conditions must be met:
1376 <itemizedlist>
1377 <listitem><para>
1378 Your <replaceable>MACHINE</replaceable> must be either
1379qemux86" or "qemux86-64".
1380 </para></listitem>
1381 <listitem><para>
1382 Your build host has to have the KVM modules
1383 installed, which are
1384 <filename>/dev/kvm</filename>.
1385 </para></listitem>
1386 <listitem><para>
1387 The build host <filename>/dev/kvm</filename>
1388 directory has to be both writable and readable.
1389 </para></listitem>
1390 </itemizedlist>
1391 </para></listitem>
1392 <listitem><para>
1393 <filename>kvm-vhost</filename>:
1394 Enables KVM with VHOST support when running "qemux86"
1395 or "qemux86-64" QEMU architectures.
1396 For KVM with VHOST to work, the following conditions must
1397 be met:
1398 <itemizedlist>
1399 <listitem><para>
1400 <link linkend='kvm-cond'>kvm</link> option
1401 conditions must be met.
1402 </para></listitem>
1403 <listitem><para>
1404 Your build host has to have virtio net device, which
1405 are <filename>/dev/vhost-net</filename>.
1406 </para></listitem>
1407 <listitem><para>
1408 The build host <filename>/dev/vhost-net</filename>
1409 directory has to be either readable or writable
1410 and “slirp-enabled”.
1411 </para></listitem>
1412 </itemizedlist>
1413 </para></listitem>
1414 <listitem><para>
1415 <filename>publicvnc</filename>:
1416 Enables a VNC server open to all hosts.
1417 </para></listitem>
1418 </itemizedlist>
1419 </para>
1420 </section>
1421</section>
1422
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001423<section id='maintaining-build-output-quality'>
1424 <title>Maintaining Build Output Quality</title>
1425
1426 <para>
1427 Many factors can influence the quality of a build.
1428 For example, if you upgrade a recipe to use a new version of an upstream software
1429 package or you experiment with some new configuration options, subtle changes
1430 can occur that you might not detect until later.
1431 Consider the case where your recipe is using a newer version of an upstream package.
1432 In this case, a new version of a piece of software might introduce an optional
1433 dependency on another library, which is auto-detected.
1434 If that library has already been built when the software is building,
1435 the software will link to the built library and that library will be pulled
1436 into your image along with the new software even if you did not want the
1437 library.
1438 </para>
1439
1440 <para>
1441 The
1442 <link linkend='ref-classes-buildhistory'><filename>buildhistory</filename></link>
1443 class exists to help you maintain
1444 the quality of your build output.
1445 You can use the class to highlight unexpected and possibly unwanted
1446 changes in the build output.
1447 When you enable build history, it records information about the contents of
1448 each package and image and then commits that information to a local Git
1449 repository where you can examine the information.
1450 </para>
1451
1452 <para>
1453 The remainder of this section describes the following:
1454 <itemizedlist>
1455 <listitem><para>How you can enable and disable
1456 build history</para></listitem>
1457 <listitem><para>How to understand what the build history contains
1458 </para></listitem>
1459 <listitem><para>How to limit the information used for build history
1460 </para></listitem>
1461 <listitem><para>How to examine the build history from both a
1462 command-line and web interface</para></listitem>
1463 </itemizedlist>
1464 </para>
1465
1466 <section id='enabling-and-disabling-build-history'>
1467 <title>Enabling and Disabling Build History</title>
1468
1469 <para>
1470 Build history is disabled by default.
1471 To enable it, add the following <filename>INHERIT</filename>
1472 statement and set the
1473 <link linkend='var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT</filename></link>
1474 variable to "1" at the end of your
1475 <filename>conf/local.conf</filename> file found in the
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001476 <link linkend='build-directory'>Build Directory</link>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001477 <literallayout class='monospaced'>
1478 INHERIT += "buildhistory"
1479 BUILDHISTORY_COMMIT = "1"
1480 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001481 Enabling build history as previously described causes the
1482 OpenEmbedded build system to collect build output information and
1483 commit it as a single commit to a local
1484 <link linkend='git'>Git</link> repository.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001485 <note>
1486 Enabling build history increases your build times slightly,
1487 particularly for images, and increases the amount of disk
1488 space used during the build.
1489 </note>
1490 </para>
1491
1492 <para>
1493 You can disable build history by removing the previous statements
1494 from your <filename>conf/local.conf</filename> file.
1495 </para>
1496 </section>
1497
1498 <section id='understanding-what-the-build-history-contains'>
1499 <title>Understanding What the Build History Contains</title>
1500
1501 <para>
1502 Build history information is kept in
1503 <filename>${</filename><link linkend='var-TOPDIR'><filename>TOPDIR</filename></link><filename>}/buildhistory</filename>
1504 in the Build Directory as defined by the
1505 <link linkend='var-BUILDHISTORY_DIR'><filename>BUILDHISTORY_DIR</filename></link>
1506 variable.
1507 The following is an example abbreviated listing:
1508 <imagedata fileref="figures/buildhistory.png" align="center" width="6in" depth="4in" />
1509 </para>
1510
1511 <para>
1512 At the top level, there is a <filename>metadata-revs</filename> file
1513 that lists the revisions of the repositories for the layers enabled
1514 when the build was produced.
1515 The rest of the data splits into separate
1516 <filename>packages</filename>, <filename>images</filename> and
1517 <filename>sdk</filename> directories, the contents of which are
1518 described below.
1519 </para>
1520
1521 <section id='build-history-package-information'>
1522 <title>Build History Package Information</title>
1523
1524 <para>
1525 The history for each package contains a text file that has
1526 name-value pairs with information about the package.
1527 For example, <filename>buildhistory/packages/i586-poky-linux/busybox/busybox/latest</filename>
1528 contains the following:
1529 <literallayout class='monospaced'>
1530 PV = 1.22.1
1531 PR = r32
1532 RPROVIDES =
1533 RDEPENDS = glibc (>= 2.20) update-alternatives-opkg
1534 RRECOMMENDS = busybox-syslog busybox-udhcpc update-rc.d
1535 PKGSIZE = 540168
1536 FILES = /usr/bin/* /usr/sbin/* /usr/lib/busybox/* /usr/lib/lib*.so.* \
1537 /etc /com /var /bin/* /sbin/* /lib/*.so.* /lib/udev/rules.d \
1538 /usr/lib/udev/rules.d /usr/share/busybox /usr/lib/busybox/* \
1539 /usr/share/pixmaps /usr/share/applications /usr/share/idl \
1540 /usr/share/omf /usr/share/sounds /usr/lib/bonobo/servers
1541 FILELIST = /bin/busybox /bin/busybox.nosuid /bin/busybox.suid /bin/sh \
1542 /etc/busybox.links.nosuid /etc/busybox.links.suid
1543 </literallayout>
1544 Most of these name-value pairs correspond to variables used
1545 to produce the package.
1546 The exceptions are <filename>FILELIST</filename>, which is the
1547 actual list of files in the package, and
1548 <filename>PKGSIZE</filename>, which is the total size of files
1549 in the package in bytes.
1550 </para>
1551
1552 <para>
1553 There is also a file corresponding to the recipe from which the
1554 package came (e.g.
1555 <filename>buildhistory/packages/i586-poky-linux/busybox/latest</filename>):
1556 <literallayout class='monospaced'>
1557 PV = 1.22.1
1558 PR = r32
1559 DEPENDS = initscripts kern-tools-native update-rc.d-native \
1560 virtual/i586-poky-linux-compilerlibs virtual/i586-poky-linux-gcc \
1561 virtual/libc virtual/update-alternatives
1562 PACKAGES = busybox-ptest busybox-httpd busybox-udhcpd busybox-udhcpc \
1563 busybox-syslog busybox-mdev busybox-hwclock busybox-dbg \
1564 busybox-staticdev busybox-dev busybox-doc busybox-locale busybox
1565 </literallayout>
1566 </para>
1567
1568 <para>
1569 Finally, for those recipes fetched from a version control
1570 system (e.g., Git), a file exists that lists source revisions
1571 that are specified in the recipe and lists the actual revisions
1572 used during the build.
1573 Listed and actual revisions might differ when
1574 <link linkend='var-SRCREV'><filename>SRCREV</filename></link>
1575 is set to
1576 <filename>${<link linkend='var-AUTOREV'>AUTOREV</link>}</filename>.
1577 Here is an example assuming
1578 <filename>buildhistory/packages/qemux86-poky-linux/linux-yocto/latest_srcrev</filename>):
1579 <literallayout class='monospaced'>
1580 # SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
1581 SRCREV_machine = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
1582 # SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
1583 SRCREV_meta = "a227f20eff056e511d504b2e490f3774ab260d6f"
1584 </literallayout>
1585 You can use the <filename>buildhistory-collect-srcrevs</filename>
1586 command with the <filename>-a</filename> option to
1587 collect the stored <filename>SRCREV</filename> values
1588 from build history and report them in a format suitable for
1589 use in global configuration (e.g.,
1590 <filename>local.conf</filename> or a distro include file) to
1591 override floating <filename>AUTOREV</filename> values to a
1592 fixed set of revisions.
1593 Here is some example output from this command:
1594 <literallayout class='monospaced'>
1595 $ buildhistory-collect-srcrevs -a
1596 # i586-poky-linux
1597 SRCREV_pn-glibc = "b8079dd0d360648e4e8de48656c5c38972621072"
1598 SRCREV_pn-glibc-initial = "b8079dd0d360648e4e8de48656c5c38972621072"
1599 SRCREV_pn-opkg-utils = "53274f087565fd45d8452c5367997ba6a682a37a"
1600 SRCREV_pn-kmod = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
1601 # x86_64-linux
1602 SRCREV_pn-gtk-doc-stub-native = "1dea266593edb766d6d898c79451ef193eb17cfa"
1603 SRCREV_pn-dtc-native = "65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf"
1604 SRCREV_pn-update-rc.d-native = "eca680ddf28d024954895f59a241a622dd575c11"
1605 SRCREV_glibc_pn-cross-localedef-native = "b8079dd0d360648e4e8de48656c5c38972621072"
1606 SRCREV_localedef_pn-cross-localedef-native = "c833367348d39dad7ba018990bfdaffaec8e9ed3"
1607 SRCREV_pn-prelink-native = "faa069deec99bf61418d0bab831c83d7c1b797ca"
1608 SRCREV_pn-opkg-utils-native = "53274f087565fd45d8452c5367997ba6a682a37a"
1609 SRCREV_pn-kern-tools-native = "23345b8846fe4bd167efdf1bd8a1224b2ba9a5ff"
1610 SRCREV_pn-kmod-native = "fd56638aed3fe147015bfa10ed4a5f7491303cb4"
1611 # qemux86-poky-linux
1612 SRCREV_machine_pn-linux-yocto = "38cd560d5022ed2dbd1ab0dca9642e47c98a0aa1"
1613 SRCREV_meta_pn-linux-yocto = "a227f20eff056e511d504b2e490f3774ab260d6f"
1614 # all-poky-linux
1615 SRCREV_pn-update-rc.d = "eca680ddf28d024954895f59a241a622dd575c11"
1616 </literallayout>
1617 <note>
1618 Here are some notes on using the
1619 <filename>buildhistory-collect-srcrevs</filename> command:
1620 <itemizedlist>
1621 <listitem><para>By default, only values where the
1622 <filename>SRCREV</filename> was
1623 not hardcoded (usually when <filename>AUTOREV</filename>
1624 was used) are reported.
1625 Use the <filename>-a</filename> option to see all
1626 <filename>SRCREV</filename> values.
1627 </para></listitem>
1628 <listitem><para>The output statements might not have any effect
1629 if overrides are applied elsewhere in the build system
1630 configuration.
1631 Use the <filename>-f</filename> option to add the
1632 <filename>forcevariable</filename> override to each output line
1633 if you need to work around this restriction.
1634 </para></listitem>
1635 <listitem><para>The script does apply special handling when
1636 building for multiple machines.
1637 However, the script does place a
1638 comment before each set of values that specifies
1639 which triplet to which they belong as shown above
1640 (e.g., <filename>i586-poky-linux</filename>).
1641 </para></listitem>
1642 </itemizedlist>
1643 </note>
1644 </para>
1645 </section>
1646
1647 <section id='build-history-image-information'>
1648 <title>Build History Image Information</title>
1649
1650 <para>
1651 The files produced for each image are as follows:
1652 <itemizedlist>
1653 <listitem><para><filename>image-files:</filename>
1654 A directory containing selected files from the root
1655 filesystem.
1656 The files are defined by
1657 <link linkend='var-BUILDHISTORY_IMAGE_FILES'><filename>BUILDHISTORY_IMAGE_FILES</filename></link>.
1658 </para></listitem>
1659 <listitem><para><filename>build-id.txt:</filename>
1660 Human-readable information about the build configuration
1661 and metadata source revisions.
1662 This file contains the full build header as printed
1663 by BitBake.</para></listitem>
1664 <listitem><para><filename>*.dot:</filename>
1665 Dependency graphs for the image that are
1666 compatible with <filename>graphviz</filename>.
1667 </para></listitem>
1668 <listitem><para><filename>files-in-image.txt:</filename>
1669 A list of files in the image with permissions,
1670 owner, group, size, and symlink information.
1671 </para></listitem>
1672 <listitem><para><filename>image-info.txt:</filename>
1673 A text file containing name-value pairs with information
1674 about the image.
1675 See the following listing example for more information.
1676 </para></listitem>
1677 <listitem><para><filename>installed-package-names.txt:</filename>
1678 A list of installed packages by name only.</para></listitem>
1679 <listitem><para><filename>installed-package-sizes.txt:</filename>
1680 A list of installed packages ordered by size.
1681 </para></listitem>
1682 <listitem><para><filename>installed-packages.txt:</filename>
1683 A list of installed packages with full package
1684 filenames.</para></listitem>
1685 </itemizedlist>
1686 <note>
1687 Installed package information is able to be gathered and
1688 produced even if package management is disabled for the final
1689 image.
1690 </note>
1691 </para>
1692
1693 <para>
1694 Here is an example of <filename>image-info.txt</filename>:
1695 <literallayout class='monospaced'>
1696 DISTRO = poky
1697 DISTRO_VERSION = 1.7
1698 USER_CLASSES = buildstats image-mklibs image-prelink
1699 IMAGE_CLASSES = image_types
1700 IMAGE_FEATURES = debug-tweaks
1701 IMAGE_LINGUAS =
1702 IMAGE_INSTALL = packagegroup-core-boot run-postinsts
1703 BAD_RECOMMENDATIONS =
1704 NO_RECOMMENDATIONS =
1705 PACKAGE_EXCLUDE =
1706 ROOTFS_POSTPROCESS_COMMAND = write_package_manifest; license_create_manifest; \
1707 write_image_manifest ; buildhistory_list_installed_image ; \
1708 buildhistory_get_image_installed ; ssh_allow_empty_password; \
1709 postinst_enable_logging; rootfs_update_timestamp ; ssh_disable_dns_lookup ;
1710 IMAGE_POSTPROCESS_COMMAND = buildhistory_get_imageinfo ;
1711 IMAGESIZE = 6900
1712 </literallayout>
1713 Other than <filename>IMAGESIZE</filename>, which is the
1714 total size of the files in the image in Kbytes, the
1715 name-value pairs are variables that may have influenced the
1716 content of the image.
1717 This information is often useful when you are trying to determine
1718 why a change in the package or file listings has occurred.
1719 </para>
1720 </section>
1721
1722 <section id='using-build-history-to-gather-image-information-only'>
1723 <title>Using Build History to Gather Image Information Only</title>
1724
1725 <para>
1726 As you can see, build history produces image information,
1727 including dependency graphs, so you can see why something
1728 was pulled into the image.
1729 If you are just interested in this information and not
1730 interested in collecting specific package or SDK information,
1731 you can enable writing only image information without
1732 any history by adding the following to your
1733 <filename>conf/local.conf</filename> file found in the
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001734 <link linkend='build-directory'>Build Directory</link>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001735 <literallayout class='monospaced'>
1736 INHERIT += "buildhistory"
1737 BUILDHISTORY_COMMIT = "0"
1738 BUILDHISTORY_FEATURES = "image"
1739 </literallayout>
1740 Here, you set the
1741 <link linkend='var-BUILDHISTORY_FEATURES'><filename>BUILDHISTORY_FEATURES</filename></link>
1742 variable to use the image feature only.
1743 </para>
1744 </section>
1745
1746 <section id='build-history-sdk-information'>
1747 <title>Build History SDK Information</title>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001748
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001749 <para>
1750 Build history collects similar information on the contents
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001751 of SDKs
1752 (e.g. <filename>bitbake -c populate_sdk imagename</filename>)
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001753 as compared to information it collects for images.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001754 Furthermore, this information differs depending on whether an
1755 extensible or standard SDK is being produced.
1756 </para>
1757
1758 <para>
1759 The following list shows the files produced for SDKs:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001760 <itemizedlist>
1761 <listitem><para><filename>files-in-sdk.txt:</filename>
1762 A list of files in the SDK with permissions,
1763 owner, group, size, and symlink information.
1764 This list includes both the host and target parts
1765 of the SDK.
1766 </para></listitem>
1767 <listitem><para><filename>sdk-info.txt:</filename>
1768 A text file containing name-value pairs with information
1769 about the SDK.
1770 See the following listing example for more information.
1771 </para></listitem>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001772 <listitem><para><filename>sstate-task-sizes.txt:</filename>
1773 A text file containing name-value pairs with information
1774 about task group sizes
1775 (e.g. <filename>do_populate_sysroot</filename> tasks
1776 have a total size).
1777 The <filename>sstate-task-sizes.txt</filename> file
1778 exists only when an extensible SDK is created.
1779 </para></listitem>
1780 <listitem><para><filename>sstate-package-sizes.txt:</filename>
1781 A text file containing name-value pairs with information
1782 for the shared-state packages and sizes in the SDK.
1783 The <filename>sstate-package-sizes.txt</filename> file
1784 exists only when an extensible SDK is created.
1785 </para></listitem>
1786 <listitem><para><filename>sdk-files:</filename>
1787 A folder that contains copies of the files mentioned in
1788 <filename>BUILDHISTORY_SDK_FILES</filename> if the
1789 files are present in the output.
1790 Additionally, the default value of
1791 <filename>BUILDHISTORY_SDK_FILES</filename> is specific
1792 to the extensible SDK although you can set it
1793 differently if you would like to pull in specific files
1794 from the standard SDK.</para>
1795 <para>The default files are
1796 <filename>conf/local.conf</filename>,
1797 <filename>conf/bblayers.conf</filename>,
1798 <filename>conf/auto.conf</filename>,
1799 <filename>conf/locked-sigs.inc</filename>, and
1800 <filename>conf/devtool.conf</filename>.
1801 Thus, for an extensible SDK, these files get copied
1802 into the <filename>sdk-files</filename> directory.
1803 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001804 <listitem><para>The following information appears under
1805 each of the <filename>host</filename>
1806 and <filename>target</filename> directories
1807 for the portions of the SDK that run on the host and
1808 on the target, respectively:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001809 <note>
1810 The following files for the most part are empty
1811 when producing an extensible SDK because this
1812 type of SDK is not constructed from packages as is
1813 the standard SDK.
1814 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001815 <itemizedlist>
1816 <listitem><para><filename>depends.dot:</filename>
1817 Dependency graph for the SDK that is
1818 compatible with <filename>graphviz</filename>.
1819 </para></listitem>
1820 <listitem><para><filename>installed-package-names.txt:</filename>
1821 A list of installed packages by name only.
1822 </para></listitem>
1823 <listitem><para><filename>installed-package-sizes.txt:</filename>
1824 A list of installed packages ordered by size.
1825 </para></listitem>
1826 <listitem><para><filename>installed-packages.txt:</filename>
1827 A list of installed packages with full package
1828 filenames.</para></listitem>
1829 </itemizedlist>
1830 </para></listitem>
1831 </itemizedlist>
1832 </para>
1833
1834 <para>
1835 Here is an example of <filename>sdk-info.txt</filename>:
1836 <literallayout class='monospaced'>
1837 DISTRO = poky
1838 DISTRO_VERSION = 1.3+snapshot-20130327
1839 SDK_NAME = poky-glibc-i686-arm
1840 SDK_VERSION = 1.3+snapshot
1841 SDKMACHINE =
1842 SDKIMAGE_FEATURES = dev-pkgs dbg-pkgs
1843 BAD_RECOMMENDATIONS =
1844 SDKSIZE = 352712
1845 </literallayout>
1846 Other than <filename>SDKSIZE</filename>, which is the
1847 total size of the files in the SDK in Kbytes, the
1848 name-value pairs are variables that might have influenced the
1849 content of the SDK.
1850 This information is often useful when you are trying to
1851 determine why a change in the package or file listings
1852 has occurred.
1853 </para>
1854 </section>
1855
1856 <section id='examining-build-history-information'>
1857 <title>Examining Build History Information</title>
1858
1859 <para>
1860 You can examine build history output from the command line or
1861 from a web interface.
1862 </para>
1863
1864 <para>
1865 To see any changes that have occurred (assuming you have
1866 <link linkend='var-BUILDHISTORY_COMMIT'><filename>BUILDHISTORY_COMMIT = "1"</filename></link>),
1867 you can simply
1868 use any Git command that allows you to view the history of
1869 a repository.
1870 Here is one method:
1871 <literallayout class='monospaced'>
1872 $ git log -p
1873 </literallayout>
1874 You need to realize, however, that this method does show
1875 changes that are not significant (e.g. a package's size
1876 changing by a few bytes).
1877 </para>
1878
1879 <para>
1880 A command-line tool called <filename>buildhistory-diff</filename>
1881 does exist, though, that queries the Git repository and prints just
1882 the differences that might be significant in human-readable form.
1883 Here is an example:
1884 <literallayout class='monospaced'>
1885 $ ~/poky/poky/scripts/buildhistory-diff . HEAD^
1886 Changes to images/qemux86_64/glibc/core-image-minimal (files-in-image.txt):
1887 /etc/anotherpkg.conf was added
1888 /sbin/anotherpkg was added
1889 * (installed-package-names.txt):
1890 * anotherpkg was added
1891 Changes to images/qemux86_64/glibc/core-image-minimal (installed-package-names.txt):
1892 anotherpkg was added
1893 packages/qemux86_64-poky-linux/v86d: PACKAGES: added "v86d-extras"
1894 * PR changed from "r0" to "r1"
1895 * PV changed from "0.1.10" to "0.1.12"
1896 packages/qemux86_64-poky-linux/v86d/v86d: PKGSIZE changed from 110579 to 144381 (+30%)
1897 * PR changed from "r0" to "r1"
1898 * PV changed from "0.1.10" to "0.1.12"
1899 </literallayout>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001900 <note>
1901 The <filename>buildhistory-diff</filename> tool requires
1902 the <filename>GitPython</filename> package.
1903 Be sure to install it using Pip3 as follows:
1904 <literallayout class='monospaced'>
1905 $ pip3 install GitPython --user
1906 </literallayout>
1907 Alternatively, you can install
1908 <filename>python3-git</filename> using the appropriate
1909 distribution package manager (e.g.
1910 <filename>apt-get</filename>, <filename>dnf</filename>, or
1911 <filename>zipper</filename>).
1912 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001913 </para>
1914
1915 <para>
1916 To see changes to the build history using a web interface, follow
1917 the instruction in the <filename>README</filename> file here.
1918 <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/buildhistory-web/'></ulink>.
1919 </para>
1920
1921 <para>
1922 Here is a sample screenshot of the interface:
1923 <imagedata fileref="figures/buildhistory-web.png" align="center" scalefit="1" width="130%" contentdepth="130%" />
1924 </para>
1925 </section>
1926 </section>
1927</section>
1928
1929<section id='speeding-up-the-build'>
1930 <title>Speeding Up the Build</title>
1931
1932 <para>
1933 Build time can be an issue.
1934 By default, the build system uses simple controls to try and maximize
1935 build efficiency.
1936 In general, the default settings for all the following variables
1937 result in the most efficient build times when dealing with single
1938 socket systems (i.e. a single CPU).
1939 If you have multiple CPUs, you might try increasing the default
1940 values to gain more speed.
1941 See the descriptions in the glossary for each variable for more
1942 information:
1943 <itemizedlist>
1944 <listitem><para>
1945 <link linkend='var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename>:</link>
1946 The maximum number of threads BitBake simultaneously executes.
1947 </para></listitem>
1948 <listitem><para>
1949 <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename>:</ulink>
1950 The number of threads BitBake uses during parsing.
1951 </para></listitem>
1952 <listitem><para>
1953 <link linkend='var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename>:</link>
1954 Extra options passed to the <filename>make</filename> command
1955 during the
1956 <link linkend='ref-tasks-compile'><filename>do_compile</filename></link>
1957 task in order to specify parallel compilation on the
1958 local build host.
1959 </para></listitem>
1960 <listitem><para>
1961 <link linkend='var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename>:</link>
1962 Extra options passed to the <filename>make</filename> command
1963 during the
1964 <link linkend='ref-tasks-install'><filename>do_install</filename></link>
1965 task in order to specify parallel installation on the
1966 local build host.
1967 </para></listitem>
1968 </itemizedlist>
1969 As mentioned, these variables all scale to the number of processor
1970 cores available on the build system.
1971 For single socket systems, this auto-scaling ensures that the build
1972 system fundamentally takes advantage of potential parallel operations
1973 during the build based on the build machine's capabilities.
1974 </para>
1975
1976 <para>
1977 Following are additional factors that can affect build speed:
1978 <itemizedlist>
1979 <listitem><para>
1980 File system type:
1981 The file system type that the build is being performed on can
1982 also influence performance.
1983 Using <filename>ext4</filename> is recommended as compared
1984 to <filename>ext2</filename> and <filename>ext3</filename>
1985 due to <filename>ext4</filename> improved features
1986 such as extents.
1987 </para></listitem>
1988 <listitem><para>
1989 Disabling the updating of access time using
1990 <filename>noatime</filename>:
1991 The <filename>noatime</filename> mount option prevents the
1992 build system from updating file and directory access times.
1993 </para></listitem>
1994 <listitem><para>
1995 Setting a longer commit:
1996 Using the "commit=" mount option increases the interval
1997 in seconds between disk cache writes.
1998 Changing this interval from the five second default to
1999 something longer increases the risk of data loss but decreases
2000 the need to write to the disk, thus increasing the build
2001 performance.
2002 </para></listitem>
2003 <listitem><para>
2004 Choosing the packaging backend:
2005 Of the available packaging backends, IPK is the fastest.
2006 Additionally, selecting a singular packaging backend also
2007 helps.
2008 </para></listitem>
2009 <listitem><para>
2010 Using <filename>tmpfs</filename> for
2011 <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link>
2012 as a temporary file system:
2013 While this can help speed up the build, the benefits are
2014 limited due to the compiler using
2015 <filename>-pipe</filename>.
2016 The build system goes to some lengths to avoid
2017 <filename>sync()</filename> calls into the
2018 file system on the principle that if there was a significant
2019 failure, the
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002020 <link linkend='build-directory'>Build Directory</link>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002021 contents could easily be rebuilt.
2022 </para></listitem>
2023 <listitem><para>
2024 Inheriting the
2025 <link linkend='ref-classes-rm-work'><filename>rm_work</filename></link>
2026 class:
2027 Inheriting this class has shown to speed up builds due to
2028 significantly lower amounts of data stored in the data
2029 cache as well as on disk.
2030 Inheriting this class also makes cleanup of
2031 <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link>
2032 faster, at the expense of being easily able to dive into the
2033 source code.
2034 File system maintainers have recommended that the fastest way
2035 to clean up large numbers of files is to reformat partitions
2036 rather than delete files due to the linear nature of partitions.
2037 This, of course, assumes you structure the disk partitions and
2038 file systems in a way that this is practical.
2039 </para></listitem>
2040 </itemizedlist>
2041 Aside from the previous list, you should keep some trade offs in
2042 mind that can help you speed up the build:
2043 <itemizedlist>
2044 <listitem><para>
2045 Remove items from
2046 <link linkend='var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></link>
2047 that you might not need.
2048 </para></listitem>
2049 <listitem><para>
2050 Exclude debug symbols and other debug information:
2051 If you do not need these symbols and other debug information,
2052 disabling the <filename>*-dbg</filename> package generation
2053 can speed up the build.
2054 You can disable this generation by setting the
2055 <link linkend='var-INHIBIT_PACKAGE_DEBUG_SPLIT'><filename>INHIBIT_PACKAGE_DEBUG_SPLIT</filename></link>
2056 variable to "1".
2057 </para></listitem>
2058 <listitem><para>
2059 Disable static library generation for recipes derived from
2060 <filename>autoconf</filename> or <filename>libtool</filename>:
2061 Following is an example showing how to disable static
2062 libraries and still provide an override to handle exceptions:
2063 <literallayout class='monospaced'>
2064 STATICLIBCONF = "--disable-static"
2065 STATICLIBCONF_sqlite3-native = ""
2066 EXTRA_OECONF += "${STATICLIBCONF}"
2067 </literallayout>
2068 <note><title>Notes</title>
2069 <itemizedlist>
2070 <listitem><para>
2071 Some recipes need static libraries in order to work
2072 correctly (e.g. <filename>pseudo-native</filename>
2073 needs <filename>sqlite3-native</filename>).
2074 Overrides, as in the previous example, account for
2075 these kinds of exceptions.
2076 </para></listitem>
2077 <listitem><para>
2078 Some packages have packaging code that assumes the
2079 presence of the static libraries.
2080 If so, you might need to exclude them as well.
2081 </para></listitem>
2082 </itemizedlist>
2083 </note>
2084 </para></listitem>
2085 </itemizedlist>
2086 </para>
2087</section>
2088</chapter>
2089<!--
2090vim: expandtab tw=80 ts=4
2091-->