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