blob: 6e0ded2f174fa0727d9222f3dc72458c1254ffdb [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-model'>
6
7<title>Common Development Models</title>
8
9<para>
10 Many development models exist for which you can use the Yocto Project.
11 This chapter overviews simple methods that use tools provided by the
12 Yocto Project:
13 <itemizedlist>
14 <listitem><para><emphasis>System Development:</emphasis>
15 System Development covers Board Support Package (BSP) development
16 and kernel modification or configuration.
17 For an example on how to create a BSP, see the
18 "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
19 section in the Yocto Project Board Support Package (BSP)
20 Developer's Guide.
21 For more complete information on how to work with the kernel,
22 see the
23 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>.
24 </para></listitem>
25 <listitem><para><emphasis>User Application Development:</emphasis>
26 User Application Development covers development of applications
27 that you intend to run on target hardware.
28 For information on how to set up your host development system for
29 user-space application development, see the
30 <ulink url='&YOCTO_DOCS_ADT_URL;'>Yocto Project Application Developer's Guide</ulink>.
31 For a simple example of user-space application development using
32 the <trademark class='trade'>Eclipse</trademark> IDE, see the
33 "<link linkend='application-development-workflow'>Application
34 Development Workflow</link>" section.
35 </para></listitem>
36 <listitem><para><emphasis>Temporary Source Code Modification:</emphasis>
37 Direct modification of temporary source code is a convenient
38 development model to quickly iterate and develop towards a
39 solution.
40 Once you implement the solution, you should of course take
41 steps to get the changes upstream and applied in the affected
42 recipes.
43 </para></listitem>
44 <listitem><para><emphasis>Image Development using Toaster:</emphasis>
45 You can use <ulink url='&YOCTO_HOME_URL;/Tools-resources/projects/toaster'>Toaster</ulink>
46 to build custom operating system images within the build
47 environment.
48 Toaster provides an efficient interface to the OpenEmbedded build
49 that allows you to start builds and examine build statistics.
50 </para></listitem>
51 <listitem><para><emphasis>Image Development using Hob:</emphasis>
52 You can use the <ulink url='&YOCTO_HOME_URL;/tools-resources/projects/hob'>Hob</ulink>
53 to build custom operating system images within the build
54 environment.
55 Hob provides an efficient interface to the OpenEmbedded build system.
56 </para></listitem>
57 <listitem><para><emphasis>Using a Development Shell:</emphasis>
58 You can use a <filename>devshell</filename> to efficiently debug
59 commands or simply edit packages.
60 Working inside a development shell is a quick way to set up the
61 OpenEmbedded build environment to work on parts of a project.
62 </para></listitem>
63 </itemizedlist>
64</para>
65
66<section id='system-development-model'>
67 <title>System Development Workflow</title>
68
69 <para>
70 System development involves modification or creation of an image that you want to run on
71 a specific hardware target.
72 Usually, when you want to create an image that runs on embedded hardware, the image does
73 not require the same number of features that a full-fledged Linux distribution provides.
74 Thus, you can create a much smaller image that is designed to use only the
75 features for your particular hardware.
76 </para>
77
78 <para>
79 To help you understand how system development works in the Yocto Project, this section
80 covers two types of image development: BSP creation and kernel modification or
81 configuration.
82 </para>
83
84 <section id='developing-a-board-support-package-bsp'>
85 <title>Developing a Board Support Package (BSP)</title>
86
87 <para>
88 A BSP is a collection of recipes that, when applied during a build, results in
89 an image that you can run on a particular board.
90 Thus, the package when compiled into the new image, supports the operation of the board.
91 </para>
92
93 <note>
94 For a brief list of terms used when describing the development process in the Yocto Project,
95 see the "<link linkend='yocto-project-terms'>Yocto Project Terms</link>" section.
96 </note>
97
98 <para>
99 The remainder of this section presents the basic
100 steps used to create a BSP using the Yocto Project's
101 <ulink url='&YOCTO_DOCS_BSP_URL;#using-the-yocto-projects-bsp-tools'>BSP Tools</ulink>.
102 Although not required for BSP creation, the
103 <filename>meta-intel</filename> repository, which contains
104 many BSPs supported by the Yocto Project, is part of the example.
105 </para>
106
107 <para>
108 For an example that shows how to create a new layer using the tools, see the
109 "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
110 section in the Yocto Project Board Support Package (BSP) Developer's Guide.
111 </para>
112
113 <para>
114 The following illustration and list summarize the BSP creation general workflow.
115 </para>
116
117 <para>
118 <imagedata fileref="figures/bsp-dev-flow.png" width="6in" depth="7in" align="center" scalefit="1" />
119 </para>
120
121 <para>
122 <orderedlist>
123 <listitem><para><emphasis>Set up your host development system to support
124 development using the Yocto Project</emphasis>: See the
125 "<ulink url='&YOCTO_DOCS_QS_URL;#the-linux-distro'>The Linux Distribution</ulink>"
126 and the
127 "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>" sections both
128 in the Yocto Project Quick Start for requirements.</para></listitem>
129 <listitem><para><emphasis>Establish a local copy of the project files on your
130 system</emphasis>: You need this <link linkend='source-directory'>Source
131 Directory</link> available on your host system.
132 Having these files on your system gives you access to the build
133 process and to the tools you need.
134 For information on how to set up the Source Directory,
135 see the
136 "<link linkend='getting-setup'>Getting Set Up</link>" section.</para></listitem>
137 <listitem><para><emphasis>Establish the <filename>meta-intel</filename>
138 repository on your system</emphasis>: Having local copies
139 of these supported BSP layers on your system gives you
140 access to layers you might be able to build on or modify
141 to create your BSP.
142 For information on how to get these files, see the
143 "<link linkend='getting-setup'>Getting Set Up</link>" section.</para></listitem>
144 <listitem><para><emphasis>Create your own BSP layer using the
145 <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'><filename>yocto-bsp</filename></ulink> script</emphasis>:
146 Layers are ideal for
147 isolating and storing work for a given piece of hardware.
148 A layer is really just a location or area in which you place
149 the recipes and configurations for your BSP.
150 In fact, a BSP is, in itself, a special type of layer.
151 The simplest way to create a new BSP layer that is compliant with the
152 Yocto Project is to use the <filename>yocto-bsp</filename> script.
153 For information about that script, see the
154 "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a New BSP Layer Using the yocto-bsp Script</ulink>"
155 section in the Yocto Project Board Support (BSP) Developer's Guide.
156 </para>
157 <para>
158 Another example that illustrates a layer is an application.
159 Suppose you are creating an application that has library or other dependencies in
160 order for it to compile and run.
161 The layer, in this case, would be where all the recipes that define those dependencies
162 are kept.
163 The key point for a layer is that it is an isolated area that contains
164 all the relevant information for the project that the OpenEmbedded build
165 system knows about.
166 For more information on layers, see the
167 "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
168 section.
169 For more information on BSP layers, see the
170 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" section in the
171 Yocto Project Board Support Package (BSP) Developer's Guide.</para>
172 <note>Five BSPs exist that are part of the
173 Yocto Project release: <filename>genericx86</filename>, <filename>genericx86-64</filename>,
174 <filename>beaglebone</filename> (ARM),
175 <filename>mpc8315e</filename> (PowerPC),
176 and <filename>edgerouter</filename> (MIPS).
177 The recipes and configurations for these five BSPs are located and dispersed
178 within the <link linkend='source-directory'>Source Directory</link>.
179 On the other hand, the <filename>meta-intel</filename> layer
180 contains BSP layers for many supported BSPs (e.g.
181 Crystal Forest, Emenlow, Fish River Island 2, Haswell,
182 Jasper Forest, and so forth).
183 Aside from the BSPs in the <filename>meta-intel</filename>
184 layer, the
185 <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink>
186 contain additional BSP layers such as
187 <filename>meta-minnow</filename> and
188 <filename>meta-raspberrypi</filename>.</note>
189 <para>When you set up a layer for a new BSP, you should follow a standard layout.
190 This layout is described in the
191 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout'>Example Filesystem Layout</ulink>"
192 section of the Board Support Package (BSP) Development Guide.
193 In the standard layout, you will notice a suggested structure for recipes and
194 configuration information.
195 You can see the standard layout for a BSP by examining
196 any supported BSP found in the <filename>meta-intel</filename> layer inside
197 the Source Directory.</para></listitem>
198 <listitem><para><emphasis>Make configuration changes to your new BSP
199 layer</emphasis>: The standard BSP layer structure organizes the files you need
200 to edit in <filename>conf</filename> and several <filename>recipes-*</filename>
201 directories within the BSP layer.
202 Configuration changes identify where your new layer is on the local system
203 and identify which kernel you are going to use.
204 When you run the <filename>yocto-bsp</filename> script, you are able to interactively
205 configure many things for the BSP (e.g. keyboard, touchscreen, and so forth).
206 </para></listitem>
207 <listitem><para><emphasis>Make recipe changes to your new BSP layer</emphasis>: Recipe
208 changes include altering recipes (<filename>.bb</filename> files), removing
209 recipes you do not use, and adding new recipes or append files
210 (<filename>.bbappend</filename>) that you need to support your hardware.
211 </para></listitem>
212 <listitem><para><emphasis>Prepare for the build</emphasis>: Once you have made all the
213 changes to your BSP layer, there remains a few things
214 you need to do for the OpenEmbedded build system in order for it to create your image.
215 You need to get the build environment ready by sourcing an environment setup script
216 (i.e. <filename>oe-init-build-env</filename> or
217 <filename>oe-init-build-env-memres</filename>)
218 and you need to be sure two key configuration files are configured appropriately:
219 the <filename>conf/local.conf</filename> and the
220 <filename>conf/bblayers.conf</filename> file.
221 You must make the OpenEmbedded build system aware of your new layer.
222 See the
223 "<link linkend='enabling-your-layer'>Enabling Your Layer</link>" section
224 for information on how to let the build system know about your new layer.</para>
225 <para>The entire process for building an image is overviewed in the section
226 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>" section
227 of the Yocto Project Quick Start.
228 You might want to reference this information.</para></listitem>
229 <listitem><para><emphasis>Build the image</emphasis>: The OpenEmbedded build system
230 uses the BitBake tool to build images based on the type of image you want to create.
231 You can find more information about BitBake in the
232 <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
233 </para>
234 <para>The build process supports several types of images to satisfy different needs.
235 See the
236 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter
237 in the Yocto Project Reference Manual for information on
238 supported images.</para></listitem>
239 </orderedlist>
240 </para>
241
242 <para>
243 You can view a video presentation on "Building Custom Embedded Images with Yocto"
244 at <ulink url='http://free-electrons.com/blog/elc-2011-videos'>Free Electrons</ulink>.
245 After going to the page, just search for "Embedded".
246 You can also find supplemental information in the
247 <ulink url='&YOCTO_DOCS_BSP_URL;'>
248 Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
249 Finally, there is helpful material and links on this
250 <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_creating_one_generic_Atom_BSP_from_another'>wiki page</ulink>.
251 Although a bit dated, you might find the information on the wiki
252 helpful.
253 </para>
254 </section>
255
256 <section id='modifying-the-kernel'>
257 <title><anchor id='kernel-spot' />Modifying the Kernel</title>
258
259 <para>
260 Kernel modification involves changing the Yocto Project kernel, which could involve changing
261 configuration options as well as adding new kernel recipes.
262 Configuration changes can be added in the form of configuration fragments, while recipe
263 modification comes through the kernel's <filename>recipes-kernel</filename> area
264 in a kernel layer you create.
265 </para>
266
267 <para>
268 The remainder of this section presents a high-level overview of the Yocto Project
269 kernel architecture and the steps to modify the kernel.
270 You can reference the
271 "<link linkend='patching-the-kernel'>Patching the Kernel</link>" section
272 for an example that changes the source code of the kernel.
273 For information on how to configure the kernel, see the
274 "<link linkend='configuring-the-kernel'>Configuring the Kernel</link>" section.
275 For more information on the kernel and on modifying the kernel, see the
276 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>.
277 </para>
278
279 <section id='kernel-overview'>
280 <title>Kernel Overview</title>
281
282 <para>
283 Traditionally, when one thinks of a patched kernel, they think of a base kernel
284 source tree and a fixed structure that contains kernel patches.
285 The Yocto Project, however, employs mechanisms that, in a sense, result in a kernel source
286 generator.
287 By the end of this section, this analogy will become clearer.
288 </para>
289
290 <para>
291 You can find a web interface to the Yocto Project kernel source repositories at
292 <ulink url='&YOCTO_GIT_URL;'></ulink>.
293 If you look at the interface, you will see to the left a grouping of
294 Git repositories titled "Yocto Linux Kernel."
295 Within this group, you will find several kernels supported by
296 the Yocto Project:
297 <itemizedlist>
298 <listitem><para><emphasis>
299 <filename>linux-yocto-3.8</filename></emphasis> - The
300 stable Yocto Project kernel to use with the Yocto
301 Project Release 1.4. This kernel is based on the
302 Linux 3.8 released kernel.
303 </para></listitem>
304 <listitem><para><emphasis>
305 <filename>linux-yocto-3.10</filename></emphasis> - An
306 additional, unsupported Yocto Project kernel used with
307 the Yocto Project Release 1.5.
308 This kernel is based on the Linux 3.10 released kernel.
309 </para></listitem>
310 <listitem><para><emphasis>
311 <filename>linux-yocto-3.14</filename></emphasis> - The
312 stable Yocto Project kernel to use with the Yocto
313 Project Releases 1.6 and 1.7.
314 This kernel is based on the Linux 3.14 released kernel.
315 </para></listitem>
316 <listitem><para><emphasis>
317 <filename>linux-yocto-3.17</filename></emphasis> - An
318 additional, unsupported Yocto Project kernel used with
319 the Yocto Project Release 1.7.
320 This kernel is based on the Linux 3.17 released kernel.
321 </para></listitem>
322 <listitem><para><emphasis>
323 <filename>linux-yocto-3.19</filename></emphasis> - The
324 stable Yocto Project kernel to use with the Yocto
325 Project Release 1.8.
326 This kernel is based on the Linux 3.19 released kernel.
327 </para></listitem>
328 <listitem><para><emphasis>
329 <filename>linux-yocto-dev</filename></emphasis> - A
330 development kernel based on the latest upstream release
331 candidate available.
332 </para></listitem>
333 </itemizedlist>
334 </para>
335
336 <para>
337 The kernels are maintained using the Git revision control system
338 that structures them using the familiar "tree", "branch", and "leaf" scheme.
339 Branches represent diversions from general code to more specific code, while leaves
340 represent the end-points for a complete and unique kernel whose source files,
341 when gathered from the root of the tree to the leaf, accumulate to create the files
342 necessary for a specific piece of hardware and its features.
343 The following figure displays this concept:
344 <para>
345 <imagedata fileref="figures/kernel-overview-1.png"
346 width="6in" depth="6in" align="center" scale="100" />
347 </para>
348
349 <para>
350 Within the figure, the "Kernel.org Branch Point" represents the point in the tree
351 where a supported base kernel is modified from the Linux kernel.
352 For example, this could be the branch point for the <filename>linux-yocto-3.19</filename>
353 kernel.
354 Thus, everything further to the right in the structure is based on the
355 <filename>linux-yocto-3.19</filename> kernel.
356 Branch points to the right in the figure represent where the
357 <filename>linux-yocto-3.19</filename> kernel is modified for specific hardware
358 or types of kernels, such as real-time kernels.
359 Each leaf thus represents the end-point for a kernel designed to run on a specific
360 targeted device.
361 </para>
362
363 <para>
364 The overall result is a Git-maintained repository from which all the supported
365 kernel types can be derived for all the supported devices.
366 A big advantage to this scheme is the sharing of common features by keeping them in
367 "larger" branches within the tree.
368 This practice eliminates redundant storage of similar features shared among kernels.
369 </para>
370
371 <note>
372 Keep in mind the figure does not take into account all the supported Yocto
373 Project kernel types, but rather shows a single generic kernel just for conceptual purposes.
374 Also keep in mind that this structure represents the Yocto Project source repositories
375 that are either pulled from during the build or established on the host development system
376 prior to the build by either cloning a particular kernel's Git repository or by
377 downloading and unpacking a tarball.
378 </note>
379
380 <para>
381 Upstream storage of all the available kernel source code is one thing, while
382 representing and using the code on your host development system is another.
383 Conceptually, you can think of the kernel source repositories as all the
384 source files necessary for all the supported kernels.
385 As a developer, you are just interested in the source files for the kernel on
386 which you are working.
387 And, furthermore, you need them available on your host system.
388 </para>
389
390 <para>
391 Kernel source code is available on your host system a couple of different
392 ways.
393 If you are working in the kernel all the time, you probably would want
394 to set up your own local Git repository of the kernel tree.
395 If you just need to make some patches to the kernel, you can access
396 temporary kernel source files that were extracted and used
397 during a build.
398 We will just talk about working with the temporary source code.
399 For more information on how to get kernel source code onto your
400 host system, see the
401 "<link linkend='local-kernel-files'>Yocto Project Kernel</link>"
402 bulleted item earlier in the manual.
403 </para>
404
405 <para>
406 What happens during the build?
407 When you build the kernel on your development system, all files needed for the build
408 are taken from the source repositories pointed to by the
409 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> variable
410 and gathered in a temporary work area
411 where they are subsequently used to create the unique kernel.
412 Thus, in a sense, the process constructs a local source tree specific to your
413 kernel to generate the new kernel image - a source generator if you will.
414 </para>
415 The following figure shows the temporary file structure
416 created on your host system when the build occurs.
417 This
418 <link linkend='build-directory'>Build Directory</link> contains all the
419 source files used during the build.
420 </para>
421
422 <para>
423 <imagedata fileref="figures/kernel-overview-2-generic.png"
424 width="6in" depth="5in" align="center" scale="100" />
425 </para>
426
427 <para>
428 Again, for additional information on the Yocto Project kernel's
429 architecture and its branching strategy, see the
430 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>.
431 You can also reference the
432 "<link linkend='patching-the-kernel'>Patching the Kernel</link>"
433 section for a detailed example that modifies the kernel.
434 </para>
435 </section>
436
437 <section id='kernel-modification-workflow'>
438 <title>Kernel Modification Workflow</title>
439
440 <para>
441 This illustration and the following list summarizes the kernel modification general workflow.
442 </para>
443
444 <para>
445 <imagedata fileref="figures/kernel-dev-flow.png"
446 width="6in" depth="5in" align="center" scalefit="1" />
447 </para>
448
449 <para>
450 <orderedlist>
451 <listitem><para><emphasis>Set up your host development system to support
452 development using the Yocto Project</emphasis>: See
453 "<ulink url='&YOCTO_DOCS_QS_URL;#the-linux-distro'>The Linux Distribution</ulink>" and
454 "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>" sections both
455 in the Yocto Project Quick Start for requirements.</para></listitem>
456 <listitem><para><emphasis>Establish a local copy of project files on your
457 system</emphasis>: Having the <link linkend='source-directory'>Source
458 Directory</link> on your system gives you access to the build process and tools
459 you need.
460 For information on how to get these files, see the bulleted item
461 "<link linkend='local-yp-release'>Yocto Project Release</link>" earlier in this manual.
462 </para></listitem>
463 <listitem><para><emphasis>Establish the temporary kernel source files</emphasis>:
464 Temporary kernel source files are kept in the
465 <link linkend='build-directory'>Build Directory</link>
466 created by the
467 OpenEmbedded build system when you run BitBake.
468 If you have never built the kernel in which you are
469 interested, you need to run an initial build to
470 establish local kernel source files.</para>
471 <para>If you are building an image for the first time, you need to get the build
472 environment ready by sourcing an environment setup script
473 (i.e. <filename>oe-init-build-env</filename> or
474 <filename>oe-init-build-env-memres</filename>).
475 You also need to be sure two key configuration files
476 (<filename>local.conf</filename> and <filename>bblayers.conf</filename>)
477 are configured appropriately.</para>
478 <para>The entire process for building an image is overviewed in the
479 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
480 section of the Yocto Project Quick Start.
481 You might want to reference this information.
482 You can find more information on BitBake in the
483 <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
484 </para>
485 <para>The build process supports several types of images to satisfy different needs.
486 See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter in
487 the Yocto Project Reference Manual for information on supported images.
488 </para></listitem>
489 <listitem><para><emphasis>Make changes to the kernel source code if
490 applicable</emphasis>: Modifying the kernel does not always mean directly
491 changing source files.
492 However, if you have to do this, you make the changes to the files in the
493 Build Directory.</para></listitem>
494 <listitem><para><emphasis>Make kernel configuration changes if applicable</emphasis>:
495 If your situation calls for changing the kernel's
496 configuration, you can use
497 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'><filename>menuconfig</filename></ulink>,
498 which allows you to interactively develop and test the
499 configuration changes you are making to the kernel.
500 Saving changes you make with
501 <filename>menuconfig</filename> updates
502 the kernel's <filename>.config</filename> file.
503 <note><title>Warning</title>
504 Try to resist the temptation to directly edit an
505 existing <filename>.config</filename> file, which is
506 found in the Build Directory at
507 <filename>tmp/sysroots/<replaceable>machine-name</replaceable>/kernel</filename>.
508 Doing so, can produce unexpected results when the
509 OpenEmbedded build system regenerates the configuration
510 file.
511 </note>
512 Once you are satisfied with the configuration
513 changes made using <filename>menuconfig</filename>
514 and you have saved them, you can directly compare the
515 resulting <filename>.config</filename> file against an
516 existing original and gather those changes into a
517 <link linkend='creating-config-fragments'>configuration fragment file</link>
518 to be referenced from within the kernel's
519 <filename>.bbappend</filename> file.</para>
520
521 <para>Additionally, if you are working in a BSP layer
522 and need to modify the BSP's kernel's configuration,
523 you can use the
524 <ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'><filename>yocto-kernel</filename></ulink>
525 script as well as <filename>menuconfig</filename>.
526 The <filename>yocto-kernel</filename> script lets
527 you interactively set up kernel configurations.
528 </para></listitem>
529 <listitem><para><emphasis>Rebuild the kernel image with your changes</emphasis>:
530 Rebuilding the kernel image applies your changes.
531 </para></listitem>
532 </orderedlist>
533 </para>
534 </section>
535 </section>
536</section>
537
538<section id='application-development-workflow'>
539 <title>Application Development Workflow</title>
540
541 <para>
542 Application development involves creating an application that you want
543 to run on your target hardware, which is running a kernel image created using the
544 OpenEmbedded build system.
545 The Yocto Project provides an
546 <ulink url='&YOCTO_DOCS_ADT_URL;#adt-intro'>Application Development Toolkit (ADT)</ulink>
547 and stand-alone
548 <ulink url='&YOCTO_DOCS_ADT_URL;#the-cross-development-toolchain'>cross-development toolchains</ulink>
549 that facilitate quick development and integration of your application into its runtime environment.
550 Using the ADT and toolchains, you can compile and link your application.
551 You can then deploy your application to the actual hardware or to the QEMU emulator for testing.
552 If you are familiar with the popular <trademark class='trade'>Eclipse</trademark> IDE,
553 you can use an Eclipse Yocto Plug-in to
554 allow you to develop, deploy, and test your application all from within Eclipse.
555 </para>
556
557 <para>
558 While we strongly suggest using the ADT to develop your application, this option might not
559 be best for you.
560 If this is the case, you can still use pieces of the Yocto Project for your development process.
561 However, because the process can vary greatly, this manual does not provide detail on the process.
562 </para>
563
564 <section id='workflow-using-the-adt-and-eclipse'>
565 <title>Workflow Using the ADT and <trademark class='trade'>Eclipse</trademark></title>
566
567 <para>
568 To help you understand how application development works using the ADT, this section
569 provides an overview of the general development process and a detailed example of the process
570 as it is used from within the Eclipse IDE.
571 </para>
572
573 <para>
574 The following illustration and list summarize the application development general workflow.
575 </para>
576
577 <para>
578 <imagedata fileref="figures/app-dev-flow.png"
579 width="7in" depth="8in" align="center" scale="100" />
580 </para>
581
582 <para>
583 <orderedlist>
584 <listitem><para><emphasis>Prepare the host system for the Yocto Project</emphasis>:
585 See
586 "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
587 and
588 "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>" sections both
589 in the Yocto Project Reference Manual for requirements.
590 In particular, be sure your host system has the
591 <filename>xterm</filename> package installed.
592 </para></listitem>
593 <listitem><para><emphasis>Secure the Yocto Project kernel target image</emphasis>:
594 You must have a target kernel image that has been built using the OpenEmbedded
595 build system.</para>
596 <para>Depending on whether the Yocto Project has a pre-built image that matches your target
597 architecture and where you are going to run the image while you develop your application
598 (QEMU or real hardware), the area from which you get the image differs.
599 <itemizedlist>
600 <listitem><para>Download the image from
601 <ulink url='&YOCTO_MACHINES_DL_URL;'><filename>machines</filename></ulink>
602 if your target architecture is supported and you are going to develop
603 and test your application on actual hardware.</para></listitem>
604 <listitem><para>Download the image from
605 <ulink url='&YOCTO_QEMU_DL_URL;'>
606 <filename>machines/qemu</filename></ulink> if your target architecture is supported
607 and you are going to develop and test your application using the QEMU
608 emulator.</para></listitem>
609 <listitem><para>Build your image if you cannot find a pre-built image that matches
610 your target architecture.
611 If your target architecture is similar to a supported architecture, you can
612 modify the kernel image before you build it.
613 See the
614 "<link linkend='patching-the-kernel'>Patching the Kernel</link>"
615 section for an example.</para></listitem>
616 </itemizedlist></para>
617 <para>For information on pre-built kernel image naming schemes for images
618 that can run on the QEMU emulator, see the
619 "<ulink url='&YOCTO_DOCS_QS_URL;#downloading-the-pre-built-linux-kernel'>Downloading the Pre-Built Linux Kernel</ulink>"
620 section in the Yocto Project Application Developer's Guide.</para></listitem>
621 <listitem><para><emphasis>Install the ADT</emphasis>:
622 The ADT provides a target-specific cross-development toolchain, the root filesystem,
623 the QEMU emulator, and other tools that can help you develop your application.
624 While it is possible to get these pieces separately, the ADT Installer provides an
625 easy, inclusive method.
626 You can get these pieces by running an ADT installer script, which is configurable.
627 For information on how to install the ADT, see the
628 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-the-adt-installer'>Using the ADT Installer</ulink>"
629 section
630 in the Yocto Project Application Developer's Guide.</para></listitem>
631 <listitem><para><emphasis>If applicable, secure the target root filesystem
632 and the Cross-development toolchain</emphasis>:
633 If you choose not to install the ADT using the ADT Installer,
634 you need to find and download the appropriate root filesystem and
635 the cross-development toolchain.</para>
636 <para>You can find the tarballs for the root filesystem in the same area used
637 for the kernel image.
638 Depending on the type of image you are running, the root filesystem you need differs.
639 For example, if you are developing an application that runs on an image that
640 supports Sato, you need to get a root filesystem that supports Sato.</para>
641 <para>You can find the cross-development toolchains at
642 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'><filename>toolchains</filename></ulink>.
643 Be sure to get the correct toolchain for your development host and your
644 target architecture.
645 See the "<ulink url='&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball'>Using a Cross-Toolchain Tarball</ulink>"
646 section in the Yocto Project Application Developer's Guide for information
647 and the
648 "<ulink url='&YOCTO_DOCS_QS_URL;#installing-the-toolchain'>Installing the Toolchain</ulink>"
649 in the Yocto Project Application Developer's Guide for information on finding and installing
650 the correct toolchain based on your host development system and your target
651 architecture.
652 </para></listitem>
653 <listitem><para><emphasis>Create and build your application</emphasis>:
654 At this point, you need to have source files for your application.
655 Once you have the files, you can use the Eclipse IDE to import them and build the
656 project.
657 If you are not using Eclipse, you need to use the cross-development tools you have
658 installed to create the image.</para></listitem>
659 <listitem><para><emphasis>Deploy the image with the application</emphasis>:
660 If you are using the Eclipse IDE, you can deploy your image to the hardware or to
661 QEMU through the project's preferences.
662 If you are not using the Eclipse IDE, then you need to deploy the application
663 to the hardware using other methods.
664 Or, if you are using QEMU, you need to use that tool and
665 load your image in for testing.
666 See the
667 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
668 chapter for information on using QEMU.
669 </para></listitem>
670 <listitem><para><emphasis>Test and debug the application</emphasis>:
671 Once your application is deployed, you need to test it.
672 Within the Eclipse IDE, you can use the debugging environment along with the
673 set of user-space tools installed along with the ADT to debug your application.
674 Of course, the same user-space tools are available separately if you choose
675 not to use the Eclipse IDE.</para></listitem>
676 </orderedlist>
677 </para>
678 </section>
679
680 <section id='adt-eclipse'>
681 <title>Working Within Eclipse</title>
682
683 <para>
684 The Eclipse IDE is a popular development environment and it fully
685 supports development using the Yocto Project.
686 <note>
687 This release of the Yocto Project supports both the Luna
688 and Kepler versions of the Eclipse IDE.
689 Thus, the following information provides setup information for
690 both versions.
691 </note>
692 </para>
693
694 <para>
695 When you install and configure the Eclipse Yocto Project Plug-in
696 into the Eclipse IDE, you maximize your Yocto Project experience.
697 Installing and configuring the Plug-in results in an environment
698 that has extensions specifically designed to let you more easily
699 develop software.
700 These extensions allow for cross-compilation, deployment, and
701 execution of your output into a QEMU emulation session as well as
702 actual target hardware.
703 You can also perform cross-debugging and profiling.
704 The environment also supports a suite of tools that allows you
705 to perform remote profiling, tracing, collection of power data,
706 collection of latency data, and collection of performance data.
707 </para>
708
709 <para>
710 This section describes how to install and configure the Eclipse IDE
711 Yocto Plug-in and how to use it to develop your application.
712 </para>
713
714 <section id='setting-up-the-eclipse-ide'>
715 <title>Setting Up the Eclipse IDE</title>
716
717 <para>
718 To develop within the Eclipse IDE, you need to do the following:
719 <orderedlist>
720 <listitem><para>Install the optimal version of the Eclipse
721 IDE.</para></listitem>
722 <listitem><para>Configure the Eclipse IDE.
723 </para></listitem>
724 <listitem><para>Install the Eclipse Yocto Plug-in.
725 </para></listitem>
726 <listitem><para>Configure the Eclipse Yocto Plug-in.
727 </para></listitem>
728 </orderedlist>
729 <note>
730 Do not install Eclipse from your distribution's package
731 repository.
732 Be sure to install Eclipse from the official Eclipse
733 download site as directed in the next section.
734 </note>
735 </para>
736
737 <section id='installing-eclipse-ide'>
738 <title>Installing the Eclipse IDE</title>
739
740 <para>
741 It is recommended that you have the Luna SR2 (4.4.2)
742 version of the Eclipse IDE installed on your development
743 system.
744 However, if you currently have the Kepler 4.3.2 version
745 installed and you do not want to upgrade the IDE, you can
746 configure Kepler to work with the Yocto Project.
747 </para>
748
749 <para>
750 If you do not have the Luna SR2 (4.4.2) Eclipse IDE
751 installed, you can find the tarball at
752 <ulink url='&ECLIPSE_MAIN_URL;'></ulink>.
753 From that site, choose the appropriate download from the
754 "Eclipse IDE for C/C++ Developers".
755 This version contains the Eclipse Platform, the Java
756 Development Tools (JDT), and the Plug-in Development
757 Environment.
758 </para>
759
760 <para>
761 Once you have downloaded the tarball, extract it into a
762 clean directory.
763 For example, the following commands unpack and install the
764 downloaded Eclipse IDE tarball into a clean directory
765 using the default name <filename>eclipse</filename>:
766 <literallayout class='monospaced'>
767 $ cd ~
768 $ tar -xzvf ~/Downloads/eclipse-cpp-luna-SR2-linux-gtk-x86_64.tar.gz
769 </literallayout>
770 </para>
771 </section>
772
773 <section id='configuring-the-eclipse-ide'>
774 <title>Configuring the Eclipse IDE</title>
775
776 <para>
777 This section presents the steps needed to configure the
778 Eclipse IDE.
779 </para>
780
781 <para>
782 Before installing and configuring the Eclipse Yocto Plug-in,
783 you need to configure the Eclipse IDE.
784 Follow these general steps:
785 <orderedlist>
786 <listitem><para>Start the Eclipse IDE.</para></listitem>
787 <listitem><para>Make sure you are in your Workbench and
788 select "Install New Software" from the "Help"
789 pull-down menu.</para></listitem>
790 <listitem><para>Select
791 <filename>Luna - &ECLIPSE_LUNA_URL;</filename>
792 from the "Work with:" pull-down menu.
793 <note>
794 For Kepler, select
795 <filename>Kepler - &ECLIPSE_KEPLER_URL;</filename>
796 </note>
797 </para></listitem>
798 <listitem><para>Expand the box next to "Linux Tools"
799 and select the
800 <filename>Linux Tools LTTng Tracer Control</filename>,
801 <filename>Linux Tools LTTng Userspace Analysis</filename>,
802 and
803 <filename>LTTng Kernel Analysis</filename> boxes.
804 If these selections do not appear in the list,
805 that means the items are already installed.
806 <note>
807 For Kepler, select
808 <filename>LTTng - Linux Tracing Toolkit</filename>
809 box.
810 </note>
811 </para></listitem>
812 <listitem><para>Expand the box next to "Mobile and
813 Device Development" and select the following boxes.
814 Again, if any of the following items are not
815 available for selection, that means the items are
816 already installed:
817 <itemizedlist>
818 <listitem><para><filename>C/C++ Remote Launch (Requires RSE Remote System Explorer)</filename></para></listitem>
819 <listitem><para><filename>Remote System Explorer End-user Runtime</filename></para></listitem>
820 <listitem><para><filename>Remote System Explorer User Actions</filename></para></listitem>
821 <listitem><para><filename>Target Management Terminal (Core SDK)</filename></para></listitem>
822 <listitem><para><filename>TCF Remote System Explorer add-in</filename></para></listitem>
823 <listitem><para><filename>TCF Target Explorer</filename></para></listitem>
824 </itemizedlist></para></listitem>
825 <listitem><para>Expand the box next to "Programming
826 Languages" and select the
827 <filename>C/C++ Autotools Support</filename>
828 and <filename>C/C++ Development Tools</filename>
829 boxes.
830 For Luna, these items do not appear on the list
831 as they are already installed.
832 </para></listitem>
833 <listitem><para>Complete the installation and restart
834 the Eclipse IDE.</para></listitem>
835 </orderedlist>
836 </para>
837 </section>
838
839 <section id='installing-the-eclipse-yocto-plug-in'>
840 <title>Installing or Accessing the Eclipse Yocto Plug-in</title>
841
842 <para>
843 You can install the Eclipse Yocto Plug-in into the Eclipse
844 IDE one of two ways: use the Yocto Project's Eclipse
845 Update site to install the pre-built plug-in or build and
846 install the plug-in from the latest source code.
847 </para>
848
849 <section id='new-software'>
850 <title>Installing the Pre-built Plug-in from the Yocto Project Eclipse Update Site</title>
851
852 <para>
853 To install the Eclipse Yocto Plug-in from the update
854 site, follow these steps:
855 <orderedlist>
856 <listitem><para>Start up the Eclipse IDE.
857 </para></listitem>
858 <listitem><para>In Eclipse, select "Install New
859 Software" from the "Help" menu.
860 </para></listitem>
861 <listitem><para>Click "Add..." in the "Work with:"
862 area.</para></listitem>
863 <listitem><para>Enter
864 <filename>&ECLIPSE_DL_PLUGIN_URL;/luna</filename>
865 in the URL field and provide a meaningful name
866 in the "Name" field.
867 <note>
868 If you are using Kepler, use
869 <filename>&ECLIPSE_DL_PLUGIN_URL;/kepler</filename>
870 in the URL field.
871 </note></para></listitem>
872 <listitem><para>Click "OK" to have the entry added
873 to the "Work with:" drop-down list.
874 </para></listitem>
875 <listitem><para>Select the entry for the plug-in
876 from the "Work with:" drop-down list.
877 </para></listitem>
878 <listitem><para>Check the boxes next to
879 <filename>Yocto Project ADT Plug-in</filename>,
880 <filename>Yocto Project Bitbake Commander Plug-in</filename>,
881 and
882 <filename>Yocto Project Documentation plug-in</filename>.
883 </para></listitem>
884 <listitem><para>Complete the remaining software
885 installation steps and then restart the Eclipse
886 IDE to finish the installation of the plug-in.
887 <note>
888 You can click "OK" when prompted about
889 installing software that contains unsigned
890 content.
891 </note>
892 </para></listitem>
893 </orderedlist>
894 </para>
895 </section>
896
897 <section id='zip-file-method'>
898 <title>Installing the Plug-in Using the Latest Source Code</title>
899
900 <para>
901 To install the Eclipse Yocto Plug-in from the latest
902 source code, follow these steps:
903 <orderedlist>
904 <listitem><para>Be sure your development system
905 is not using OpenJDK to build the plug-in
906 by doing the following:
907 <orderedlist>
908 <listitem><para>Use the Oracle JDK.
909 If you don't have that, go to
910 <ulink url='http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html'></ulink>
911 and download the latest appropriate
912 Java SE Development Kit tarball for
913 your development system and
914 extract it into your home directory.
915 </para></listitem>
916 <listitem><para>In the shell you are going
917 to do your work, export the location of
918 the Oracle Java.
919 The previous step creates a new folder
920 for the extracted software.
921 You need to use the following
922 <filename>export</filename> command
923 and provide the specific location:
924 <literallayout class='monospaced'>
925 export PATH=~/<replaceable>extracted_jdk_location</replaceable>/bin:$PATH
926 </literallayout>
927 </para></listitem>
928 </orderedlist>
929 </para></listitem>
930 <listitem><para>In the same shell, create a Git
931 repository with:
932 <literallayout class='monospaced'>
933 $ cd ~
934 $ git clone git://git.yoctoproject.org/eclipse-poky
935 </literallayout>
936 </para></listitem>
937 <listitem><para>Be sure to checkout the correct
938 tag.
939 For example, if you are using Luna, do the
940 following:
941 <literallayout class='monospaced'>
942 $ git checkout luna/yocto-1.8
943 </literallayout>
944 This puts you in a detached HEAD state, which
945 is fine since you are only going to be building
946 and not developing.
947 <note>
948 If you are building kepler, checkout the
949 <filename>kepler/yocto-1.8</filename>
950 branch.
951 </note>
952 </para></listitem>
953 <listitem><para>Change to the
954 <filename>scripts</filename>
955 directory within the Git repository:
956 <literallayout class='monospaced'>
957 $ cd scripts
958 </literallayout>
959 </para></listitem>
960 <listitem><para>Set up the local build environment
961 by running the setup script:
962 <literallayout class='monospaced'>
963 $ ./setup.sh
964 </literallayout>
965 </para></listitem>
966 <listitem><para>When the script finishes execution,
967 it prompts you with instructions on how to run
968 the <filename>build.sh</filename> script, which
969 is also in the <filename>scripts</filename>
970 directory of the Git repository created
971 earlier.
972 </para></listitem>
973 <listitem><para>Run the <filename>build.sh</filename>
974 script as directed.
975 Be sure to provide the tag name, documentation
976 branch, and a release name.
977 Here is an example that uses the
978 <filename>luna/yocto-1.8</filename> tag, the
979 <filename>master</filename> documentation
980 branch, and
981 <filename>&DISTRO_NAME;</filename> for the
982 release name:
983 <literallayout class='monospaced'>
984 $ ECLIPSE_HOME=/home/scottrif/eclipse-poky/scripts/eclipse ./build.sh luna/yocto-1.8 master &DISTRO_NAME; 2>&amp;1 | tee -a build.log
985 </literallayout>
986 After running the script, the file
987 <filename>org.yocto.sdk-</filename><replaceable>release</replaceable><filename>-</filename><replaceable>date</replaceable><filename>-archive.zip</filename>
988 is in the current directory.
989 </para></listitem>
990 <listitem><para>If necessary, start the Eclipse IDE
991 and be sure you are in the Workbench.
992 </para></listitem>
993 <listitem><para>Select "Install New Software" from
994 the "Help" pull-down menu.
995 </para></listitem>
996 <listitem><para>Click "Add".</para></listitem>
997 <listitem><para>Provide anything you want in the
998 "Name" field.
999 </para></listitem>
1000 <listitem><para>Click "Archive" and browse to the
1001 ZIP file you built in step eight.
1002 This ZIP file should not be "unzipped", and must
1003 be the <filename>*archive.zip</filename> file
1004 created by running the
1005 <filename>build.sh</filename> script.
1006 </para></listitem>
1007 <listitem><para>Click the "OK" button.
1008 </para></listitem>
1009 <listitem><para>Check the boxes that appear in
1010 the installation window to install the
1011 <filename>Yocto Project ADT Plug-in</filename>,
1012 <filename>Yocto Project Bitbake Commander Plug-in</filename>,
1013 and the
1014 <filename>Yocto Project Documentation plug-in</filename>.
1015 </para></listitem>
1016 <listitem><para>Finish the installation by clicking
1017 through the appropriate buttons.
1018 You can click "OK" when prompted about
1019 installing software that contains unsigned
1020 content.
1021 </para></listitem>
1022 <listitem><para>Restart the Eclipse IDE if
1023 necessary.
1024 </para></listitem>
1025 </orderedlist>
1026 </para>
1027
1028 <para>
1029 At this point you should be able to configure the
1030 Eclipse Yocto Plug-in as described in the
1031 "<link linkend='configuring-the-eclipse-yocto-plug-in'>Configuring the Eclipse Yocto Plug-in</link>"
1032 section.</para>
1033 </section>
1034 </section>
1035
1036 <section id='configuring-the-eclipse-yocto-plug-in'>
1037 <title>Configuring the Eclipse Yocto Plug-in</title>
1038
1039 <para>
1040 Configuring the Eclipse Yocto Plug-in involves setting the
1041 Cross Compiler options and the Target options.
1042 The configurations you choose become the default settings
1043 for all projects.
1044 You do have opportunities to change them later when
1045 you configure the project (see the following section).
1046 </para>
1047
1048 <para>
1049 To start, you need to do the following from within the
1050 Eclipse IDE:
1051 <itemizedlist>
1052 <listitem><para>Choose "Preferences" from the
1053 "Window" menu to display the Preferences Dialog.
1054 </para></listitem>
1055 <listitem><para>Click "Yocto Project ADT" to display
1056 the configuration screen.
1057 </para></listitem>
1058 </itemizedlist>
1059 </para>
1060
1061 <section id='configuring-the-cross-compiler-options'>
1062 <title>Configuring the Cross-Compiler Options</title>
1063
1064 <para>
1065 To configure the Cross Compiler Options, you must select
1066 the type of toolchain, point to the toolchain, specify
1067 the sysroot location, and select the target
1068 architecture.
1069 <itemizedlist>
1070 <listitem><para><emphasis>Selecting the Toolchain Type:</emphasis>
1071 Choose between
1072 <filename>Standalone pre-built toolchain</filename>
1073 and
1074 <filename>Build system derived toolchain</filename>
1075 for Cross Compiler Options.
1076 <itemizedlist>
1077 <listitem><para><emphasis>
1078 <filename>Standalone Pre-built Toolchain:</filename></emphasis>
1079 Select this mode when you are using
1080 a stand-alone cross-toolchain.
1081 For example, suppose you are an
1082 application developer and do not
1083 need to build a target image.
1084 Instead, you just want to use an
1085 architecture-specific toolchain on
1086 an existing kernel and target root
1087 filesystem.</para></listitem>
1088 <listitem><para><emphasis>
1089 <filename>Build System Derived Toolchain:</filename></emphasis>
1090 Select this mode if the
1091 cross-toolchain has been installed
1092 and built as part of the
1093 <link linkend='build-directory'>Build Directory</link>.
1094 When you select
1095 <filename>Build system derived toolchain</filename>,
1096 you are using the toolchain bundled
1097 inside the Build Directory.
1098 </para></listitem>
1099 </itemizedlist>
1100 </para></listitem>
1101 <listitem><para><emphasis>Point to the Toolchain:</emphasis>
1102 If you are using a stand-alone pre-built
1103 toolchain, you should be pointing to where it is
1104 installed.
1105 If you used the ADT Installer script and
1106 accepted the default installation directory, the
1107 toolchain will be installed in the
1108 <filename>&YOCTO_ADTPATH_DIR;</filename>
1109 directory.
1110 Sections "<ulink url='&YOCTO_DOCS_ADT_URL;#configuring-and-running-the-adt-installer-script'>Configuring and Running the ADT Installer Script</ulink>"
1111 and
1112 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball'>Using a Cross-Toolchain Tarball</ulink>"
1113 in the Yocto Project Application Developer's
1114 Guide describe how to install a stand-alone
1115 cross-toolchain.</para>
1116 <para>If you are using a system-derived
1117 toolchain, the path you provide for the
1118 <filename>Toolchain Root Location</filename>
1119 field is the
1120 <link linkend='build-directory'>Build Directory</link>.
1121 See the
1122 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-the-toolchain-from-within-the-build-tree'>Using BitBake and the Build Directory</ulink>"
1123 section in the Yocto Project Application
1124 Developer's Guide for information on how to
1125 install the toolchain into the Build
1126 Directory.</para></listitem>
1127 <listitem><para><emphasis>Specify the Sysroot Location:</emphasis>
1128 This location is where the root filesystem for
1129 the target hardware resides.
1130 If you used the ADT Installer script and
1131 accepted the default installation directory,
1132 then the location in your home directory
1133 in a folder named
1134 <filename>test-yocto/</filename><replaceable>target_arch</replaceable>.
1135 Additionally, when you use the ADT Installer
1136 script, the
1137 <filename>/opt/poky/&DISTRO;/sysroots</filename>
1138 location is used for the QEMU
1139 user-space tools and the NFS boot process.
1140 </para>
1141 <para>If you used either of the other two
1142 methods to install the toolchain or did not
1143 accept the ADT Installer script's default
1144 installation directory, then the location of
1145 the sysroot filesystem depends on where you
1146 separately extracted and installed the
1147 filesystem.</para>
1148 <para>For information on how to install the
1149 toolchain and on how to extract and install the
1150 sysroot filesystem, see the
1151 "<ulink url='&YOCTO_DOCS_ADT_URL;#installing-the-adt'>Installing the ADT and Toolchains</ulink>"
1152 section in the Yocto Project Application
1153 Developer's Guide.
1154 </para></listitem>
1155 <listitem><para><emphasis>Select the Target Architecture:</emphasis>
1156 The target architecture is the type of hardware
1157 you are going to use or emulate.
1158 Use the pull-down
1159 <filename>Target Architecture</filename> menu
1160 to make your selection.
1161 The pull-down menu should have the supported
1162 architectures.
1163 If the architecture you need is not listed in
1164 the menu, you will need to build the image.
1165 See the
1166 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
1167 section of the Yocto Project Quick Start for
1168 more information.</para></listitem>
1169 </itemizedlist>
1170 </para>
1171 </section>
1172
1173 <section id='configuring-the-target-options'>
1174 <title>Configuring the Target Options</title>
1175
1176 <para>
1177 You can choose to emulate hardware using the QEMU
1178 emulator, or you can choose to run your image on actual
1179 hardware.
1180 <itemizedlist>
1181 <listitem><para><emphasis>QEMU:</emphasis>
1182 Select this option if you will be using the
1183 QEMU emulator.
1184 If you are using the emulator, you also need to
1185 locate the kernel and specify any custom
1186 options.</para>
1187 <para>If you selected
1188 <filename>Build system derived toolchain</filename>,
1189 the target kernel you built will be located in
1190 the Build Directory in
1191 <filename>tmp/deploy/images/<replaceable>machine</replaceable></filename>
1192 directory.
1193 If you selected
1194 <filename>Standalone pre-built toolchain</filename>,
1195 the pre-built image you downloaded is located
1196 in the directory you specified when you
1197 downloaded the image.</para>
1198 <para>Most custom options are for advanced QEMU
1199 users to further customize their QEMU instance.
1200 These options are specified between paired
1201 angled brackets.
1202 Some options must be specified outside the
1203 brackets.
1204 In particular, the options
1205 <filename>serial</filename>,
1206 <filename>nographic</filename>, and
1207 <filename>kvm</filename> must all be outside the
1208 brackets.
1209 Use the <filename>man qemu</filename> command
1210 to get help on all the options and their use.
1211 The following is an example:
1212 <literallayout class='monospaced'>
1213 serial ‘&lt;-m 256 -full-screen&gt;’
1214 </literallayout></para>
1215 <para>
1216 Regardless of the mode, Sysroot is already
1217 defined as part of the Cross-Compiler Options
1218 configuration in the
1219 <filename>Sysroot Location:</filename> field.
1220 </para></listitem>
1221 <listitem><para><emphasis>External HW:</emphasis>
1222 Select this option if you will be using actual
1223 hardware.</para></listitem>
1224 </itemizedlist>
1225 </para>
1226
1227 <para>
1228 Click the "OK" to save your plug-in configurations.
1229 </para>
1230 </section>
1231 </section>
1232 </section>
1233
1234 <section id='creating-the-project'>
1235 <title>Creating the Project</title>
1236
1237 <para>
1238 You can create two types of projects: Autotools-based, or
1239 Makefile-based.
1240 This section describes how to create Autotools-based projects
1241 from within the Eclipse IDE.
1242 For information on creating Makefile-based projects in a
1243 terminal window, see the section
1244 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-the-command-line'>Using the Command Line</ulink>"
1245 in the Yocto Project Application Developer's Guide.
1246 <note>
1247 Do not use special characters in project names
1248 (e.g. spaces, underscores, etc.). Doing so can
1249 cause configuration to fail.
1250 </note>
1251 </para>
1252
1253 <para>
1254 To create a project based on a Yocto template and then display
1255 the source code, follow these steps:
1256 <orderedlist>
1257 <listitem><para>Select "Project" from the "File -> New" menu.
1258 </para></listitem>
1259 <listitem><para>Double click <filename>CC++</filename>.
1260 </para></listitem>
1261 <listitem><para>Double click <filename>C Project</filename>
1262 to create the project.</para></listitem>
1263 <listitem><para>Expand <filename>Yocto Project ADT Autotools Project</filename>.
1264 </para></listitem>
1265 <listitem><para>Select <filename>Hello World ANSI C Autotools Project</filename>.
1266 This is an Autotools-based project based on a Yocto
1267 template.</para></listitem>
1268 <listitem><para>Put a name in the <filename>Project name:</filename>
1269 field.
1270 Do not use hyphens as part of the name.
1271 </para></listitem>
1272 <listitem><para>Click "Next".</para></listitem>
1273 <listitem><para>Add information in the
1274 <filename>Author</filename> and
1275 <filename>Copyright notice</filename> fields.
1276 </para></listitem>
1277 <listitem><para>Be sure the <filename>License</filename>
1278 field is correct.</para></listitem>
1279 <listitem><para>Click "Finish".</para></listitem>
1280 <listitem><para>If the "open perspective" prompt appears,
1281 click "Yes" so that you in the C/C++ perspective.
1282 </para></listitem>
1283 <listitem><para>The left-hand navigation pane shows your
1284 project.
1285 You can display your source by double clicking the
1286 project's source file.</para></listitem>
1287 </orderedlist>
1288 </para>
1289 </section>
1290
1291 <section id='configuring-the-cross-toolchains'>
1292 <title>Configuring the Cross-Toolchains</title>
1293
1294 <para>
1295 The earlier section,
1296 "<link linkend='configuring-the-eclipse-yocto-plug-in'>Configuring the Eclipse Yocto Plug-in</link>",
1297 sets up the default project configurations.
1298 You can override these settings for a given project by following
1299 these steps:
1300 <orderedlist>
1301 <listitem><para>Select "Change Yocto Project Settings" from
1302 the "Project" menu.
1303 This selection brings up the Yocto Project Settings
1304 Dialog and allows you to make changes specific to an
1305 individual project.</para>
1306 <para>By default, the Cross Compiler Options and Target
1307 Options for a project are inherited from settings you
1308 provided using the Preferences Dialog as described
1309 earlier in the
1310 "<link linkend='configuring-the-eclipse-yocto-plug-in'>Configuring the Eclipse Yocto Plug-in</link>" section.
1311 The Yocto Project Settings Dialog allows you to override
1312 those default settings for a given project.
1313 </para></listitem>
1314 <listitem><para>Make your configurations for the project
1315 and click "OK".
1316 </para></listitem>
1317 <listitem><para>Right-click in the navigation pane and
1318 select "Reconfigure Project" from the pop-up menu.
1319 This selection reconfigures the project by running
1320 <filename>autogen.sh</filename> in the workspace for
1321 your project.
1322 The script also runs <filename>libtoolize</filename>,
1323 <filename>aclocal</filename>,
1324 <filename>autoconf</filename>,
1325 <filename>autoheader</filename>,
1326 <filename>automake --a</filename>, and
1327 <filename>./configure</filename>.
1328 Click on the "Console" tab beneath your source code to
1329 see the results of reconfiguring your project.
1330 </para></listitem>
1331 </orderedlist>
1332 </para>
1333 </section>
1334
1335 <section id='building-the-project'>
1336 <title>Building the Project</title>
1337
1338 <para>
1339 To build the project select "Build Project" from the
1340 "Project" menu.
1341 The console should update and you can note the cross-compiler
1342 you are using.
1343 </para>
1344 </section>
1345
1346 <section id='starting-qemu-in-user-space-nfs-mode'>
1347 <title>Starting QEMU in User-Space NFS Mode</title>
1348
1349 <para>
1350 To start the QEMU emulator from within Eclipse, follow these
1351 steps:
1352 <note>
1353 See the
1354 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
1355 chapter for more information on using QEMU.
1356 </note>
1357 <orderedlist>
1358 <listitem><para>Expose and select "External Tools" from
1359 the "Run" menu.
1360 Your image should appear as a selectable menu item.
1361 </para></listitem>
1362 <listitem><para>Select your image from the menu to launch
1363 the emulator in a new window.
1364 </para></listitem>
1365 <listitem><para>If needed, enter your host root password in
1366 the shell window at the prompt.
1367 This sets up a <filename>Tap 0</filename> connection
1368 needed for running in user-space NFS mode.
1369 </para></listitem>
1370 <listitem><para>Wait for QEMU to launch.</para></listitem>
1371 <listitem><para>Once QEMU launches, you can begin operating
1372 within that environment.
1373 One useful task at this point would be to determine the
1374 IP Address for the user-space NFS by using the
1375 <filename>ifconfig</filename> command.
1376 </para></listitem>
1377 </orderedlist>
1378 </para>
1379 </section>
1380
1381 <section id='deploying-and-debugging-the-application'>
1382 <title>Deploying and Debugging the Application</title>
1383
1384 <para>
1385 Once the QEMU emulator is running the image, you can deploy
1386 your application using the Eclipse IDE and then use
1387 the emulator to perform debugging.
1388 Follow these steps to deploy the application.
1389 <orderedlist>
1390 <listitem><para>Select "Debug Configurations..." from the
1391 "Run" menu.</para></listitem>
1392 <listitem><para>In the left area, expand
1393 <filename>C/C++Remote Application</filename>.
1394 </para></listitem>
1395 <listitem><para>Locate your project and select it to bring
1396 up a new tabbed view in the Debug Configurations Dialog.
1397 </para></listitem>
1398 <listitem><para>Enter the absolute path into which you want
1399 to deploy the application.
1400 Use the "Remote Absolute File Path for
1401 C/C++Application:" field.
1402 For example, enter
1403 <filename>/usr/bin/<replaceable>programname</replaceable></filename>.
1404 </para></listitem>
1405 <listitem><para>Click on the "Debugger" tab to see the
1406 cross-tool debugger you are using.</para></listitem>
1407 <listitem><para>Click on the "Main" tab.</para></listitem>
1408 <listitem><para>Create a new connection to the QEMU instance
1409 by clicking on "new".</para></listitem>
1410 <listitem><para>Select <filename>TCF</filename>, which means
1411 Target Communication Framework.</para></listitem>
1412 <listitem><para>Click "Next".</para></listitem>
1413 <listitem><para>Clear out the "host name" field and enter
1414 the IP Address determined earlier.</para></listitem>
1415 <listitem><para>Click "Finish" to close the
1416 New Connections Dialog.</para></listitem>
1417 <listitem><para>Use the drop-down menu now in the
1418 "Connection" field and pick the IP Address you entered.
1419 </para></listitem>
1420 <listitem><para>Click "Debug" to bring up a login screen
1421 and login.</para></listitem>
1422 <listitem><para>Accept the debug perspective.
1423 </para></listitem>
1424 </orderedlist>
1425 </para>
1426 </section>
1427
1428 <section id='running-user-space-tools'>
1429 <title>Running User-Space Tools</title>
1430
1431 <para>
1432 As mentioned earlier in the manual, several tools exist that
1433 enhance your development experience.
1434 These tools are aids in developing and debugging applications
1435 and images.
1436 You can run these user-space tools from within the Eclipse
1437 IDE through the "YoctoProjectTools" menu.
1438 </para>
1439
1440 <para>
1441 Once you pick a tool, you need to configure it for the remote
1442 target.
1443 Every tool needs to have the connection configured.
1444 You must select an existing TCF-based RSE connection to the
1445 remote target.
1446 If one does not exist, click "New" to create one.
1447 </para>
1448
1449 <para>
1450 Here are some specifics about the remote tools:
1451 <itemizedlist>
1452 <listitem><para><emphasis><filename>OProfile</filename>:</emphasis>
1453 Selecting this tool causes the
1454 <filename>oprofile-server</filename> on the remote
1455 target to launch on the local host machine.
1456 The <filename>oprofile-viewer</filename> must be
1457 installed on the local host machine and the
1458 <filename>oprofile-server</filename> must be installed
1459 on the remote target, respectively, in order to use.
1460 You must compile and install the
1461 <filename>oprofile-viewer</filename> from the source
1462 code on your local host machine.
1463 Furthermore, in order to convert the target's sample
1464 format data into a form that the host can use, you must
1465 have OProfile version 0.9.4 or greater installed on the
1466 host.</para>
1467 <para>You can locate both the viewer and server from
1468 <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/oprofileui/'></ulink>.
1469 You can also find more information on setting up and
1470 using this tool in the
1471 "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-oprofile'>oprofile</ulink>"
1472 section of the Yocto Project Profiling and Tracing
1473 Manual.
1474 <note>The <filename>oprofile-server</filename> is
1475 installed by default on the
1476 <filename>core-image-sato-sdk</filename> image.</note>
1477 </para></listitem>
1478 <listitem><para><emphasis><filename>Lttng2.0 trace import</filename>:</emphasis>
1479 Selecting this tool transfers the remote target's
1480 <filename>Lttng</filename> tracing data back to the
1481 local host machine and uses the Lttng Eclipse plug-in
1482 to graphically display the output.
1483 For information on how to use Lttng to trace an
1484 application,
1485 see <ulink url='http://lttng.org/documentation'></ulink>
1486 and the
1487 "<ulink url='&YOCTO_DOCS_PROF_URL;#lttng-linux-trace-toolkit-next-generation'>LTTng (Linux Trace Toolkit, next generation)</ulink>"
1488 section, which is in the Yocto Project Profiling and
1489 Tracing Manual.
1490 <note>Do not use
1491 <filename>Lttng-user space (legacy)</filename> tool.
1492 This tool no longer has any upstream support.</note>
1493 </para>
1494 <para>Before you use the
1495 <filename>Lttng2.0 trace import</filename> tool,
1496 you need to setup the Lttng Eclipse plug-in and create a
1497 Tracing project.
1498 Do the following:
1499 <orderedlist>
1500 <listitem><para>Select "Open Perspective" from the
1501 "Window" menu and then select "Other..." to
1502 bring up a menu of other perspectives.
1503 Choose "Tracing".
1504 </para></listitem>
1505 <listitem><para>Click "OK" to change the Eclipse
1506 perspective into the Tracing perspective.
1507 </para></listitem>
1508 <listitem><para>Create a new Tracing project by
1509 selecting "Project" from the "File -> New" menu.
1510 </para></listitem>
1511 <listitem><para>Choose "Tracing Project" from the
1512 "Tracing" menu and click "Next".
1513 </para></listitem>
1514 <listitem><para>Provide a name for your tracing
1515 project and click "Finish".
1516 </para></listitem>
1517 <listitem><para>Generate your tracing data on the
1518 remote target.</para></listitem>
1519 <listitem><para>Select "Lttng2.0 trace import"
1520 from the "Yocto Project Tools" menu to
1521 start the data import process.</para></listitem>
1522 <listitem><para>Specify your remote connection name.
1523 </para></listitem>
1524 <listitem><para>For the Ust directory path, specify
1525 the location of your remote tracing data.
1526 Make sure the location ends with
1527 <filename>ust</filename> (e.g.
1528 <filename>/usr/mysession/ust</filename>).
1529 </para></listitem>
1530 <listitem><para>Click "OK" to complete the import
1531 process.
1532 The data is now in the local tracing project
1533 you created.</para></listitem>
1534 <listitem><para>Right click on the data and then use
1535 the menu to Select "Generic CTF Trace" from the
1536 "Trace Type... -> Common Trace Format" menu to
1537 map the tracing type.</para></listitem>
1538 <listitem><para>Right click the mouse and select
1539 "Open" to bring up the Eclipse Lttng Trace
1540 Viewer so you view the tracing data.
1541 </para></listitem>
1542 </orderedlist></para></listitem>
1543 <listitem><para><emphasis><filename>PowerTOP</filename>:</emphasis>
1544 Selecting this tool runs PowerTOP on the remote target
1545 machine and displays the results in a new view called
1546 PowerTOP.</para>
1547 <para>The "Time to gather data(sec):" field is the time
1548 passed in seconds before data is gathered from the
1549 remote target for analysis.</para>
1550 <para>The "show pids in wakeups list:" field corresponds
1551 to the <filename>-p</filename> argument passed to
1552 <filename>PowerTOP</filename>.</para></listitem>
1553 <listitem><para><emphasis><filename>LatencyTOP and Perf</filename>:</emphasis>
1554 LatencyTOP identifies system latency, while
1555 Perf monitors the system's performance counter
1556 registers.
1557 Selecting either of these tools causes an RSE terminal
1558 view to appear from which you can run the tools.
1559 Both tools refresh the entire screen to display results
1560 while they run.
1561 For more information on setting up and using
1562 <filename>perf</filename>, see the
1563 "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-perf'>perf</ulink>"
1564 section in the Yocto Project Profiling and Tracing
1565 Manual.
1566 </para></listitem>
1567 <listitem><para><emphasis><filename>SystemTap</filename>:</emphasis>
1568 Systemtap is a tool that lets you create and reuse
1569 scripts to examine the activities of a live Linux
1570 system.
1571 You can easily extract, filter, and summarize data
1572 that helps you diagnose complex performance or
1573 functional problems.
1574 For more information on setting up and using
1575 <filename>SystemTap</filename>, see the
1576 <ulink url='https://sourceware.org/systemtap/documentation.html'>SystemTap Documentation</ulink>.
1577 </para></listitem>
1578 <listitem><para><emphasis><filename>yocto-bsp</filename>:</emphasis>
1579 The <filename>yocto-bsp</filename> tool lets you
1580 quickly set up a Board Support Package (BSP) layer.
1581 The tool requires a Metadata location, build location,
1582 BSP name, BSP output location, and a kernel
1583 architecture.
1584 For more information on the
1585 <filename>yocto-bsp</filename> tool outside of Eclipse,
1586 see the
1587 "<ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'>Creating a new BSP Layer Using the yocto-bsp Script</ulink>"
1588 section in the Yocto Project Board Support Package
1589 (BSP) Developer's Guide.
1590 </para></listitem>
1591 </itemizedlist>
1592 </para>
1593 </section>
1594 </section>
1595
1596 <section id='workflow-using-stand-alone-cross-development-toolchains'>
1597 <title>Workflow Using Stand-Alone Cross-Development Toolchains</title>
1598
1599 <para>
1600 If you want to develop an application without prior installation
1601 of the ADT, you still can employ the
1602 <link linkend='cross-development-toolchain'>Cross Development Toolchain</link>,
1603 the QEMU emulator, and a number of supported target image files.
1604 You just need to follow these general steps:
1605 <orderedlist>
1606 <listitem><para><emphasis>Install the cross-development
1607 toolchain for your target hardware:</emphasis>
1608 For information on how to install the toolchain, see the
1609 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball'>Using a Cross-Toolchain Tarball</ulink>"
1610 section in the Yocto Project Application Developer's
1611 Guide.</para></listitem>
1612 <listitem><para><emphasis>Download the Target Image:</emphasis>
1613 The Yocto Project supports several target architectures
1614 and has many pre-built kernel images and root filesystem
1615 images.</para>
1616 <para>If you are going to develop your application on
1617 hardware, go to the
1618 <ulink url='&YOCTO_MACHINES_DL_URL;'><filename>machines</filename></ulink>
1619 download area and choose a target machine area
1620 from which to download the kernel image and root filesystem.
1621 This download area could have several files in it that
1622 support development using actual hardware.
1623 For example, the area might contain
1624 <filename>.hddimg</filename> files that combine the
1625 kernel image with the filesystem, boot loaders, and
1626 so forth.
1627 Be sure to get the files you need for your particular
1628 development process.</para>
1629 <para>If you are going to develop your application and
1630 then run and test it using the QEMU emulator, go to the
1631 <ulink url='&YOCTO_QEMU_DL_URL;'><filename>machines/qemu</filename></ulink>
1632 download area.
1633 From this area, go down into the directory for your
1634 target architecture (e.g. <filename>qemux86_64</filename>
1635 for an <trademark class='registered'>Intel</trademark>-based
1636 64-bit architecture).
1637 Download kernel, root filesystem, and any other files you
1638 need for your process.
1639 <note>In order to use the root filesystem in QEMU, you
1640 need to extract it.
1641 See the
1642 "<ulink url='&YOCTO_DOCS_ADT_URL;#extracting-the-root-filesystem'>Extracting the Root Filesystem</ulink>"
1643 section for information on how to extract the root
1644 filesystem.</note></para></listitem>
1645 <listitem><para><emphasis>Develop and Test your
1646 Application:</emphasis> At this point, you have the tools
1647 to develop your application.
1648 If you need to separately install and use the QEMU
1649 emulator, you can go to
1650 <ulink url='http://wiki.qemu.org/Main_Page'>QEMU Home Page</ulink>
1651 to download and learn about the emulator.
1652 You can see the
1653 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
1654 chapter for information on using QEMU within the Yocto
1655 Project.</para></listitem>
1656 </orderedlist>
1657 </para>
1658 </section>
1659</section>
1660
1661<section id="dev-modifying-source-code">
1662 <title>Modifying Source Code</title>
1663
1664 <para>
1665 A common development workflow consists of modifying project source
1666 files that are external to the Yocto Project and then integrating
1667 that project's build output into an image built using the
1668 OpenEmbedded build system.
1669 Given this scenario, development engineers typically want to stick
1670 to their familiar project development tools and methods, which allows
1671 them to just focus on the project.
1672 </para>
1673
1674 <para>
1675 Several workflows exist that allow you to develop, build, and test
1676 code that is going to be integrated into an image built using the
1677 OpenEmbedded build system.
1678 This section describes two:
1679 <itemizedlist>
1680 <listitem><para><emphasis><filename>devtool</filename>:</emphasis>
1681 A set of tools to aid in working on the source code built by
1682 the OpenEmbedded build system.
1683 Section
1684 "<link linkend='using-devtool-in-your-workflow'>Using <filename>devtool</filename> in Your Workflow</link>"
1685 describes this workflow.
1686 If you want more information that showcases the workflow, click
1687 <ulink url='https://drive.google.com/a/linaro.org/file/d/0B3KGzY5fW7laTDVxUXo3UDRvd2s/view'>here</ulink>
1688 for an excellent presentation by Trevor Woerner that
1689 provides detailed background information and a complete
1690 working tutorial.
1691 </para></listitem>
1692 <listitem><para><emphasis><ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>:</emphasis>
1693 A powerful tool that allows you to capture source
1694 code changes without having a clean source tree.
1695 While Quilt is not the preferred workflow of the two, this
1696 section includes it for users that are committed to using
1697 the tool.
1698 See the
1699 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
1700 section for more information.
1701 </para></listitem>
1702 </itemizedlist>
1703 </para>
1704
1705 <section id='using-devtool-in-your-workflow'>
1706 <title>Using <filename>devtool</filename> in Your Workflow</title>
1707
1708 <para>
1709 As mentioned earlier, <filename>devtool</filename> helps
1710 you easily develop projects whose build output must be part of
1711 an image built using the OpenEmbedded build system.
1712 The remainder of this section presents the workflow you would
1713 use that includes <filename>devtool</filename>.
1714 <footnote>
1715 <para>
1716 Kudos and thanks to
1717 <ulink url='mailto:twoerner@gmail.com'>Trevor Woerner</ulink>
1718 whose
1719 "<ulink url='https://drive.google.com/file/d/0B3KGzY5fW7laTDVxUXo3UDRvd2s/view'>Yocto Project Developer Workflow Tutorial</ulink>"
1720 paper contributed nicely towards the development of this
1721 section.
1722 </para>
1723 </footnote>
1724 </para>
1725
1726 <para>
1727 The steps in this section assume you have a previously built
1728 image that is already either running in QEMU or running on actual
1729 hardware.
1730 Also, it is assumed that for deployment of the image to the
1731 target, SSH is installed in the image and if the image is running
1732 on real hardware that you have network access to and from your
1733 development machine.
1734 </para>
1735
1736 <section id='update-your-external-source'>
1737 <title>Update Your External Source</title>
1738
1739 <para>
1740 Part of the development flow using
1741 <filename>devtool</filename> of course involves updating
1742 your source files.
1743 Several opportunities exist in the workflow to extract and
1744 work on the files.
1745 For now, just realize that you need to be able to have
1746 access to and edit files.
1747 One obvious solution is to initially extract the code into an
1748 isolated area in preparation for modification.
1749 </para>
1750
1751 <para>
1752 Another option is to use the
1753 <filename>devtool modify</filename> command.
1754 This command makes use of a "workspace" layer where much of
1755 the transitional work occurs, which is needed for setting up
1756 Metadata used by the OpenEmbedded build system that lets you
1757 build your software.
1758 Options (i.e. "-x") exist using <filename>devtool</filename>
1759 that enable you to use the tool to extract source code.
1760 </para>
1761 </section>
1762
1763 <section id='use-devtool-to-integrate-your-code-with-the-image'>
1764 <title>Use <filename>devtool add</filename> to Integrate Your Code with the Image</title>
1765
1766 <para>
1767 The <filename>devtool add</filename> command automatically
1768 generates the needed Metadata that allows the OpenEmbedded
1769 build system to build your code into the image.
1770 <note>
1771 If a package or packages produced by the recipe on which
1772 you are working are not already in
1773 <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
1774 for the image, you must add them.
1775 The <filename>devtool add</filename> command does not
1776 add them for you.
1777 </note>
1778 Use the following command form:
1779 <literallayout class='monospaced'>
1780 $ devtool add <replaceable>your-project-name</replaceable>&nbsp;<replaceable>path-to-source</replaceable>
1781 </literallayout>
1782 </para>
1783
1784 <para>
1785 Running <filename>devtool</filename> for the first time
1786 creates a workspace layer through the
1787 <filename>bblayers.conf</filename> file that
1788 is based on your project's location:
1789 <literallayout class='monospaced'>
1790 <replaceable>path-to-source</replaceable>/<replaceable>build-directory</replaceable>/<replaceable>workspace-layer</replaceable>
1791 </literallayout>
1792 By default, the name of the workspace layer is "workspace".
1793 </para>
1794
1795 <para>
1796 For details on the workspace layer created in the
1797 <replaceable>build-directory</replaceable>,
1798 see the
1799 "<link linkend='devtool-adding-a-new-recipe-to-the-workspace'>Adding a New Recipe to the Workspace Layer</link>"
1800 section.
1801 </para>
1802
1803<!--
1804 <para>
1805 Of course, each layer must have a
1806 <filename>layer.conf</filename> configuration file.
1807 <filename>devtool</filename> also creates this configuration
1808 file:
1809 <literallayout class='monospaced'>
1810 $ cat workspace/conf/layer.conf
1811 # ### workspace layer auto­generated by devtool ###
1812 BBPATH =. "${LAYERDIR}:"
1813 BBFILES += "${LAYERDIR}/recipes/*/*.bb \
1814 ${LAYERDIR}/appends/*.bbappend"
1815 BBFILE_COLLECTIONS += "workspacelayer"
1816 BBFILE_PATTERN_workspacelayer = "^${LAYERDIR}/"
1817 BBFILE_PATTERN_IGNORE_EMPTY_workspacelayer = "1"
1818 BBFILE_PRIORITY_workspacelayer = "99"
1819 </literallayout>
1820 </para>
1821-->
1822
1823 <para>
1824 Running <filename>devtool add</filename> automatically
1825 generates your recipe:
1826 <literallayout class='monospaced'>
1827 $ cat workspace/recipes/<replaceable>your-project-name</replaceable>/<replaceable>your-project-name</replaceable>.bb
1828 # Recipe created by recipetool
1829 # This is the basis of a recipe and may need further editing in order to be fully functional.
1830 # (Feel free to remove these comments when editing.)
1831 #
1832 # Unable to find any files that looked like license statements. Check the accompanying
1833 # documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
1834 LICENSE = "CLOSED"
1835 LIC_FILES_CHKSUM = ""
1836
1837 # No information for SRC_URI yet (only an external source tree was
1838 # specified)
1839 SRC_URI = ""
1840
1841 DEPENDS = "libx11"
1842 # NOTE: if this software is not capable of being built in a separate build directory
1843 # from the source, you should replace autotools with autotools­-brokensep in the
1844 # inherit line
1845 inherit autotools
1846
1847 # Specify any options you want to pass to the configure script using EXTRA_OECONF:
1848 EXTRA_OECONF = ""
1849 </literallayout>
1850 </para>
1851
1852 <para>
1853 Lastly, the <filename>devtool add</filename> command creates the
1854 <filename>.bbappend</filename> file:
1855 <literallayout class='monospaced'>
1856 $ cat workspace/appends/<replaceable>your-project-name</replaceable>.bbappend
1857 inherit externalsrc
1858 EXTERNALSRC = "/<replaceable>path-to-source</replaceable>/<replaceable>your-project-name</replaceable>"
1859
1860 # initial_rev: <replaceable>commit-ID</replaceable>
1861 </literallayout>
1862 </para>
1863 </section>
1864
1865 <section id='build-your-project'>
1866 <title>Build Your Project</title>
1867
1868 <para>
1869 You can use BitBake or <filename>devtool build</filename> to
1870 build your modified project.
1871 </para>
1872
1873 <para>
1874 To use BitBake, use the following:
1875 <literallayout class='monospaced'>
1876 $ bitbake <replaceable>your-project-name</replaceable>
1877 </literallayout>
1878 Alternatively, you can use
1879 <filename>devtool build</filename>, which is equivalent to
1880 <filename>bitbake -c populate_sysroot</filename>.
1881 For example:
1882 <literallayout class='monospaced'>
1883 $ devtool build <replaceable>your-project-name</replaceable>
1884 </literallayout>
1885 </para>
1886 </section>
1887
1888<!--
1889 <section id='dev-build-the-image'>
1890 <title>Build the Image</title>
1891
1892 <para>
1893 The final step before testing is to rebuild the base image
1894 with your project changes as part of the image.
1895 Simply run BitBake again on your image.
1896 Here is an example:
1897 <literallayout class='monospaced'>
1898 $ bitbake <replaceable>image</replaceable>
1899 </literallayout>
1900 </para>
1901 </section>
1902
1903 <section id='dev-testing-the-image'>
1904 <title>Testing the Image</title>
1905
1906 <para>
1907 Once you have the image, you can test it using QEMU.
1908 Here is an example assuming "qemux86":
1909 <literallayout class='monospaced'>
1910 $ runqemu qemux86 <replaceable>image</replaceable>
1911 </literallayout>
1912 For information on how to test an image using QEMU, see the
1913 "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
1914 section.
1915 </para>
1916 </section>
1917-->
1918 </section>
1919
1920 <section id='devtool-quick-reference'>
1921 <title><filename>devtool</filename> Quick Reference</title>
1922
1923 <para>
1924 <filename>devtool</filename> has more functionality than simply
1925 adding a new recipe and the supporting Metadata to a temporary
1926 workspace layer.
1927 This section provides a short reference on
1928 <filename>devtool</filename> for most of the commands.
1929 </para>
1930
1931 <section id='devtool-getting-help'>
1932 <title>Getting Help</title>
1933
1934 <para>
1935 The easiest way to get help with the
1936 <filename>devtool</filename> command is using the
1937 <filename>--help</filename> option:
1938 <literallayout class='monospaced'>
1939 $ devtool --help
1940 usage: devtool [-h] [--basepath BASEPATH] [-d] [-q] [--color COLOR]
1941 &lt;subcommand&gt; ...
1942
1943 OpenEmbedded development tool
1944
1945 optional arguments:
1946 -h, --help show this help message and exit
1947 --basepath BASEPATH Base directory of SDK / build directory
1948 -d, --debug Enable debug output
1949 -q, --quiet Print only errors
1950 --color COLOR Colorize output (where COLOR is auto, always, never)
1951
1952 subcommands:
1953 &lt;subcommand&gt;
1954 create-workspace Set up a workspace
1955 deploy-target Deploy recipe output files to live target machine
1956 undeploy-target Undeploy recipe output files in live target machine
1957 add Add a new recipe
1958 modify Modify the source for an existing recipe
1959 extract Extract the source for an existing recipe
1960 update-recipe Apply changes from external source tree to recipe
1961 status Show workspace status
1962 build Build a recipe
1963 reset Remove a recipe from your workspace
1964
1965 Use devtool &lt;subcommand&gt; --help to get help on a specific command
1966 </literallayout>
1967 </para>
1968
1969 <para>
1970 As directed in the general help output, you can get more
1971 syntax on a specific command by providing the command
1972 name and using <filename>--help</filename>:
1973 <literallayout class='monospaced'>
1974 $ devtool add --help
1975 usage: devtool add [-h] [--same-dir] [--fetch URI] [--version VERSION]
1976 recipename srctree
1977
1978 Adds a new recipe
1979
1980 positional arguments:
1981 recipename Name for new recipe to add
1982 srctree Path to external source tree
1983
1984 optional arguments:
1985 -h, --help show this help message and exit
1986 --same-dir, -s Build in same directory as source
1987 --fetch URI, -f URI Fetch the specified URI and extract it to create the
1988 source tree
1989 --version VERSION, -V VERSION
1990 Version to use within recipe (PV)
1991 </literallayout>
1992 </para>
1993 </section>
1994
1995 <section id='devtool-adding-a-new-recipe-to-the-workspace'>
1996 <title>Adding a New Recipe to the Workspace Layer</title>
1997
1998 <para>
1999 Use the <filename>devtool add</filename> command to add a new recipe
2000 to the workspace layer.
2001 The recipe you add should not exist -
2002 <filename>devtool</filename> creates it for you.
2003 The source files the recipe uses should exist in an external
2004 area.
2005 </para>
2006
2007 <para>
2008 The following example creates and adds a new recipe named
2009 <filename>jackson</filename> to the workspace layer.
2010 The source code built by the recipes resides in
2011 <filename>/home/scottrif/sources/jackson</filename>:
2012 <literallayout class='monospaced'>
2013 $ devtool add jackson /home/scottrif/sources/jackson
2014 </literallayout>
2015 <note>
2016 For complete syntax, use the
2017 <filename>devtool add --help</filename> command.
2018 </note>
2019 </para>
2020
2021 <para>
2022 If you add a recipe and the workspace layer does not exist,
2023 the command creates the layer and populates it as follows:
2024 </para>
2025
2026 <para>
2027 <imagedata fileref="figures/build-workspace-directory.png"
2028 width="6in" depth="4in" align="center" scale="100" />
2029 </para>
2030
2031 <para>
2032 <literallayout class='monospaced'>
2033 README - Provides information on what is in workspace layer and how to
2034 manage it.
2035
2036 appends - A directory that contains *.bbappend files, which point to
2037 external source.
2038
2039 conf - A configuration directory that contains the layer.conf file.
2040
2041 recipes - A directory containing recipes. This directory contains a
2042 folder for each directory added whose name matches that of the
2043 added recipe. devtool places the <replaceable>recipe</replaceable>.bb file
2044 within that sub-directory.
2045 </literallayout>
2046 </para>
2047
2048 <para>
2049 Running <filename>devtool add</filename> when the
2050 workspace layer exists causes the tool to add the recipe
2051 and append files into the existing workspace layer.
2052 The <filename>.bbappend</filename> file is created to point
2053 to the external source tree.
2054 </para>
2055 </section>
2056
2057 <section id='devtool-modifying-a-recipe'>
2058 <title>Modifying an Existing Recipe</title>
2059
2060 <para>
2061 Use the <filename>devtool modify</filename> command to begin
2062 modifying the source of an existing recipe.
2063 This command is very similar to the
2064 <link linkend='devtool-adding-a-new-recipe-to-the-workspace'><filename>add</filename></link>
2065 command except that it does not physically create the
2066 recipe in the workspace layer because the recipe already
2067 exists in an another layer.
2068 </para>
2069
2070 <para>
2071 The <filename>devtool modify</filename> command extracts the
2072 source for a recipe, sets it up as a Git repository if the
2073 source had not already been fetched from Git, checks out a
2074 branch for development, and applies any patches from the recipe
2075 as commits on top.
2076 You can use the following command to checkout the source
2077 files:
2078 <literallayout class='monospaced'>
2079 $ devtool modify -x <replaceable>recipe</replaceable>&nbsp;<replaceable>path-to-source</replaceable>
2080 </literallayout>
2081 Using the above command form, the default development branch
2082 would be "devtool".
2083 <note>
2084 For complete syntax, use the
2085 <filename>devtool modify --help</filename> command.
2086 </note>
2087 </para>
2088 </section>
2089
2090 <section id='devtool-updating-a-recipe'>
2091 <title>Updating a Recipe</title>
2092
2093 <para>
2094 Use the <filename>devtool update-recipe</filename> command to
2095 update your recipe with patches that reflect changes you make
2096 to the source files.
2097 For example, if you know you are going to work on some
2098 code, you could first use the
2099 <link linkend='devtool-modifying-a-recipe'><filename>devtool modify</filename></link>
2100 command to extract the code and set up the workspace.
2101 After which, you could modify, compile, and test the code.
2102 </para>
2103
2104 <para>
2105 When you are satisfied with the results and you have committed
2106 your changes to the Git repository, you can then
2107 run the <filename>devtool update-recipe</filename> to create the
2108 patches and update the recipe:
2109 <literallayout class='monospaced'>
2110 $ devtool update-recipe <replaceable>recipe</replaceable>
2111 </literallayout>
2112 If you run the <filename>devtool update-recipe</filename>
2113 without committing your changes, the command ignores the
2114 changes.
2115 </para>
2116
2117 <para>
2118 Often, you might want to apply customizations made to your
2119 software in your own layer rather than apply them to the
2120 original recipe.
2121 If so, you can use the
2122 <filename>-a</filename> or <filename>--append</filename>
2123 option with the <filename>devtool update-recipe</filename>
2124 command.
2125 These options allow you to specify the layer into which to
2126 write an append file:
2127 <literallayout class='monospaced'>
2128 $ devtool update-recipe <replaceable>recipe</replaceable> -a <replaceable>base-layer-directory</replaceable>
2129 </literallayout>
2130 The <filename>*.bbappend</filename> file is created at the
2131 appropriate path within the specified layer directory, which
2132 may or may not be in your <filename>bblayers.conf</filename>
2133 file.
2134 If an append file already exists, the command updates it
2135 appropriately.
2136 <note>
2137 For complete syntax, use the
2138 <filename>devtool update-recipe --help</filename> command.
2139 </note>
2140 </para>
2141 </section>
2142
2143 <section id='devtool-resetting-a-recipe'>
2144 <title>Resetting a Recipe</title>
2145
2146 <para>
2147 Use the <filename>devtool reset</filename> command to remove a
2148 recipe and its configuration (e.g. the corresponding
2149 <filename>.bbappend</filename> file) from the workspace layer.
2150 Realize that this command deletes the recipe and the
2151 append file.
2152 The command does not physically move them for you.
2153 Consequently, you must be sure to physically relocate your
2154 updated recipe and the append file outside of the workspace
2155 layer before running the <filename>devtool reset</filename>
2156 command.
2157 </para>
2158
2159 <para>
2160 If the <filename>devtool reset</filename> command detects that
2161 the recipe or the append files have been modified, the
2162 command preserves the modified files in a separate "attic"
2163 subdirectory under the workspace layer.
2164 <note>
2165 For complete syntax, use the
2166 <filename>devtool reset --help</filename> command.
2167 </note>
2168 </para>
2169 </section>
2170
2171 <section id='devtool-building-your-software'>
2172 <title>Building Your Software</title>
2173
2174 <para>
2175 Use the <filename>devtool build</filename> command to cause the
2176 OpenEmbedded build system to build your software based
2177 on the recipe file.
2178 The <filename>devtool build</filename> command is equivalent to
2179 <filename>bitbake -c populate_sysroot</filename>.
2180 Here is an example:
2181 <literallayout class='monospaced'>
2182 $ devtool build <replaceable>recipe</replaceable>
2183 </literallayout>
2184 <note>
2185 For complete syntax, use the
2186 <filename>devtool update-recipe --help</filename> command.
2187 </note>
2188 Building your software using <filename>devtool build</filename>
2189 is identical to using BitBake to build the software.
2190 </para>
2191 </section>
2192
2193 <section id='devtool-deploying-your-software-on-the-target-machine'>
2194 <title>Deploying Your Software on the Target Machine</title>
2195
2196 <para>
2197 Use the <filename>devtool deploy-target</filename> command to
2198 deploy the recipe's build output to the live target machine:
2199 <literallayout class='monospaced'>
2200 $ devtool deploy-target <replaceable>recipe</replaceable>&nbsp;<replaceable>target</replaceable>
2201 </literallayout>
2202 The <replaceable>target</replaceable> is the address of the
2203 target machine, which must be running an SSH server (i.e.
2204 <filename>user@hostname[:destdir]</filename>).
2205 </para>
2206
2207 <para>
2208 This command deploys all files installed during the
2209 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
2210 task.
2211 Furthermore, you do not need to have package management enabled
2212 within the target machine.
2213 If you do, the package manager is bypassed.
2214 <note><title>Notes</title>
2215 <para>
2216 The <filename>deploy-target</filename>
2217 functionality is for development only.
2218 You should never use it to update an image that will be
2219 used in production.
2220 </para>
2221
2222 <para>
2223 For complete syntax, use the
2224 <filename>devtool deploy-target --help</filename>
2225 command.
2226 </para>
2227 </note>
2228 </para>
2229 </section>
2230
2231 <section id='devtool-removing-your-software-from-the-target-machine'>
2232 <title>Removing Your Software from the Target Machine</title>
2233
2234 <para>
2235 Use the <filename>devtool undeploy-target</filename> command to
2236 remove deployed build output from the target machine.
2237 For the <filename>devtool undeploy-target</filename> command to
2238 work, you must have previously used the
2239 <link linkend='devtool-deploying-your-software-on-the-target-machine'><filename>devtool deploy-target</filename></link>
2240 command.
2241 <literallayout class='monospaced'>
2242 $ devtool undeploy-target <replaceable>recipe</replaceable>&nbsp;<replaceable>target</replaceable>
2243 </literallayout>
2244 The <replaceable>target</replaceable> is the address of the
2245 target machine, which must be running an SSH server (i.e.
2246 <filename>user@hostname</filename>).
2247 <note>
2248 For complete syntax, use the
2249 <filename>devtool undeploy-target --help</filename> command.
2250 </note>
2251 </para>
2252 </section>
2253
2254 <section id='devtool-creating-the-workspace'>
2255 <title>Creating the Workspace Layer in an Alternative Location</title>
2256
2257 <para>
2258 Use the <filename>devtool create-workspace</filename> command to
2259 create a new workspace layer in your
2260 <link linkend='build-directory'>Build Directory</link>.
2261 When you create a new workspace layer, it is populated with the
2262 <filename>README</filename> file and the
2263 <filename>conf</filename> directory only.
2264 </para>
2265
2266 <para>
2267 The following example creates a new workspace layer in your
2268 current working and by default names the workspace layer
2269 "workspace":
2270 <literallayout class='monospaced'>
2271 $ devtool create-workspace
2272 </literallayout>
2273 <note>
2274 For complete syntax, use the
2275 <filename>devtool create-workspace --help</filename> command.
2276 </note>
2277 </para>
2278
2279 <para>
2280 You can create a workspace layer anywhere by supplying
2281 a pathname with the command.
2282 The following command creates a new workspace layer named
2283 "new-workspace":
2284 <literallayout class='monospaced'>
2285 $ devtool create-workspace /home/scottrif/new-workspace
2286 </literallayout>
2287 </para>
2288 </section>
2289 </section>
2290
2291 <section id="using-a-quilt-workflow">
2292 <title>Using Quilt in Your Workflow</title>
2293
2294 <para>
2295 <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
2296 is a powerful tool that allows you to capture source code changes
2297 without having a clean source tree.
2298 This section outlines the typical workflow you can use to modify
2299 source code, test changes, and then preserve the changes in the
2300 form of a patch all using Quilt.
2301 <note><title>Tip</title>
2302 With regard to preserving changes to source files if you
2303 clean a recipe or have <filename>rm_work</filename> enabled,
2304 the workflow described in the
2305 "<link linkend='using-devtool-in-your-workflow'>Using <filename>devtool</filename> in Your Workflow</link>"
2306 section is a safer development flow than than the flow that
2307 uses Quilt.
2308 </note>
2309 </para>
2310
2311 <para>
2312 Follow these general steps:
2313 <orderedlist>
2314 <listitem><para><emphasis>Find the Source Code:</emphasis>
2315 Temporary source code used by the OpenEmbedded build system
2316 is kept in the
2317 <link linkend='build-directory'>Build Directory</link>.
2318 See the
2319 "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
2320 section to learn how to locate the directory that has the
2321 temporary source code for a particular package.
2322 </para></listitem>
2323 <listitem><para><emphasis>Change Your Working Directory:</emphasis>
2324 You need to be in the directory that has the temporary source code.
2325 That directory is defined by the
2326 <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
2327 variable.</para></listitem>
2328 <listitem><para><emphasis>Create a New Patch:</emphasis>
2329 Before modifying source code, you need to create a new patch.
2330 To create a new patch file, use <filename>quilt new</filename> as below:
2331 <literallayout class='monospaced'>
2332 $ quilt new my_changes.patch
2333 </literallayout></para></listitem>
2334 <listitem><para><emphasis>Notify Quilt and Add Files:</emphasis>
2335 After creating the patch, you need to notify Quilt about the files
2336 you plan to edit.
2337 You notify Quilt by adding the files to the patch you just created:
2338 <literallayout class='monospaced'>
2339 $ quilt add file1.c file2.c file3.c
2340 </literallayout>
2341 </para></listitem>
2342 <listitem><para><emphasis>Edit the Files:</emphasis>
2343 Make your changes in the source code to the files you added
2344 to the patch.
2345 </para></listitem>
2346 <listitem><para><emphasis>Test Your Changes:</emphasis>
2347 Once you have modified the source code, the easiest way to
2348 your changes is by calling the
2349 <filename>do_compile</filename> task as shown in the
2350 following example:
2351 <literallayout class='monospaced'>
2352 $ bitbake -c compile -f <replaceable>package</replaceable>
2353 </literallayout>
2354 The <filename>-f</filename> or <filename>--force</filename>
2355 option forces the specified task to execute.
2356 If you find problems with your code, you can just keep editing and
2357 re-testing iteratively until things work as expected.
2358 <note>All the modifications you make to the temporary source code
2359 disappear once you run the
2360 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
2361 or
2362 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
2363 tasks using BitBake (i.e.
2364 <filename>bitbake -c clean <replaceable>package</replaceable></filename>
2365 and
2366 <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
2367 Modifications will also disappear if you use the <filename>rm_work</filename>
2368 feature as described in the
2369 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
2370 section of the Yocto Project Quick Start.
2371 </note></para></listitem>
2372 <listitem><para><emphasis>Generate the Patch:</emphasis>
2373 Once your changes work as expected, you need to use Quilt to generate the final patch that
2374 contains all your modifications.
2375 <literallayout class='monospaced'>
2376 $ quilt refresh
2377 </literallayout>
2378 At this point, the <filename>my_changes.patch</filename> file has all your edits made
2379 to the <filename>file1.c</filename>, <filename>file2.c</filename>, and
2380 <filename>file3.c</filename> files.</para>
2381 <para>You can find the resulting patch file in the <filename>patches/</filename>
2382 subdirectory of the source (<filename>S</filename>) directory.</para></listitem>
2383 <listitem><para><emphasis>Copy the Patch File:</emphasis>
2384 For simplicity, copy the patch file into a directory named <filename>files</filename>,
2385 which you can create in the same directory that holds the recipe
2386 (<filename>.bb</filename>) file or the
2387 append (<filename>.bbappend</filename>) file.
2388 Placing the patch here guarantees that the OpenEmbedded build system will find
2389 the patch.
2390 Next, add the patch into the
2391 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
2392 of the recipe.
2393 Here is an example:
2394 <literallayout class='monospaced'>
2395 SRC_URI += "file://my_changes.patch"
2396 </literallayout></para></listitem>
2397 </orderedlist>
2398 </para>
2399 </section>
2400
2401 <section id='finding-the-temporary-source-code'>
2402 <title>Finding Temporary Source Code</title>
2403
2404 <para>
2405 You might find it helpful during development to modify the
2406 temporary source code used by recipes to build packages.
2407 For example, suppose you are developing a patch and you need to
2408 experiment a bit to figure out your solution.
2409 After you have initially built the package, you can iteratively
2410 tweak the source code, which is located in the
2411 <link linkend='build-directory'>Build Directory</link>, and then
2412 you can force a re-compile and quickly test your altered code.
2413 Once you settle on a solution, you can then preserve your changes
2414 in the form of patches.
2415 If you are using Quilt for development, see the
2416 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
2417 section for more information.
2418 </para>
2419
2420 <para>
2421 During a build, the unpacked temporary source code used by recipes
2422 to build packages is available in the Build Directory as
2423 defined by the
2424 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> variable.
2425 Below is the default value for the <filename>S</filename> variable as defined in the
2426 <filename>meta/conf/bitbake.conf</filename> configuration file in the
2427 <link linkend='source-directory'>Source Directory</link>:
2428 <literallayout class='monospaced'>
2429 S = "${WORKDIR}/${BP}"
2430 </literallayout>
2431 You should be aware that many recipes override the <filename>S</filename> variable.
2432 For example, recipes that fetch their source from Git usually set
2433 <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
2434 <note>
2435 The
2436 <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
2437 represents the base recipe name, which consists of the name and version:
2438 <literallayout class='monospaced'>
2439 BP = "${BPN}-${PV}"
2440 </literallayout>
2441 </note>
2442 </para>
2443
2444 <para>
2445 The path to the work directory for the recipe
2446 (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
2447 is defined as follows:
2448 <literallayout class='monospaced'>
2449 ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
2450 </literallayout>
2451 The actual directory depends on several things:
2452 <itemizedlist>
2453 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
2454 The top-level build output directory</listitem>
2455 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
2456 The target system identifier</listitem>
2457 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
2458 The recipe name</listitem>
2459 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
2460 The epoch - (if
2461 <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
2462 is not specified, which is usually the case for most
2463 recipes, then <filename>EXTENDPE</filename> is blank)</listitem>
2464 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
2465 The recipe version</listitem>
2466 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
2467 The recipe revision</listitem>
2468 </itemizedlist>
2469 </para>
2470
2471 <para>
2472 As an example, assume a Source Directory top-level folder
2473 named <filename>poky</filename>, a default Build Directory at
2474 <filename>poky/build</filename>, and a
2475 <filename>qemux86-poky-linux</filename> machine target
2476 system.
2477 Furthermore, suppose your recipe is named
2478 <filename>foo_1.3.0.bb</filename>.
2479 In this case, the work directory the build system uses to
2480 build the package would be as follows:
2481 <literallayout class='monospaced'>
2482 poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
2483 </literallayout>
2484 </para>
2485
2486 <para>
2487 Now that you know where to locate the directory that has the
2488 temporary source code, you can use a Quilt as described in section
2489 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
2490 to make your edits, test the changes, and preserve the changes in
2491 the form of patches.
2492 </para>
2493 </section>
2494</section>
2495
2496<section id='image-development-using-toaster'>
2497 <title>Image Development Using Toaster</title>
2498
2499 <para>
2500 Toaster is a web interface to the Yocto Project's OpenEmbedded build
2501 system.
2502 You can initiate builds using Toaster as well as examine the results
2503 and statistics of builds.
2504 See the
2505 <ulink url='&YOCTO_DOCS_TOAST_URL;#toaster-manual-intro'>Toaster User Manual</ulink>
2506 for information on how to set up and use Toaster to build images.
2507 </para>
2508</section>
2509
2510<section id='image-development-using-hob'>
2511 <title>Image Development Using Hob</title>
2512
2513 <para>
2514 The <ulink url='&YOCTO_HOME_URL;/tools-resources/projects/hob'>Hob</ulink> is a graphical user interface for the
2515 OpenEmbedded build system, which is based on BitBake.
2516 You can use the Hob to build custom operating system images within the Yocto Project build environment.
2517 Hob simply provides a friendly interface over the build system used during development.
2518 In other words, building images with the Hob lets you take care of common build tasks more easily.
2519 </para>
2520
2521 <para>
2522 For a better understanding of Hob, see the project page at
2523 <ulink url='&YOCTO_HOME_URL;/tools-resources/projects/hob'></ulink>
2524 on the Yocto Project website.
2525 If you follow the "Documentation" link from the Hob page, you will
2526 find a short introductory training video on Hob.
2527 The following lists some features of Hob:
2528 <itemizedlist>
2529 <listitem><para>You can setup and run Hob using these commands:
2530 <literallayout class='monospaced'>
2531 $ source oe-init-build-env
2532 $ hob
2533 </literallayout></para></listitem>
2534 <listitem><para>You can set the
2535 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
2536 for which you are building the image.</para></listitem>
2537 <listitem><para>You can modify various policy settings such as the
2538 package format with which to build,
2539 the parallelism BitBake uses, whether or not to build an
2540 external toolchain, and which host to build against.
2541 </para></listitem>
2542 <listitem><para>You can manage
2543 <link linkend='understanding-and-creating-layers'>layers</link>.</para></listitem>
2544 <listitem><para>You can select a base image and then add extra packages for your custom build.
2545 </para></listitem>
2546 <listitem><para>You can launch and monitor the build from within Hob.</para></listitem>
2547 </itemizedlist>
2548 </para>
2549</section>
2550
2551<section id="platdev-appdev-devshell">
2552 <title>Using a Development Shell</title>
2553
2554 <para>
2555 When debugging certain commands or even when just editing packages,
2556 <filename>devshell</filename> can be a useful tool.
2557 When you invoke <filename>devshell</filename>, source files are
2558 extracted into your working directory and patches are applied.
2559 Then, a new terminal is opened and you are placed in the working directory.
2560 In the new terminal, all the OpenEmbedded build-related environment variables are
2561 still defined so you can use commands such as <filename>configure</filename> and
2562 <filename>make</filename>.
2563 The commands execute just as if the OpenEmbedded build system were executing them.
2564 Consequently, working this way can be helpful when debugging a build or preparing
2565 software to be used with the OpenEmbedded build system.
2566 </para>
2567
2568 <para>
2569 Following is an example that uses <filename>devshell</filename> on a target named
2570 <filename>matchbox-desktop</filename>:
2571 <literallayout class='monospaced'>
2572 $ bitbake matchbox-desktop -c devshell
2573 </literallayout>
2574 </para>
2575
2576 <para>
2577 This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
2578 The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
2579 variable controls what type of shell is opened.
2580 </para>
2581
2582 <para>
2583 For spawned terminals, the following occurs:
2584 <itemizedlist>
2585 <listitem><para>The <filename>PATH</filename> variable includes the
2586 cross-toolchain.</para></listitem>
2587 <listitem><para>The <filename>pkgconfig</filename> variables find the correct
2588 <filename>.pc</filename> files.</para></listitem>
2589 <listitem><para>The <filename>configure</filename> command finds the
2590 Yocto Project site files as well as any other necessary files.</para></listitem>
2591 </itemizedlist>
2592 </para>
2593
2594 <para>
2595 Within this environment, you can run configure or compile
2596 commands as if they were being run by
2597 the OpenEmbedded build system itself.
2598 As noted earlier, the working directory also automatically changes to the
2599 Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
2600 </para>
2601
2602 <para>
2603 When you are finished, you just exit the shell or close the terminal window.
2604 </para>
2605
2606 <note>
2607 <para>
2608 It is worth remembering that when using <filename>devshell</filename>
2609 you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
2610 instead of just using <filename>gcc</filename>.
2611 The same applies to other applications such as <filename>binutils</filename>,
2612 <filename>libtool</filename> and so forth.
2613 BitBake sets up environment variables such as <filename>CC</filename>
2614 to assist applications, such as <filename>make</filename> to find the correct tools.
2615 </para>
2616
2617 <para>
2618 It is also worth noting that <filename>devshell</filename> still works over
2619 X11 forwarding and similar situations.
2620 </para>
2621 </note>
2622</section>
2623
2624</chapter>