blob: 421412ebe4fb025a55e94e9ddb32cb440fff0666 [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'>
Brad Bishop19323692019-04-05 15:28:33 -0400134 $ sudo apt-get install &UBUNTU_HOST_PACKAGES_ESSENTIAL;
Brad Bishop316dfdd2018-06-25 12:45:53 -0400135 </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'...
Brad Bishop19323692019-04-05 15:28:33 -0400151 remote: Counting objects: 432160, done.
152 remote: Compressing objects: 100% (102056/102056), done.
153 remote: Total 432160 (delta 323116), reused 432037 (delta 323000)
154 Receiving objects: 100% (432160/432160), 153.81 MiB | 8.54 MiB/s, done.
155 Resolving deltas: 100% (323116/323116), 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
Scott Rifenbarkb0466fb2019-01-22 10:21:44 -0800176 yocto-2.6.1
Brad Bishop19323692019-04-05 15:28:33 -0400177 yocto-2.7
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800178 yocto_1.5_M5.rc8
179 </literallayout>
180 For this example, check out the branch based on the
181 &DISTRO_REL_TAG; release:
182 <literallayout class='monospaced'>
183 $ git checkout tags/&DISTRO_REL_TAG; -b my-&DISTRO_REL_TAG;
184 Switched to a new branch 'my-&DISTRO_REL_TAG;'
Brad Bishop316dfdd2018-06-25 12:45:53 -0400185 </literallayout>
186 The previous Git checkout command creates a local branch
187 named my-&DISTRO_REL_TAG;. The files available to you in that
188 branch exactly match the repository's files in the
189 "&DISTRO_NAME_NO_CAP;" development branch at the time of the
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800190 Yocto Project &DISTRO_REL_TAG; release.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400191 </para>
192
193 <para>
194 For more options and information about accessing Yocto
195 Project related repositories, see the
196 "<ulink url='&YOCTO_DOCS_DEV_URL;#locating-yocto-project-source-files'>Locating Yocto Project Source Files</ulink>"
197 section in the Yocto Project Development Tasks Manual.
198 </para>
199 </section>
200
201 <section id='brief-building-your-image'>
202 <title>Building Your Image</title>
203
204 <para>
205 Use the following steps to build your image.
206 The build process creates an entire Linux distribution, including
207 the toolchain, from source.
208 <note>
209 <itemizedlist>
210 <listitem><para>
211 If you are working behind a firewall and your build
212 host is not set up for proxies, you could encounter
213 problems with the build process when fetching source
214 code (e.g. fetcher failures or Git failures).
215 </para></listitem>
216 <listitem><para>
217 If you do not know your proxy settings, consult your
218 local network infrastructure resources and get that
219 information.
220 A good starting point could also be to check your
221 web browser settings.
222 Finally, you can find more information on the
223 "<ulink url='https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy'>Working Behind a Network Proxy</ulink>"
224 page of the Yocto Project Wiki.
225 </para></listitem>
226 </itemizedlist>
227 </note>
228 </para>
229
230 <para>
231 <orderedlist>
232 <listitem><para>
233 <emphasis>Initialize the Build Environment:</emphasis>
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800234 From within the <filename>poky</filename> directory, run the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400235 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
236 environment setup script to define Yocto Project's
237 build environment on your build host.
238 <literallayout class='monospaced'>
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800239 $ cd ~/poky
Brad Bishop316dfdd2018-06-25 12:45:53 -0400240 $ source &OE_INIT_FILE;
Scott Rifenbarkfa4cfe32019-01-11 11:55:06 -0800241 You had no conf/local.conf file. This configuration file has therefore been
242 created for you with some default values. You may wish to edit it to, for
243 example, select a different MACHINE (target hardware). See conf/local.conf
244 for more information as common configuration options are commented.
245
246 You had no conf/bblayers.conf file. This configuration file has therefore been
247 created for you with some default values. To add additional metadata layers
248 into your configuration please add entries to conf/bblayers.conf.
249
250 The Yocto Project has extensive documentation about OE including a reference
251 manual which can be found at:
252 http://yoctoproject.org/documentation
253
254 For more information about OpenEmbedded see their website:
255 http://www.openembedded.org/
256
257
258 ### Shell environment set up for builds. ###
259
260 You can now run 'bitbake &lt;target&gt;'
261
262 Common targets are:
263 core-image-minimal
264 core-image-sato
265 meta-toolchain
266 meta-ide-support
267
268 You can also run generated qemu images with a command like 'runqemu qemux86'
Brad Bishop316dfdd2018-06-25 12:45:53 -0400269 </literallayout>
270 Among other things, the script creates the
271 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
272 which is <filename>build</filename> in this case
273 and is located in the
274 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
275 After the script runs, your current working directory
276 is set to the Build Directory.
277 Later, when the build completes, the Build Directory
278 contains all the files created during the build.
279 </para></listitem>
280 <listitem><para id='conf-file-step'>
281 <emphasis>Examine Your Local Configuration File:</emphasis>
282 When you set up the build environment, a local
283 configuration file named
284 <filename>local.conf</filename> becomes available in
285 a <filename>conf</filename> subdirectory of the
286 Build Directory.
287 For this example, the defaults are set to build
288 for a <filename>qemux86</filename> target, which is
289 suitable for emulation.
290 The package manager used is set to the RPM package
291 manager.
292 <tip>
293 You can significantly speed up your build and guard
294 against fetcher failures by using mirrors.
295 To use mirrors, add these lines to your
296 <filename>local.conf</filename> file in the Build
297 directory:
298 <literallayout class='monospaced'>
299 SSTATE_MIRRORS = "\
300 file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH \n \
301 file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION_MINUS_ONE;/PATH;downloadfilename=PATH \n \
302 file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION;/PATH;downloadfilename=PATH \n \
303 "
304 </literallayout>
305 The previous examples showed how to add sstate
306 paths for Yocto Project &YOCTO_DOC_VERSION_MINUS_ONE;,
307 &YOCTO_DOC_VERSION;, and a development area.
308 For a complete index of sstate locations, see
309 <ulink url='http://sstate.yoctoproject.org/'></ulink>.
310 </tip>
311 </para></listitem>
312 <listitem><para>
313 <emphasis>Start the Build:</emphasis>
314 Continue with the following command to build an OS image
315 for the target, which is
316 <filename>core-image-sato</filename> in this example:
317 <literallayout class='monospaced'>
318 $ bitbake core-image-sato
319 </literallayout>
320 For information on using the
321 <filename>bitbake</filename> command, see the
322 "<ulink url='&YOCTO_DOCS_OM_URL;#usingpoky-components-bitbake'>BitBake</ulink>"
323 section in the Yocto Project Overview and Concepts Manual,
324 or see the
325 "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-command'>BitBake Command</ulink>"
326 section in the BitBake User Manual.
327 </para></listitem>
328 <listitem><para>
329 <emphasis>Simulate Your Image Using QEMU:</emphasis>
330 Once this particular image is built, you can start
331 QEMU, which is a Quick EMUlator that ships with
332 the Yocto Project:
333 <literallayout class='monospaced'>
334 $ runqemu qemux86
335 </literallayout>
336 If you want to learn more about running QEMU, see the
337 "<ulink url="&YOCTO_DOCS_DEV_URL;#dev-manual-qemu">Using the Quick EMUlator (QEMU)</ulink>"
338 chapter in the Yocto Project Development Tasks Manual.
339 </para></listitem>
340 <listitem><para>
341 <emphasis>Exit QEMU:</emphasis>
342 Exit QEMU by either clicking on the shutdown icon or by
343 typing <filename>Ctrl-C</filename> in the QEMU
344 transcript window from which you evoked QEMU.
345 </para></listitem>
346 </orderedlist>
347 </para>
348 </section>
349
350 <section id='customizing-your-build-for-specific-hardware'>
351 <title>Customizing Your Build for Specific Hardware</title>
352
353 <para>
354 So far, all you have done is quickly built an image suitable
355 for emulation only.
356 This section shows you how to customize your build for specific
357 hardware by adding a hardware layer into the Yocto Project
358 development environment.
359 </para>
360
361 <para>
362 In general, layers are repositories that contain related sets of
363 instructions and configurations that tell the Yocto Project what
364 to do.
365 Isolating related metadata into functionally specific layers
366 facilitates modular development and makes it easier to reuse the
367 layer metadata.
368 <note>
369 By convention, layer names start with the string "meta-".
370 </note>
371 </para>
372
373 <para>
374 Follow these steps to add a hardware layer:
375 <orderedlist>
376 <listitem><para>
377 <emphasis>Find a Layer:</emphasis>
378 Lots of hardware layers exist.
379 The Yocto Project
380 <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink>
381 has many hardware layers.
382 This example adds the
383 <ulink url='https://github.com/kraj/meta-altera'>meta-altera</ulink>
384 hardware layer.
385 </para></listitem>
386 <listitem><para>
387 <emphasis>Clone the Layer</emphasis>
388 Use Git to make a local copy of the layer on your machine.
389 You can put the copy in the top level of the copy of the
390 Poky repository created earlier:
391 <literallayout class='monospaced'>
392 $ cd ~/poky
393 $ git clone https://github.com/kraj/meta-altera.git
394 Cloning into 'meta-altera'...
395 remote: Counting objects: 25170, done.
396 remote: Compressing objects: 100% (350/350), done.
397 remote: Total 25170 (delta 645), reused 719 (delta 538), pack-reused 24219
398 Receiving objects: 100% (25170/25170), 41.02 MiB | 1.64 MiB/s, done.
399 Resolving deltas: 100% (13385/13385), done.
400 Checking connectivity... done.
401 </literallayout>
402 The hardware layer now exists with other layers inside
403 the Poky reference repository on your build host as
404 <filename>meta-altera</filename> and contains all the
405 metadata needed to support hardware from Altera, which
406 is owned by Intel.
407 </para></listitem>
408 <listitem><para>
409 <emphasis>Change the Configuration to Build for a Specific Machine:</emphasis>
410 The
411 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
412 variable in the <filename>local.conf</filename> file
413 specifies the machine for the build.
414 For this example, set the <filename>MACHINE</filename>
415 variable to "cyclone5".
416 These configurations are used:
417 <ulink url='https://github.com/kraj/meta-altera/blob/master/conf/machine/cyclone5.conf'></ulink>.
418 <note>
419 See the
420 "<link linkend='conf-file-step'>Examine Your Local Configuration File</link>"
421 step earlier for more information on configuring the
422 build.
423 </note>
424 </para></listitem>
425 <listitem><para>
426 <emphasis>Add Your Layer to the Layer Configuration File:</emphasis>
427 Before you can use a layer during a build, you must add it
428 to your <filename>bblayers.conf</filename> file, which
429 is found in the
430 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory's</ulink>
431 <filename>conf</filename> directory.</para>
432
433 <para>Use the <filename>bitbake-layers add-layer</filename>
434 command to add the layer to the configuration file:
435 <literallayout class='monospaced'>
436 $ cd ~/poky/build
437 $ bitbake-layers add-layer ../meta-altera
438 NOTE: Starting bitbake server...
439 Parsing recipes: 100% |##################################################################| Time: 0:00:32
440 Parsing of 918 .bb files complete (0 cached, 918 parsed). 1401 targets, 123 skipped, 0 masked, 0 errors.
441 </literallayout>
442 You can find more information on adding layers in the
443 "<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>"
444 section.
445 </para></listitem>
446 </orderedlist>
447 Completing these steps has added the
448 <filename>meta-altera</filename> layer to your Yocto Project
449 development environment and configured it to build for the
450 "cyclone5" machine.
451 <note>
452 The previous steps are for demonstration purposes only.
453 If you were to attempt to build an image for the
454 "cyclone5" build, you should read the Altera
455 <filename>README</filename>.
456 </note>
457 </para>
458 </section>
459
460 <section id='creating-your-own-general-layer'>
461 <title>Creating Your Own General Layer</title>
462
463 <para>
464 Maybe you have an application or specific set of behaviors you
465 need to isolate.
466 You can create your own general layer using the
467 <filename>bitbake-layers create-layer</filename> command.
468 The tool automates layer creation by setting up a
469 subdirectory with a <filename>layer.conf</filename>
470 configuration file, a <filename>recipes-example</filename>
471 subdirectory that contains an <filename>example.bb</filename>
472 recipe, a licensing file, and a <filename>README</filename>.
473 </para>
474
475 <para>
476 The following commands run the tool to create a layer named
477 <filename>meta-mylayer</filename> in the
478 <filename>poky</filename> directory:
479 <literallayout class='monospaced'>
480 $ cd ~/poky
481 $ bitbake-layers create-layer meta-mylayer
482 NOTE: Starting bitbake server...
483 Add your new layer with 'bitbake-layers add-layer meta-mylayer'
484 </literallayout>
485 For more information on layers and how to create them, see the
486 "<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>"
487 section in the Yocto Project Development Tasks Manual.
488 </para>
489 </section>
490
491 <section id='brief-where-to-go-next'>
492 <title>Where To Go Next</title>
493
494 <para>
495 Now that you have experienced using the Yocto Project, you might
496 be asking yourself "What now?"
497 The Yocto Project has many sources of information including
498 the website, wiki pages, and user manuals:
499 <itemizedlist>
500 <listitem><para>
501 <emphasis>Website:</emphasis>
502 The
503 <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>
504 provides background information, the latest builds,
505 breaking news, full development documentation, and
506 access to a rich Yocto Project Development Community
507 into which you can tap.
508 </para></listitem>
509 <listitem><para>
510 <emphasis>Developer Screencast:</emphasis>
511 The
512 <ulink url='http://vimeo.com/36450321'>Getting Started with the Yocto Project - New Developer Screencast Tutorial</ulink>
513 provides a 30-minute video created for users unfamiliar
514 with the Yocto Project but familiar with Linux build
515 hosts.
516 While this screencast is somewhat dated, the
517 introductory and fundamental concepts are useful for
518 the beginner.
519 </para></listitem>
520 <listitem><para>
521 <emphasis>Yocto Project Overview and Concepts Manual:</emphasis>
522 The
523 <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>
524 is a great place to start to learn about the
525 Yocto Project.
526 This manual introduces you to the Yocto Project and its
527 development environment.
528 The manual also provides conceptual information for
529 various aspects of the Yocto Project.
530 </para></listitem>
531 <listitem><para>
532 <emphasis>Yocto Project Wiki:</emphasis>
533 The
534 <ulink url='&YOCTO_WIKI_URL;'>Yocto Project Wiki</ulink>
535 provides additional information on where to go next
536 when ramping up with the Yocto Project, release
537 information, project planning, and QA information.
538 </para></listitem>
539 <listitem><para>
540 <emphasis>Yocto Project Mailing Lists:</emphasis>
541 Related mailing lists provide a forum for discussion,
542 patch submission and announcements.
543 Several mailing lists exist and are grouped according
544 to areas of concern.
545 See the
546 "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>"
547 section in the Yocto Project Reference Manual for a
548 complete list of Yocto Project mailing lists.
549 </para></listitem>
550 <listitem><para>
551 <emphasis>Comprehensive List of Links and Other Documentation:</emphasis>
552 The
553 "<ulink url='&YOCTO_DOCS_REF_URL;#resources-links-and-related-documentation'>Links and Related Documentation</ulink>"
554 section in the Yocto Project Reference Manual provides a
555 comprehensive list of all related links and other
556 user documentation.
557 </para></listitem>
558 </itemizedlist>
559 </para>
560 </section>
561</article>
562<!--
563vim: expandtab tw=80 ts=4
564-->