blob: 1008e1169676e9de97da8d34eaba10f94df4e74c [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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 For a simple example of user-space application development using
32 the <trademark class='trade'>Eclipse</trademark> IDE, see the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-developing-applications-using-eclipse'>Developing Applications Using <trademark class='trade'>Eclipse</trademark></ulink>" section.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 </para></listitem>
35 <listitem><para><emphasis>Temporary Source Code Modification:</emphasis>
36 Direct modification of temporary source code is a convenient
37 development model to quickly iterate and develop towards a
38 solution.
39 Once you implement the solution, you should of course take
40 steps to get the changes upstream and applied in the affected
41 recipes.
42 </para></listitem>
43 <listitem><para><emphasis>Image Development using Toaster:</emphasis>
44 You can use <ulink url='&YOCTO_HOME_URL;/Tools-resources/projects/toaster'>Toaster</ulink>
45 to build custom operating system images within the build
46 environment.
47 Toaster provides an efficient interface to the OpenEmbedded build
48 that allows you to start builds and examine build statistics.
49 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 <listitem><para><emphasis>Using a Development Shell:</emphasis>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050051 You can use a
52 <link linkend='platdev-appdev-devshell'><filename>devshell</filename></link>
53 to efficiently debug
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 commands or simply edit packages.
55 Working inside a development shell is a quick way to set up the
56 OpenEmbedded build environment to work on parts of a project.
57 </para></listitem>
58 </itemizedlist>
59</para>
60
61<section id='system-development-model'>
62 <title>System Development Workflow</title>
63
64 <para>
65 System development involves modification or creation of an image that you want to run on
66 a specific hardware target.
67 Usually, when you want to create an image that runs on embedded hardware, the image does
68 not require the same number of features that a full-fledged Linux distribution provides.
69 Thus, you can create a much smaller image that is designed to use only the
70 features for your particular hardware.
71 </para>
72
73 <para>
74 To help you understand how system development works in the Yocto Project, this section
75 covers two types of image development: BSP creation and kernel modification or
76 configuration.
77 </para>
78
79 <section id='developing-a-board-support-package-bsp'>
80 <title>Developing a Board Support Package (BSP)</title>
81
82 <para>
83 A BSP is a collection of recipes that, when applied during a build, results in
84 an image that you can run on a particular board.
85 Thus, the package when compiled into the new image, supports the operation of the board.
86 </para>
87
88 <note>
89 For a brief list of terms used when describing the development process in the Yocto Project,
90 see the "<link linkend='yocto-project-terms'>Yocto Project Terms</link>" section.
91 </note>
92
93 <para>
94 The remainder of this section presents the basic
95 steps used to create a BSP using the Yocto Project's
96 <ulink url='&YOCTO_DOCS_BSP_URL;#using-the-yocto-projects-bsp-tools'>BSP Tools</ulink>.
97 Although not required for BSP creation, the
98 <filename>meta-intel</filename> repository, which contains
99 many BSPs supported by the Yocto Project, is part of the example.
100 </para>
101
102 <para>
103 For an example that shows how to create a new layer using the tools, see the
104 "<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>"
105 section in the Yocto Project Board Support Package (BSP) Developer's Guide.
106 </para>
107
108 <para>
109 The following illustration and list summarize the BSP creation general workflow.
110 </para>
111
112 <para>
113 <imagedata fileref="figures/bsp-dev-flow.png" width="6in" depth="7in" align="center" scalefit="1" />
114 </para>
115
116 <para>
117 <orderedlist>
118 <listitem><para><emphasis>Set up your host development system to support
119 development using the Yocto Project</emphasis>: See the
120 "<ulink url='&YOCTO_DOCS_QS_URL;#the-linux-distro'>The Linux Distribution</ulink>"
121 and the
122 "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>" sections both
123 in the Yocto Project Quick Start for requirements.</para></listitem>
124 <listitem><para><emphasis>Establish a local copy of the project files on your
125 system</emphasis>: You need this <link linkend='source-directory'>Source
126 Directory</link> available on your host system.
127 Having these files on your system gives you access to the build
128 process and to the tools you need.
129 For information on how to set up the Source Directory,
130 see the
131 "<link linkend='getting-setup'>Getting Set Up</link>" section.</para></listitem>
132 <listitem><para><emphasis>Establish the <filename>meta-intel</filename>
133 repository on your system</emphasis>: Having local copies
134 of these supported BSP layers on your system gives you
135 access to layers you might be able to build on or modify
136 to create your BSP.
137 For information on how to get these files, see the
138 "<link linkend='getting-setup'>Getting Set Up</link>" section.</para></listitem>
139 <listitem><para><emphasis>Create your own BSP layer using the
140 <ulink url='&YOCTO_DOCS_BSP_URL;#creating-a-new-bsp-layer-using-the-yocto-bsp-script'><filename>yocto-bsp</filename></ulink> script</emphasis>:
141 Layers are ideal for
142 isolating and storing work for a given piece of hardware.
143 A layer is really just a location or area in which you place
144 the recipes and configurations for your BSP.
145 In fact, a BSP is, in itself, a special type of layer.
146 The simplest way to create a new BSP layer that is compliant with the
147 Yocto Project is to use the <filename>yocto-bsp</filename> script.
148 For information about that script, see the
149 "<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>"
150 section in the Yocto Project Board Support (BSP) Developer's Guide.
151 </para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500152
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500154 Another example that illustrates a layer
155 is an application.
156 Suppose you are creating an application that has
157 library or other dependencies in order for it to
158 compile and run.
159 The layer, in this case, would be where all the
160 recipes that define those dependencies are kept.
161 The key point for a layer is that it is an isolated
162 area that contains all the relevant information for
163 the project that the OpenEmbedded build system knows
164 about.
165 For more information on layers, see the
166 "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>"
167 section.
168 For more information on BSP layers, see the
169 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
170 section in the Yocto Project Board Support Package (BSP)
171 Developer's Guide.
172 <note>
173 <para>
174 Five BSPs exist that are part of the Yocto Project release:
175 <filename>beaglebone</filename> (ARM),
176 <filename>mpc8315e</filename> (PowerPC),
177 and <filename>edgerouter</filename> (MIPS).
178 The recipes and configurations for these five BSPs
179 are located and dispersed within the
180 <link linkend='source-directory'>Source Directory</link>.
181 </para>
182
183 <para>
184 Three core Intel BSPs exist as part of the Yocto
185 Project release in the
186 <filename>meta-intel</filename> layer:
187 <itemizedlist>
188 <listitem><para><filename>intel-core2-32</filename>,
189 which is a BSP optimized for the Core2 family of CPUs
190 as well as all CPUs prior to the Silvermont core.
191 </para></listitem>
192 <listitem><para><filename>intel-corei7-64</filename>,
193 which is a BSP optimized for Nehalem and later
194 Core and Xeon CPUs as well as Silvermont and later
195 Atom CPUs, such as the Baytrail SoCs.
196 </para></listitem>
197 <listitem><para><filename>intel-quark</filename>,
198 which is a BSP optimized for the Intel Galileo
199 gen1 &amp; gen2 development boards.
200 </para></listitem>
201 </itemizedlist>
202 </para>
203 </note>
204 </para>
205
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206 <para>When you set up a layer for a new BSP, you should follow a standard layout.
207 This layout is described in the
208 "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout'>Example Filesystem Layout</ulink>"
209 section of the Board Support Package (BSP) Development Guide.
210 In the standard layout, you will notice a suggested structure for recipes and
211 configuration information.
212 You can see the standard layout for a BSP by examining
213 any supported BSP found in the <filename>meta-intel</filename> layer inside
214 the Source Directory.</para></listitem>
215 <listitem><para><emphasis>Make configuration changes to your new BSP
216 layer</emphasis>: The standard BSP layer structure organizes the files you need
217 to edit in <filename>conf</filename> and several <filename>recipes-*</filename>
218 directories within the BSP layer.
219 Configuration changes identify where your new layer is on the local system
220 and identify which kernel you are going to use.
221 When you run the <filename>yocto-bsp</filename> script, you are able to interactively
222 configure many things for the BSP (e.g. keyboard, touchscreen, and so forth).
223 </para></listitem>
224 <listitem><para><emphasis>Make recipe changes to your new BSP layer</emphasis>: Recipe
225 changes include altering recipes (<filename>.bb</filename> files), removing
226 recipes you do not use, and adding new recipes or append files
227 (<filename>.bbappend</filename>) that you need to support your hardware.
228 </para></listitem>
229 <listitem><para><emphasis>Prepare for the build</emphasis>: Once you have made all the
230 changes to your BSP layer, there remains a few things
231 you need to do for the OpenEmbedded build system in order for it to create your image.
232 You need to get the build environment ready by sourcing an environment setup script
233 (i.e. <filename>oe-init-build-env</filename> or
234 <filename>oe-init-build-env-memres</filename>)
235 and you need to be sure two key configuration files are configured appropriately:
236 the <filename>conf/local.conf</filename> and the
237 <filename>conf/bblayers.conf</filename> file.
238 You must make the OpenEmbedded build system aware of your new layer.
239 See the
240 "<link linkend='enabling-your-layer'>Enabling Your Layer</link>" section
241 for information on how to let the build system know about your new layer.</para>
242 <para>The entire process for building an image is overviewed in the section
243 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>" section
244 of the Yocto Project Quick Start.
245 You might want to reference this information.</para></listitem>
246 <listitem><para><emphasis>Build the image</emphasis>: The OpenEmbedded build system
247 uses the BitBake tool to build images based on the type of image you want to create.
248 You can find more information about BitBake in the
249 <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
250 </para>
251 <para>The build process supports several types of images to satisfy different needs.
252 See the
253 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter
254 in the Yocto Project Reference Manual for information on
255 supported images.</para></listitem>
256 </orderedlist>
257 </para>
258
259 <para>
260 You can view a video presentation on "Building Custom Embedded Images with Yocto"
261 at <ulink url='http://free-electrons.com/blog/elc-2011-videos'>Free Electrons</ulink>.
262 After going to the page, just search for "Embedded".
263 You can also find supplemental information in the
264 <ulink url='&YOCTO_DOCS_BSP_URL;'>
265 Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
266 Finally, there is helpful material and links on this
267 <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_creating_one_generic_Atom_BSP_from_another'>wiki page</ulink>.
268 Although a bit dated, you might find the information on the wiki
269 helpful.
270 </para>
271 </section>
272
273 <section id='modifying-the-kernel'>
274 <title><anchor id='kernel-spot' />Modifying the Kernel</title>
275
276 <para>
277 Kernel modification involves changing the Yocto Project kernel, which could involve changing
278 configuration options as well as adding new kernel recipes.
279 Configuration changes can be added in the form of configuration fragments, while recipe
280 modification comes through the kernel's <filename>recipes-kernel</filename> area
281 in a kernel layer you create.
282 </para>
283
284 <para>
285 The remainder of this section presents a high-level overview of the Yocto Project
286 kernel architecture and the steps to modify the kernel.
287 You can reference the
288 "<link linkend='patching-the-kernel'>Patching the Kernel</link>" section
289 for an example that changes the source code of the kernel.
290 For information on how to configure the kernel, see the
291 "<link linkend='configuring-the-kernel'>Configuring the Kernel</link>" section.
292 For more information on the kernel and on modifying the kernel, see the
293 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>.
294 </para>
295
296 <section id='kernel-overview'>
297 <title>Kernel Overview</title>
298
299 <para>
300 Traditionally, when one thinks of a patched kernel, they think of a base kernel
301 source tree and a fixed structure that contains kernel patches.
302 The Yocto Project, however, employs mechanisms that, in a sense, result in a kernel source
303 generator.
304 By the end of this section, this analogy will become clearer.
305 </para>
306
307 <para>
308 You can find a web interface to the Yocto Project kernel source repositories at
309 <ulink url='&YOCTO_GIT_URL;'></ulink>.
310 If you look at the interface, you will see to the left a grouping of
311 Git repositories titled "Yocto Linux Kernel."
312 Within this group, you will find several kernels supported by
313 the Yocto Project:
314 <itemizedlist>
315 <listitem><para><emphasis>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316 <filename>linux-yocto-3.14</filename></emphasis> - The
317 stable Yocto Project kernel to use with the Yocto
318 Project Releases 1.6 and 1.7.
319 This kernel is based on the Linux 3.14 released kernel.
320 </para></listitem>
321 <listitem><para><emphasis>
322 <filename>linux-yocto-3.17</filename></emphasis> - An
323 additional, unsupported Yocto Project kernel used with
324 the Yocto Project Release 1.7.
325 This kernel is based on the Linux 3.17 released kernel.
326 </para></listitem>
327 <listitem><para><emphasis>
328 <filename>linux-yocto-3.19</filename></emphasis> - The
329 stable Yocto Project kernel to use with the Yocto
330 Project Release 1.8.
331 This kernel is based on the Linux 3.19 released kernel.
332 </para></listitem>
333 <listitem><para><emphasis>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500334 <filename>linux-yocto-4.1</filename></emphasis> - The
335 stable Yocto Project kernel to use with the Yocto
336 Project Release 2.0.
337 This kernel is based on the Linux 4.1 released kernel.
338 </para></listitem>
339 <listitem><para><emphasis>
340 <filename>linux-yocto-4.4</filename></emphasis> - The
341 stable Yocto Project kernel to use with the Yocto
342 Project Release 2.1.
343 This kernel is based on the Linux 4.4 released kernel.
344 </para></listitem>
345 <listitem><para><emphasis>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346 <filename>linux-yocto-dev</filename></emphasis> - A
347 development kernel based on the latest upstream release
348 candidate available.
349 </para></listitem>
350 </itemizedlist>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500351 <note>
352 Long Term Support Initiative (LTSI) for Yocto Project kernels
353 is as follows:
354 <itemizedlist>
355 <listitem><para>For Yocto Project releases 1.7, 1.8, and 2.0,
356 the LTSI kernel is <filename>linux-yocto-3.14</filename>.
357 </para></listitem>
358 <listitem><para>For Yocto Project release 2.1, the
359 LTSI kernel is <filename>linux-yocto-4.1</filename>.
360 </para></listitem>
361 </itemizedlist>
362 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500363 </para>
364
365 <para>
366 The kernels are maintained using the Git revision control system
367 that structures them using the familiar "tree", "branch", and "leaf" scheme.
368 Branches represent diversions from general code to more specific code, while leaves
369 represent the end-points for a complete and unique kernel whose source files,
370 when gathered from the root of the tree to the leaf, accumulate to create the files
371 necessary for a specific piece of hardware and its features.
372 The following figure displays this concept:
373 <para>
374 <imagedata fileref="figures/kernel-overview-1.png"
375 width="6in" depth="6in" align="center" scale="100" />
376 </para>
377
378 <para>
379 Within the figure, the "Kernel.org Branch Point" represents the point in the tree
380 where a supported base kernel is modified from the Linux kernel.
381 For example, this could be the branch point for the <filename>linux-yocto-3.19</filename>
382 kernel.
383 Thus, everything further to the right in the structure is based on the
384 <filename>linux-yocto-3.19</filename> kernel.
385 Branch points to the right in the figure represent where the
386 <filename>linux-yocto-3.19</filename> kernel is modified for specific hardware
387 or types of kernels, such as real-time kernels.
388 Each leaf thus represents the end-point for a kernel designed to run on a specific
389 targeted device.
390 </para>
391
392 <para>
393 The overall result is a Git-maintained repository from which all the supported
394 kernel types can be derived for all the supported devices.
395 A big advantage to this scheme is the sharing of common features by keeping them in
396 "larger" branches within the tree.
397 This practice eliminates redundant storage of similar features shared among kernels.
398 </para>
399
400 <note>
401 Keep in mind the figure does not take into account all the supported Yocto
402 Project kernel types, but rather shows a single generic kernel just for conceptual purposes.
403 Also keep in mind that this structure represents the Yocto Project source repositories
404 that are either pulled from during the build or established on the host development system
405 prior to the build by either cloning a particular kernel's Git repository or by
406 downloading and unpacking a tarball.
407 </note>
408
409 <para>
410 Upstream storage of all the available kernel source code is one thing, while
411 representing and using the code on your host development system is another.
412 Conceptually, you can think of the kernel source repositories as all the
413 source files necessary for all the supported kernels.
414 As a developer, you are just interested in the source files for the kernel on
415 which you are working.
416 And, furthermore, you need them available on your host system.
417 </para>
418
419 <para>
420 Kernel source code is available on your host system a couple of different
421 ways.
422 If you are working in the kernel all the time, you probably would want
423 to set up your own local Git repository of the kernel tree.
424 If you just need to make some patches to the kernel, you can access
425 temporary kernel source files that were extracted and used
426 during a build.
427 We will just talk about working with the temporary source code.
428 For more information on how to get kernel source code onto your
429 host system, see the
430 "<link linkend='local-kernel-files'>Yocto Project Kernel</link>"
431 bulleted item earlier in the manual.
432 </para>
433
434 <para>
435 What happens during the build?
436 When you build the kernel on your development system, all files needed for the build
437 are taken from the source repositories pointed to by the
438 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> variable
439 and gathered in a temporary work area
440 where they are subsequently used to create the unique kernel.
441 Thus, in a sense, the process constructs a local source tree specific to your
442 kernel to generate the new kernel image - a source generator if you will.
443 </para>
444 The following figure shows the temporary file structure
445 created on your host system when the build occurs.
446 This
447 <link linkend='build-directory'>Build Directory</link> contains all the
448 source files used during the build.
449 </para>
450
451 <para>
452 <imagedata fileref="figures/kernel-overview-2-generic.png"
453 width="6in" depth="5in" align="center" scale="100" />
454 </para>
455
456 <para>
457 Again, for additional information on the Yocto Project kernel's
458 architecture and its branching strategy, see the
459 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;'>Yocto Project Linux Kernel Development Manual</ulink>.
460 You can also reference the
461 "<link linkend='patching-the-kernel'>Patching the Kernel</link>"
462 section for a detailed example that modifies the kernel.
463 </para>
464 </section>
465
466 <section id='kernel-modification-workflow'>
467 <title>Kernel Modification Workflow</title>
468
469 <para>
470 This illustration and the following list summarizes the kernel modification general workflow.
471 </para>
472
473 <para>
474 <imagedata fileref="figures/kernel-dev-flow.png"
475 width="6in" depth="5in" align="center" scalefit="1" />
476 </para>
477
478 <para>
479 <orderedlist>
480 <listitem><para><emphasis>Set up your host development system to support
481 development using the Yocto Project</emphasis>: See
482 "<ulink url='&YOCTO_DOCS_QS_URL;#the-linux-distro'>The Linux Distribution</ulink>" and
483 "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>" sections both
484 in the Yocto Project Quick Start for requirements.</para></listitem>
485 <listitem><para><emphasis>Establish a local copy of project files on your
486 system</emphasis>: Having the <link linkend='source-directory'>Source
487 Directory</link> on your system gives you access to the build process and tools
488 you need.
489 For information on how to get these files, see the bulleted item
490 "<link linkend='local-yp-release'>Yocto Project Release</link>" earlier in this manual.
491 </para></listitem>
492 <listitem><para><emphasis>Establish the temporary kernel source files</emphasis>:
493 Temporary kernel source files are kept in the
494 <link linkend='build-directory'>Build Directory</link>
495 created by the
496 OpenEmbedded build system when you run BitBake.
497 If you have never built the kernel in which you are
498 interested, you need to run an initial build to
499 establish local kernel source files.</para>
500 <para>If you are building an image for the first time, you need to get the build
501 environment ready by sourcing an environment setup script
502 (i.e. <filename>oe-init-build-env</filename> or
503 <filename>oe-init-build-env-memres</filename>).
504 You also need to be sure two key configuration files
505 (<filename>local.conf</filename> and <filename>bblayers.conf</filename>)
506 are configured appropriately.</para>
507 <para>The entire process for building an image is overviewed in the
508 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
509 section of the Yocto Project Quick Start.
510 You might want to reference this information.
511 You can find more information on BitBake in the
512 <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
513 </para>
514 <para>The build process supports several types of images to satisfy different needs.
515 See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter in
516 the Yocto Project Reference Manual for information on supported images.
517 </para></listitem>
518 <listitem><para><emphasis>Make changes to the kernel source code if
519 applicable</emphasis>: Modifying the kernel does not always mean directly
520 changing source files.
521 However, if you have to do this, you make the changes to the files in the
522 Build Directory.</para></listitem>
523 <listitem><para><emphasis>Make kernel configuration changes if applicable</emphasis>:
524 If your situation calls for changing the kernel's
525 configuration, you can use
526 <ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'><filename>menuconfig</filename></ulink>,
527 which allows you to interactively develop and test the
528 configuration changes you are making to the kernel.
529 Saving changes you make with
530 <filename>menuconfig</filename> updates
531 the kernel's <filename>.config</filename> file.
532 <note><title>Warning</title>
533 Try to resist the temptation to directly edit an
534 existing <filename>.config</filename> file, which is
535 found in the Build Directory at
536 <filename>tmp/sysroots/<replaceable>machine-name</replaceable>/kernel</filename>.
537 Doing so, can produce unexpected results when the
538 OpenEmbedded build system regenerates the configuration
539 file.
540 </note>
541 Once you are satisfied with the configuration
542 changes made using <filename>menuconfig</filename>
543 and you have saved them, you can directly compare the
544 resulting <filename>.config</filename> file against an
545 existing original and gather those changes into a
546 <link linkend='creating-config-fragments'>configuration fragment file</link>
547 to be referenced from within the kernel's
548 <filename>.bbappend</filename> file.</para>
549
550 <para>Additionally, if you are working in a BSP layer
551 and need to modify the BSP's kernel's configuration,
552 you can use the
553 <ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'><filename>yocto-kernel</filename></ulink>
554 script as well as <filename>menuconfig</filename>.
555 The <filename>yocto-kernel</filename> script lets
556 you interactively set up kernel configurations.
557 </para></listitem>
558 <listitem><para><emphasis>Rebuild the kernel image with your changes</emphasis>:
559 Rebuilding the kernel image applies your changes.
560 </para></listitem>
561 </orderedlist>
562 </para>
563 </section>
564 </section>
565</section>
566
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500567<section id='application-development-workflow-using-an-sdk'>
568 <title>Application Development Workflow Using an SDK</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500569
570 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500571 Standard and extensible Software Development Kits (SDK) make it easy
572 to develop applications inside or outside of the Yocto Project
573 development environment.
574 Tools exist to help the application developer during any phase
575 of development.
576 For information on how to install and use an SDK, see the
577 <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500578 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500579</section>
580
581<section id="dev-modifying-source-code">
582 <title>Modifying Source Code</title>
583
584 <para>
585 A common development workflow consists of modifying project source
586 files that are external to the Yocto Project and then integrating
587 that project's build output into an image built using the
588 OpenEmbedded build system.
589 Given this scenario, development engineers typically want to stick
590 to their familiar project development tools and methods, which allows
591 them to just focus on the project.
592 </para>
593
594 <para>
595 Several workflows exist that allow you to develop, build, and test
596 code that is going to be integrated into an image built using the
597 OpenEmbedded build system.
598 This section describes two:
599 <itemizedlist>
600 <listitem><para><emphasis><filename>devtool</filename>:</emphasis>
601 A set of tools to aid in working on the source code built by
602 the OpenEmbedded build system.
603 Section
604 "<link linkend='using-devtool-in-your-workflow'>Using <filename>devtool</filename> in Your Workflow</link>"
605 describes this workflow.
606 If you want more information that showcases the workflow, click
607 <ulink url='https://drive.google.com/a/linaro.org/file/d/0B3KGzY5fW7laTDVxUXo3UDRvd2s/view'>here</ulink>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500608 for a presentation by Trevor Woerner that, while somewhat dated,
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500609 provides detailed background information and a complete
610 working tutorial.
611 </para></listitem>
612 <listitem><para><emphasis><ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>:</emphasis>
613 A powerful tool that allows you to capture source
614 code changes without having a clean source tree.
615 While Quilt is not the preferred workflow of the two, this
616 section includes it for users that are committed to using
617 the tool.
618 See the
619 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
620 section for more information.
621 </para></listitem>
622 </itemizedlist>
623 </para>
624
625 <section id='using-devtool-in-your-workflow'>
626 <title>Using <filename>devtool</filename> in Your Workflow</title>
627
628 <para>
629 As mentioned earlier, <filename>devtool</filename> helps
630 you easily develop projects whose build output must be part of
631 an image built using the OpenEmbedded build system.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500632 </para>
633
634 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500635 Three entry points exist that allow you to develop using
636 <filename>devtool</filename>:
637 <itemizedlist>
638 <listitem><para><emphasis><filename>devtool add</filename></emphasis>
639 </para></listitem>
640 <listitem><para><emphasis><filename>devtool modify</filename></emphasis>
641 </para></listitem>
642 <listitem><para><emphasis><filename>devtool upgrade</filename></emphasis>
643 </para></listitem>
644 </itemizedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500645 </para>
646
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500647 <para>
648 The remainder of this section presents these workflows.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600649 See the
650 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename>&nbsp;Quick Reference</ulink>"
651 in the Yocto Project Reference Manual for a
652 <filename>devtool</filename> quick reference.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500653 </para>
654
655 <section id='use-devtool-to-integrate-new-code'>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600656 <title>Use <filename>devtool add</filename> to Add an Application</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500657
658 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500659 The <filename>devtool add</filename> command generates
660 a new recipe based on existing source code.
661 This command takes advantage of the
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600662 <ulink url='&YOCTO_DOCS_DEV_URL;#devtool-the-workspace-layer-structure'>workspace</ulink>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500663 layer that many <filename>devtool</filename> commands
664 use.
665 The command is flexible enough to allow you to extract source
666 code into both the workspace or a separate local Git repository
667 and to use existing code that does not need to be extracted.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500668 </para>
669
670 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500671 Depending on your particular scenario, the arguments and options
672 you use with <filename>devtool add</filename> form different
673 combinations.
674 The following diagram shows common development flows
675 you would use with the <filename>devtool add</filename>
676 command:
677 </para>
678
679 <para>
680 <imagedata fileref="figures/devtool-add-flow.png" align="center" />
681 </para>
682
683 <para>
684 <orderedlist>
685 <listitem><para><emphasis>Generating the New Recipe</emphasis>:
686 The top part of the flow shows three scenarios by which
687 you could use <filename>devtool add</filename> to
688 generate a recipe based on existing source code.</para>
689
690 <para>In a shared development environment, it is
691 typical where other developers are responsible for
692 various areas of source code.
693 As a developer, you are probably interested in using
694 that source code as part of your development using
695 the Yocto Project.
696 All you need is access to the code, a recipe, and a
697 controlled area in which to do your work.</para>
698
699 <para>Within the diagram, three possible scenarios
700 feed into the <filename>devtool add</filename> workflow:
701 <itemizedlist>
702 <listitem><para><emphasis>Left</emphasis>:
703 The left scenario represents a common situation
704 where the source code does not exist locally
705 and needs to be extracted.
706 In this situation, you just let it get
707 extracted to the default workspace - you do not
708 want it in some specific location outside of the
709 workspace.
710 Thus, everything you need will be located in the
711 workspace:
712 <literallayout class='monospaced'>
713 $ devtool add <replaceable>recipe fetchuri</replaceable>
714 </literallayout>
715 With this command, <filename>devtool</filename>
716 creates a recipe and an append file in the
717 workspace as well as extracts the upstream
718 source files into a local Git repository also
719 within the <filename>sources</filename> folder.
720 </para></listitem>
721 <listitem><para><emphasis>Middle</emphasis>:
722 The middle scenario also represents a situation where
723 the source code does not exist locally.
724 In this case, the code is again upstream
725 and needs to be extracted to some
726 local area - this time outside of the default
727 workspace.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600728 If required, <filename>devtool</filename>
729 always creates
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500730 a Git repository locally during the extraction.
731 Furthermore, the first positional argument
732 <replaceable>srctree</replaceable> in this case
733 identifies where the
734 <filename>devtool add</filename> command
735 will locate the extracted code outside of the
736 workspace:
737 <literallayout class='monospaced'>
738 $ devtool add <replaceable>recipe srctree fetchuri</replaceable>
739 </literallayout>
740 In summary, the source code is pulled from
741 <replaceable>fetchuri</replaceable> and extracted
742 into the location defined by
743 <replaceable>srctree</replaceable> as a local
744 Git repository.</para>
745
746 <para>Within workspace, <filename>devtool</filename>
747 creates both the recipe and an append file
748 for the recipe.
749 </para></listitem>
750 <listitem><para><emphasis>Right</emphasis>:
751 The right scenario represents a situation
752 where the source tree (srctree) has been
753 previously prepared outside of the
754 <filename>devtool</filename> workspace.
755 </para>
756
757 <para>The following command names the recipe
758 and identifies where the existing source tree
759 is located:
760 <literallayout class='monospaced'>
761 $ devtool add <replaceable>recipe srctree</replaceable>
762 </literallayout>
763 The command examines the source code and creates
764 a recipe for it placing the recipe into the
765 workspace.</para>
766
767 <para>Because the extracted source code already exists,
768 <filename>devtool</filename> does not try to
769 relocate it into the workspace - just the new
770 the recipe is placed in the workspace.</para>
771
772 <para>Aside from a recipe folder, the command
773 also creates an append folder and places an initial
774 <filename>*.bbappend</filename> within.
775 </para></listitem>
776 </itemizedlist>
777 </para></listitem>
778 <listitem><para><emphasis>Edit the Recipe</emphasis>:
779 At this point, you can use <filename>devtool edit-recipe</filename>
780 to open up the editor as defined by the
781 <filename>$EDITOR</filename> environment variable
782 and modify the file:
783 <literallayout class='monospaced'>
784 $ devtool edit-recipe <replaceable>recipe</replaceable>
785 </literallayout>
786 From within the editor, you can make modifications to the
787 recipe that take affect when you build it later.
788 </para></listitem>
789 <listitem><para><emphasis>Build the Recipe or Rebuild the Image</emphasis>:
790 At this point in the flow, the next step you
791 take depends on what you are going to do with
792 the new code.</para>
793 <para>If you need to take the build output and eventually
794 move it to the target hardware, you would use
795 <filename>devtool build</filename>:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500796 <literallayout class='monospaced'>
797 $ devtool build <replaceable>recipe</replaceable>
798 </literallayout></para>
799 <para>On the other hand, if you want an image to
800 contain the recipe's packages for immediate deployment
801 onto a device (e.g. for testing purposes), you can use
802 the <filename>devtool build-image</filename> command:
803 <literallayout class='monospaced'>
804 $ devtool build-image <replaceable>image</replaceable>
805 </literallayout>
806 </para></listitem>
807 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
808 When you use the <filename>devtool build</filename>
809 command to build out your recipe, you probably want to
810 see if the resulting build output works as expected on target
811 hardware.
812 <note>
813 This step assumes you have a previously built
814 image that is already either running in QEMU or
815 running on actual hardware.
816 Also, it is assumed that for deployment of the image
817 to the target, SSH is installed in the image and if
818 the image is running on real hardware that you have
819 network access to and from your development machine.
820 </note>
821 You can deploy your build output to that target hardware by
822 using the <filename>devtool deploy-target</filename> command:
823 <literallayout class='monospaced'>
824 $ devtool deploy-target <replaceable>recipe target</replaceable>
825 </literallayout>
826 The <replaceable>target</replaceable> is a live target machine
827 running as an SSH server.</para>
828
829 <para>You can, of course, also deploy the image you build
830 using the <filename>devtool build-image</filename> command
831 to actual hardware.
832 However, <filename>devtool</filename> does not provide a
833 specific command that allows you to do this.
834 </para></listitem>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600835 <listitem><para>
836 <emphasis>Finish Your Work With the Recipe</emphasis>:
837 The <filename>devtool finish</filename> command creates
838 any patches corresponding to commits in the local
839 Git repository, moves the new recipe to a more permanent
840 layer, and then resets the recipe so that the recipe is
841 built normally rather than from the workspace.
842 <literallayout class='monospaced'>
843 $ devtool finish <replaceable>recipe layer</replaceable>
844 </literallayout>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500845 <note>
846 Any changes you want to turn into patches must be
847 committed to the Git repository in the source tree.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600848 </note></para>
849
850 <para>As mentioned, the <filename>devtool finish</filename>
851 command moves the final recipe to its permanent layer.
852 </para>
853
854 <para>As a final process of the
855 <filename>devtool finish</filename> command, the state
856 of the standard layers and the upstream source is
857 restored so that you can build the recipe from those
858 areas rather than the workspace.
859 <note>
860 You can use the <filename>devtool reset</filename>
861 command to put things back should you decide you
862 do not want to proceed with your work.
863 If you do use this command, realize that the source
864 tree is preserved.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500865 </note>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500866 </para></listitem>
867 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500868 </para>
869 </section>
870
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500871 <section id='devtool-use-devtool-modify-to-enable-work-on-code-associated-with-an-existing-recipe'>
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600872 <title>Use <filename>devtool modify</filename> to Modify the Source of an Existing Component</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500873
874 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500875 The <filename>devtool modify</filename> command prepares the
876 way to work on existing code that already has a recipe in
877 place.
878 The command is flexible enough to allow you to extract code,
879 specify the existing recipe, and keep track of and gather any
880 patch files from other developers that are
881 associated with the code.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500882 </para>
883
884 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500885 Depending on your particular scenario, the arguments and options
886 you use with <filename>devtool modify</filename> form different
887 combinations.
888 The following diagram shows common development flows
889 you would use with the <filename>devtool modify</filename>
890 command:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500891 </para>
892
893 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500894 <imagedata fileref="figures/devtool-modify-flow.png" align="center" />
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500895 </para>
896
897 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500898 <orderedlist>
899 <listitem><para><emphasis>Preparing to Modify the Code</emphasis>:
900 The top part of the flow shows three scenarios by which
901 you could use <filename>devtool modify</filename> to
902 prepare to work on source files.
903 Each scenario assumes the following:
904 <itemizedlist>
905 <listitem><para>The recipe exists in some layer external
906 to the <filename>devtool</filename> workspace.
907 </para></listitem>
908 <listitem><para>The source files exist upstream in an
909 un-extracted state or locally in a previously
910 extracted state.
911 </para></listitem>
912 </itemizedlist>
913 The typical situation is where another developer has
914 created some layer for use with the Yocto Project and
915 their recipe already resides in that layer.
916 Furthermore, their source code is readily available
917 either upstream or locally.
918 <itemizedlist>
919 <listitem><para><emphasis>Left</emphasis>:
920 The left scenario represents a common situation
921 where the source code does not exist locally
922 and needs to be extracted.
923 In this situation, the source is extracted
924 into the default workspace location.
925 The recipe, in this scenario, is in its own
926 layer outside the workspace
927 (i.e.
928 <filename>meta-</filename><replaceable>layername</replaceable>).
929 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500930
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500931 <para>The following command identifies the recipe
932 and by default extracts the source files:
933 <literallayout class='monospaced'>
934 $ devtool modify <replaceable>recipe</replaceable>
935 </literallayout>
936 Once <filename>devtool</filename>locates the recipe,
937 it uses the
938 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
939 variable to locate the source code and
940 any local patch files from other developers are
941 located.
942 <note>
943 You cannot provide an URL for
944 <replaceable>srctree</replaceable> when using the
945 <filename>devtool modify</filename> command.
946 </note>
947 With this scenario, however, since no
948 <replaceable>srctree</replaceable> argument exists, the
949 <filename>devtool modify</filename> command by default
950 extracts the source files to a Git structure.
951 Furthermore, the location for the extracted source is the
952 default area within the workspace.
953 The result is that the command sets up both the source
954 code and an append file within the workspace with the
955 recipe remaining in its original location.
956 </para></listitem>
957 <listitem><para><emphasis>Middle</emphasis>:
958 The middle scenario represents a situation where
959 the source code also does not exist locally.
960 In this case, the code is again upstream
961 and needs to be extracted to some
962 local area as a Git repository.
963 The recipe, in this scenario, is again in its own
964 layer outside the workspace.</para>
965
966 <para>The following command tells
967 <filename>devtool</filename> what recipe with
968 which to work and, in this case, identifies a local
969 area for the extracted source files that is outside
970 of the default workspace:
971 <literallayout class='monospaced'>
972 $ devtool modify <replaceable>recipe srctree</replaceable>
973 </literallayout>
974 As with all extractions, the command uses
975 the recipe's <filename>SRC_URI</filename> to locate the
976 source files.
977 Once the files are located, the command by default
978 extracts them.
979 Providing the <replaceable>srctree</replaceable>
980 argument instructs <filename>devtool</filename> where
981 place the extracted source.</para>
982
983 <para>Within workspace, <filename>devtool</filename>
984 creates an append file for the recipe.
985 The recipe remains in its original location but
986 the source files are extracted to the location you
987 provided with <replaceable>srctree</replaceable>.
988 </para></listitem>
989 <listitem><para><emphasis>Right</emphasis>:
990 The right scenario represents a situation
991 where the source tree
992 (<replaceable>srctree</replaceable>) exists as a
993 previously extracted Git structure outside of
994 the <filename>devtool</filename> workspace.
995 In this example, the recipe also exists
996 elsewhere in its own layer.
997 </para>
998
999 <para>The following command tells
1000 <filename>devtool</filename> the recipe
1001 with which to work, uses the "-n" option to indicate
1002 source does not need to be extracted, and uses
1003 <replaceable>srctree</replaceable> to point to the
1004 previously extracted source files:
1005 <literallayout class='monospaced'>
1006 $ devtool modify -n <replaceable>recipe srctree</replaceable>
1007 </literallayout>
1008 </para>
1009
1010 <para>Once the command finishes, it creates only
1011 an append file for the recipe in the workspace.
1012 The recipe and the source code remain in their
1013 original locations.
1014 </para></listitem>
1015 </itemizedlist>
1016 </para></listitem>
1017 <listitem><para><emphasis>Edit the Source</emphasis>:
1018 Once you have used the <filename>devtool modify</filename>
1019 command, you are free to make changes to the source
1020 files.
1021 You can use any editor you like to make and save
1022 your source code modifications.
1023 </para></listitem>
1024 <listitem><para><emphasis>Build the Recipe</emphasis>:
1025 Once you have updated the source files, you can build
1026 the recipe.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001027 </para></listitem>
1028 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
1029 When you use the <filename>devtool build</filename>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001030 command to build out your recipe, you probably want to see
1031 if the resulting build output works as expected on target
1032 hardware.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001033 <note>
1034 This step assumes you have a previously built
1035 image that is already either running in QEMU or
1036 running on actual hardware.
1037 Also, it is assumed that for deployment of the image
1038 to the target, SSH is installed in the image and if
1039 the image is running on real hardware that you have
1040 network access to and from your development machine.
1041 </note>
1042 You can deploy your build output to that target hardware by
1043 using the <filename>devtool deploy-target</filename> command:
1044 <literallayout class='monospaced'>
1045 $ devtool deploy-target <replaceable>recipe target</replaceable>
1046 </literallayout>
1047 The <replaceable>target</replaceable> is a live target machine
1048 running as an SSH server.</para>
1049
1050 <para>You can, of course, also deploy the image you build
1051 using the <filename>devtool build-image</filename> command
1052 to actual hardware.
1053 However, <filename>devtool</filename> does not provide a
1054 specific command that allows you to do this.
1055 </para></listitem>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001056 <listitem><para>
1057 <emphasis>Finish Your Work With the Recipe</emphasis>:
1058 The <filename>devtool finish</filename> command creates
1059 any patches corresponding to commits in the local
1060 Git repository, updates the recipe to point to them
1061 (or creates a <filename>.bbappend</filename> file to do
1062 so, depending on the specified destination layer), and
1063 then resets the recipe so that the recipe is built normally
1064 rather than from the workspace.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001065 <literallayout class='monospaced'>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001066 $ devtool finish <replaceable>recipe layer</replaceable>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001067 </literallayout>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001068 <note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001069 Any changes you want to turn into patches must be
1070 committed to the Git repository in the source tree.
1071 </note></para>
1072
1073 <para>Because there is no need to move the recipe,
1074 <filename>devtool finish</filename> either updates the
1075 original recipe in the original layer or the command
1076 creates a <filename>.bbappend</filename> in a different
1077 layer as provided by <replaceable>layer</replaceable>.
1078 </para>
1079
1080 <para>As a final process of the
1081 <filename>devtool finish</filename> command, the state
1082 of the standard layers and the upstream source is
1083 restored so that you can build the recipe from those
1084 areas rather than the workspace.
1085 <note>
1086 You can use the <filename>devtool reset</filename>
1087 command to put things back should you decide you
1088 do not want to proceed with your work.
1089 If you do use this command, realize that the source
1090 tree is preserved.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001091 </note>
1092 </para></listitem>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001093 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001094 </para>
1095 </section>
1096
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001097 <section id='devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'>
1098 <title>Use <filename>devtool upgrade</filename> to Create a Version of the Recipe that Supports a Newer Version of the Software</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001099
1100 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001101 The <filename>devtool upgrade</filename> command updates
1102 an existing recipe so that you can build it for an updated
1103 set of source files.
1104 The command is flexible enough to allow you to specify
1105 source code revision and versioning schemes, extract code into
1106 or out of the <filename>devtool</filename> workspace, and
1107 work with any source file forms that the fetchers support.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001108 </para>
1109
1110 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001111 Depending on your particular scenario, the arguments and options
1112 you use with <filename>devtool upgrade</filename> form different
1113 combinations.
1114 The following diagram shows a common development flow
1115 you would use with the <filename>devtool modify</filename>
1116 command:
1117 </para>
1118
1119 <para>
1120 <imagedata fileref="figures/devtool-upgrade-flow.png" align="center" />
1121 </para>
1122
1123 <para>
1124 <orderedlist>
1125 <listitem><para><emphasis>Initiate the Upgrade</emphasis>:
1126 The top part of the flow shows a typical scenario by which
1127 you could use <filename>devtool upgrade</filename>.
1128 The following conditions exist:
1129 <itemizedlist>
1130 <listitem><para>The recipe exists in some layer external
1131 to the <filename>devtool</filename> workspace.
1132 </para></listitem>
1133 <listitem><para>The source files for the new release
1134 exist adjacent to the same location pointed to by
1135 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1136 in the recipe (e.g. a tarball with the new version
1137 number in the name, or as a different revision in
1138 the upstream Git repository).
1139 </para></listitem>
1140 </itemizedlist>
1141 A common situation is where third-party software has
1142 undergone a revision so that it has been upgraded.
1143 The recipe you have access to is likely in your own layer.
1144 Thus, you need to upgrade the recipe to use the
1145 newer version of the software:
1146 <literallayout class='monospaced'>
1147 $ devtool upgrade -V <replaceable>version recipe</replaceable>
1148 </literallayout>
1149 By default, the <filename>devtool upgrade</filename> command
1150 extracts source code into the <filename>sources</filename>
1151 directory in the workspace.
1152 If you want the code extracted to any other location, you
1153 need to provide the <replaceable>srctree</replaceable>
1154 positional argument with the command as follows:
1155 <literallayout class='monospaced'>
1156 $ devtool upgrade -V <replaceable>version recipe srctree</replaceable>
1157 </literallayout>
1158 Also, in this example, the "-V" option is used to specify
1159 the new version.
1160 If the source files pointed to by the
1161 <filename>SRC_URI</filename> statement in the recipe are
1162 in a Git repository, you must provide the "-S" option and
1163 specify a revision for the software.</para>
1164
1165 <para>Once <filename>devtool</filename> locates the recipe,
1166 it uses the <filename>SRC_URI</filename> variable to locate
1167 the source code and any local patch files from other
1168 developers are located.
1169 The result is that the command sets up the source
1170 code, the new version of the recipe, and an append file
1171 all within the workspace.
1172 </para></listitem>
1173 <listitem><para><emphasis>Resolve any Conflicts created by the Upgrade</emphasis>:
1174 At this point, there could be some conflicts due to the
1175 software being upgraded to a new version.
1176 This would occur if your recipe specifies some patch files in
1177 <filename>SRC_URI</filename> that conflict with changes
1178 made in the new version of the software.
1179 If this is the case, you need to resolve the conflicts
1180 by editing the source and following the normal
1181 <filename>git rebase</filename> conflict resolution
1182 process.</para>
1183
1184 <para>Before moving onto the next step, be sure to resolve any
1185 such conflicts created through use of a newer or different
1186 version of the software.
1187 </para></listitem>
1188 <listitem><para><emphasis>Build the Recipe</emphasis>:
1189 Once you have your recipe in order, you can build it.
1190 You can either use <filename>devtool build</filename> or
1191 <filename>bitbake</filename>.
1192 Either method produces build output that is stored
1193 in
1194 <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>.
1195 </para></listitem>
1196 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
1197 When you use the <filename>devtool build</filename>
1198 command or <filename>bitbake</filename> to build out your
1199 recipe, you probably want to see if the resulting build
1200 output works as expected on target hardware.
1201 <note>
1202 This step assumes you have a previously built
1203 image that is already either running in QEMU or
1204 running on actual hardware.
1205 Also, it is assumed that for deployment of the image
1206 to the target, SSH is installed in the image and if
1207 the image is running on real hardware that you have
1208 network access to and from your development machine.
1209 </note>
1210 You can deploy your build output to that target hardware by
1211 using the <filename>devtool deploy-target</filename> command:
1212 <literallayout class='monospaced'>
1213 $ devtool deploy-target <replaceable>recipe target</replaceable>
1214 </literallayout>
1215 The <replaceable>target</replaceable> is a live target machine
1216 running as an SSH server.</para>
1217
1218 <para>You can, of course, also deploy the image you build
1219 using the <filename>devtool build-image</filename> command
1220 to actual hardware.
1221 However, <filename>devtool</filename> does not provide a
1222 specific command that allows you to do this.
1223 </para></listitem>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001224 <listitem><para>
1225 <emphasis>Finish Your Work With the Recipe</emphasis>:
1226 The <filename>devtool finish</filename> command creates
1227 any patches corresponding to commits in the local
1228 Git repository, moves the new recipe to a more permanent
1229 layer, and then resets the recipe so that the recipe is
1230 built normally rather than from the workspace.
1231 If you specify a destination layer that is the same as
1232 the original source, then the old version of the
1233 recipe and associated files will be removed prior to
1234 adding the new version.
1235 <literallayout class='monospaced'>
1236 $ devtool finish <replaceable>recipe layer</replaceable>
1237 </literallayout>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001238 <note>
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001239 Any changes you want to turn into patches must be
1240 committed to the Git repository in the source tree.
1241 </note></para>
1242 <para>As a final process of the
1243 <filename>devtool finish</filename> command, the state
1244 of the standard layers and the upstream source is
1245 restored so that you can build the recipe from those
1246 areas rather than the workspace.
1247 <note>
1248 You can use the <filename>devtool reset</filename>
1249 command to put things back should you decide you
1250 do not want to proceed with your work.
1251 If you do use this command, realize that the source
1252 tree is preserved.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001253 </note>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001254 </para></listitem>
1255 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001256 </para>
1257 </section>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001258 </section>
1259
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001260 <section id="using-a-quilt-workflow">
1261 <title>Using Quilt in Your Workflow</title>
1262
1263 <para>
1264 <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
1265 is a powerful tool that allows you to capture source code changes
1266 without having a clean source tree.
1267 This section outlines the typical workflow you can use to modify
1268 source code, test changes, and then preserve the changes in the
1269 form of a patch all using Quilt.
1270 <note><title>Tip</title>
1271 With regard to preserving changes to source files if you
1272 clean a recipe or have <filename>rm_work</filename> enabled,
1273 the workflow described in the
1274 "<link linkend='using-devtool-in-your-workflow'>Using <filename>devtool</filename> in Your Workflow</link>"
1275 section is a safer development flow than than the flow that
1276 uses Quilt.
1277 </note>
1278 </para>
1279
1280 <para>
1281 Follow these general steps:
1282 <orderedlist>
1283 <listitem><para><emphasis>Find the Source Code:</emphasis>
1284 Temporary source code used by the OpenEmbedded build system
1285 is kept in the
1286 <link linkend='build-directory'>Build Directory</link>.
1287 See the
1288 "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
1289 section to learn how to locate the directory that has the
1290 temporary source code for a particular package.
1291 </para></listitem>
1292 <listitem><para><emphasis>Change Your Working Directory:</emphasis>
1293 You need to be in the directory that has the temporary source code.
1294 That directory is defined by the
1295 <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
1296 variable.</para></listitem>
1297 <listitem><para><emphasis>Create a New Patch:</emphasis>
1298 Before modifying source code, you need to create a new patch.
1299 To create a new patch file, use <filename>quilt new</filename> as below:
1300 <literallayout class='monospaced'>
1301 $ quilt new my_changes.patch
1302 </literallayout></para></listitem>
1303 <listitem><para><emphasis>Notify Quilt and Add Files:</emphasis>
1304 After creating the patch, you need to notify Quilt about the files
1305 you plan to edit.
1306 You notify Quilt by adding the files to the patch you just created:
1307 <literallayout class='monospaced'>
1308 $ quilt add file1.c file2.c file3.c
1309 </literallayout>
1310 </para></listitem>
1311 <listitem><para><emphasis>Edit the Files:</emphasis>
1312 Make your changes in the source code to the files you added
1313 to the patch.
1314 </para></listitem>
1315 <listitem><para><emphasis>Test Your Changes:</emphasis>
1316 Once you have modified the source code, the easiest way to
1317 your changes is by calling the
1318 <filename>do_compile</filename> task as shown in the
1319 following example:
1320 <literallayout class='monospaced'>
1321 $ bitbake -c compile -f <replaceable>package</replaceable>
1322 </literallayout>
1323 The <filename>-f</filename> or <filename>--force</filename>
1324 option forces the specified task to execute.
1325 If you find problems with your code, you can just keep editing and
1326 re-testing iteratively until things work as expected.
1327 <note>All the modifications you make to the temporary source code
1328 disappear once you run the
1329 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
1330 or
1331 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
1332 tasks using BitBake (i.e.
1333 <filename>bitbake -c clean <replaceable>package</replaceable></filename>
1334 and
1335 <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
1336 Modifications will also disappear if you use the <filename>rm_work</filename>
1337 feature as described in the
1338 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
1339 section of the Yocto Project Quick Start.
1340 </note></para></listitem>
1341 <listitem><para><emphasis>Generate the Patch:</emphasis>
1342 Once your changes work as expected, you need to use Quilt to generate the final patch that
1343 contains all your modifications.
1344 <literallayout class='monospaced'>
1345 $ quilt refresh
1346 </literallayout>
1347 At this point, the <filename>my_changes.patch</filename> file has all your edits made
1348 to the <filename>file1.c</filename>, <filename>file2.c</filename>, and
1349 <filename>file3.c</filename> files.</para>
1350 <para>You can find the resulting patch file in the <filename>patches/</filename>
1351 subdirectory of the source (<filename>S</filename>) directory.</para></listitem>
1352 <listitem><para><emphasis>Copy the Patch File:</emphasis>
1353 For simplicity, copy the patch file into a directory named <filename>files</filename>,
1354 which you can create in the same directory that holds the recipe
1355 (<filename>.bb</filename>) file or the
1356 append (<filename>.bbappend</filename>) file.
1357 Placing the patch here guarantees that the OpenEmbedded build system will find
1358 the patch.
1359 Next, add the patch into the
1360 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
1361 of the recipe.
1362 Here is an example:
1363 <literallayout class='monospaced'>
1364 SRC_URI += "file://my_changes.patch"
1365 </literallayout></para></listitem>
1366 </orderedlist>
1367 </para>
1368 </section>
1369
1370 <section id='finding-the-temporary-source-code'>
1371 <title>Finding Temporary Source Code</title>
1372
1373 <para>
1374 You might find it helpful during development to modify the
1375 temporary source code used by recipes to build packages.
1376 For example, suppose you are developing a patch and you need to
1377 experiment a bit to figure out your solution.
1378 After you have initially built the package, you can iteratively
1379 tweak the source code, which is located in the
1380 <link linkend='build-directory'>Build Directory</link>, and then
1381 you can force a re-compile and quickly test your altered code.
1382 Once you settle on a solution, you can then preserve your changes
1383 in the form of patches.
1384 If you are using Quilt for development, see the
1385 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
1386 section for more information.
1387 </para>
1388
1389 <para>
1390 During a build, the unpacked temporary source code used by recipes
1391 to build packages is available in the Build Directory as
1392 defined by the
1393 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> variable.
1394 Below is the default value for the <filename>S</filename> variable as defined in the
1395 <filename>meta/conf/bitbake.conf</filename> configuration file in the
1396 <link linkend='source-directory'>Source Directory</link>:
1397 <literallayout class='monospaced'>
1398 S = "${WORKDIR}/${BP}"
1399 </literallayout>
1400 You should be aware that many recipes override the <filename>S</filename> variable.
1401 For example, recipes that fetch their source from Git usually set
1402 <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
1403 <note>
1404 The
1405 <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
1406 represents the base recipe name, which consists of the name and version:
1407 <literallayout class='monospaced'>
1408 BP = "${BPN}-${PV}"
1409 </literallayout>
1410 </note>
1411 </para>
1412
1413 <para>
1414 The path to the work directory for the recipe
1415 (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
1416 is defined as follows:
1417 <literallayout class='monospaced'>
1418 ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
1419 </literallayout>
1420 The actual directory depends on several things:
1421 <itemizedlist>
1422 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
1423 The top-level build output directory</listitem>
1424 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
1425 The target system identifier</listitem>
1426 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
1427 The recipe name</listitem>
1428 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
1429 The epoch - (if
1430 <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
1431 is not specified, which is usually the case for most
1432 recipes, then <filename>EXTENDPE</filename> is blank)</listitem>
1433 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
1434 The recipe version</listitem>
1435 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
1436 The recipe revision</listitem>
1437 </itemizedlist>
1438 </para>
1439
1440 <para>
1441 As an example, assume a Source Directory top-level folder
1442 named <filename>poky</filename>, a default Build Directory at
1443 <filename>poky/build</filename>, and a
1444 <filename>qemux86-poky-linux</filename> machine target
1445 system.
1446 Furthermore, suppose your recipe is named
1447 <filename>foo_1.3.0.bb</filename>.
1448 In this case, the work directory the build system uses to
1449 build the package would be as follows:
1450 <literallayout class='monospaced'>
1451 poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
1452 </literallayout>
1453 </para>
1454
1455 <para>
1456 Now that you know where to locate the directory that has the
1457 temporary source code, you can use a Quilt as described in section
1458 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
1459 to make your edits, test the changes, and preserve the changes in
1460 the form of patches.
1461 </para>
1462 </section>
1463</section>
1464
1465<section id='image-development-using-toaster'>
1466 <title>Image Development Using Toaster</title>
1467
1468 <para>
1469 Toaster is a web interface to the Yocto Project's OpenEmbedded build
1470 system.
1471 You can initiate builds using Toaster as well as examine the results
1472 and statistics of builds.
1473 See the
1474 <ulink url='&YOCTO_DOCS_TOAST_URL;#toaster-manual-intro'>Toaster User Manual</ulink>
1475 for information on how to set up and use Toaster to build images.
1476 </para>
1477</section>
1478
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001479<section id="platdev-appdev-devshell">
1480 <title>Using a Development Shell</title>
1481
1482 <para>
1483 When debugging certain commands or even when just editing packages,
1484 <filename>devshell</filename> can be a useful tool.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001485 When you invoke <filename>devshell</filename>, all tasks up to and
1486 including
1487 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
1488 are run for the specified target.
1489 Then, a new terminal is opened and you are placed in
1490 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
1491 the source directory.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001492 In the new terminal, all the OpenEmbedded build-related environment variables are
1493 still defined so you can use commands such as <filename>configure</filename> and
1494 <filename>make</filename>.
1495 The commands execute just as if the OpenEmbedded build system were executing them.
1496 Consequently, working this way can be helpful when debugging a build or preparing
1497 software to be used with the OpenEmbedded build system.
1498 </para>
1499
1500 <para>
1501 Following is an example that uses <filename>devshell</filename> on a target named
1502 <filename>matchbox-desktop</filename>:
1503 <literallayout class='monospaced'>
1504 $ bitbake matchbox-desktop -c devshell
1505 </literallayout>
1506 </para>
1507
1508 <para>
1509 This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
1510 The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
1511 variable controls what type of shell is opened.
1512 </para>
1513
1514 <para>
1515 For spawned terminals, the following occurs:
1516 <itemizedlist>
1517 <listitem><para>The <filename>PATH</filename> variable includes the
1518 cross-toolchain.</para></listitem>
1519 <listitem><para>The <filename>pkgconfig</filename> variables find the correct
1520 <filename>.pc</filename> files.</para></listitem>
1521 <listitem><para>The <filename>configure</filename> command finds the
1522 Yocto Project site files as well as any other necessary files.</para></listitem>
1523 </itemizedlist>
1524 </para>
1525
1526 <para>
1527 Within this environment, you can run configure or compile
1528 commands as if they were being run by
1529 the OpenEmbedded build system itself.
1530 As noted earlier, the working directory also automatically changes to the
1531 Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
1532 </para>
1533
1534 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001535 To manually run a specific task using <filename>devshell</filename>,
1536 run the corresponding <filename>run.*</filename> script in
1537 the
1538 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
1539 directory (e.g.,
1540 <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
1541 If a task's script does not exist, which would be the case if the task was
1542 skipped by way of the sstate cache, you can create the task by first running
1543 it outside of the <filename>devshell</filename>:
1544 <literallayout class='monospaced'>
1545 $ bitbake -c <replaceable>task</replaceable>
1546 </literallayout>
1547 <note><title>Notes</title>
1548 <itemizedlist>
1549 <listitem><para>Execution of a task's <filename>run.*</filename>
1550 script and BitBake's execution of a task are identical.
1551 In other words, running the script re-runs the task
1552 just as it would be run using the
1553 <filename>bitbake -c</filename> command.
1554 </para></listitem>
1555 <listitem><para>Any <filename>run.*</filename> file that does not
1556 have a <filename>.pid</filename> extension is a
1557 symbolic link (symlink) to the most recent version of that
1558 file.
1559 </para></listitem>
1560 </itemizedlist>
1561 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001562 </para>
1563
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001564 <para>
1565 Remember, that the <filename>devshell</filename> is a mechanism that allows
1566 you to get into the BitBake task execution environment.
1567 And as such, all commands must be called just as BitBake would call them.
1568 That means you need to provide the appropriate options for
1569 cross-compilation and so forth as applicable.
1570 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001571
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001572 <para>
1573 When you are finished using <filename>devshell</filename>, exit the shell
1574 or close the terminal window.
1575 </para>
1576
1577 <note><title>Notes</title>
1578 <itemizedlist>
1579 <listitem><para>
1580 It is worth remembering that when using <filename>devshell</filename>
1581 you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
1582 instead of just using <filename>gcc</filename>.
1583 The same applies to other applications such as <filename>binutils</filename>,
1584 <filename>libtool</filename> and so forth.
1585 BitBake sets up environment variables such as <filename>CC</filename>
1586 to assist applications, such as <filename>make</filename> to find the correct tools.
1587 </para></listitem>
1588 <listitem><para>
1589 It is also worth noting that <filename>devshell</filename> still works over
1590 X11 forwarding and similar situations.
1591 </para></listitem>
1592 </itemizedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001593 </note>
1594</section>
1595
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001596<section id="platdev-appdev-devpyshell">
1597 <title>Using a Development Python Shell</title>
1598
1599 <para>
1600 Similar to working within a development shell as described in
1601 the previous section, you can also spawn and work within an
1602 interactive Python development shell.
1603 When debugging certain commands or even when just editing packages,
1604 <filename>devpyshell</filename> can be a useful tool.
1605 When you invoke <filename>devpyshell</filename>, all tasks up to and
1606 including
1607 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
1608 are run for the specified target.
1609 Then a new terminal is opened.
1610 Additionally, key Python objects and code are available in the same
1611 way they are to BitBake tasks, in particular, the data store 'd'.
1612 So, commands such as the following are useful when exploring the data
1613 store and running functions:
1614 <literallayout class='monospaced'>
1615 pydevshell> d.getVar("STAGING_DIR", True)
1616 '/media/build1/poky/build/tmp/sysroots'
1617 pydevshell> d.getVar("STAGING_DIR", False)
1618 '${TMPDIR}/sysroots'
1619 pydevshell> d.setVar("FOO", "bar")
1620 pydevshell> d.getVar("FOO", True)
1621 'bar'
1622 pydevshell> d.delVar("FOO")
1623 pydevshell> d.getVar("FOO", True)
1624 pydevshell> bb.build.exec_func("do_unpack", d)
1625 pydevshell>
1626 </literallayout>
1627 The commands execute just as if the OpenEmbedded build system were executing them.
1628 Consequently, working this way can be helpful when debugging a build or preparing
1629 software to be used with the OpenEmbedded build system.
1630 </para>
1631
1632 <para>
1633 Following is an example that uses <filename>devpyshell</filename> on a target named
1634 <filename>matchbox-desktop</filename>:
1635 <literallayout class='monospaced'>
1636 $ bitbake matchbox-desktop -c devpyshell
1637 </literallayout>
1638 </para>
1639
1640 <para>
1641 This command spawns a terminal and places you in an interactive
1642 Python interpreter within the OpenEmbedded build environment.
1643 The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
1644 variable controls what type of shell is opened.
1645 </para>
1646
1647 <para>
1648 When you are finished using <filename>devpyshell</filename>, you
1649 can exit the shell either by using Ctrl+d or closing the terminal
1650 window.
1651 </para>
1652</section>
1653
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001654</chapter>