blob: 2e7beb1644bfe09fddbd7ff7a31003dd657b797c [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001<!DOCTYPE article 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<article id='brief-yocto-project-qs-intro'>
6 <articleinfo>
7 <title>Yocto Project Quick Build</title>
8
9 <copyright>
10 <year>&COPYRIGHT_YEAR;</year>
11 <holder>Linux Foundation</holder>
12 </copyright>
13
14 <legalnotice>
15 <para>
16 Permission is granted to copy, distribute and/or modify this document under
17 the terms of the <ulink type="http" url="http://creativecommons.org/licenses/by-sa/2.0/uk/">Creative Commons Attribution-Share Alike 2.0 UK: England &amp; Wales</ulink> as published by Creative Commons.
18 </para>
19 </legalnotice>
20
21
22 <abstract>
23 <imagedata fileref="figures/yocto-project-transp.png"
24 width="6in" depth="1in"
25 align="right" scale="25" />
26 </abstract>
27 </articleinfo>
28
29 <section id='brief-welcome'>
30 <title>Welcome!</title>
31
32 <para>
33 Welcome!
34 This short document steps you through the process for a typical
35 image build using the Yocto Project.
36 The document also introduces how to configure a build for specific
37 hardware.
38 You will use Yocto Project to build a reference embedded OS
39 called Poky.
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080040 <note><title>Notes</title>
41 <itemizedlist>
42 <listitem><para>
43 The examples in this paper assume you are using a
44 native Linux system running a recent Ubuntu Linux
45 distribution.
46 If the machine you want to use Yocto Project on to
47 build an image
48 (<ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>)
49 is not a native Linux system, you can
50 still perform these steps by using CROss PlatformS
51 (CROPS) and setting up a Poky container.
52 See the
53 <ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-to-use-crops'>Setting Up to Use CROss PlatformS (CROPS)</ulink>"
54 section in the Yocto Project Development Tasks Manual for more
55 information.
56 </para></listitem>
57 <listitem><para>
58 You cannot use a build host that is using the
59 <ulink url='https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux'>Windows Subsystem for Linux</ulink>
60 (WSL).
61 The Yocto Project is not compatible with WSL.
62 </para></listitem>
63 </itemizedlist>
Brad Bishop316dfdd2018-06-25 12:45:53 -040064 </note>
65 </para>
66
67 <para>
68 If you want more conceptual or background information on the
69 Yocto Project, see the
70 <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>.
71 </para>
72 </section>
73
74 <section id='brief-compatible-distro'>
75 <title>Compatible Linux Distribution</title>
76
77 <para>
78 Make sure your
79 <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>
80 meets the following requirements:
81 <itemizedlist>
82 <listitem><para>
83 50 Gbytes of free disk space
84 </para></listitem>
85 <listitem><para>
86 Runs a supported Linux distribution (i.e. recent releases of
87 Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of
88 Linux distributions that support the Yocto Project, see the
89 "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
90 section in the Yocto Project Reference Manual.
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080091 For detailed information on preparing your build host, see
92 the
93 "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-preparing-the-build-host'>Preparing the Build Host</ulink>"
94 section in the Yocto Project Development Tasks Manual.
Brad Bishop316dfdd2018-06-25 12:45:53 -040095 </para></listitem>
96 <listitem><para>
97 <itemizedlist>
98 <listitem><para>
99 Git 1.8.3.1 or greater
100 </para></listitem>
101 <listitem><para>
102 tar 1.27 or greater
103 </para></listitem>
104 <listitem><para>
105 Python 3.4.0 or greater.
106 </para></listitem>
107 </itemizedlist>
108 If your build host does not meet any of these three listed
109 version requirements, you can take steps to prepare the
110 system so that you can still use the Yocto Project.
111 See the
112 "<ulink url='&YOCTO_DOCS_REF_URL;#required-git-tar-and-python-versions'>Required Git, tar, and Python Versions</ulink>"
113 section in the Yocto Project Reference Manual for information.
114 </para></listitem>
115 </itemizedlist>
116 </para>
117 </section>
118
119 <section id='brief-build-system-packages'>
120 <title>Build Host Packages</title>
121
122 <para>
123 You must install essential host packages on your
124 build host.
125 The following command installs the host packages based on an
126 Ubuntu distribution:
127 <note>
128 For host package requirements on all supported Linux
129 distributions, see the
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800130 "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-build-host'>Required Packages for the Build Host</ulink>"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400131 section in the Yocto Project Reference Manual.
132 </note>
133 <literallayout class='monospaced'>
134 $ sudo apt-get install &UBUNTU_HOST_PACKAGES_ESSENTIAL; libsdl1.2-dev xterm
135 </literallayout>
136 </para>
137 </section>
138
139 <section id='brief-use-git-to-clone-poky'>
140 <title>Use Git to Clone Poky</title>
141
142 <para>
143 Once you complete the setup instructions for your machine,
144 you need to get a copy of the Poky repository on your build
145 host.
146 Use the following commands to clone the Poky
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800147 repository.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400148 <literallayout class='monospaced'>
149 $ git clone git://git.yoctoproject.org/poky
150 Cloning into 'poky'...
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800151 remote: Counting objects: 428632, done.
152 remote: Compressing objects: 100% (101203/101203), done.
153 remote: Total 428632 (delta 320463), reused 428532 (delta 320363)
154 Receiving objects: 100% (428632/428632), 153.01 MiB | 12.40 MiB/s, done.
155 Resolving deltas: 100% (320463/320463), done.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400156 Checking connectivity... done.
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800157 </literallayout>
158 Move to the <filename>poky</filename> directory and take a look
159 at the tags:
160 <literallayout class='monospaced'>
161 $ cd poky
162 $ git fetch --tags
163 $ git tag
164 1.1_M1.final
165 1.1_M1.rc1
166 1.1_M1.rc2
167 1.1_M2.final
168 1.1_M2.rc1
169 .
170 .
171 .
172 yocto-2.5
173 yocto-2.5.1
174 yocto-2.5.2
175 yocto-2.6
176 yocto_1.5_M5.rc8
177 </literallayout>
178 For this example, check out the branch based on the
179 &DISTRO_REL_TAG; release:
180 <literallayout class='monospaced'>
181 $ git checkout tags/&DISTRO_REL_TAG; -b my-&DISTRO_REL_TAG;
182 Switched to a new branch 'my-&DISTRO_REL_TAG;'
Brad Bishop316dfdd2018-06-25 12:45:53 -0400183 </literallayout>
184 The previous Git checkout command creates a local branch
185 named my-&DISTRO_REL_TAG;. The files available to you in that
186 branch exactly match the repository's files in the
187 "&DISTRO_NAME_NO_CAP;" development branch at the time of the
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800188 Yocto Project &DISTRO_REL_TAG; release.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400189 </para>
190
191 <para>
192 For more options and information about accessing Yocto
193 Project related repositories, see the
194 "<ulink url='&YOCTO_DOCS_DEV_URL;#locating-yocto-project-source-files'>Locating Yocto Project Source Files</ulink>"
195 section in the Yocto Project Development Tasks Manual.
196 </para>
197 </section>
198
199 <section id='brief-building-your-image'>
200 <title>Building Your Image</title>
201
202 <para>
203 Use the following steps to build your image.
204 The build process creates an entire Linux distribution, including
205 the toolchain, from source.
206 <note>
207 <itemizedlist>
208 <listitem><para>
209 If you are working behind a firewall and your build
210 host is not set up for proxies, you could encounter
211 problems with the build process when fetching source
212 code (e.g. fetcher failures or Git failures).
213 </para></listitem>
214 <listitem><para>
215 If you do not know your proxy settings, consult your
216 local network infrastructure resources and get that
217 information.
218 A good starting point could also be to check your
219 web browser settings.
220 Finally, you can find more information on the
221 "<ulink url='https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy'>Working Behind a Network Proxy</ulink>"
222 page of the Yocto Project Wiki.
223 </para></listitem>
224 </itemizedlist>
225 </note>
226 </para>
227
228 <para>
229 <orderedlist>
230 <listitem><para>
231 <emphasis>Initialize the Build Environment:</emphasis>
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800232 From within the <filename>poky</filename> directory, run the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400233 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
234 environment setup script to define Yocto Project's
235 build environment on your build host.
236 <literallayout class='monospaced'>
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800237 $ cd ~/poky
Brad Bishop316dfdd2018-06-25 12:45:53 -0400238 $ source &OE_INIT_FILE;
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800239 You had no conf/local.conf file. This configuration file has therefore been
240 created for you with some default values. You may wish to edit it to, for
241 example, select a different MACHINE (target hardware). See conf/local.conf
242 for more information as common configuration options are commented.
243
244 You had no conf/bblayers.conf file. This configuration file has therefore been
245 created for you with some default values. To add additional metadata layers
246 into your configuration please add entries to conf/bblayers.conf.
247
248 The Yocto Project has extensive documentation about OE including a reference
249 manual which can be found at:
250 http://yoctoproject.org/documentation
251
252 For more information about OpenEmbedded see their website:
253 http://www.openembedded.org/
254
255
256 ### Shell environment set up for builds. ###
257
258 You can now run 'bitbake &lt;target&gt;'
259
260 Common targets are:
261 core-image-minimal
262 core-image-sato
263 meta-toolchain
264 meta-ide-support
265
266 You can also run generated qemu images with a command like 'runqemu qemux86'
Brad Bishop316dfdd2018-06-25 12:45:53 -0400267 </literallayout>
268 Among other things, the script creates the
269 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
270 which is <filename>build</filename> in this case
271 and is located in the
272 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
273 After the script runs, your current working directory
274 is set to the Build Directory.
275 Later, when the build completes, the Build Directory
276 contains all the files created during the build.
277 </para></listitem>
278 <listitem><para id='conf-file-step'>
279 <emphasis>Examine Your Local Configuration File:</emphasis>
280 When you set up the build environment, a local
281 configuration file named
282 <filename>local.conf</filename> becomes available in
283 a <filename>conf</filename> subdirectory of the
284 Build Directory.
285 For this example, the defaults are set to build
286 for a <filename>qemux86</filename> target, which is
287 suitable for emulation.
288 The package manager used is set to the RPM package
289 manager.
290 <tip>
291 You can significantly speed up your build and guard
292 against fetcher failures by using mirrors.
293 To use mirrors, add these lines to your
294 <filename>local.conf</filename> file in the Build
295 directory:
296 <literallayout class='monospaced'>
297 SSTATE_MIRRORS = "\
298 file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH \n \
299 file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION_MINUS_ONE;/PATH;downloadfilename=PATH \n \
300 file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION;/PATH;downloadfilename=PATH \n \
301 "
302 </literallayout>
303 The previous examples showed how to add sstate
304 paths for Yocto Project &YOCTO_DOC_VERSION_MINUS_ONE;,
305 &YOCTO_DOC_VERSION;, and a development area.
306 For a complete index of sstate locations, see
307 <ulink url='http://sstate.yoctoproject.org/'></ulink>.
308 </tip>
309 </para></listitem>
310 <listitem><para>
311 <emphasis>Start the Build:</emphasis>
312 Continue with the following command to build an OS image
313 for the target, which is
314 <filename>core-image-sato</filename> in this example:
315 <literallayout class='monospaced'>
316 $ bitbake core-image-sato
317 </literallayout>
318 For information on using the
319 <filename>bitbake</filename> command, see the
320 "<ulink url='&YOCTO_DOCS_OM_URL;#usingpoky-components-bitbake'>BitBake</ulink>"
321 section in the Yocto Project Overview and Concepts Manual,
322 or see the
323 "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-command'>BitBake Command</ulink>"
324 section in the BitBake User Manual.
325 </para></listitem>
326 <listitem><para>
327 <emphasis>Simulate Your Image Using QEMU:</emphasis>
328 Once this particular image is built, you can start
329 QEMU, which is a Quick EMUlator that ships with
330 the Yocto Project:
331 <literallayout class='monospaced'>
332 $ runqemu qemux86
333 </literallayout>
334 If you want to learn more about running QEMU, see the
335 "<ulink url="&YOCTO_DOCS_DEV_URL;#dev-manual-qemu">Using the Quick EMUlator (QEMU)</ulink>"
336 chapter in the Yocto Project Development Tasks Manual.
337 </para></listitem>
338 <listitem><para>
339 <emphasis>Exit QEMU:</emphasis>
340 Exit QEMU by either clicking on the shutdown icon or by
341 typing <filename>Ctrl-C</filename> in the QEMU
342 transcript window from which you evoked QEMU.
343 </para></listitem>
344 </orderedlist>
345 </para>
346 </section>
347
348 <section id='customizing-your-build-for-specific-hardware'>
349 <title>Customizing Your Build for Specific Hardware</title>
350
351 <para>
352 So far, all you have done is quickly built an image suitable
353 for emulation only.
354 This section shows you how to customize your build for specific
355 hardware by adding a hardware layer into the Yocto Project
356 development environment.
357 </para>
358
359 <para>
360 In general, layers are repositories that contain related sets of
361 instructions and configurations that tell the Yocto Project what
362 to do.
363 Isolating related metadata into functionally specific layers
364 facilitates modular development and makes it easier to reuse the
365 layer metadata.
366 <note>
367 By convention, layer names start with the string "meta-".
368 </note>
369 </para>
370
371 <para>
372 Follow these steps to add a hardware layer:
373 <orderedlist>
374 <listitem><para>
375 <emphasis>Find a Layer:</emphasis>
376 Lots of hardware layers exist.
377 The Yocto Project
378 <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink>
379 has many hardware layers.
380 This example adds the
381 <ulink url='https://github.com/kraj/meta-altera'>meta-altera</ulink>
382 hardware layer.
383 </para></listitem>
384 <listitem><para>
385 <emphasis>Clone the Layer</emphasis>
386 Use Git to make a local copy of the layer on your machine.
387 You can put the copy in the top level of the copy of the
388 Poky repository created earlier:
389 <literallayout class='monospaced'>
390 $ cd ~/poky
391 $ git clone https://github.com/kraj/meta-altera.git
392 Cloning into 'meta-altera'...
393 remote: Counting objects: 25170, done.
394 remote: Compressing objects: 100% (350/350), done.
395 remote: Total 25170 (delta 645), reused 719 (delta 538), pack-reused 24219
396 Receiving objects: 100% (25170/25170), 41.02 MiB | 1.64 MiB/s, done.
397 Resolving deltas: 100% (13385/13385), done.
398 Checking connectivity... done.
399 </literallayout>
400 The hardware layer now exists with other layers inside
401 the Poky reference repository on your build host as
402 <filename>meta-altera</filename> and contains all the
403 metadata needed to support hardware from Altera, which
404 is owned by Intel.
405 </para></listitem>
406 <listitem><para>
407 <emphasis>Change the Configuration to Build for a Specific Machine:</emphasis>
408 The
409 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
410 variable in the <filename>local.conf</filename> file
411 specifies the machine for the build.
412 For this example, set the <filename>MACHINE</filename>
413 variable to "cyclone5".
414 These configurations are used:
415 <ulink url='https://github.com/kraj/meta-altera/blob/master/conf/machine/cyclone5.conf'></ulink>.
416 <note>
417 See the
418 "<link linkend='conf-file-step'>Examine Your Local Configuration File</link>"
419 step earlier for more information on configuring the
420 build.
421 </note>
422 </para></listitem>
423 <listitem><para>
424 <emphasis>Add Your Layer to the Layer Configuration File:</emphasis>
425 Before you can use a layer during a build, you must add it
426 to your <filename>bblayers.conf</filename> file, which
427 is found in the
428 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory's</ulink>
429 <filename>conf</filename> directory.</para>
430
431 <para>Use the <filename>bitbake-layers add-layer</filename>
432 command to add the layer to the configuration file:
433 <literallayout class='monospaced'>
434 $ cd ~/poky/build
435 $ bitbake-layers add-layer ../meta-altera
436 NOTE: Starting bitbake server...
437 Parsing recipes: 100% |##################################################################| Time: 0:00:32
438 Parsing of 918 .bb files complete (0 cached, 918 parsed). 1401 targets, 123 skipped, 0 masked, 0 errors.
439 </literallayout>
440 You can find more information on adding layers in the
441 "<ulink url='&YOCTO_DOCS_DEV_URL;#adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
442 section.
443 </para></listitem>
444 </orderedlist>
445 Completing these steps has added the
446 <filename>meta-altera</filename> layer to your Yocto Project
447 development environment and configured it to build for the
448 "cyclone5" machine.
449 <note>
450 The previous steps are for demonstration purposes only.
451 If you were to attempt to build an image for the
452 "cyclone5" build, you should read the Altera
453 <filename>README</filename>.
454 </note>
455 </para>
456 </section>
457
458 <section id='creating-your-own-general-layer'>
459 <title>Creating Your Own General Layer</title>
460
461 <para>
462 Maybe you have an application or specific set of behaviors you
463 need to isolate.
464 You can create your own general layer using the
465 <filename>bitbake-layers create-layer</filename> command.
466 The tool automates layer creation by setting up a
467 subdirectory with a <filename>layer.conf</filename>
468 configuration file, a <filename>recipes-example</filename>
469 subdirectory that contains an <filename>example.bb</filename>
470 recipe, a licensing file, and a <filename>README</filename>.
471 </para>
472
473 <para>
474 The following commands run the tool to create a layer named
475 <filename>meta-mylayer</filename> in the
476 <filename>poky</filename> directory:
477 <literallayout class='monospaced'>
478 $ cd ~/poky
479 $ bitbake-layers create-layer meta-mylayer
480 NOTE: Starting bitbake server...
481 Add your new layer with 'bitbake-layers add-layer meta-mylayer'
482 </literallayout>
483 For more information on layers and how to create them, see the
484 "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
485 section in the Yocto Project Development Tasks Manual.
486 </para>
487 </section>
488
489 <section id='brief-where-to-go-next'>
490 <title>Where To Go Next</title>
491
492 <para>
493 Now that you have experienced using the Yocto Project, you might
494 be asking yourself "What now?"
495 The Yocto Project has many sources of information including
496 the website, wiki pages, and user manuals:
497 <itemizedlist>
498 <listitem><para>
499 <emphasis>Website:</emphasis>
500 The
501 <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>
502 provides background information, the latest builds,
503 breaking news, full development documentation, and
504 access to a rich Yocto Project Development Community
505 into which you can tap.
506 </para></listitem>
507 <listitem><para>
508 <emphasis>Developer Screencast:</emphasis>
509 The
510 <ulink url='http://vimeo.com/36450321'>Getting Started with the Yocto Project - New Developer Screencast Tutorial</ulink>
511 provides a 30-minute video created for users unfamiliar
512 with the Yocto Project but familiar with Linux build
513 hosts.
514 While this screencast is somewhat dated, the
515 introductory and fundamental concepts are useful for
516 the beginner.
517 </para></listitem>
518 <listitem><para>
519 <emphasis>Yocto Project Overview and Concepts Manual:</emphasis>
520 The
521 <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>
522 is a great place to start to learn about the
523 Yocto Project.
524 This manual introduces you to the Yocto Project and its
525 development environment.
526 The manual also provides conceptual information for
527 various aspects of the Yocto Project.
528 </para></listitem>
529 <listitem><para>
530 <emphasis>Yocto Project Wiki:</emphasis>
531 The
532 <ulink url='&YOCTO_WIKI_URL;'>Yocto Project Wiki</ulink>
533 provides additional information on where to go next
534 when ramping up with the Yocto Project, release
535 information, project planning, and QA information.
536 </para></listitem>
537 <listitem><para>
538 <emphasis>Yocto Project Mailing Lists:</emphasis>
539 Related mailing lists provide a forum for discussion,
540 patch submission and announcements.
541 Several mailing lists exist and are grouped according
542 to areas of concern.
543 See the
544 "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>"
545 section in the Yocto Project Reference Manual for a
546 complete list of Yocto Project mailing lists.
547 </para></listitem>
548 <listitem><para>
549 <emphasis>Comprehensive List of Links and Other Documentation:</emphasis>
550 The
551 "<ulink url='&YOCTO_DOCS_REF_URL;#resources-links-and-related-documentation'>Links and Related Documentation</ulink>"
552 section in the Yocto Project Reference Manual provides a
553 comprehensive list of all related links and other
554 user documentation.
555 </para></listitem>
556 </itemizedlist>
557 </para>
558 </section>
559</article>
560<!--
561vim: expandtab tw=80 ts=4
562-->