blob: 23bf8eb0e4e65ae95c3078d59254bc038026d0a4 [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='dev-manual-start'>
6
7<title>Getting Started with the Yocto Project</title>
8
9<para>
10 This chapter introduces the Yocto Project and gives you an idea of what you need to get started.
11 You can find enough information to set up your development host and build or use images for
12 hardware supported by the Yocto Project by reading the
13 <ulink url='&YOCTO_DOCS_QS_URL;'>Yocto Project Quick Start</ulink>.
14</para>
15
16<para>
17 The remainder of this chapter summarizes what is in the Yocto Project Quick Start and provides
18 some higher-level concepts you might want to consider.
19</para>
20
21<section id='introducing-the-yocto-project'>
22 <title>Introducing the Yocto Project</title>
23
24 <para>
25 The Yocto Project is an open-source collaboration project focused on embedded Linux development.
26 The project currently provides a build system that is
27 referred to as the
28 <link linkend='build-system-term'>OpenEmbedded build system</link>
29 in the Yocto Project documentation.
30 The Yocto Project provides various ancillary tools for the embedded developer
31 and also features the Sato reference User Interface, which is optimized for
32 stylus-driven, low-resolution screens.
33 </para>
34
35 <para>
36 You can use the OpenEmbedded build system, which uses
37 <link linkend='bitbake-term'>BitBake</link>, to develop complete Linux
38 images and associated user-space applications for architectures based
39 on ARM, MIPS, PowerPC, x86 and x86-64.
40 <note>
41 By default, using the Yocto Project creates a Poky distribution.
42 However, you can create your own distribution by providing key
43 <link linkend='metadata'>Metadata</link>.
44 See the "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
45 section for more information.
46 </note>
47 While the Yocto Project does not provide a strict testing framework,
48 it does provide or generate for you artifacts that let you perform target-level and
49 emulated testing and debugging.
50 Additionally, if you are an <trademark class='trade'>Eclipse</trademark>
51 IDE user, you can install an Eclipse Yocto Plug-in to allow you to
52 develop within that familiar environment.
53 </para>
54</section>
55
56<section id='getting-setup'>
57 <title>Getting Set Up</title>
58
59 <para>
60 Here is what you need to use the Yocto Project:
61 <itemizedlist>
62 <listitem><para><emphasis>Host System:</emphasis> You should have a reasonably current
63 Linux-based host system.
64 You will have the best results with a recent release of Fedora,
65 openSUSE, Debian, Ubuntu, or CentOS as these releases are frequently tested against the Yocto Project
66 and officially supported.
67 For a list of the distributions under validation and their status, see the
68 "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" section
69 in the Yocto Project Reference Manual and the wiki page at
70 <ulink url='&YOCTO_WIKI_URL;/wiki/Distribution_Support'>Distribution Support</ulink>.</para>
71 <para>
72 You should also have about 50 Gbytes of free disk space for building images.
73 </para></listitem>
74 <listitem><para><emphasis>Packages:</emphasis> The OpenEmbedded build system
75 requires that certain packages exist on your development system (e.g. Python 2.7).
76 See "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>"
77 section in the Yocto Project Quick Start and the
78 "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>"
79 section in the Yocto Project Reference Manual for the exact
80 package requirements and the installation commands to install
81 them for the supported distributions.
82 </para></listitem>
83 <listitem id='local-yp-release'><para><emphasis>Yocto Project Release:</emphasis>
84 You need a release of the Yocto Project locally installed on
85 your development system.
86 The documentation refers to this set of locally installed files
87 as the <link linkend='source-directory'>Source Directory</link>.
88 You create your Source Directory by using
89 <link linkend='git'>Git</link> to clone a local copy
90 of the upstream <filename>poky</filename> repository,
91 or by downloading and unpacking a tarball of an official
92 Yocto Project release.
93 The preferred method is to create a clone of the repository.
94 </para>
95 <para>Working from a copy of the upstream repository allows you
96 to contribute back into the Yocto Project or simply work with
97 the latest software on a development branch.
98 Because Git maintains and creates an upstream repository with
99 a complete history of changes and you are working with a local
100 clone of that repository, you have access to all the Yocto
101 Project development branches and tag names used in the upstream
102 repository.</para>
103 <note>You can view the Yocto Project Source Repositories at
104 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>
105 </note>
106 <para>The following transcript shows how to clone the
107 <filename>poky</filename> Git repository into the current
108 working directory.
109 The command creates the local repository in a directory
110 named <filename>poky</filename>.
111 For information on Git used within the Yocto Project, see
112 the "<link linkend='git'>Git</link>" section.
113 <literallayout class='monospaced'>
114 $ git clone git://git.yoctoproject.org/poky
115 Cloning into 'poky'...
116 remote: Counting objects: 226790, done.
117 remote: Compressing objects: 100% (57465/57465), done.
118 remote: Total 226790 (delta 165212), reused 225887 (delta 164327)
119 Receiving objects: 100% (226790/226790), 100.98 MiB | 263 KiB/s, done.
120 Resolving deltas: 100% (165212/165212), done.
121 </literallayout></para>
122 <para>For another example of how to set up your own local Git
123 repositories, see this
124 <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>
125 wiki page</ulink>, which describes how to create local
126 Git repositories for both
127 <filename>poky</filename> and <filename>meta-intel</filename>.
128 </para>
129 <para>
130 You can also get the Yocto Project Files by downloading
131 Yocto Project releases from the
132 <ulink url="&YOCTO_HOME_URL;">Yocto Project website</ulink>.
133 From the website, you just click "Downloads" in the navigation
134 pane to the left to display all Yocto Project downloads.
135 Current and archived releases are available for download.
136 Nightly and developmental builds are also maintained at
137 <ulink url="&YOCTO_AB_NIGHTLY_URL;"></ulink>.
138 One final site you can visit for information on Yocto Project
139 releases is the
140 <ulink url='&YOCTO_WIKI_URL;/wiki/Releases'>Releases</ulink>
141 wiki.
142 </para></listitem>
143 <listitem id='local-kernel-files'><para><emphasis>Yocto Project Kernel:</emphasis>
144 If you are going to be making modifications to a supported Yocto Project kernel, you
145 need to establish local copies of the source.
146 You can find Git repositories of supported Yocto Project kernels organized under
147 "Yocto Linux Kernel" in the Yocto Project Source Repositories at
148 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
149 <para>This setup can involve creating a bare clone of the Yocto Project kernel and then
150 copying that cloned repository.
151 You can create the bare clone and the copy of the bare clone anywhere you like.
152 For simplicity, it is recommended that you create these structures outside of the
153 Source Directory, which is usually named <filename>poky</filename>.</para>
154 <para>As an example, the following transcript shows how to create the bare clone
155 of the <filename>linux-yocto-3.19</filename> kernel and then create a copy of
156 that clone.
157 <note>When you have a local Yocto Project kernel Git repository, you can
158 reference that repository rather than the upstream Git repository as
159 part of the <filename>clone</filename> command.
160 Doing so can speed up the process.</note></para>
161 <para>In the following example, the bare clone is named
162 <filename>linux-yocto-3.19.git</filename>, while the
163 copy is named <filename>my-linux-yocto-3.19-work</filename>:
164 <literallayout class='monospaced'>
165 $ git clone --bare git://git.yoctoproject.org/linux-yocto-3.19 linux-yocto-3.19.git
166 Cloning into bare repository 'linux-yocto-3.19.git'...
167 remote: Counting objects: 3983256, done.
168 remote: Compressing objects: 100% (605006/605006), done.
169 remote: Total 3983256 (delta 3352832), reused 3974503 (delta 3344079)
170 Receiving objects: 100% (3983256/3983256), 843.66 MiB | 1.07 MiB/s, done.
171 Resolving deltas: 100% (3352832/3352832), done.
172 Checking connectivity... done.
173 </literallayout></para>
174 <para>Now create a clone of the bare clone just created:
175 <literallayout class='monospaced'>
176 $ git clone linux-yocto-3.19.git my-linux-yocto-3.19-work
177 Cloning into 'my-linux-yocto-3.19-work'...
178 done.
179 Checking out files: 100% (48440/48440), done.
180 </literallayout></para></listitem>
181 <listitem id='meta-yocto-kernel-extras-repo'><para><emphasis>
182 The <filename>meta-yocto-kernel-extras</filename> Git Repository</emphasis>:
183 The <filename>meta-yocto-kernel-extras</filename> Git repository contains Metadata needed
184 only if you are modifying and building the kernel image.
185 In particular, it contains the kernel BitBake append (<filename>.bbappend</filename>)
186 files that you
187 edit to point to your locally modified kernel source files and to build the kernel
188 image.
189 Pointing to these local files is much more efficient than requiring a download of the
190 kernel's source files from upstream each time you make changes to the kernel.</para>
191 <para>You can find the <filename>meta-yocto-kernel-extras</filename> Git Repository in the
192 "Yocto Metadata Layers" area of the Yocto Project Source Repositories at
193 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
194 It is good practice to create this Git repository inside the Source Directory.</para>
195 <para>Following is an example that creates the <filename>meta-yocto-kernel-extras</filename> Git
196 repository inside the Source Directory, which is named <filename>poky</filename>
197 in this case:
198 <literallayout class='monospaced'>
199 $ cd ~/poky
200 $ git clone git://git.yoctoproject.org/meta-yocto-kernel-extras meta-yocto-kernel-extras
201 Cloning into 'meta-yocto-kernel-extras'...
202 remote: Counting objects: 727, done.
203 remote: Compressing objects: 100% (452/452), done.
204 remote: Total 727 (delta 260), reused 719 (delta 252)
205 Receiving objects: 100% (727/727), 536.36 KiB | 240 KiB/s, done.
206 Resolving deltas: 100% (260/260), done.
207 </literallayout></para></listitem>
208 <listitem><para id='supported-board-support-packages-(bsps)'><emphasis>Supported Board Support Packages (BSPs):</emphasis>
209 The Yocto Project supports many BSPs, which are maintained in
210 their own layers or in layers designed to contain several
211 BSPs.
212 To get an idea of machine support through BSP layers, you can
213 look at the
214 <ulink url='&YOCTO_RELEASE_DL_URL;/machines'>index of machines</ulink>
215 for the release.</para>
216
217 <para>The Yocto Project uses the following BSP layer naming
218 scheme:
219 <literallayout class='monospaced'>
220 meta-<replaceable>bsp_name</replaceable>
221 </literallayout>
222 where <replaceable>bsp_name</replaceable> is the recognized
223 BSP name.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500224 Here is an example:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500225 <literallayout class='monospaced'>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500226 meta-raspberrypi
227 </literallayout>
228 See the
229 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
230 section in the Yocto Project Board Support Package (BSP)
231 Developer's Guide for more information on BSP Layers.</para>
232
233 <para>A useful Git repository released with the Yocto
234 Project is <filename>meta-intel</filename>, which is a
235 parent layer that contains many supported
236 <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>.
237 You can locate the <filename>meta-intel</filename> Git
238 repository in the "Yocto Metadata Layers" area of the Yocto
239 Project Source Repositories at
240 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
241
242 <para>Using
243 <link linkend='git'>Git</link> to create a local clone of the
244 upstream repository can be helpful if you are working with
245 BSPs.
246 Typically, you set up the <filename>meta-intel</filename>
247 Git repository inside the Source Directory.
248 For example, the following transcript shows the steps to clone
249 <filename>meta-intel</filename>.
250 <note>
251 Be sure to work in the <filename>meta-intel</filename>
252 branch that matches your
253 <link linkend='source-directory'>Source Directory</link>
254 (i.e. <filename>poky</filename>) branch.
255 For example, if you have checked out the "master" branch
256 of <filename>poky</filename> and you are going to use
257 <filename>meta-intel</filename>, be sure to checkout the
258 "master" branch of <filename>meta-intel</filename>.
259 </note>
260 <literallayout class='monospaced'>
261 $ cd ~/poky
262 $ git clone git://git.yoctoproject.org/meta-intel.git
263 Cloning into 'meta-intel'...
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500264 remote: Counting objects: 11917, done.
265 remote: Compressing objects: 100% (3842/3842), done.
266 remote: Total 11917 (delta 6840), reused 11699 (delta 6622)
267 Receiving objects: 100% (11917/11917), 2.92 MiB | 2.88 MiB/s, done.
268 Resolving deltas: 100% (6840/6840), done.
269 Checking connectivity... done.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500270 </literallayout></para>
271
272 <para>The same
273 <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>wiki page</ulink>
274 referenced earlier covers how to set up the
275 <filename>meta-intel</filename> Git repository.
276 </para></listitem>
277 <listitem><para><emphasis>Eclipse Yocto Plug-in:</emphasis> If you are developing
278 applications using the Eclipse Integrated Development Environment (IDE),
279 you will need this plug-in.
280 See the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500281 "<ulink url='&YOCTO_DOCS_SDK_URL;#setting-up-the-eclipse-ide'>Setting up the Eclipse IDE</ulink>"
282 section in the Yocto Project Software Development Kit (SDK)
283 Developer's Guide for more information.</para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500284 </itemizedlist>
285 </para>
286</section>
287
288<section id='building-images'>
289 <title>Building Images</title>
290
291 <para>
292 The build process creates an entire Linux distribution, including the toolchain, from source.
293 For more information on this topic, see the
294 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
295 section in the Yocto Project Quick Start.
296 </para>
297
298 <para>
299 The build process is as follows:
300 <orderedlist>
301 <listitem><para>Make sure you have set up the Source Directory described in the
302 previous section.</para></listitem>
303 <listitem><para>Initialize the build environment by sourcing a build
304 environment script (i.e.
305 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
306 or
307 <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
308 </para></listitem>
309 <listitem><para>Optionally ensure the <filename>conf/local.conf</filename> configuration file,
310 which is found in the
311 <link linkend='build-directory'>Build Directory</link>,
312 is set up how you want it.
313 This file defines many aspects of the build environment including
314 the target machine architecture through the
315 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
316 the packaging format used during the build
317 (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>),
318 and a centralized tarball download directory through the
319 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'>DL_DIR</ulink></filename> variable.</para></listitem>
320 <listitem><para>
321 Build the image using the <filename>bitbake</filename> command.
322 If you want information on BitBake, see the
323 <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
324 </para></listitem>
325 <listitem><para>Run the image either on the actual hardware or using the QEMU
326 emulator.</para></listitem>
327 </orderedlist>
328 </para>
329</section>
330
331<section id='using-pre-built-binaries-and-qemu'>
332 <title>Using Pre-Built Binaries and QEMU</title>
333
334 <para>
335 Another option you have to get started is to use pre-built binaries.
336 The Yocto Project provides many types of binaries with each release.
337 See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
338 chapter in the Yocto Project Reference Manual
339 for descriptions of the types of binaries that ship with a Yocto Project
340 release.
341 </para>
342
343 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500344 Using a pre-built binary is ideal for developing software
345 applications to run on your target hardware.
346 To do this, you need to be able to access the appropriate
347 cross-toolchain tarball for the architecture on which you are
348 developing.
349 If you are using an SDK type image, the image ships with the complete
350 toolchain native to the architecture (i.e. a toolchain designed to
351 run on the
352 <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>).
353 If you are not using an SDK type image, you need to separately download
354 and install the stand-alone Yocto Project cross-toolchain tarball.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500355 </para>
356
357 <para>
358 Regardless of the type of image you are using, you need to download the pre-built kernel
359 that you will boot in the QEMU emulator and then download and extract the target root
360 filesystem for your target machine’s architecture.
361 You can get architecture-specific binaries and file systems from
362 <ulink url='&YOCTO_MACHINES_DL_URL;'>machines</ulink>.
363 You can get installation scripts for stand-alone toolchains from
364 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchains</ulink>.
365 Once you have all your files, you set up the environment to emulate the hardware
366 by sourcing an environment setup script.
367 Finally, you start the QEMU emulator.
368 You can find details on all these steps in the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500369 <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500370 You can learn more about using QEMU with the Yocto Project in the
371 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
372 section.
373 </para>
374
375 <para>
376 Using QEMU to emulate your hardware can result in speed issues
377 depending on the target and host architecture mix.
378 For example, using the <filename>qemux86</filename> image in the emulator
379 on an Intel-based 32-bit (x86) host machine is fast because the target and
380 host architectures match.
381 On the other hand, using the <filename>qemuarm</filename> image on the same Intel-based
382 host can be slower.
383 But, you still achieve faithful emulation of ARM-specific issues.
384 </para>
385
386 <para>
387 To speed things up, the QEMU images support using <filename>distcc</filename>
388 to call a cross-compiler outside the emulated system.
389 If you used <filename>runqemu</filename> to start QEMU, and the
390 <filename>distccd</filename> application is present on the host system, any
391 BitBake cross-compiling toolchain available from the build system is automatically
392 used from within QEMU simply by calling <filename>distcc</filename>.
393 You can accomplish this by defining the cross-compiler variable
394 (e.g. <filename>export CC="distcc"</filename>).
395 Alternatively, if you are using a suitable SDK image or the appropriate
396 stand-alone toolchain is present,
397 the toolchain is also automatically used.
398 </para>
399
400 <note>
401 Several mechanisms exist that let you connect to the system running on the
402 QEMU emulator:
403 <itemizedlist>
404 <listitem><para>QEMU provides a framebuffer interface that makes standard
405 consoles available.</para></listitem>
406 <listitem><para>Generally, headless embedded devices have a serial port.
407 If so, you can configure the operating system of the running image
408 to use that port to run a console.
409 The connection uses standard IP networking.</para></listitem>
410 <listitem><para>
411 SSH servers exist in some QEMU images.
412 The <filename>core-image-sato</filename> QEMU image has a
413 Dropbear secure shell (SSH) server that runs with the root
414 password disabled.
415 The <filename>core-image-full-cmdline</filename> and
416 <filename>core-image-lsb</filename> QEMU images
417 have OpenSSH instead of Dropbear.
418 Including these SSH servers allow you to use standard
419 <filename>ssh</filename> and <filename>scp</filename> commands.
420 The <filename>core-image-minimal</filename> QEMU image,
421 however, contains no SSH server.
422 </para></listitem>
423 <listitem><para>You can use a provided, user-space NFS server to boot the QEMU session
424 using a local copy of the root filesystem on the host.
425 In order to make this connection, you must extract a root filesystem tarball by using the
426 <filename>runqemu-extract-sdk</filename> command.
427 After running the command, you must then point the <filename>runqemu</filename>
428 script to the extracted directory instead of a root filesystem image file.</para></listitem>
429 </itemizedlist>
430 </note>
431</section>
432</chapter>
433<!--
434vim: expandtab tw=80 ts=4
435-->