blob: ff44a3f68bfdd69c86884cfc9ce8f6d1197b7b36 [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.
649 </para>
650
651 <section id='use-devtool-to-integrate-new-code'>
652 <title>Use <filename>devtool add</filename> to Integrate New Code</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500653
654 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500655 The <filename>devtool add</filename> command generates
656 a new recipe based on existing source code.
657 This command takes advantage of the
658 <link linkend='devtool-the-workspace-layer-structure'>workspace</link>
659 layer that many <filename>devtool</filename> commands
660 use.
661 The command is flexible enough to allow you to extract source
662 code into both the workspace or a separate local Git repository
663 and to use existing code that does not need to be extracted.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500664 </para>
665
666 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500667 Depending on your particular scenario, the arguments and options
668 you use with <filename>devtool add</filename> form different
669 combinations.
670 The following diagram shows common development flows
671 you would use with the <filename>devtool add</filename>
672 command:
673 </para>
674
675 <para>
676 <imagedata fileref="figures/devtool-add-flow.png" align="center" />
677 </para>
678
679 <para>
680 <orderedlist>
681 <listitem><para><emphasis>Generating the New Recipe</emphasis>:
682 The top part of the flow shows three scenarios by which
683 you could use <filename>devtool add</filename> to
684 generate a recipe based on existing source code.</para>
685
686 <para>In a shared development environment, it is
687 typical where other developers are responsible for
688 various areas of source code.
689 As a developer, you are probably interested in using
690 that source code as part of your development using
691 the Yocto Project.
692 All you need is access to the code, a recipe, and a
693 controlled area in which to do your work.</para>
694
695 <para>Within the diagram, three possible scenarios
696 feed into the <filename>devtool add</filename> workflow:
697 <itemizedlist>
698 <listitem><para><emphasis>Left</emphasis>:
699 The left scenario represents a common situation
700 where the source code does not exist locally
701 and needs to be extracted.
702 In this situation, you just let it get
703 extracted to the default workspace - you do not
704 want it in some specific location outside of the
705 workspace.
706 Thus, everything you need will be located in the
707 workspace:
708 <literallayout class='monospaced'>
709 $ devtool add <replaceable>recipe fetchuri</replaceable>
710 </literallayout>
711 With this command, <filename>devtool</filename>
712 creates a recipe and an append file in the
713 workspace as well as extracts the upstream
714 source files into a local Git repository also
715 within the <filename>sources</filename> folder.
716 </para></listitem>
717 <listitem><para><emphasis>Middle</emphasis>:
718 The middle scenario also represents a situation where
719 the source code does not exist locally.
720 In this case, the code is again upstream
721 and needs to be extracted to some
722 local area - this time outside of the default
723 workspace.
724 As always, if required <filename>devtool</filename> creates
725 a Git repository locally during the extraction.
726 Furthermore, the first positional argument
727 <replaceable>srctree</replaceable> in this case
728 identifies where the
729 <filename>devtool add</filename> command
730 will locate the extracted code outside of the
731 workspace:
732 <literallayout class='monospaced'>
733 $ devtool add <replaceable>recipe srctree fetchuri</replaceable>
734 </literallayout>
735 In summary, the source code is pulled from
736 <replaceable>fetchuri</replaceable> and extracted
737 into the location defined by
738 <replaceable>srctree</replaceable> as a local
739 Git repository.</para>
740
741 <para>Within workspace, <filename>devtool</filename>
742 creates both the recipe and an append file
743 for the recipe.
744 </para></listitem>
745 <listitem><para><emphasis>Right</emphasis>:
746 The right scenario represents a situation
747 where the source tree (srctree) has been
748 previously prepared outside of the
749 <filename>devtool</filename> workspace.
750 </para>
751
752 <para>The following command names the recipe
753 and identifies where the existing source tree
754 is located:
755 <literallayout class='monospaced'>
756 $ devtool add <replaceable>recipe srctree</replaceable>
757 </literallayout>
758 The command examines the source code and creates
759 a recipe for it placing the recipe into the
760 workspace.</para>
761
762 <para>Because the extracted source code already exists,
763 <filename>devtool</filename> does not try to
764 relocate it into the workspace - just the new
765 the recipe is placed in the workspace.</para>
766
767 <para>Aside from a recipe folder, the command
768 also creates an append folder and places an initial
769 <filename>*.bbappend</filename> within.
770 </para></listitem>
771 </itemizedlist>
772 </para></listitem>
773 <listitem><para><emphasis>Edit the Recipe</emphasis>:
774 At this point, you can use <filename>devtool edit-recipe</filename>
775 to open up the editor as defined by the
776 <filename>$EDITOR</filename> environment variable
777 and modify the file:
778 <literallayout class='monospaced'>
779 $ devtool edit-recipe <replaceable>recipe</replaceable>
780 </literallayout>
781 From within the editor, you can make modifications to the
782 recipe that take affect when you build it later.
783 </para></listitem>
784 <listitem><para><emphasis>Build the Recipe or Rebuild the Image</emphasis>:
785 At this point in the flow, the next step you
786 take depends on what you are going to do with
787 the new code.</para>
788 <para>If you need to take the build output and eventually
789 move it to the target hardware, you would use
790 <filename>devtool build</filename>:
791 <note>
792 You could use <filename>bitbake</filename> to build
793 the recipe as well.
794 </note>
795 <literallayout class='monospaced'>
796 $ devtool build <replaceable>recipe</replaceable>
797 </literallayout></para>
798 <para>On the other hand, if you want an image to
799 contain the recipe's packages for immediate deployment
800 onto a device (e.g. for testing purposes), you can use
801 the <filename>devtool build-image</filename> command:
802 <literallayout class='monospaced'>
803 $ devtool build-image <replaceable>image</replaceable>
804 </literallayout>
805 </para></listitem>
806 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
807 When you use the <filename>devtool build</filename>
808 command to build out your recipe, you probably want to
809 see if the resulting build output works as expected on target
810 hardware.
811 <note>
812 This step assumes you have a previously built
813 image that is already either running in QEMU or
814 running on actual hardware.
815 Also, it is assumed that for deployment of the image
816 to the target, SSH is installed in the image and if
817 the image is running on real hardware that you have
818 network access to and from your development machine.
819 </note>
820 You can deploy your build output to that target hardware by
821 using the <filename>devtool deploy-target</filename> command:
822 <literallayout class='monospaced'>
823 $ devtool deploy-target <replaceable>recipe target</replaceable>
824 </literallayout>
825 The <replaceable>target</replaceable> is a live target machine
826 running as an SSH server.</para>
827
828 <para>You can, of course, also deploy the image you build
829 using the <filename>devtool build-image</filename> command
830 to actual hardware.
831 However, <filename>devtool</filename> does not provide a
832 specific command that allows you to do this.
833 </para></listitem>
834 <listitem><para><emphasis>Optionally Update the Recipe With Patch Files</emphasis>:
835 Once you are satisfied with the recipe, if you have made
836 any changes to the source tree that you want to have
837 applied by the recipe, you need to generate patches
838 from those changes.
839 You do this before moving the recipe
840 to its final layer and cleaning up the workspace area
841 <filename>devtool</filename> uses.
842 This optional step is especially relevant if you are
843 using or adding third-party software.</para>
844 <para>To convert commits created using Git to patch files,
845 use the <filename>devtool update-recipe</filename> command.
846 <note>
847 Any changes you want to turn into patches must be
848 committed to the Git repository in the source tree.
849 </note>
850 <literallayout class='monospaced'>
851 $ devtool update-recipe <replaceable>recipe</replaceable>
852 </literallayout>
853 </para></listitem>
854 <listitem><para><emphasis>Move the Recipe to its Permanent Layer</emphasis>:
855 Before cleaning up the workspace, you need to move the
856 final recipe to its permanent layer.
857 You must do this before using the
858 <filename>devtool reset</filename> command if you want to
859 retain the recipe.
860 </para></listitem>
861 <listitem><para><emphasis>Reset the Recipe</emphasis>:
862 As a final step, you can restore the state such that
863 standard layers and the upstream source is used to build
864 the recipe rather than data in the workspace.
865 To reset the recipe, use the <filename>devtool reset</filename>
866 command:
867 <literallayout class='monospaced'>
868 $ devtool reset <replaceable>recipe</replaceable>
869 </literallayout>
870 </para></listitem>
871 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500872 </para>
873 </section>
874
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500875 <section id='devtool-use-devtool-modify-to-enable-work-on-code-associated-with-an-existing-recipe'>
876 <title>Use <filename>devtool modify</filename> to Enable Work on Code Associated with an Existing Recipe</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500877
878 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500879 The <filename>devtool modify</filename> command prepares the
880 way to work on existing code that already has a recipe in
881 place.
882 The command is flexible enough to allow you to extract code,
883 specify the existing recipe, and keep track of and gather any
884 patch files from other developers that are
885 associated with the code.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500886 </para>
887
888 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500889 Depending on your particular scenario, the arguments and options
890 you use with <filename>devtool modify</filename> form different
891 combinations.
892 The following diagram shows common development flows
893 you would use with the <filename>devtool modify</filename>
894 command:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500895 </para>
896
897 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500898 <imagedata fileref="figures/devtool-modify-flow.png" align="center" />
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500899 </para>
900
901 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500902 <orderedlist>
903 <listitem><para><emphasis>Preparing to Modify the Code</emphasis>:
904 The top part of the flow shows three scenarios by which
905 you could use <filename>devtool modify</filename> to
906 prepare to work on source files.
907 Each scenario assumes the following:
908 <itemizedlist>
909 <listitem><para>The recipe exists in some layer external
910 to the <filename>devtool</filename> workspace.
911 </para></listitem>
912 <listitem><para>The source files exist upstream in an
913 un-extracted state or locally in a previously
914 extracted state.
915 </para></listitem>
916 </itemizedlist>
917 The typical situation is where another developer has
918 created some layer for use with the Yocto Project and
919 their recipe already resides in that layer.
920 Furthermore, their source code is readily available
921 either upstream or locally.
922 <itemizedlist>
923 <listitem><para><emphasis>Left</emphasis>:
924 The left scenario represents a common situation
925 where the source code does not exist locally
926 and needs to be extracted.
927 In this situation, the source is extracted
928 into the default workspace location.
929 The recipe, in this scenario, is in its own
930 layer outside the workspace
931 (i.e.
932 <filename>meta-</filename><replaceable>layername</replaceable>).
933 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500934
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500935 <para>The following command identifies the recipe
936 and by default extracts the source files:
937 <literallayout class='monospaced'>
938 $ devtool modify <replaceable>recipe</replaceable>
939 </literallayout>
940 Once <filename>devtool</filename>locates the recipe,
941 it uses the
942 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
943 variable to locate the source code and
944 any local patch files from other developers are
945 located.
946 <note>
947 You cannot provide an URL for
948 <replaceable>srctree</replaceable> when using the
949 <filename>devtool modify</filename> command.
950 </note>
951 With this scenario, however, since no
952 <replaceable>srctree</replaceable> argument exists, the
953 <filename>devtool modify</filename> command by default
954 extracts the source files to a Git structure.
955 Furthermore, the location for the extracted source is the
956 default area within the workspace.
957 The result is that the command sets up both the source
958 code and an append file within the workspace with the
959 recipe remaining in its original location.
960 </para></listitem>
961 <listitem><para><emphasis>Middle</emphasis>:
962 The middle scenario represents a situation where
963 the source code also does not exist locally.
964 In this case, the code is again upstream
965 and needs to be extracted to some
966 local area as a Git repository.
967 The recipe, in this scenario, is again in its own
968 layer outside the workspace.</para>
969
970 <para>The following command tells
971 <filename>devtool</filename> what recipe with
972 which to work and, in this case, identifies a local
973 area for the extracted source files that is outside
974 of the default workspace:
975 <literallayout class='monospaced'>
976 $ devtool modify <replaceable>recipe srctree</replaceable>
977 </literallayout>
978 As with all extractions, the command uses
979 the recipe's <filename>SRC_URI</filename> to locate the
980 source files.
981 Once the files are located, the command by default
982 extracts them.
983 Providing the <replaceable>srctree</replaceable>
984 argument instructs <filename>devtool</filename> where
985 place the extracted source.</para>
986
987 <para>Within workspace, <filename>devtool</filename>
988 creates an append file for the recipe.
989 The recipe remains in its original location but
990 the source files are extracted to the location you
991 provided with <replaceable>srctree</replaceable>.
992 </para></listitem>
993 <listitem><para><emphasis>Right</emphasis>:
994 The right scenario represents a situation
995 where the source tree
996 (<replaceable>srctree</replaceable>) exists as a
997 previously extracted Git structure outside of
998 the <filename>devtool</filename> workspace.
999 In this example, the recipe also exists
1000 elsewhere in its own layer.
1001 </para>
1002
1003 <para>The following command tells
1004 <filename>devtool</filename> the recipe
1005 with which to work, uses the "-n" option to indicate
1006 source does not need to be extracted, and uses
1007 <replaceable>srctree</replaceable> to point to the
1008 previously extracted source files:
1009 <literallayout class='monospaced'>
1010 $ devtool modify -n <replaceable>recipe srctree</replaceable>
1011 </literallayout>
1012 </para>
1013
1014 <para>Once the command finishes, it creates only
1015 an append file for the recipe in the workspace.
1016 The recipe and the source code remain in their
1017 original locations.
1018 </para></listitem>
1019 </itemizedlist>
1020 </para></listitem>
1021 <listitem><para><emphasis>Edit the Source</emphasis>:
1022 Once you have used the <filename>devtool modify</filename>
1023 command, you are free to make changes to the source
1024 files.
1025 You can use any editor you like to make and save
1026 your source code modifications.
1027 </para></listitem>
1028 <listitem><para><emphasis>Build the Recipe</emphasis>:
1029 Once you have updated the source files, you can build
1030 the recipe.
1031 You can either use <filename>devtool build</filename> or
1032 <filename>bitbake</filename>.
1033 Either method produces build output that is stored
1034 in
1035 <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>.
1036 </para></listitem>
1037 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
1038 When you use the <filename>devtool build</filename>
1039 command or <filename>bitbake</filename> to build out your
1040 recipe, you probably want to see if the resulting build
1041 output works as expected on target hardware.
1042 <note>
1043 This step assumes you have a previously built
1044 image that is already either running in QEMU or
1045 running on actual hardware.
1046 Also, it is assumed that for deployment of the image
1047 to the target, SSH is installed in the image and if
1048 the image is running on real hardware that you have
1049 network access to and from your development machine.
1050 </note>
1051 You can deploy your build output to that target hardware by
1052 using the <filename>devtool deploy-target</filename> command:
1053 <literallayout class='monospaced'>
1054 $ devtool deploy-target <replaceable>recipe target</replaceable>
1055 </literallayout>
1056 The <replaceable>target</replaceable> is a live target machine
1057 running as an SSH server.</para>
1058
1059 <para>You can, of course, also deploy the image you build
1060 using the <filename>devtool build-image</filename> command
1061 to actual hardware.
1062 However, <filename>devtool</filename> does not provide a
1063 specific command that allows you to do this.
1064 </para></listitem>
1065 <listitem><para><emphasis>Optionally Create Patch Files for Your Changes</emphasis>:
1066 After you have debugged your changes, you can
1067 use <filename>devtool update-recipe</filename> to
1068 generate patch files for all the commits you have
1069 made.
1070 <note>
1071 Patch files are generated only for changes
1072 you have committed.
1073 </note>
1074 <literallayout class='monospaced'>
1075 $ devtool update-recipe <replaceable>recipe</replaceable>
1076 </literallayout>
1077 By default, the
1078 <filename>devtool update-recipe</filename> command
1079 creates the patch files in a folder named the same
1080 as the recipe beneath the folder in which the recipe
1081 resides, and updates the recipe's
1082 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1083 statement to point to the generated patch files.
1084 <note>
1085 You can use the
1086 "--append <replaceable>LAYERDIR</replaceable>"
1087 option to cause the command to create append files
1088 in a specific layer rather than the default
1089 recipe layer.
1090 </note>
1091 </para></listitem>
1092 <listitem><para><emphasis>Restore the Workspace</emphasis>:
1093 The <filename>devtool reset</filename> restores the
1094 state so that standard layers and upstream sources are
1095 used to build the recipe rather than what is in the
1096 workspace.
1097 <literallayout class='monospaced'>
1098 $ devtool reset <replaceable>recipe</replaceable>
1099 </literallayout>
1100 </para></listitem>
1101 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001102 </para>
1103 </section>
1104
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001105 <section id='devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'>
1106 <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 -05001107
1108 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001109 The <filename>devtool upgrade</filename> command updates
1110 an existing recipe so that you can build it for an updated
1111 set of source files.
1112 The command is flexible enough to allow you to specify
1113 source code revision and versioning schemes, extract code into
1114 or out of the <filename>devtool</filename> workspace, and
1115 work with any source file forms that the fetchers support.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001116 </para>
1117
1118 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001119 Depending on your particular scenario, the arguments and options
1120 you use with <filename>devtool upgrade</filename> form different
1121 combinations.
1122 The following diagram shows a common development flow
1123 you would use with the <filename>devtool modify</filename>
1124 command:
1125 </para>
1126
1127 <para>
1128 <imagedata fileref="figures/devtool-upgrade-flow.png" align="center" />
1129 </para>
1130
1131 <para>
1132 <orderedlist>
1133 <listitem><para><emphasis>Initiate the Upgrade</emphasis>:
1134 The top part of the flow shows a typical scenario by which
1135 you could use <filename>devtool upgrade</filename>.
1136 The following conditions exist:
1137 <itemizedlist>
1138 <listitem><para>The recipe exists in some layer external
1139 to the <filename>devtool</filename> workspace.
1140 </para></listitem>
1141 <listitem><para>The source files for the new release
1142 exist adjacent to the same location pointed to by
1143 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1144 in the recipe (e.g. a tarball with the new version
1145 number in the name, or as a different revision in
1146 the upstream Git repository).
1147 </para></listitem>
1148 </itemizedlist>
1149 A common situation is where third-party software has
1150 undergone a revision so that it has been upgraded.
1151 The recipe you have access to is likely in your own layer.
1152 Thus, you need to upgrade the recipe to use the
1153 newer version of the software:
1154 <literallayout class='monospaced'>
1155 $ devtool upgrade -V <replaceable>version recipe</replaceable>
1156 </literallayout>
1157 By default, the <filename>devtool upgrade</filename> command
1158 extracts source code into the <filename>sources</filename>
1159 directory in the workspace.
1160 If you want the code extracted to any other location, you
1161 need to provide the <replaceable>srctree</replaceable>
1162 positional argument with the command as follows:
1163 <literallayout class='monospaced'>
1164 $ devtool upgrade -V <replaceable>version recipe srctree</replaceable>
1165 </literallayout>
1166 Also, in this example, the "-V" option is used to specify
1167 the new version.
1168 If the source files pointed to by the
1169 <filename>SRC_URI</filename> statement in the recipe are
1170 in a Git repository, you must provide the "-S" option and
1171 specify a revision for the software.</para>
1172
1173 <para>Once <filename>devtool</filename> locates the recipe,
1174 it uses the <filename>SRC_URI</filename> variable to locate
1175 the source code and any local patch files from other
1176 developers are located.
1177 The result is that the command sets up the source
1178 code, the new version of the recipe, and an append file
1179 all within the workspace.
1180 </para></listitem>
1181 <listitem><para><emphasis>Resolve any Conflicts created by the Upgrade</emphasis>:
1182 At this point, there could be some conflicts due to the
1183 software being upgraded to a new version.
1184 This would occur if your recipe specifies some patch files in
1185 <filename>SRC_URI</filename> that conflict with changes
1186 made in the new version of the software.
1187 If this is the case, you need to resolve the conflicts
1188 by editing the source and following the normal
1189 <filename>git rebase</filename> conflict resolution
1190 process.</para>
1191
1192 <para>Before moving onto the next step, be sure to resolve any
1193 such conflicts created through use of a newer or different
1194 version of the software.
1195 </para></listitem>
1196 <listitem><para><emphasis>Build the Recipe</emphasis>:
1197 Once you have your recipe in order, you can build it.
1198 You can either use <filename>devtool build</filename> or
1199 <filename>bitbake</filename>.
1200 Either method produces build output that is stored
1201 in
1202 <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>.
1203 </para></listitem>
1204 <listitem><para><emphasis>Deploy the Build Output</emphasis>:
1205 When you use the <filename>devtool build</filename>
1206 command or <filename>bitbake</filename> to build out your
1207 recipe, you probably want to see if the resulting build
1208 output works as expected on target hardware.
1209 <note>
1210 This step assumes you have a previously built
1211 image that is already either running in QEMU or
1212 running on actual hardware.
1213 Also, it is assumed that for deployment of the image
1214 to the target, SSH is installed in the image and if
1215 the image is running on real hardware that you have
1216 network access to and from your development machine.
1217 </note>
1218 You can deploy your build output to that target hardware by
1219 using the <filename>devtool deploy-target</filename> command:
1220 <literallayout class='monospaced'>
1221 $ devtool deploy-target <replaceable>recipe target</replaceable>
1222 </literallayout>
1223 The <replaceable>target</replaceable> is a live target machine
1224 running as an SSH server.</para>
1225
1226 <para>You can, of course, also deploy the image you build
1227 using the <filename>devtool build-image</filename> command
1228 to actual hardware.
1229 However, <filename>devtool</filename> does not provide a
1230 specific command that allows you to do this.
1231 </para></listitem>
1232 <listitem><para><emphasis>Optionally Create Patch Files for Your Changes</emphasis>:
1233 After you have debugged your changes, you can
1234 use <filename>devtool update-recipe</filename> to
1235 generate patch files for all the commits you have
1236 made.
1237 <note>
1238 Patch files are generated only for changes
1239 you have committed.
1240 </note>
1241 <literallayout class='monospaced'>
1242 $ devtool update-recipe <replaceable>recipe</replaceable>
1243 </literallayout>
1244 By default, the
1245 <filename>devtool update-recipe</filename> command
1246 creates the patch files in a folder named the same
1247 as the recipe beneath the folder in which the recipe
1248 resides, and updates the recipe's
1249 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1250 statement to point to the generated patch files.
1251 </para></listitem>
1252 <listitem><para><emphasis>Move the Recipe to its Permanent Layer</emphasis>:
1253 Before cleaning up the workspace, you need to move the
1254 final recipe to its permanent layer.
1255 You can either overwrite the original recipe or you can
1256 overlay the upgraded recipe into a separate layer.
1257 You must do this before using the
1258 <filename>devtool reset</filename> command if you want to
1259 retain the upgraded recipe.
1260 </para></listitem>
1261 <listitem><para><emphasis>Restore the Workspace</emphasis>:
1262 The <filename>devtool reset</filename> restores the
1263 state so that standard layers and upstream sources are
1264 used to build the recipe rather than what is in the
1265 workspace.
1266 <literallayout class='monospaced'>
1267 $ devtool reset <replaceable>recipe</replaceable>
1268 </literallayout>
1269 </para></listitem>
1270 </orderedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001271 </para>
1272 </section>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001273 </section>
1274
1275 <section id='devtool-quick-reference'>
1276 <title><filename>devtool</filename> Quick Reference</title>
1277
1278 <para>
1279 <filename>devtool</filename> has more functionality than simply
1280 adding a new recipe and the supporting Metadata to a temporary
1281 workspace layer.
1282 This section provides a short reference on
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001283 <filename>devtool</filename> and its commands.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001284 </para>
1285
1286 <section id='devtool-getting-help'>
1287 <title>Getting Help</title>
1288
1289 <para>
1290 The easiest way to get help with the
1291 <filename>devtool</filename> command is using the
1292 <filename>--help</filename> option:
1293 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001294 usage: devtool [--basepath BASEPATH] [--bbpath BBPATH] [-d] [-q]
1295 [--color COLOR] [-h]
1296 &lt;subcommand&gt; ...
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001297
1298 OpenEmbedded development tool
1299
1300 optional arguments:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001301 --basepath BASEPATH Base directory of SDK / build directory
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001302 --bbpath BBPATH Explicitly specify the BBPATH, rather than getting it
1303 from the metadata
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001304 -d, --debug Enable debug output
1305 -q, --quiet Print only errors
1306 --color COLOR Colorize output (where COLOR is auto, always, never)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001307 -h, --help show this help message and exit
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001308
1309 subcommands:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001310 Beginning work on a recipe:
1311 add Add a new recipe
1312 modify Modify the source for an existing recipe
1313 upgrade Upgrade an existing recipe
1314 Getting information:
1315 status Show workspace status
1316 search Search available recipes
1317 Working on a recipe in the workspace:
1318 build Build a recipe
1319 edit-recipe Edit a recipe file in your workspace
1320 configure-help Get help on configure script options
1321 update-recipe Apply changes from external source tree to recipe
1322 reset Remove a recipe from your workspace
1323 Testing changes on target:
1324 deploy-target Deploy recipe output files to live target machine
1325 undeploy-target Undeploy recipe output files in live target machine
1326 build-image Build image including workspace recipe packages
1327 Advanced:
1328 create-workspace Set up workspace in an alternative location
1329 extract Extract the source for an existing recipe
1330 sync Synchronize the source tree for an existing recipe
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001331 Use devtool &lt;subcommand&gt; --help to get help on a specific command
1332 </literallayout>
1333 </para>
1334
1335 <para>
1336 As directed in the general help output, you can get more
1337 syntax on a specific command by providing the command
1338 name and using <filename>--help</filename>:
1339 <literallayout class='monospaced'>
1340 $ devtool add --help
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001341 usage: devtool add [-h] [--same-dir | --no-same-dir] [--fetch URI]
1342 [--version VERSION] [--no-git] [--binary] [--also-native]
1343 [--src-subdir SUBDIR]
1344 [recipename] [srctree] [fetchuri]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001345
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001346 Adds a new recipe to the workspace to build a specified source tree. Can
1347 optionally fetch a remote URI and unpack it to create the source tree.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001348
1349 positional arguments:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001350 recipename Name for new recipe to add (just name - no version,
1351 path or extension). If not specified, will attempt to
1352 auto-detect it.
1353 srctree Path to external source tree. If not specified, a
1354 subdirectory of
1355 /home/scottrif/poky/build/workspace/sources will be
1356 used.
1357 fetchuri Fetch the specified URI and extract it to create the
1358 source tree
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001359
1360 optional arguments:
1361 -h, --help show this help message and exit
1362 --same-dir, -s Build in same directory as source
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001363 --no-same-dir Force build in a separate build directory
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001364 --fetch URI, -f URI Fetch the specified URI and extract it to create the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001365 source tree (deprecated - pass as positional argument
1366 instead)
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001367 --version VERSION, -V VERSION
1368 Version to use within recipe (PV)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001369 --no-git, -g If fetching source, do not set up source tree as a git
1370 repository
1371 --binary, -b Treat the source tree as something that should be
1372 installed verbatim (no compilation, same directory
1373 structure). Useful with binary packages e.g. RPMs.
1374 --also-native Also add native variant (i.e. support building recipe
1375 for the build host as well as the target machine)
1376 --src-subdir SUBDIR Specify subdirectory within source tree to use
1377 </literallayout>
1378 </para>
1379 </section>
1380
1381 <section id='devtool-the-workspace-layer-structure'>
1382 <title>The Workspace Layer Structure</title>
1383
1384 <para>
1385 <filename>devtool</filename> uses a "Workspace" layer
1386 in which to accomplish builds.
1387 This layer is not specific to any single
1388 <filename>devtool</filename> command but is rather a common
1389 working area used across the tool.
1390 </para>
1391
1392 <para>
1393 The following figure shows the workspace structure:
1394 </para>
1395
1396 <para>
1397 <imagedata fileref="figures/build-workspace-directory.png"
1398 width="6in" depth="5in" align="left" scale="70" />
1399 </para>
1400
1401 <para>
1402 <literallayout class='monospaced'>
1403 attic - A directory created if devtool believes it preserve
1404 anything when you run "devtool reset". For example, if you
1405 run "devtool add", make changes to the recipe, and then
1406 run "devtool reset", devtool takes notice that the file has
1407 been changed and moves it into the attic should you still
1408 want the recipe.
1409
1410 README - Provides information on what is in workspace layer and how to
1411 manage it.
1412
1413 .devtool_md5 - A checksum file used by devtool.
1414
1415 appends - A directory that contains *.bbappend files, which point to
1416 external source.
1417
1418 conf - A configuration directory that contains the layer.conf file.
1419
1420 recipes - A directory containing recipes. This directory contains a
1421 folder for each directory added whose name matches that of the
1422 added recipe. devtool places the <replaceable>recipe</replaceable>.bb file
1423 within that sub-directory.
1424
1425 sources - A directory containing a working copy of the source files used
1426 when building the recipe. This is the default directory used
1427 as the location of the source tree when you do not provide a
1428 source tree path. This directory contains a folder for each
1429 set of source files matched to a corresponding recipe.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001430 </literallayout>
1431 </para>
1432 </section>
1433
1434 <section id='devtool-adding-a-new-recipe-to-the-workspace'>
1435 <title>Adding a New Recipe to the Workspace Layer</title>
1436
1437 <para>
1438 Use the <filename>devtool add</filename> command to add a new recipe
1439 to the workspace layer.
1440 The recipe you add should not exist -
1441 <filename>devtool</filename> creates it for you.
1442 The source files the recipe uses should exist in an external
1443 area.
1444 </para>
1445
1446 <para>
1447 The following example creates and adds a new recipe named
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001448 <filename>jackson</filename> to a workspace layer the tool creates.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001449 The source code built by the recipes resides in
1450 <filename>/home/scottrif/sources/jackson</filename>:
1451 <literallayout class='monospaced'>
1452 $ devtool add jackson /home/scottrif/sources/jackson
1453 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001454 </para>
1455
1456 <para>
1457 If you add a recipe and the workspace layer does not exist,
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001458 the command creates the layer and populates it as
1459 described in
1460 "<link linkend='devtool-the-workspace-layer-structure'>The Workspace Layer Structure</link>"
1461 section.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001462 </para>
1463
1464 <para>
1465 Running <filename>devtool add</filename> when the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001466 workspace layer exists causes the tool to add the recipe,
1467 append files, and source files into the existing workspace layer.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001468 The <filename>.bbappend</filename> file is created to point
1469 to the external source tree.
1470 </para>
1471 </section>
1472
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001473 <section id='devtool-extracting-the-source-for-an-existing-recipe'>
1474 <title>Extracting the Source for an Existing Recipe</title>
1475
1476 <para>
1477 Use the <filename>devtool extract</filename> command to
1478 extract the source for an existing recipe.
1479 When you use this command, you must supply the root name
1480 of the recipe (i.e. no version, paths, or extensions), and
1481 you must supply the directory to which you want the source
1482 extracted.
1483 </para>
1484
1485 <para>
1486 Additional command options let you control the name of a
1487 development branch into which you can checkout the source
1488 and whether or not to keep a temporary directory, which is
1489 useful for debugging.
1490 </para>
1491 </section>
1492
1493 <section id='devtool-synchronizing-a-recipes-extracted-source-tree'>
1494 <title>Synchronizing a Recipe's Extracted Source Tree</title>
1495
1496 <para>
1497 Use the <filename>devtool sync</filename> command to
1498 synchronize a previously extracted source tree for an
1499 existing recipe.
1500 When you use this command, you must supply the root name
1501 of the recipe (i.e. no version, paths, or extensions), and
1502 you must supply the directory to which you want the source
1503 extracted.
1504 </para>
1505
1506 <para>
1507 Additional command options let you control the name of a
1508 development branch into which you can checkout the source
1509 and whether or not to keep a temporary directory, which is
1510 useful for debugging.
1511 </para>
1512 </section>
1513
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001514 <section id='devtool-modifying-a-recipe'>
1515 <title>Modifying an Existing Recipe</title>
1516
1517 <para>
1518 Use the <filename>devtool modify</filename> command to begin
1519 modifying the source of an existing recipe.
1520 This command is very similar to the
1521 <link linkend='devtool-adding-a-new-recipe-to-the-workspace'><filename>add</filename></link>
1522 command except that it does not physically create the
1523 recipe in the workspace layer because the recipe already
1524 exists in an another layer.
1525 </para>
1526
1527 <para>
1528 The <filename>devtool modify</filename> command extracts the
1529 source for a recipe, sets it up as a Git repository if the
1530 source had not already been fetched from Git, checks out a
1531 branch for development, and applies any patches from the recipe
1532 as commits on top.
1533 You can use the following command to checkout the source
1534 files:
1535 <literallayout class='monospaced'>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001536 $ devtool modify <replaceable>recipe</replaceable>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001537 </literallayout>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001538 Using the above command form, <filename>devtool</filename> uses
1539 the existing recipe's
1540 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
1541 statement to locate the upstream source, extracts the source
1542 into the default sources location in the workspace.
1543 The default development branch used is "devtool".
1544 </para>
1545 </section>
1546
1547 <section id='devtool-edit-an-existing-recipe'>
1548 <title>Edit an Existing Recipe</title>
1549
1550 <para>
1551 Use the <filename>devtool edit-recipe</filename> command
1552 to run the default editor, which is identified using the
1553 <filename>EDITOR</filename> variable, on the specified recipe.
1554 </para>
1555
1556 <para>
1557 When you use the <filename>devtool edit-recipe</filename>
1558 command, you must supply the root name of the recipe
1559 (i.e. no version, paths, or extensions).
1560 Also, the recipe file itself must reside in the workspace
1561 as a result of the <filename>devtool add</filename> or
1562 <filename>devtool upgrade</filename> commands.
1563 However, you can override that requirement by using the
1564 "-a" or "--any-recipe" option.
1565 Using either of these options allows you to edit any recipe
1566 regardless of its location.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001567 </para>
1568 </section>
1569
1570 <section id='devtool-updating-a-recipe'>
1571 <title>Updating a Recipe</title>
1572
1573 <para>
1574 Use the <filename>devtool update-recipe</filename> command to
1575 update your recipe with patches that reflect changes you make
1576 to the source files.
1577 For example, if you know you are going to work on some
1578 code, you could first use the
1579 <link linkend='devtool-modifying-a-recipe'><filename>devtool modify</filename></link>
1580 command to extract the code and set up the workspace.
1581 After which, you could modify, compile, and test the code.
1582 </para>
1583
1584 <para>
1585 When you are satisfied with the results and you have committed
1586 your changes to the Git repository, you can then
1587 run the <filename>devtool update-recipe</filename> to create the
1588 patches and update the recipe:
1589 <literallayout class='monospaced'>
1590 $ devtool update-recipe <replaceable>recipe</replaceable>
1591 </literallayout>
1592 If you run the <filename>devtool update-recipe</filename>
1593 without committing your changes, the command ignores the
1594 changes.
1595 </para>
1596
1597 <para>
1598 Often, you might want to apply customizations made to your
1599 software in your own layer rather than apply them to the
1600 original recipe.
1601 If so, you can use the
1602 <filename>-a</filename> or <filename>--append</filename>
1603 option with the <filename>devtool update-recipe</filename>
1604 command.
1605 These options allow you to specify the layer into which to
1606 write an append file:
1607 <literallayout class='monospaced'>
1608 $ devtool update-recipe <replaceable>recipe</replaceable> -a <replaceable>base-layer-directory</replaceable>
1609 </literallayout>
1610 The <filename>*.bbappend</filename> file is created at the
1611 appropriate path within the specified layer directory, which
1612 may or may not be in your <filename>bblayers.conf</filename>
1613 file.
1614 If an append file already exists, the command updates it
1615 appropriately.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001616 </para>
1617 </section>
1618
1619 <section id='devtool-upgrading-a-recipe'>
1620 <title>Upgrading a Recipe</title>
1621
1622 <para>
1623 Use the <filename>devtool upgrade</filename> command
1624 to upgrade an existing recipe to a new upstream version.
1625 The command puts the upgraded recipe file into the
1626 workspace along with any associated files, and extracts
1627 the source tree to a specified location should patches
1628 need rebased or added to as a result of the upgrade.
1629 </para>
1630
1631 <para>
1632 When you use the <filename>devtool upgrade</filename> command,
1633 you must supply the root name of the recipe (i.e. no version,
1634 paths, or extensions), and you must supply the directory
1635 to which you want the source extracted.
1636 Additional command options let you control things such as
1637 the version number to which you want to upgrade (i.e. the
1638 <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>),
1639 the source revision to which you want to upgrade (i.e. the
1640 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>,
1641 whether or not to apply patches, and so forth.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001642 </para>
1643 </section>
1644
1645 <section id='devtool-resetting-a-recipe'>
1646 <title>Resetting a Recipe</title>
1647
1648 <para>
1649 Use the <filename>devtool reset</filename> command to remove a
1650 recipe and its configuration (e.g. the corresponding
1651 <filename>.bbappend</filename> file) from the workspace layer.
1652 Realize that this command deletes the recipe and the
1653 append file.
1654 The command does not physically move them for you.
1655 Consequently, you must be sure to physically relocate your
1656 updated recipe and the append file outside of the workspace
1657 layer before running the <filename>devtool reset</filename>
1658 command.
1659 </para>
1660
1661 <para>
1662 If the <filename>devtool reset</filename> command detects that
1663 the recipe or the append files have been modified, the
1664 command preserves the modified files in a separate "attic"
1665 subdirectory under the workspace layer.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001666 </para>
1667
1668 <para>
1669 Here is an example that resets the workspace directory that
1670 contains the <filename>mtr</filename> recipe:
1671 <literallayout class='monospaced'>
1672 $ devtool reset mtr
1673 NOTE: Cleaning sysroot for recipe mtr...
1674 NOTE: Leaving source tree /home/scottrif/poky/build/workspace/sources/mtr as-is; if you no
1675 longer need it then please delete it manually
1676 $
1677 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001678 </para>
1679 </section>
1680
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001681 <section id='devtool-building-your-recipe'>
1682 <title>Building Your Recipe</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001683
1684 <para>
1685 Use the <filename>devtool build</filename> command to cause the
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001686 OpenEmbedded build system to build your recipe.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001687 The <filename>devtool build</filename> command is equivalent to
1688 <filename>bitbake -c populate_sysroot</filename>.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001689 </para>
1690
1691 <para>
1692 When you use the <filename>devtool build</filename> command,
1693 you must supply the root name of the recipe (i.e. no version,
1694 paths, or extensions).
1695 You can use either the "-s" or the "--disable-parallel-make"
1696 option to disable parallel makes during the build.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001697 Here is an example:
1698 <literallayout class='monospaced'>
1699 $ devtool build <replaceable>recipe</replaceable>
1700 </literallayout>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001701 </para>
1702 </section>
1703
1704 <section id='devtool-building-your-image'>
1705 <title>Building Your Image</title>
1706
1707 <para>
1708 Use the <filename>devtool build-image</filename> command
1709 to build an image, extending it to include packages from
1710 recipes in the workspace.
1711 Using this command is useful when you want an image that
1712 ready for immediate deployment onto a device for testing.
1713 For proper integration into a final image, you need to
1714 edit your custom image recipe appropriately.
1715 </para>
1716
1717 <para>
1718 When you use the <filename>devtool build-image</filename>
1719 command, you must supply the name of the image.
1720 This command has no command line options:
1721 <literallayout class='monospaced'>
1722 $ devtool build-image <replaceable>image</replaceable>
1723 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001724 </para>
1725 </section>
1726
1727 <section id='devtool-deploying-your-software-on-the-target-machine'>
1728 <title>Deploying Your Software on the Target Machine</title>
1729
1730 <para>
1731 Use the <filename>devtool deploy-target</filename> command to
1732 deploy the recipe's build output to the live target machine:
1733 <literallayout class='monospaced'>
1734 $ devtool deploy-target <replaceable>recipe</replaceable>&nbsp;<replaceable>target</replaceable>
1735 </literallayout>
1736 The <replaceable>target</replaceable> is the address of the
1737 target machine, which must be running an SSH server (i.e.
1738 <filename>user@hostname[:destdir]</filename>).
1739 </para>
1740
1741 <para>
1742 This command deploys all files installed during the
1743 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink>
1744 task.
1745 Furthermore, you do not need to have package management enabled
1746 within the target machine.
1747 If you do, the package manager is bypassed.
1748 <note><title>Notes</title>
1749 <para>
1750 The <filename>deploy-target</filename>
1751 functionality is for development only.
1752 You should never use it to update an image that will be
1753 used in production.
1754 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001755 </note>
1756 </para>
1757 </section>
1758
1759 <section id='devtool-removing-your-software-from-the-target-machine'>
1760 <title>Removing Your Software from the Target Machine</title>
1761
1762 <para>
1763 Use the <filename>devtool undeploy-target</filename> command to
1764 remove deployed build output from the target machine.
1765 For the <filename>devtool undeploy-target</filename> command to
1766 work, you must have previously used the
1767 <link linkend='devtool-deploying-your-software-on-the-target-machine'><filename>devtool deploy-target</filename></link>
1768 command.
1769 <literallayout class='monospaced'>
1770 $ devtool undeploy-target <replaceable>recipe</replaceable>&nbsp;<replaceable>target</replaceable>
1771 </literallayout>
1772 The <replaceable>target</replaceable> is the address of the
1773 target machine, which must be running an SSH server (i.e.
1774 <filename>user@hostname</filename>).
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001775 </para>
1776 </section>
1777
1778 <section id='devtool-creating-the-workspace'>
1779 <title>Creating the Workspace Layer in an Alternative Location</title>
1780
1781 <para>
1782 Use the <filename>devtool create-workspace</filename> command to
1783 create a new workspace layer in your
1784 <link linkend='build-directory'>Build Directory</link>.
1785 When you create a new workspace layer, it is populated with the
1786 <filename>README</filename> file and the
1787 <filename>conf</filename> directory only.
1788 </para>
1789
1790 <para>
1791 The following example creates a new workspace layer in your
1792 current working and by default names the workspace layer
1793 "workspace":
1794 <literallayout class='monospaced'>
1795 $ devtool create-workspace
1796 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001797 </para>
1798
1799 <para>
1800 You can create a workspace layer anywhere by supplying
1801 a pathname with the command.
1802 The following command creates a new workspace layer named
1803 "new-workspace":
1804 <literallayout class='monospaced'>
1805 $ devtool create-workspace /home/scottrif/new-workspace
1806 </literallayout>
1807 </para>
1808 </section>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001809
1810 <section id='devtool-get-the-status-of-the-recipes-in-your-workspace'>
1811 <title>Get the Status of the Recipes in Your Workspace</title>
1812
1813 <para>
1814 Use the <filename>devtool status</filename> command to
1815 list the recipes currently in your workspace.
1816 Information includes the paths to their respective
1817 external source trees.
1818 </para>
1819
1820 <para>
1821 The <filename>devtool status</filename> command has no
1822 command-line options:
1823 <literallayout class='monospaced'>
1824 devtool status
1825 </literallayout>
1826 Following is sample output after using
1827 <link linkend='devtool-adding-a-new-recipe-to-the-workspace'><filename>devtool add</filename></link>
1828 to create and add the <filename>mtr_0.86.bb</filename> recipe
1829 to the <filename>workspace</filename> directory:
1830 <literallayout class='monospaced'>
1831 $ devtool status
1832 mtr: /home/scottrif/poky/build/workspace/sources/mtr (/home/scottrif/poky/build/workspace/recipes/mtr/mtr_0.86.bb)
1833 $
1834 </literallayout>
1835 </para>
1836 </section>
1837
1838 <section id='devtool-search-for-available-target-recipes'>
1839 <title>Search for Available Target Recipes</title>
1840
1841 <para>
1842 Use the <filename>devtool search</filename> command to
1843 search for available target recipes.
1844 The command matches the recipe name, package name,
1845 description, and installed files.
1846 The command displays the recipe name as a result of a
1847 match.
1848 </para>
1849
1850 <para>
1851 When you use the <filename>devtool search</filename> command,
1852 you must supply a <replaceable>keyword</replaceable>.
1853 The command uses the <replaceable>keyword</replaceable> when
1854 searching for a match.
1855 </para>
1856 </section>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001857 </section>
1858
1859 <section id="using-a-quilt-workflow">
1860 <title>Using Quilt in Your Workflow</title>
1861
1862 <para>
1863 <ulink url='http://savannah.nongnu.org/projects/quilt'>Quilt</ulink>
1864 is a powerful tool that allows you to capture source code changes
1865 without having a clean source tree.
1866 This section outlines the typical workflow you can use to modify
1867 source code, test changes, and then preserve the changes in the
1868 form of a patch all using Quilt.
1869 <note><title>Tip</title>
1870 With regard to preserving changes to source files if you
1871 clean a recipe or have <filename>rm_work</filename> enabled,
1872 the workflow described in the
1873 "<link linkend='using-devtool-in-your-workflow'>Using <filename>devtool</filename> in Your Workflow</link>"
1874 section is a safer development flow than than the flow that
1875 uses Quilt.
1876 </note>
1877 </para>
1878
1879 <para>
1880 Follow these general steps:
1881 <orderedlist>
1882 <listitem><para><emphasis>Find the Source Code:</emphasis>
1883 Temporary source code used by the OpenEmbedded build system
1884 is kept in the
1885 <link linkend='build-directory'>Build Directory</link>.
1886 See the
1887 "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>"
1888 section to learn how to locate the directory that has the
1889 temporary source code for a particular package.
1890 </para></listitem>
1891 <listitem><para><emphasis>Change Your Working Directory:</emphasis>
1892 You need to be in the directory that has the temporary source code.
1893 That directory is defined by the
1894 <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>
1895 variable.</para></listitem>
1896 <listitem><para><emphasis>Create a New Patch:</emphasis>
1897 Before modifying source code, you need to create a new patch.
1898 To create a new patch file, use <filename>quilt new</filename> as below:
1899 <literallayout class='monospaced'>
1900 $ quilt new my_changes.patch
1901 </literallayout></para></listitem>
1902 <listitem><para><emphasis>Notify Quilt and Add Files:</emphasis>
1903 After creating the patch, you need to notify Quilt about the files
1904 you plan to edit.
1905 You notify Quilt by adding the files to the patch you just created:
1906 <literallayout class='monospaced'>
1907 $ quilt add file1.c file2.c file3.c
1908 </literallayout>
1909 </para></listitem>
1910 <listitem><para><emphasis>Edit the Files:</emphasis>
1911 Make your changes in the source code to the files you added
1912 to the patch.
1913 </para></listitem>
1914 <listitem><para><emphasis>Test Your Changes:</emphasis>
1915 Once you have modified the source code, the easiest way to
1916 your changes is by calling the
1917 <filename>do_compile</filename> task as shown in the
1918 following example:
1919 <literallayout class='monospaced'>
1920 $ bitbake -c compile -f <replaceable>package</replaceable>
1921 </literallayout>
1922 The <filename>-f</filename> or <filename>--force</filename>
1923 option forces the specified task to execute.
1924 If you find problems with your code, you can just keep editing and
1925 re-testing iteratively until things work as expected.
1926 <note>All the modifications you make to the temporary source code
1927 disappear once you run the
1928 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>
1929 or
1930 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>
1931 tasks using BitBake (i.e.
1932 <filename>bitbake -c clean <replaceable>package</replaceable></filename>
1933 and
1934 <filename>bitbake -c cleanall <replaceable>package</replaceable></filename>).
1935 Modifications will also disappear if you use the <filename>rm_work</filename>
1936 feature as described in the
1937 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
1938 section of the Yocto Project Quick Start.
1939 </note></para></listitem>
1940 <listitem><para><emphasis>Generate the Patch:</emphasis>
1941 Once your changes work as expected, you need to use Quilt to generate the final patch that
1942 contains all your modifications.
1943 <literallayout class='monospaced'>
1944 $ quilt refresh
1945 </literallayout>
1946 At this point, the <filename>my_changes.patch</filename> file has all your edits made
1947 to the <filename>file1.c</filename>, <filename>file2.c</filename>, and
1948 <filename>file3.c</filename> files.</para>
1949 <para>You can find the resulting patch file in the <filename>patches/</filename>
1950 subdirectory of the source (<filename>S</filename>) directory.</para></listitem>
1951 <listitem><para><emphasis>Copy the Patch File:</emphasis>
1952 For simplicity, copy the patch file into a directory named <filename>files</filename>,
1953 which you can create in the same directory that holds the recipe
1954 (<filename>.bb</filename>) file or the
1955 append (<filename>.bbappend</filename>) file.
1956 Placing the patch here guarantees that the OpenEmbedded build system will find
1957 the patch.
1958 Next, add the patch into the
1959 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>
1960 of the recipe.
1961 Here is an example:
1962 <literallayout class='monospaced'>
1963 SRC_URI += "file://my_changes.patch"
1964 </literallayout></para></listitem>
1965 </orderedlist>
1966 </para>
1967 </section>
1968
1969 <section id='finding-the-temporary-source-code'>
1970 <title>Finding Temporary Source Code</title>
1971
1972 <para>
1973 You might find it helpful during development to modify the
1974 temporary source code used by recipes to build packages.
1975 For example, suppose you are developing a patch and you need to
1976 experiment a bit to figure out your solution.
1977 After you have initially built the package, you can iteratively
1978 tweak the source code, which is located in the
1979 <link linkend='build-directory'>Build Directory</link>, and then
1980 you can force a re-compile and quickly test your altered code.
1981 Once you settle on a solution, you can then preserve your changes
1982 in the form of patches.
1983 If you are using Quilt for development, see the
1984 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
1985 section for more information.
1986 </para>
1987
1988 <para>
1989 During a build, the unpacked temporary source code used by recipes
1990 to build packages is available in the Build Directory as
1991 defined by the
1992 <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> variable.
1993 Below is the default value for the <filename>S</filename> variable as defined in the
1994 <filename>meta/conf/bitbake.conf</filename> configuration file in the
1995 <link linkend='source-directory'>Source Directory</link>:
1996 <literallayout class='monospaced'>
1997 S = "${WORKDIR}/${BP}"
1998 </literallayout>
1999 You should be aware that many recipes override the <filename>S</filename> variable.
2000 For example, recipes that fetch their source from Git usually set
2001 <filename>S</filename> to <filename>${WORKDIR}/git</filename>.
2002 <note>
2003 The
2004 <ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink>
2005 represents the base recipe name, which consists of the name and version:
2006 <literallayout class='monospaced'>
2007 BP = "${BPN}-${PV}"
2008 </literallayout>
2009 </note>
2010 </para>
2011
2012 <para>
2013 The path to the work directory for the recipe
2014 (<ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>)
2015 is defined as follows:
2016 <literallayout class='monospaced'>
2017 ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}
2018 </literallayout>
2019 The actual directory depends on several things:
2020 <itemizedlist>
2021 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>:
2022 The top-level build output directory</listitem>
2023 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-MULTIMACH_TARGET_SYS'><filename>MULTIMACH_TARGET_SYS</filename></ulink>:
2024 The target system identifier</listitem>
2025 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>:
2026 The recipe name</listitem>
2027 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-EXTENDPE'><filename>EXTENDPE</filename></ulink>:
2028 The epoch - (if
2029 <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>
2030 is not specified, which is usually the case for most
2031 recipes, then <filename>EXTENDPE</filename> is blank)</listitem>
2032 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
2033 The recipe version</listitem>
2034 <listitem><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
2035 The recipe revision</listitem>
2036 </itemizedlist>
2037 </para>
2038
2039 <para>
2040 As an example, assume a Source Directory top-level folder
2041 named <filename>poky</filename>, a default Build Directory at
2042 <filename>poky/build</filename>, and a
2043 <filename>qemux86-poky-linux</filename> machine target
2044 system.
2045 Furthermore, suppose your recipe is named
2046 <filename>foo_1.3.0.bb</filename>.
2047 In this case, the work directory the build system uses to
2048 build the package would be as follows:
2049 <literallayout class='monospaced'>
2050 poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0
2051 </literallayout>
2052 </para>
2053
2054 <para>
2055 Now that you know where to locate the directory that has the
2056 temporary source code, you can use a Quilt as described in section
2057 "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>"
2058 to make your edits, test the changes, and preserve the changes in
2059 the form of patches.
2060 </para>
2061 </section>
2062</section>
2063
2064<section id='image-development-using-toaster'>
2065 <title>Image Development Using Toaster</title>
2066
2067 <para>
2068 Toaster is a web interface to the Yocto Project's OpenEmbedded build
2069 system.
2070 You can initiate builds using Toaster as well as examine the results
2071 and statistics of builds.
2072 See the
2073 <ulink url='&YOCTO_DOCS_TOAST_URL;#toaster-manual-intro'>Toaster User Manual</ulink>
2074 for information on how to set up and use Toaster to build images.
2075 </para>
2076</section>
2077
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002078<section id="platdev-appdev-devshell">
2079 <title>Using a Development Shell</title>
2080
2081 <para>
2082 When debugging certain commands or even when just editing packages,
2083 <filename>devshell</filename> can be a useful tool.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002084 When you invoke <filename>devshell</filename>, all tasks up to and
2085 including
2086 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink>
2087 are run for the specified target.
2088 Then, a new terminal is opened and you are placed in
2089 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>,
2090 the source directory.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002091 In the new terminal, all the OpenEmbedded build-related environment variables are
2092 still defined so you can use commands such as <filename>configure</filename> and
2093 <filename>make</filename>.
2094 The commands execute just as if the OpenEmbedded build system were executing them.
2095 Consequently, working this way can be helpful when debugging a build or preparing
2096 software to be used with the OpenEmbedded build system.
2097 </para>
2098
2099 <para>
2100 Following is an example that uses <filename>devshell</filename> on a target named
2101 <filename>matchbox-desktop</filename>:
2102 <literallayout class='monospaced'>
2103 $ bitbake matchbox-desktop -c devshell
2104 </literallayout>
2105 </para>
2106
2107 <para>
2108 This command spawns a terminal with a shell prompt within the OpenEmbedded build environment.
2109 The <ulink url='&YOCTO_DOCS_REF_URL;#var-OE_TERMINAL'><filename>OE_TERMINAL</filename></ulink>
2110 variable controls what type of shell is opened.
2111 </para>
2112
2113 <para>
2114 For spawned terminals, the following occurs:
2115 <itemizedlist>
2116 <listitem><para>The <filename>PATH</filename> variable includes the
2117 cross-toolchain.</para></listitem>
2118 <listitem><para>The <filename>pkgconfig</filename> variables find the correct
2119 <filename>.pc</filename> files.</para></listitem>
2120 <listitem><para>The <filename>configure</filename> command finds the
2121 Yocto Project site files as well as any other necessary files.</para></listitem>
2122 </itemizedlist>
2123 </para>
2124
2125 <para>
2126 Within this environment, you can run configure or compile
2127 commands as if they were being run by
2128 the OpenEmbedded build system itself.
2129 As noted earlier, the working directory also automatically changes to the
2130 Source Directory (<ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>).
2131 </para>
2132
2133 <para>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002134 To manually run a specific task using <filename>devshell</filename>,
2135 run the corresponding <filename>run.*</filename> script in
2136 the
2137 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/temp</filename>
2138 directory (e.g.,
2139 <filename>run.do_configure.</filename><replaceable>pid</replaceable>).
2140 If a task's script does not exist, which would be the case if the task was
2141 skipped by way of the sstate cache, you can create the task by first running
2142 it outside of the <filename>devshell</filename>:
2143 <literallayout class='monospaced'>
2144 $ bitbake -c <replaceable>task</replaceable>
2145 </literallayout>
2146 <note><title>Notes</title>
2147 <itemizedlist>
2148 <listitem><para>Execution of a task's <filename>run.*</filename>
2149 script and BitBake's execution of a task are identical.
2150 In other words, running the script re-runs the task
2151 just as it would be run using the
2152 <filename>bitbake -c</filename> command.
2153 </para></listitem>
2154 <listitem><para>Any <filename>run.*</filename> file that does not
2155 have a <filename>.pid</filename> extension is a
2156 symbolic link (symlink) to the most recent version of that
2157 file.
2158 </para></listitem>
2159 </itemizedlist>
2160 </note>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002161 </para>
2162
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002163 <para>
2164 Remember, that the <filename>devshell</filename> is a mechanism that allows
2165 you to get into the BitBake task execution environment.
2166 And as such, all commands must be called just as BitBake would call them.
2167 That means you need to provide the appropriate options for
2168 cross-compilation and so forth as applicable.
2169 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002170
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05002171 <para>
2172 When you are finished using <filename>devshell</filename>, exit the shell
2173 or close the terminal window.
2174 </para>
2175
2176 <note><title>Notes</title>
2177 <itemizedlist>
2178 <listitem><para>
2179 It is worth remembering that when using <filename>devshell</filename>
2180 you need to use the full compiler name such as <filename>arm-poky-linux-gnueabi-gcc</filename>
2181 instead of just using <filename>gcc</filename>.
2182 The same applies to other applications such as <filename>binutils</filename>,
2183 <filename>libtool</filename> and so forth.
2184 BitBake sets up environment variables such as <filename>CC</filename>
2185 to assist applications, such as <filename>make</filename> to find the correct tools.
2186 </para></listitem>
2187 <listitem><para>
2188 It is also worth noting that <filename>devshell</filename> still works over
2189 X11 forwarding and similar situations.
2190 </para></listitem>
2191 </itemizedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002192 </note>
2193</section>
2194
2195</chapter>