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