blob: db989b7bfa1f6c92b1233a3b4f76f53a6bdb0d78 [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.
224 Here are some examples:
225 <literallayout class='monospaced'>
226 meta-crownbay
227 meta-emenlow
228 meta-raspberrypi
229 </literallayout>
230 See the
231 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
232 section in the Yocto Project Board Support Package (BSP)
233 Developer's Guide for more information on BSP Layers.</para>
234
235 <para>A useful Git repository released with the Yocto
236 Project is <filename>meta-intel</filename>, which is a
237 parent layer that contains many supported
238 <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>.
239 You can locate the <filename>meta-intel</filename> Git
240 repository in the "Yocto Metadata Layers" area of the Yocto
241 Project Source Repositories at
242 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
243
244 <para>Using
245 <link linkend='git'>Git</link> to create a local clone of the
246 upstream repository can be helpful if you are working with
247 BSPs.
248 Typically, you set up the <filename>meta-intel</filename>
249 Git repository inside the Source Directory.
250 For example, the following transcript shows the steps to clone
251 <filename>meta-intel</filename>.
252 <note>
253 Be sure to work in the <filename>meta-intel</filename>
254 branch that matches your
255 <link linkend='source-directory'>Source Directory</link>
256 (i.e. <filename>poky</filename>) branch.
257 For example, if you have checked out the "master" branch
258 of <filename>poky</filename> and you are going to use
259 <filename>meta-intel</filename>, be sure to checkout the
260 "master" branch of <filename>meta-intel</filename>.
261 </note>
262 <literallayout class='monospaced'>
263 $ cd ~/poky
264 $ git clone git://git.yoctoproject.org/meta-intel.git
265 Cloning into 'meta-intel'...
266 remote: Counting objects: 8844, done.
267 remote: Compressing objects: 100% (2864/2864), done.
268 remote: Total 8844 (delta 4931), reused 8780 (delta 4867)
269 Receiving objects: 100% (8844/8844), 2.48 MiB | 264 KiB/s, done.
270 Resolving deltas: 100% (4931/4931), done.
271 </literallayout></para>
272
273 <para>The same
274 <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>wiki page</ulink>
275 referenced earlier covers how to set up the
276 <filename>meta-intel</filename> Git repository.
277 </para></listitem>
278 <listitem><para><emphasis>Eclipse Yocto Plug-in:</emphasis> If you are developing
279 applications using the Eclipse Integrated Development Environment (IDE),
280 you will need this plug-in.
281 See the
282 "<link linkend='setting-up-the-eclipse-ide'>Setting up the Eclipse IDE</link>"
283 section for more information.</para></listitem>
284 </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>
344 Using a pre-built binary is ideal for developing software applications to run on your
345 target hardware.
346 To do this, you need to be able to access the appropriate cross-toolchain tarball for
347 the architecture on which you are developing.
348 If you are using an SDK type image, the image ships with the complete toolchain native to
349 the architecture.
350 If you are not using an SDK type image, you need to separately download and
351 install the stand-alone Yocto Project cross-toolchain tarball.
352 </para>
353
354 <para>
355 Regardless of the type of image you are using, you need to download the pre-built kernel
356 that you will boot in the QEMU emulator and then download and extract the target root
357 filesystem for your target machine’s architecture.
358 You can get architecture-specific binaries and file systems from
359 <ulink url='&YOCTO_MACHINES_DL_URL;'>machines</ulink>.
360 You can get installation scripts for stand-alone toolchains from
361 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchains</ulink>.
362 Once you have all your files, you set up the environment to emulate the hardware
363 by sourcing an environment setup script.
364 Finally, you start the QEMU emulator.
365 You can find details on all these steps in the
366 "<ulink url='&YOCTO_DOCS_QS_URL;#using-pre-built'>Example Using Pre-Built Binaries and QEMU</ulink>"
367 section of the Yocto Project Application Developer's Guide.
368 You can learn more about using QEMU with the Yocto Project in the
369 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
370 section.
371 </para>
372
373 <para>
374 Using QEMU to emulate your hardware can result in speed issues
375 depending on the target and host architecture mix.
376 For example, using the <filename>qemux86</filename> image in the emulator
377 on an Intel-based 32-bit (x86) host machine is fast because the target and
378 host architectures match.
379 On the other hand, using the <filename>qemuarm</filename> image on the same Intel-based
380 host can be slower.
381 But, you still achieve faithful emulation of ARM-specific issues.
382 </para>
383
384 <para>
385 To speed things up, the QEMU images support using <filename>distcc</filename>
386 to call a cross-compiler outside the emulated system.
387 If you used <filename>runqemu</filename> to start QEMU, and the
388 <filename>distccd</filename> application is present on the host system, any
389 BitBake cross-compiling toolchain available from the build system is automatically
390 used from within QEMU simply by calling <filename>distcc</filename>.
391 You can accomplish this by defining the cross-compiler variable
392 (e.g. <filename>export CC="distcc"</filename>).
393 Alternatively, if you are using a suitable SDK image or the appropriate
394 stand-alone toolchain is present,
395 the toolchain is also automatically used.
396 </para>
397
398 <note>
399 Several mechanisms exist that let you connect to the system running on the
400 QEMU emulator:
401 <itemizedlist>
402 <listitem><para>QEMU provides a framebuffer interface that makes standard
403 consoles available.</para></listitem>
404 <listitem><para>Generally, headless embedded devices have a serial port.
405 If so, you can configure the operating system of the running image
406 to use that port to run a console.
407 The connection uses standard IP networking.</para></listitem>
408 <listitem><para>
409 SSH servers exist in some QEMU images.
410 The <filename>core-image-sato</filename> QEMU image has a
411 Dropbear secure shell (SSH) server that runs with the root
412 password disabled.
413 The <filename>core-image-full-cmdline</filename> and
414 <filename>core-image-lsb</filename> QEMU images
415 have OpenSSH instead of Dropbear.
416 Including these SSH servers allow you to use standard
417 <filename>ssh</filename> and <filename>scp</filename> commands.
418 The <filename>core-image-minimal</filename> QEMU image,
419 however, contains no SSH server.
420 </para></listitem>
421 <listitem><para>You can use a provided, user-space NFS server to boot the QEMU session
422 using a local copy of the root filesystem on the host.
423 In order to make this connection, you must extract a root filesystem tarball by using the
424 <filename>runqemu-extract-sdk</filename> command.
425 After running the command, you must then point the <filename>runqemu</filename>
426 script to the extracted directory instead of a root filesystem image file.</para></listitem>
427 </itemizedlist>
428 </note>
429</section>
430</chapter>
431<!--
432vim: expandtab tw=80 ts=4
433-->