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='extendpoky'> |
| 6 | |
| 7 | <title>Common Tasks</title> |
| 8 | <para> |
| 9 | This chapter describes fundamental procedures such as creating layers, |
| 10 | adding new software packages, extending or customizing images, |
| 11 | porting work to new hardware (adding a new machine), and so forth. |
| 12 | You will find that the procedures documented here occur often in the |
| 13 | development cycle using the Yocto Project. |
| 14 | </para> |
| 15 | |
| 16 | <section id="understanding-and-creating-layers"> |
| 17 | <title>Understanding and Creating Layers</title> |
| 18 | |
| 19 | <para> |
| 20 | The OpenEmbedded build system supports organizing |
| 21 | <link linkend='metadata'>Metadata</link> into multiple layers. |
| 22 | Layers allow you to isolate different types of customizations from |
| 23 | each other. |
| 24 | You might find it tempting to keep everything in one layer when |
| 25 | working on a single project. |
| 26 | However, the more modular your Metadata, the easier |
| 27 | it is to cope with future changes. |
| 28 | </para> |
| 29 | |
| 30 | <para> |
| 31 | To illustrate how layers are used to keep things modular, consider |
| 32 | machine customizations. |
| 33 | These types of customizations typically reside in a special layer, |
| 34 | rather than a general layer, called a Board Support Package (BSP) |
| 35 | Layer. |
| 36 | Furthermore, the machine customizations should be isolated from |
| 37 | recipes and Metadata that support a new GUI environment, |
| 38 | for example. |
| 39 | This situation gives you a couple of layers: one for the machine |
| 40 | configurations, and one for the GUI environment. |
| 41 | It is important to understand, however, that the BSP layer can |
| 42 | still make machine-specific additions to recipes within the GUI |
| 43 | environment layer without polluting the GUI layer itself |
| 44 | with those machine-specific changes. |
| 45 | You can accomplish this through a recipe that is a BitBake append |
| 46 | (<filename>.bbappend</filename>) file, which is described later |
| 47 | in this section. |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | </para> |
| 52 | |
| 53 | <section id='yocto-project-layers'> |
| 54 | <title>Layers</title> |
| 55 | |
| 56 | <para> |
| 57 | The <link linkend='source-directory'>Source Directory</link> |
| 58 | contains both general layers and BSP |
| 59 | layers right out of the box. |
| 60 | You can easily identify layers that ship with a |
| 61 | Yocto Project release in the Source Directory by their |
| 62 | folder names. |
| 63 | Folders that represent layers typically have names that begin with |
| 64 | the string <filename>meta-</filename>. |
| 65 | <note> |
| 66 | It is not a requirement that a layer name begin with the |
| 67 | prefix <filename>meta-</filename>, but it is a commonly |
| 68 | accepted standard in the Yocto Project community. |
| 69 | </note> |
| 70 | For example, when you set up the Source Directory structure, |
| 71 | you will see several layers: |
| 72 | <filename>meta</filename>, |
| 73 | <filename>meta-skeleton</filename>, |
| 74 | <filename>meta-selftest</filename>, |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 75 | <filename>meta-poky</filename>, and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | <filename>meta-yocto-bsp</filename>. |
| 77 | Each of these folders represents a distinct layer. |
| 78 | </para> |
| 79 | |
| 80 | <para> |
| 81 | As another example, if you set up a local copy of the |
| 82 | <filename>meta-intel</filename> Git repository |
| 83 | and then explore the folder of that general layer, |
| 84 | you will discover many Intel-specific BSP layers inside. |
| 85 | For more information on BSP layers, see the |
| 86 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 87 | section in the Yocto Project Board Support Package (BSP) |
| 88 | Developer's Guide. |
| 89 | </para> |
| 90 | </section> |
| 91 | |
| 92 | <section id='creating-your-own-layer'> |
| 93 | <title>Creating Your Own Layer</title> |
| 94 | |
| 95 | <para> |
| 96 | It is very easy to create your own layers to use with the |
| 97 | OpenEmbedded build system. |
| 98 | The Yocto Project ships with scripts that speed up creating |
| 99 | general layers and BSP layers. |
| 100 | This section describes the steps you perform by hand to create |
| 101 | a layer so that you can better understand them. |
| 102 | For information about the layer-creation scripts, see the |
| 103 | "<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>" |
| 104 | section in the Yocto Project Board Support Package (BSP) |
| 105 | Developer's Guide and the |
| 106 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 107 | section further down in this manual. |
| 108 | </para> |
| 109 | |
| 110 | <para> |
| 111 | Follow these general steps to create your layer: |
| 112 | <orderedlist> |
| 113 | <listitem><para><emphasis>Check Existing Layers:</emphasis> |
| 114 | Before creating a new layer, you should be sure someone |
| 115 | has not already created a layer containing the Metadata |
| 116 | you need. |
| 117 | You can see the |
| 118 | <ulink url='http://layers.openembedded.org/layerindex/layers/'><filename>OpenEmbedded Metadata Index</filename></ulink> |
| 119 | for a list of layers from the OpenEmbedded community |
| 120 | that can be used in the Yocto Project. |
| 121 | </para></listitem> |
| 122 | <listitem><para><emphasis>Create a Directory:</emphasis> |
| 123 | Create the directory for your layer. |
| 124 | While not strictly required, prepend the name of the |
| 125 | folder with the string <filename>meta-</filename>. |
| 126 | For example: |
| 127 | <literallayout class='monospaced'> |
| 128 | meta-mylayer |
| 129 | meta-GUI_xyz |
| 130 | meta-mymachine |
| 131 | </literallayout> |
| 132 | </para></listitem> |
| 133 | <listitem><para><emphasis>Create a Layer Configuration |
| 134 | File:</emphasis> |
| 135 | Inside your new layer folder, you need to create a |
| 136 | <filename>conf/layer.conf</filename> file. |
| 137 | It is easiest to take an existing layer configuration |
| 138 | file and copy that to your layer's |
| 139 | <filename>conf</filename> directory and then modify the |
| 140 | file as needed.</para> |
| 141 | <para>The |
| 142 | <filename>meta-yocto-bsp/conf/layer.conf</filename> file |
| 143 | demonstrates the required syntax: |
| 144 | <literallayout class='monospaced'> |
| 145 | # We have a conf and classes directory, add to BBPATH |
| 146 | BBPATH .= ":${LAYERDIR}" |
| 147 | |
| 148 | # We have recipes-* directories, add to BBFILES |
| 149 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 150 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 151 | |
| 152 | BBFILE_COLLECTIONS += "yoctobsp" |
| 153 | BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/" |
| 154 | BBFILE_PRIORITY_yoctobsp = "5" |
| 155 | LAYERVERSION_yoctobsp = "3" |
| 156 | </literallayout></para> |
| 157 | <para>Here is an explanation of the example: |
| 158 | <itemizedlist> |
| 159 | <listitem><para>The configuration and |
| 160 | classes directory is appended to |
| 161 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink>. |
| 162 | <note> |
| 163 | All non-distro layers, which include all BSP |
| 164 | layers, are expected to append the layer |
| 165 | directory to the |
| 166 | <filename>BBPATH</filename>. |
| 167 | On the other hand, distro layers, such as |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 168 | <filename>meta-poky</filename>, can choose |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | to enforce their own precedence over |
| 170 | <filename>BBPATH</filename>. |
| 171 | For an example of that syntax, see the |
| 172 | <filename>layer.conf</filename> file for |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 173 | the <filename>meta-poky</filename> layer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | </note></para></listitem> |
| 175 | <listitem><para>The recipes for the layers are |
| 176 | appended to |
| 177 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'>BBFILES</ulink></filename>. |
| 178 | </para></listitem> |
| 179 | <listitem><para>The |
| 180 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</ulink></filename> |
| 181 | variable is then appended with the layer name. |
| 182 | </para></listitem> |
| 183 | <listitem><para>The |
| 184 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PATTERN'>BBFILE_PATTERN</ulink></filename> |
| 185 | variable is set to a regular expression and is |
| 186 | used to match files from |
| 187 | <filename>BBFILES</filename> into a particular |
| 188 | layer. |
| 189 | In this case, |
| 190 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename> |
| 191 | is used to make <filename>BBFILE_PATTERN</filename> match within the |
| 192 | layer's path.</para></listitem> |
| 193 | <listitem><para>The |
| 194 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'>BBFILE_PRIORITY</ulink></filename> |
| 195 | variable then assigns a priority to the layer. |
| 196 | Applying priorities is useful in situations |
| 197 | where the same recipe might appear in multiple |
| 198 | layers and allows you to choose the layer |
| 199 | that takes precedence.</para></listitem> |
| 200 | <listitem><para>The |
| 201 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERVERSION'>LAYERVERSION</ulink></filename> |
| 202 | variable optionally specifies the version of a |
| 203 | layer as a single number.</para></listitem> |
| 204 | </itemizedlist></para> |
| 205 | <para>Note the use of the |
| 206 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LAYERDIR'>LAYERDIR</ulink></filename> |
| 207 | variable, which expands to the directory of the current |
| 208 | layer.</para> |
| 209 | <para>Through the use of the <filename>BBPATH</filename> |
| 210 | variable, BitBake locates class files |
| 211 | (<filename>.bbclass</filename>), |
| 212 | configuration files, and files that are included |
| 213 | with <filename>include</filename> and |
| 214 | <filename>require</filename> statements. |
| 215 | For these cases, BitBake uses the first file that |
| 216 | matches the name found in <filename>BBPATH</filename>. |
| 217 | This is similar to the way the <filename>PATH</filename> |
| 218 | variable is used for binaries. |
| 219 | It is recommended, therefore, that you use unique |
| 220 | class and configuration |
| 221 | filenames in your custom layer.</para></listitem> |
| 222 | <listitem><para><emphasis>Add Content:</emphasis> Depending |
| 223 | on the type of layer, add the content. |
| 224 | If the layer adds support for a machine, add the machine |
| 225 | configuration in a <filename>conf/machine/</filename> |
| 226 | file within the layer. |
| 227 | If the layer adds distro policy, add the distro |
| 228 | configuration in a <filename>conf/distro/</filename> |
| 229 | file within the layer. |
| 230 | If the layer introduces new recipes, put the recipes |
| 231 | you need in <filename>recipes-*</filename> |
| 232 | subdirectories within the layer. |
| 233 | <note>In order to be compliant with the Yocto Project, |
| 234 | a layer must contain a |
| 235 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-filelayout-readme'>README file.</ulink> |
| 236 | </note></para></listitem> |
| 237 | </orderedlist> |
| 238 | </para> |
| 239 | </section> |
| 240 | |
| 241 | <section id='best-practices-to-follow-when-creating-layers'> |
| 242 | <title>Best Practices to Follow When Creating Layers</title> |
| 243 | |
| 244 | <para> |
| 245 | To create layers that are easier to maintain and that will |
| 246 | not impact builds for other machines, you should consider the |
| 247 | information in the following sections. |
| 248 | </para> |
| 249 | |
| 250 | <section id='avoid-overlaying-entire-recipes'> |
| 251 | <title>Avoid "Overlaying" Entire Recipes</title> |
| 252 | |
| 253 | <para> |
| 254 | Avoid "overlaying" entire recipes from other layers in your |
| 255 | configuration. |
| 256 | In other words, do not copy an entire recipe into your |
| 257 | layer and then modify it. |
| 258 | Rather, use an append file (<filename>.bbappend</filename>) |
| 259 | to override |
| 260 | only those parts of the original recipe you need to modify. |
| 261 | </para> |
| 262 | </section> |
| 263 | |
| 264 | <section id='avoid-duplicating-include-files'> |
| 265 | <title>Avoid Duplicating Include Files</title> |
| 266 | |
| 267 | <para> |
| 268 | Avoid duplicating include files. |
| 269 | Use append files (<filename>.bbappend</filename>) |
| 270 | for each recipe |
| 271 | that uses an include file. |
| 272 | Or, if you are introducing a new recipe that requires |
| 273 | the included file, use the path relative to the original |
| 274 | layer directory to refer to the file. |
| 275 | For example, use |
| 276 | <filename>require recipes-core/</filename><replaceable>package</replaceable><filename>/</filename><replaceable>file</replaceable><filename>.inc</filename> |
| 277 | instead of <filename>require </filename><replaceable>file</replaceable><filename>.inc</filename>. |
| 278 | If you're finding you have to overlay the include file, |
| 279 | it could indicate a deficiency in the include file in |
| 280 | the layer to which it originally belongs. |
| 281 | If this is the case, you should try to address that |
| 282 | deficiency instead of overlaying the include file. |
| 283 | For example, you could address this by getting the |
| 284 | maintainer of the include file to add a variable or |
| 285 | variables to make it easy to override the parts needing |
| 286 | to be overridden. |
| 287 | </para> |
| 288 | </section> |
| 289 | |
| 290 | <section id='structure-your-layers'> |
| 291 | <title>Structure Your Layers</title> |
| 292 | |
| 293 | <para> |
| 294 | Proper use of overrides within append files and placement |
| 295 | of machine-specific files within your layer can ensure that |
| 296 | a build is not using the wrong Metadata and negatively |
| 297 | impacting a build for a different machine. |
| 298 | Following are some examples: |
| 299 | <itemizedlist> |
| 300 | <listitem><para><emphasis>Modifying Variables to Support |
| 301 | a Different Machine:</emphasis> |
| 302 | Suppose you have a layer named |
| 303 | <filename>meta-one</filename> that adds support |
| 304 | for building machine "one". |
| 305 | To do so, you use an append file named |
| 306 | <filename>base-files.bbappend</filename> and |
| 307 | create a dependency on "foo" by altering the |
| 308 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 309 | variable: |
| 310 | <literallayout class='monospaced'> |
| 311 | DEPENDS = "foo" |
| 312 | </literallayout> |
| 313 | The dependency is created during any build that |
| 314 | includes the layer |
| 315 | <filename>meta-one</filename>. |
| 316 | However, you might not want this dependency |
| 317 | for all machines. |
| 318 | For example, suppose you are building for |
| 319 | machine "two" but your |
| 320 | <filename>bblayers.conf</filename> file has the |
| 321 | <filename>meta-one</filename> layer included. |
| 322 | During the build, the |
| 323 | <filename>base-files</filename> for machine |
| 324 | "two" will also have the dependency on |
| 325 | <filename>foo</filename>.</para> |
| 326 | <para>To make sure your changes apply only when |
| 327 | building machine "one", use a machine override |
| 328 | with the <filename>DEPENDS</filename> statement: |
| 329 | <literallayout class='monospaced'> |
| 330 | DEPENDS_one = "foo" |
| 331 | </literallayout> |
| 332 | You should follow the same strategy when using |
| 333 | <filename>_append</filename> and |
| 334 | <filename>_prepend</filename> operations: |
| 335 | <literallayout class='monospaced'> |
| 336 | DEPENDS_append_one = " foo" |
| 337 | DEPENDS_prepend_one = "foo " |
| 338 | </literallayout> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 339 | As an actual example, here's a line from the recipe |
| 340 | for gnutls, which adds dependencies on |
| 341 | "argp-standalone" when building with the musl C |
| 342 | library: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 343 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 344 | DEPENDS_append_libc-musl = " argp-standalone" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 345 | </literallayout> |
| 346 | <note> |
| 347 | Avoiding "+=" and "=+" and using |
| 348 | machine-specific |
| 349 | <filename>_append</filename> |
| 350 | and <filename>_prepend</filename> operations |
| 351 | is recommended as well. |
| 352 | </note></para></listitem> |
| 353 | <listitem><para><emphasis>Place Machine-Specific Files |
| 354 | in Machine-Specific Locations:</emphasis> |
| 355 | When you have a base recipe, such as |
| 356 | <filename>base-files.bb</filename>, that |
| 357 | contains a |
| 358 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 359 | statement to a file, you can use an append file |
| 360 | to cause the build to use your own version of |
| 361 | the file. |
| 362 | For example, an append file in your layer at |
| 363 | <filename>meta-one/recipes-core/base-files/base-files.bbappend</filename> |
| 364 | could extend |
| 365 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 366 | using |
| 367 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 368 | as follows: |
| 369 | <literallayout class='monospaced'> |
| 370 | FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" |
| 371 | </literallayout> |
| 372 | The build for machine "one" will pick up your |
| 373 | machine-specific file as long as you have the |
| 374 | file in |
| 375 | <filename>meta-one/recipes-core/base-files/base-files/</filename>. |
| 376 | However, if you are building for a different |
| 377 | machine and the |
| 378 | <filename>bblayers.conf</filename> file includes |
| 379 | the <filename>meta-one</filename> layer and |
| 380 | the location of your machine-specific file is |
| 381 | the first location where that file is found |
| 382 | according to <filename>FILESPATH</filename>, |
| 383 | builds for all machines will also use that |
| 384 | machine-specific file.</para> |
| 385 | <para>You can make sure that a machine-specific |
| 386 | file is used for a particular machine by putting |
| 387 | the file in a subdirectory specific to the |
| 388 | machine. |
| 389 | For example, rather than placing the file in |
| 390 | <filename>meta-one/recipes-core/base-files/base-files/</filename> |
| 391 | as shown above, put it in |
| 392 | <filename>meta-one/recipes-core/base-files/base-files/one/</filename>. |
| 393 | Not only does this make sure the file is used |
| 394 | only when building for machine "one", but the |
| 395 | build process locates the file more quickly.</para> |
| 396 | <para>In summary, you need to place all files |
| 397 | referenced from <filename>SRC_URI</filename> |
| 398 | in a machine-specific subdirectory within the |
| 399 | layer in order to restrict those files to |
| 400 | machine-specific builds.</para></listitem> |
| 401 | </itemizedlist> |
| 402 | </para> |
| 403 | </section> |
| 404 | |
| 405 | <section id='other-recommendations'> |
| 406 | <title>Other Recommendations</title> |
| 407 | |
| 408 | <para> |
| 409 | We also recommend the following: |
| 410 | <itemizedlist> |
| 411 | <listitem><para>Store custom layers in a Git repository |
| 412 | that uses the |
| 413 | <filename>meta-<replaceable>layer_name</replaceable></filename> format. |
| 414 | </para></listitem> |
| 415 | <listitem><para>Clone the repository alongside other |
| 416 | <filename>meta</filename> directories in the |
| 417 | <link linkend='source-directory'>Source Directory</link>. |
| 418 | </para></listitem> |
| 419 | </itemizedlist> |
| 420 | Following these recommendations keeps your Source Directory and |
| 421 | its configuration entirely inside the Yocto Project's core |
| 422 | base. |
| 423 | </para> |
| 424 | </section> |
| 425 | </section> |
| 426 | |
| 427 | <section id='enabling-your-layer'> |
| 428 | <title>Enabling Your Layer</title> |
| 429 | |
| 430 | <para> |
| 431 | Before the OpenEmbedded build system can use your new layer, |
| 432 | you need to enable it. |
| 433 | To enable your layer, simply add your layer's path to the |
| 434 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'>BBLAYERS</ulink></filename> |
| 435 | variable in your <filename>conf/bblayers.conf</filename> file, |
| 436 | which is found in the |
| 437 | <link linkend='build-directory'>Build Directory</link>. |
| 438 | The following example shows how to enable a layer named |
| 439 | <filename>meta-mylayer</filename>: |
| 440 | <literallayout class='monospaced'> |
| 441 | LCONF_VERSION = "6" |
| 442 | |
| 443 | BBPATH = "${TOPDIR}" |
| 444 | BBFILES ?= "" |
| 445 | |
| 446 | BBLAYERS ?= " \ |
| 447 | $HOME/poky/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 448 | $HOME/poky/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 449 | $HOME/poky/meta-yocto-bsp \ |
| 450 | $HOME/poky/meta-mylayer \ |
| 451 | " |
| 452 | </literallayout> |
| 453 | </para> |
| 454 | |
| 455 | <para> |
| 456 | BitBake parses each <filename>conf/layer.conf</filename> file |
| 457 | as specified in the <filename>BBLAYERS</filename> variable |
| 458 | within the <filename>conf/bblayers.conf</filename> file. |
| 459 | During the processing of each |
| 460 | <filename>conf/layer.conf</filename> file, BitBake adds the |
| 461 | recipes, classes and configurations contained within the |
| 462 | particular layer to the source directory. |
| 463 | </para> |
| 464 | </section> |
| 465 | |
| 466 | <section id='using-bbappend-files'> |
| 467 | <title>Using .bbappend Files</title> |
| 468 | |
| 469 | <para> |
| 470 | Recipes used to append Metadata to other recipes are called |
| 471 | BitBake append files. |
| 472 | BitBake append files use the <filename>.bbappend</filename> file |
| 473 | type suffix, while the corresponding recipes to which Metadata |
| 474 | is being appended use the <filename>.bb</filename> file type |
| 475 | suffix. |
| 476 | </para> |
| 477 | |
| 478 | <para> |
| 479 | A <filename>.bbappend</filename> file allows your layer to make |
| 480 | additions or changes to the content of another layer's recipe |
| 481 | without having to copy the other recipe into your layer. |
| 482 | Your <filename>.bbappend</filename> file resides in your layer, |
| 483 | while the main <filename>.bb</filename> recipe file to |
| 484 | which you are appending Metadata resides in a different layer. |
| 485 | </para> |
| 486 | |
| 487 | <para> |
| 488 | Append files must have the same root names as their corresponding |
| 489 | recipes. |
| 490 | For example, the append file |
| 491 | <filename>someapp_&DISTRO;.bbappend</filename> must apply to |
| 492 | <filename>someapp_&DISTRO;.bb</filename>. |
| 493 | This means the original recipe and append file names are version |
| 494 | number-specific. |
| 495 | If the corresponding recipe is renamed to update to a newer |
| 496 | version, the corresponding <filename>.bbappend</filename> file must |
| 497 | be renamed (and possibly updated) as well. |
| 498 | During the build process, BitBake displays an error on starting |
| 499 | if it detects a <filename>.bbappend</filename> file that does |
| 500 | not have a corresponding recipe with a matching name. |
| 501 | See the |
| 502 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_DANGLINGAPPENDS_WARNONLY'><filename>BB_DANGLINGAPPENDS_WARNONLY</filename></ulink> |
| 503 | variable for information on how to handle this error. |
| 504 | </para> |
| 505 | |
| 506 | <para> |
| 507 | Being able to append information to an existing recipe not only |
| 508 | avoids duplication, but also automatically applies recipe |
| 509 | changes in a different layer to your layer. |
| 510 | If you were copying recipes, you would have to manually merge |
| 511 | changes as they occur. |
| 512 | </para> |
| 513 | |
| 514 | <para> |
| 515 | As an example, consider the main formfactor recipe and a |
| 516 | corresponding formfactor append file both from the |
| 517 | <link linkend='source-directory'>Source Directory</link>. |
| 518 | Here is the main formfactor recipe, which is named |
| 519 | <filename>formfactor_0.0.bb</filename> and located in the |
| 520 | "meta" layer at |
| 521 | <filename>meta/recipes-bsp/formfactor</filename>: |
| 522 | <literallayout class='monospaced'> |
| 523 | SUMMARY = "Device formfactor information" |
| 524 | SECTION = "base" |
| 525 | LICENSE = "MIT" |
| 526 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ |
| 527 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" |
| 528 | PR = "r45" |
| 529 | |
| 530 | SRC_URI = "file://config file://machconfig" |
| 531 | S = "${WORKDIR}" |
| 532 | |
| 533 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 534 | INHIBIT_DEFAULT_DEPS = "1" |
| 535 | |
| 536 | do_install() { |
| 537 | # Install file only if it has contents |
| 538 | install -d ${D}${sysconfdir}/formfactor/ |
| 539 | install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/ |
| 540 | if [ -s "${S}/machconfig" ]; then |
| 541 | install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/ |
| 542 | fi |
| 543 | } |
| 544 | </literallayout> |
| 545 | In the main recipe, note the |
| 546 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 547 | variable, which tells the OpenEmbedded build system where to |
| 548 | find files during the build. |
| 549 | </para> |
| 550 | |
| 551 | <para> |
| 552 | Following is the append file, which is named |
| 553 | <filename>formfactor_0.0.bbappend</filename> and is from the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 554 | Raspberry Pi BSP Layer named |
| 555 | <filename>meta-raspberrypi</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 556 | The file is in <filename>recipes-bsp/formfactor</filename>: |
| 557 | <literallayout class='monospaced'> |
| 558 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 559 | </literallayout> |
| 560 | </para> |
| 561 | |
| 562 | <para> |
| 563 | By default, the build system uses the |
| 564 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 565 | variable to locate files. |
| 566 | This append file extends the locations by setting the |
| 567 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 568 | variable. |
| 569 | Setting this variable in the <filename>.bbappend</filename> |
| 570 | file is the most reliable and recommended method for adding |
| 571 | directories to the search path used by the build system |
| 572 | to find files. |
| 573 | </para> |
| 574 | |
| 575 | <para> |
| 576 | The statement in this example extends the directories to include |
| 577 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>, |
| 578 | which resolves to a directory named |
| 579 | <filename>formfactor</filename> in the same directory |
| 580 | in which the append file resides (i.e. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 581 | <filename>meta-raspberrypi/recipes-bsp/formfactor/formfactor</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 582 | This implies that you must have the supporting directory |
| 583 | structure set up that will contain any files or patches you |
| 584 | will be including from the layer. |
| 585 | </para> |
| 586 | |
| 587 | <para> |
| 588 | Using the immediate expansion assignment operator |
| 589 | <filename>:=</filename> is important because of the reference to |
| 590 | <filename>THISDIR</filename>. |
| 591 | The trailing colon character is important as it ensures that |
| 592 | items in the list remain colon-separated. |
| 593 | <note> |
| 594 | <para> |
| 595 | BitBake automatically defines the |
| 596 | <filename>THISDIR</filename> variable. |
| 597 | You should never set this variable yourself. |
| 598 | Using "_prepend" as part of the |
| 599 | <filename>FILESEXTRAPATHS</filename> ensures your path |
| 600 | will be searched prior to other paths in the final |
| 601 | list. |
| 602 | </para> |
| 603 | |
| 604 | <para> |
| 605 | Also, not all append files add extra files. |
| 606 | Many append files simply exist to add build options |
| 607 | (e.g. <filename>systemd</filename>). |
| 608 | For these cases, your append file would not even |
| 609 | use the <filename>FILESEXTRAPATHS</filename> statement. |
| 610 | </para> |
| 611 | </note> |
| 612 | </para> |
| 613 | </section> |
| 614 | |
| 615 | <section id='prioritizing-your-layer'> |
| 616 | <title>Prioritizing Your Layer</title> |
| 617 | |
| 618 | <para> |
| 619 | Each layer is assigned a priority value. |
| 620 | Priority values control which layer takes precedence if there |
| 621 | are recipe files with the same name in multiple layers. |
| 622 | For these cases, the recipe file from the layer with a higher |
| 623 | priority number takes precedence. |
| 624 | Priority values also affect the order in which multiple |
| 625 | <filename>.bbappend</filename> files for the same recipe are |
| 626 | applied. |
| 627 | You can either specify the priority manually, or allow the |
| 628 | build system to calculate it based on the layer's dependencies. |
| 629 | </para> |
| 630 | |
| 631 | <para> |
| 632 | To specify the layer's priority manually, use the |
| 633 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILE_PRIORITY'><filename>BBFILE_PRIORITY</filename></ulink> |
| 634 | variable. |
| 635 | For example: |
| 636 | <literallayout class='monospaced'> |
| 637 | BBFILE_PRIORITY_mylayer = "1" |
| 638 | </literallayout> |
| 639 | </para> |
| 640 | |
| 641 | <note> |
| 642 | <para>It is possible for a recipe with a lower version number |
| 643 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 644 | in a layer that has a higher priority to take precedence.</para> |
| 645 | <para>Also, the layer priority does not currently affect the |
| 646 | precedence order of <filename>.conf</filename> |
| 647 | or <filename>.bbclass</filename> files. |
| 648 | Future versions of BitBake might address this.</para> |
| 649 | </note> |
| 650 | </section> |
| 651 | |
| 652 | <section id='managing-layers'> |
| 653 | <title>Managing Layers</title> |
| 654 | |
| 655 | <para> |
| 656 | You can use the BitBake layer management tool to provide a view |
| 657 | into the structure of recipes across a multi-layer project. |
| 658 | Being able to generate output that reports on configured layers |
| 659 | with their paths and priorities and on |
| 660 | <filename>.bbappend</filename> files and their applicable |
| 661 | recipes can help to reveal potential problems. |
| 662 | </para> |
| 663 | |
| 664 | <para> |
| 665 | Use the following form when running the layer management tool. |
| 666 | <literallayout class='monospaced'> |
| 667 | $ bitbake-layers <replaceable>command</replaceable> [<replaceable>arguments</replaceable>] |
| 668 | </literallayout> |
| 669 | The following list describes the available commands: |
| 670 | <itemizedlist> |
| 671 | <listitem><para><filename><emphasis>help:</emphasis></filename> |
| 672 | Displays general help or help on a specified command. |
| 673 | </para></listitem> |
| 674 | <listitem><para><filename><emphasis>show-layers:</emphasis></filename> |
| 675 | Shows the current configured layers. |
| 676 | </para></listitem> |
| 677 | <listitem><para><filename><emphasis>show-recipes:</emphasis></filename> |
| 678 | Lists available recipes and the layers that provide them. |
| 679 | </para></listitem> |
| 680 | <listitem><para><filename><emphasis>show-overlayed:</emphasis></filename> |
| 681 | Lists overlayed recipes. |
| 682 | A recipe is overlayed when a recipe with the same name |
| 683 | exists in another layer that has a higher layer |
| 684 | priority. |
| 685 | </para></listitem> |
| 686 | <listitem><para><filename><emphasis>show-appends:</emphasis></filename> |
| 687 | Lists <filename>.bbappend</filename> files and the |
| 688 | recipe files to which they apply. |
| 689 | </para></listitem> |
| 690 | <listitem><para><filename><emphasis>show-cross-depends:</emphasis></filename> |
| 691 | Lists dependency relationships between recipes that |
| 692 | cross layer boundaries. |
| 693 | </para></listitem> |
| 694 | <listitem><para><filename><emphasis>add-layer:</emphasis></filename> |
| 695 | Adds a layer to <filename>bblayers.conf</filename>. |
| 696 | </para></listitem> |
| 697 | <listitem><para><filename><emphasis>remove-layer:</emphasis></filename> |
| 698 | Removes a layer from <filename>bblayers.conf</filename> |
| 699 | </para></listitem> |
| 700 | <listitem><para><filename><emphasis>flatten:</emphasis></filename> |
| 701 | Flattens the layer configuration into a separate output |
| 702 | directory. |
| 703 | Flattening your layer configuration builds a "flattened" |
| 704 | directory that contains the contents of all layers, |
| 705 | with any overlayed recipes removed and any |
| 706 | <filename>.bbappend</filename> files appended to the |
| 707 | corresponding recipes. |
| 708 | You might have to perform some manual cleanup of the |
| 709 | flattened layer as follows: |
| 710 | <itemizedlist> |
| 711 | <listitem><para>Non-recipe files (such as patches) |
| 712 | are overwritten. |
| 713 | The flatten command shows a warning for these |
| 714 | files. |
| 715 | </para></listitem> |
| 716 | <listitem><para>Anything beyond the normal layer |
| 717 | setup has been added to the |
| 718 | <filename>layer.conf</filename> file. |
| 719 | Only the lowest priority layer's |
| 720 | <filename>layer.conf</filename> is used. |
| 721 | </para></listitem> |
| 722 | <listitem><para>Overridden and appended items from |
| 723 | <filename>.bbappend</filename> files need to be |
| 724 | cleaned up. |
| 725 | The contents of each |
| 726 | <filename>.bbappend</filename> end up in the |
| 727 | flattened recipe. |
| 728 | However, if there are appended or changed |
| 729 | variable values, you need to tidy these up |
| 730 | yourself. |
| 731 | Consider the following example. |
| 732 | Here, the <filename>bitbake-layers</filename> |
| 733 | command adds the line |
| 734 | <filename>#### bbappended ...</filename> so that |
| 735 | you know where the following lines originate: |
| 736 | <literallayout class='monospaced'> |
| 737 | ... |
| 738 | DESCRIPTION = "A useful utility" |
| 739 | ... |
| 740 | EXTRA_OECONF = "--enable-something" |
| 741 | ... |
| 742 | |
| 743 | #### bbappended from meta-anotherlayer #### |
| 744 | |
| 745 | DESCRIPTION = "Customized utility" |
| 746 | EXTRA_OECONF += "--enable-somethingelse" |
| 747 | </literallayout> |
| 748 | Ideally, you would tidy up these utilities as |
| 749 | follows: |
| 750 | <literallayout class='monospaced'> |
| 751 | ... |
| 752 | DESCRIPTION = "Customized utility" |
| 753 | ... |
| 754 | EXTRA_OECONF = "--enable-something --enable-somethingelse" |
| 755 | ... |
| 756 | </literallayout></para></listitem> |
| 757 | </itemizedlist></para></listitem> |
| 758 | </itemizedlist> |
| 759 | </para> |
| 760 | </section> |
| 761 | |
| 762 | <section id='creating-a-general-layer-using-the-yocto-layer-script'> |
| 763 | <title>Creating a General Layer Using the yocto-layer Script</title> |
| 764 | |
| 765 | <para> |
| 766 | The <filename>yocto-layer</filename> script simplifies |
| 767 | creating a new general layer. |
| 768 | <note> |
| 769 | For information on BSP layers, see the |
| 770 | "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" |
| 771 | section in the Yocto Project Board Specific (BSP) |
| 772 | Developer's Guide. |
| 773 | </note> |
| 774 | The default mode of the script's operation is to prompt you for |
| 775 | information needed to generate the layer: |
| 776 | <itemizedlist> |
| 777 | <listitem><para>The layer priority. |
| 778 | </para></listitem> |
| 779 | <listitem><para>Whether or not to create a sample recipe. |
| 780 | </para></listitem> |
| 781 | <listitem><para>Whether or not to create a sample |
| 782 | append file. |
| 783 | </para></listitem> |
| 784 | </itemizedlist> |
| 785 | </para> |
| 786 | |
| 787 | <para> |
| 788 | Use the <filename>yocto-layer create</filename> sub-command |
| 789 | to create a new general layer. |
| 790 | In its simplest form, you can create a layer as follows: |
| 791 | <literallayout class='monospaced'> |
| 792 | $ yocto-layer create mylayer |
| 793 | </literallayout> |
| 794 | The previous example creates a layer named |
| 795 | <filename>meta-mylayer</filename> in the current directory. |
| 796 | </para> |
| 797 | |
| 798 | <para> |
| 799 | As the <filename>yocto-layer create</filename> command runs, |
| 800 | default values for the prompts appear in brackets. |
| 801 | Pressing enter without supplying anything for the prompts |
| 802 | or pressing enter and providing an invalid response causes the |
| 803 | script to accept the default value. |
| 804 | Once the script completes, the new layer |
| 805 | is created in the current working directory. |
| 806 | The script names the layer by prepending |
| 807 | <filename>meta-</filename> to the name you provide. |
| 808 | </para> |
| 809 | |
| 810 | <para> |
| 811 | Minimally, the script creates the following within the layer: |
| 812 | <itemizedlist> |
| 813 | <listitem><para><emphasis>The <filename>conf</filename> |
| 814 | directory:</emphasis> |
| 815 | This directory contains the layer's configuration file. |
| 816 | The root name for the file is the same as the root name |
| 817 | your provided for the layer (e.g. |
| 818 | <filename><replaceable>layer</replaceable>.conf</filename>). |
| 819 | </para></listitem> |
| 820 | <listitem><para><emphasis>The |
| 821 | <filename>COPYING.MIT</filename> file:</emphasis> |
| 822 | The copyright and use notice for the software. |
| 823 | </para></listitem> |
| 824 | <listitem><para><emphasis>The <filename>README</filename> |
| 825 | file:</emphasis> |
| 826 | A file describing the contents of your new layer. |
| 827 | </para></listitem> |
| 828 | </itemizedlist> |
| 829 | </para> |
| 830 | |
| 831 | <para> |
| 832 | If you choose to generate a sample recipe file, the script |
| 833 | prompts you for the name for the recipe and then creates it |
| 834 | in <filename><replaceable>layer</replaceable>/recipes-example/example/</filename>. |
| 835 | The script creates a <filename>.bb</filename> file and a |
| 836 | directory, which contains a sample |
| 837 | <filename>helloworld.c</filename> source file, along with |
| 838 | a sample patch file. |
| 839 | If you do not provide a recipe name, the script uses |
| 840 | "example". |
| 841 | </para> |
| 842 | |
| 843 | <para> |
| 844 | If you choose to generate a sample append file, the script |
| 845 | prompts you for the name for the file and then creates it |
| 846 | in <filename><replaceable>layer</replaceable>/recipes-example-bbappend/example-bbappend/</filename>. |
| 847 | The script creates a <filename>.bbappend</filename> file and a |
| 848 | directory, which contains a sample patch file. |
| 849 | If you do not provide a recipe name, the script uses |
| 850 | "example". |
| 851 | The script also prompts you for the version of the append file. |
| 852 | The version should match the recipe to which the append file |
| 853 | is associated. |
| 854 | </para> |
| 855 | |
| 856 | <para> |
| 857 | The easiest way to see how the <filename>yocto-layer</filename> |
| 858 | script works is to experiment with the script. |
| 859 | You can also read the usage information by entering the |
| 860 | following: |
| 861 | <literallayout class='monospaced'> |
| 862 | $ yocto-layer help |
| 863 | </literallayout> |
| 864 | </para> |
| 865 | |
| 866 | <para> |
| 867 | Once you create your general layer, you must add it to your |
| 868 | <filename>bblayers.conf</filename> file. |
| 869 | Here is an example where a layer named |
| 870 | <filename>meta-mylayer</filename> is added: |
| 871 | <literallayout class='monospaced'> |
| 872 | BBLAYERS = ?" \ |
| 873 | /usr/local/src/yocto/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 874 | /usr/local/src/yocto/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 875 | /usr/local/src/yocto/meta-yocto-bsp \ |
| 876 | /usr/local/src/yocto/meta-mylayer \ |
| 877 | " |
| 878 | </literallayout> |
| 879 | Adding the layer to this file enables the build system to |
| 880 | locate the layer during the build. |
| 881 | </para> |
| 882 | </section> |
| 883 | </section> |
| 884 | |
| 885 | <section id='usingpoky-extend-customimage'> |
| 886 | <title>Customizing Images</title> |
| 887 | |
| 888 | <para> |
| 889 | You can customize images to satisfy particular requirements. |
| 890 | This section describes several methods and provides guidelines for each. |
| 891 | </para> |
| 892 | |
| 893 | <section id='usingpoky-extend-customimage-localconf'> |
| 894 | <title>Customizing Images Using <filename>local.conf</filename></title> |
| 895 | |
| 896 | <para> |
| 897 | Probably the easiest way to customize an image is to add a |
| 898 | package by way of the <filename>local.conf</filename> |
| 899 | configuration file. |
| 900 | Because it is limited to local use, this method generally only |
| 901 | allows you to add packages and is not as flexible as creating |
| 902 | your own customized image. |
| 903 | When you add packages using local variables this way, you need |
| 904 | to realize that these variable changes are in effect for every |
| 905 | build and consequently affect all images, which might not |
| 906 | be what you require. |
| 907 | </para> |
| 908 | |
| 909 | <para> |
| 910 | To add a package to your image using the local configuration |
| 911 | file, use the |
| 912 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 913 | variable with the <filename>_append</filename> operator: |
| 914 | <literallayout class='monospaced'> |
| 915 | IMAGE_INSTALL_append = " strace" |
| 916 | </literallayout> |
| 917 | Use of the syntax is important - specifically, the space between |
| 918 | the quote and the package name, which is |
| 919 | <filename>strace</filename> in this example. |
| 920 | This space is required since the <filename>_append</filename> |
| 921 | operator does not add the space. |
| 922 | </para> |
| 923 | |
| 924 | <para> |
| 925 | Furthermore, you must use <filename>_append</filename> instead |
| 926 | of the <filename>+=</filename> operator if you want to avoid |
| 927 | ordering issues. |
| 928 | The reason for this is because doing so unconditionally appends |
| 929 | to the variable and avoids ordering problems due to the |
| 930 | variable being set in image recipes and |
| 931 | <filename>.bbclass</filename> files with operators like |
| 932 | <filename>?=</filename>. |
| 933 | Using <filename>_append</filename> ensures the operation takes |
| 934 | affect. |
| 935 | </para> |
| 936 | |
| 937 | <para> |
| 938 | As shown in its simplest use, |
| 939 | <filename>IMAGE_INSTALL_append</filename> affects all images. |
| 940 | It is possible to extend the syntax so that the variable |
| 941 | applies to a specific image only. |
| 942 | Here is an example: |
| 943 | <literallayout class='monospaced'> |
| 944 | IMAGE_INSTALL_append_pn-core-image-minimal = " strace" |
| 945 | </literallayout> |
| 946 | This example adds <filename>strace</filename> to the |
| 947 | <filename>core-image-minimal</filename> image only. |
| 948 | </para> |
| 949 | |
| 950 | <para> |
| 951 | You can add packages using a similar approach through the |
| 952 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CORE_IMAGE_EXTRA_INSTALL'>CORE_IMAGE_EXTRA_INSTALL</ulink></filename> |
| 953 | variable. |
| 954 | If you use this variable, only |
| 955 | <filename>core-image-*</filename> images are affected. |
| 956 | </para> |
| 957 | </section> |
| 958 | |
| 959 | <section id='usingpoky-extend-customimage-imagefeatures'> |
| 960 | <title>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and |
| 961 | <filename>EXTRA_IMAGE_FEATURES</filename></title> |
| 962 | |
| 963 | <para> |
| 964 | Another method for customizing your image is to enable or |
| 965 | disable high-level image features by using the |
| 966 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 967 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 968 | variables. |
| 969 | Although the functions for both variables are nearly equivalent, |
| 970 | best practices dictate using <filename>IMAGE_FEATURES</filename> |
| 971 | from within a recipe and using |
| 972 | <filename>EXTRA_IMAGE_FEATURES</filename> from within |
| 973 | your <filename>local.conf</filename> file, which is found in the |
| 974 | <link linkend='build-directory'>Build Directory</link>. |
| 975 | </para> |
| 976 | |
| 977 | <para> |
| 978 | To understand how these features work, the best reference is |
| 979 | <filename>meta/classes/core-image.bbclass</filename>. |
| 980 | This class lists out the available |
| 981 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 982 | of which most map to package groups while some, such as |
| 983 | <filename>debug-tweaks</filename> and |
| 984 | <filename>read-only-rootfs</filename>, resolve as general |
| 985 | configuration settings. |
| 986 | </para> |
| 987 | |
| 988 | <para> |
| 989 | In summary, the file looks at the contents of the |
| 990 | <filename>IMAGE_FEATURES</filename> variable and then maps |
| 991 | or configures the feature accordingly. |
| 992 | Based on this information, the build system automatically |
| 993 | adds the appropriate packages or configurations to the |
| 994 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 995 | variable. |
| 996 | Effectively, you are enabling extra features by extending the |
| 997 | class or creating a custom class for use with specialized image |
| 998 | <filename>.bb</filename> files. |
| 999 | </para> |
| 1000 | |
| 1001 | <para> |
| 1002 | Use the <filename>EXTRA_IMAGE_FEATURES</filename> variable |
| 1003 | from within your local configuration file. |
| 1004 | Using a separate area from which to enable features with |
| 1005 | this variable helps you avoid overwriting the features in the |
| 1006 | image recipe that are enabled with |
| 1007 | <filename>IMAGE_FEATURES</filename>. |
| 1008 | The value of <filename>EXTRA_IMAGE_FEATURES</filename> is added |
| 1009 | to <filename>IMAGE_FEATURES</filename> within |
| 1010 | <filename>meta/conf/bitbake.conf</filename>. |
| 1011 | </para> |
| 1012 | |
| 1013 | <para> |
| 1014 | To illustrate how you can use these variables to modify your |
| 1015 | image, consider an example that selects the SSH server. |
| 1016 | The Yocto Project ships with two SSH servers you can use |
| 1017 | with your images: Dropbear and OpenSSH. |
| 1018 | Dropbear is a minimal SSH server appropriate for |
| 1019 | resource-constrained environments, while OpenSSH is a |
| 1020 | well-known standard SSH server implementation. |
| 1021 | By default, the <filename>core-image-sato</filename> image |
| 1022 | is configured to use Dropbear. |
| 1023 | The <filename>core-image-full-cmdline</filename> and |
| 1024 | <filename>core-image-lsb</filename> images both |
| 1025 | include OpenSSH. |
| 1026 | The <filename>core-image-minimal</filename> image does not |
| 1027 | contain an SSH server. |
| 1028 | </para> |
| 1029 | |
| 1030 | <para> |
| 1031 | You can customize your image and change these defaults. |
| 1032 | Edit the <filename>IMAGE_FEATURES</filename> variable |
| 1033 | in your recipe or use the |
| 1034 | <filename>EXTRA_IMAGE_FEATURES</filename> in your |
| 1035 | <filename>local.conf</filename> file so that it configures the |
| 1036 | image you are working with to include |
| 1037 | <filename>ssh-server-dropbear</filename> or |
| 1038 | <filename>ssh-server-openssh</filename>. |
| 1039 | </para> |
| 1040 | |
| 1041 | <note> |
| 1042 | See the |
| 1043 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" |
| 1044 | section in the Yocto Project Reference Manual for a complete |
| 1045 | list of image features that ship with the Yocto Project. |
| 1046 | </note> |
| 1047 | </section> |
| 1048 | |
| 1049 | <section id='usingpoky-extend-customimage-custombb'> |
| 1050 | <title>Customizing Images Using Custom .bb Files</title> |
| 1051 | |
| 1052 | <para> |
| 1053 | You can also customize an image by creating a custom recipe |
| 1054 | that defines additional software as part of the image. |
| 1055 | The following example shows the form for the two lines you need: |
| 1056 | <literallayout class='monospaced'> |
| 1057 | IMAGE_INSTALL = "packagegroup-core-x11-base package1 package2" |
| 1058 | |
| 1059 | inherit core-image |
| 1060 | </literallayout> |
| 1061 | </para> |
| 1062 | |
| 1063 | <para> |
| 1064 | Defining the software using a custom recipe gives you total |
| 1065 | control over the contents of the image. |
| 1066 | It is important to use the correct names of packages in the |
| 1067 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename> |
| 1068 | variable. |
| 1069 | You must use the OpenEmbedded notation and not the Debian notation for the names |
| 1070 | (e.g. <filename>glibc-dev</filename> instead of <filename>libc6-dev</filename>). |
| 1071 | </para> |
| 1072 | |
| 1073 | <para> |
| 1074 | The other method for creating a custom image is to base it on an existing image. |
| 1075 | For example, if you want to create an image based on <filename>core-image-sato</filename> |
| 1076 | but add the additional package <filename>strace</filename> to the image, |
| 1077 | copy the <filename>meta/recipes-sato/images/core-image-sato.bb</filename> to a |
| 1078 | new <filename>.bb</filename> and add the following line to the end of the copy: |
| 1079 | <literallayout class='monospaced'> |
| 1080 | IMAGE_INSTALL += "strace" |
| 1081 | </literallayout> |
| 1082 | </para> |
| 1083 | </section> |
| 1084 | |
| 1085 | <section id='usingpoky-extend-customimage-customtasks'> |
| 1086 | <title>Customizing Images Using Custom Package Groups</title> |
| 1087 | |
| 1088 | <para> |
| 1089 | For complex custom images, the best approach for customizing |
| 1090 | an image is to create a custom package group recipe that is |
| 1091 | used to build the image or images. |
| 1092 | A good example of a package group recipe is |
| 1093 | <filename>meta/recipes-core/packagegroups/packagegroup-base.bb</filename>. |
| 1094 | </para> |
| 1095 | |
| 1096 | <para> |
| 1097 | If you examine that recipe, you see that the |
| 1098 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> |
| 1099 | variable lists the package group packages to produce. |
| 1100 | The <filename>inherit packagegroup</filename> statement |
| 1101 | sets appropriate default values and automatically adds |
| 1102 | <filename>-dev</filename>, <filename>-dbg</filename>, and |
| 1103 | <filename>-ptest</filename> complementary packages for each |
| 1104 | package specified in the <filename>PACKAGES</filename> |
| 1105 | statement. |
| 1106 | <note> |
| 1107 | The <filename>inherit packages</filename> should be |
| 1108 | located near the top of the recipe, certainly before |
| 1109 | the <filename>PACKAGES</filename> statement. |
| 1110 | </note> |
| 1111 | </para> |
| 1112 | |
| 1113 | <para> |
| 1114 | For each package you specify in <filename>PACKAGES</filename>, |
| 1115 | you can use |
| 1116 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'>RDEPENDS</ulink></filename> |
| 1117 | and |
| 1118 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'>RRECOMMENDS</ulink></filename> |
| 1119 | entries to provide a list of packages the parent task package |
| 1120 | should contain. |
| 1121 | You can see examples of these further down in the |
| 1122 | <filename>packagegroup-base.bb</filename> recipe. |
| 1123 | </para> |
| 1124 | |
| 1125 | <para> |
| 1126 | Here is a short, fabricated example showing the same basic |
| 1127 | pieces: |
| 1128 | <literallayout class='monospaced'> |
| 1129 | DESCRIPTION = "My Custom Package Groups" |
| 1130 | |
| 1131 | inherit packagegroup |
| 1132 | |
| 1133 | PACKAGES = "\ |
| 1134 | packagegroup-custom-apps \ |
| 1135 | packagegroup-custom-tools \ |
| 1136 | " |
| 1137 | |
| 1138 | RDEPENDS_packagegroup-custom-apps = "\ |
| 1139 | dropbear \ |
| 1140 | portmap \ |
| 1141 | psplash" |
| 1142 | |
| 1143 | RDEPENDS_packagegroup-custom-tools = "\ |
| 1144 | oprofile \ |
| 1145 | oprofileui-server \ |
| 1146 | lttng-tools" |
| 1147 | |
| 1148 | RRECOMMENDS_packagegroup-custom-tools = "\ |
| 1149 | kernel-module-oprofile" |
| 1150 | </literallayout> |
| 1151 | </para> |
| 1152 | |
| 1153 | <para> |
| 1154 | In the previous example, two package group packages are created with their dependencies and their |
| 1155 | recommended package dependencies listed: <filename>packagegroup-custom-apps</filename>, and |
| 1156 | <filename>packagegroup-custom-tools</filename>. |
| 1157 | To build an image using these package group packages, you need to add |
| 1158 | <filename>packagegroup-custom-apps</filename> and/or |
| 1159 | <filename>packagegroup-custom-tools</filename> to |
| 1160 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'>IMAGE_INSTALL</ulink></filename>. |
| 1161 | For other forms of image dependencies see the other areas of this section. |
| 1162 | </para> |
| 1163 | </section> |
| 1164 | |
| 1165 | <section id='usingpoky-extend-customimage-image-name'> |
| 1166 | <title>Customizing an Image Hostname</title> |
| 1167 | |
| 1168 | <para> |
| 1169 | By default, the configured hostname (i.e. |
| 1170 | <filename>/etc/hostname</filename>) in an image is the |
| 1171 | same as the machine name. |
| 1172 | For example, if |
| 1173 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 1174 | equals "qemux86", the configured hostname written to |
| 1175 | <filename>/etc/hostname</filename> is "qemux86". |
| 1176 | </para> |
| 1177 | |
| 1178 | <para> |
| 1179 | You can customize this name by altering the value of the |
| 1180 | "hostname" variable in the |
| 1181 | <filename>base-files</filename> recipe using either |
| 1182 | an append file or a configuration file. |
| 1183 | Use the following in an append file: |
| 1184 | <literallayout class='monospaced'> |
| 1185 | hostname="myhostname" |
| 1186 | </literallayout> |
| 1187 | Use the following in a configuration file: |
| 1188 | <literallayout class='monospaced'> |
| 1189 | hostname_pn-base-files = "myhostname" |
| 1190 | </literallayout> |
| 1191 | </para> |
| 1192 | |
| 1193 | <para> |
| 1194 | Changing the default value of the variable "hostname" can be |
| 1195 | useful in certain situations. |
| 1196 | For example, suppose you need to do extensive testing on an |
| 1197 | image and you would like to easily identify the image |
| 1198 | under test from existing images with typical default |
| 1199 | hostnames. |
| 1200 | In this situation, you could change the default hostname to |
| 1201 | "testme", which results in all the images using the name |
| 1202 | "testme". |
| 1203 | Once testing is complete and you do not need to rebuild the |
| 1204 | image for test any longer, you can easily reset the default |
| 1205 | hostname. |
| 1206 | </para> |
| 1207 | |
| 1208 | <para> |
| 1209 | Another point of interest is that if you unset the variable, |
| 1210 | the image will have no default hostname in the filesystem. |
| 1211 | Here is an example that unsets the variable in a |
| 1212 | configuration file: |
| 1213 | <literallayout class='monospaced'> |
| 1214 | hostname_pn-base-files = "" |
| 1215 | </literallayout> |
| 1216 | Having no default hostname in the filesystem is suitable for |
| 1217 | environments that use dynamic hostnames such as virtual |
| 1218 | machines. |
| 1219 | </para> |
| 1220 | </section> |
| 1221 | </section> |
| 1222 | |
| 1223 | <section id='new-recipe-writing-a-new-recipe'> |
| 1224 | <title>Writing a New Recipe</title> |
| 1225 | |
| 1226 | <para> |
| 1227 | Recipes (<filename>.bb</filename> files) are fundamental components |
| 1228 | in the Yocto Project environment. |
| 1229 | Each software component built by the OpenEmbedded build system |
| 1230 | requires a recipe to define the component. |
| 1231 | This section describes how to create, write, and test a new |
| 1232 | recipe. |
| 1233 | <note> |
| 1234 | For information on variables that are useful for recipes and |
| 1235 | for information about recipe naming issues, see the |
| 1236 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-varlocality-recipe-required'>Required</ulink>" |
| 1237 | section of the Yocto Project Reference Manual. |
| 1238 | </note> |
| 1239 | </para> |
| 1240 | |
| 1241 | <section id='new-recipe-overview'> |
| 1242 | <title>Overview</title> |
| 1243 | |
| 1244 | <para> |
| 1245 | The following figure shows the basic process for creating a |
| 1246 | new recipe. |
| 1247 | The remainder of the section provides details for the steps. |
| 1248 | <imagedata fileref="figures/recipe-workflow.png" width="6in" depth="7in" align="center" scalefit="1" /> |
| 1249 | </para> |
| 1250 | </section> |
| 1251 | |
| 1252 | <section id='new-recipe-locate-or-automatically-create-a-base-recipe'> |
| 1253 | <title>Locate or Automatically Create a Base Recipe</title> |
| 1254 | |
| 1255 | <para> |
| 1256 | You can always write a recipe from scratch. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1257 | However, three choices exist that can help you quickly get a |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1258 | start on a new recipe: |
| 1259 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1260 | <listitem><para> |
| 1261 | <emphasis><filename>devtool add</filename>:</emphasis> |
| 1262 | A command that assists in creating a recipe and |
| 1263 | an environment conducive to development. |
| 1264 | </para></listitem> |
| 1265 | <listitem><para> |
| 1266 | <emphasis><filename>recipetool create</filename>:</emphasis> |
| 1267 | A command provided by the Yocto Project that automates |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1268 | creation of a base recipe based on the source |
| 1269 | files. |
| 1270 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1271 | <listitem><para> |
| 1272 | <emphasis>Existing Recipes:</emphasis> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1273 | Location and modification of an existing recipe that is |
| 1274 | similar in function to the recipe you need. |
| 1275 | </para></listitem> |
| 1276 | </itemizedlist> |
| 1277 | </para> |
| 1278 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1279 | <section id='new-recipe-creating-the-base-recipe-using-devtool'> |
| 1280 | <title>Creating the Base Recipe Using <filename>devtool add</filename></title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1281 | |
| 1282 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1283 | The <filename>devtool add</filename> command uses the same |
| 1284 | logic for auto-creating the recipe as |
| 1285 | <filename>recipetool create</filename>, which is listed |
| 1286 | below. |
| 1287 | Additionally, however, <filename>devtool add</filename> |
| 1288 | sets up an environment that makes it easy for you to |
| 1289 | patch the source and to make changes to the recipe as |
| 1290 | is often necessary when adding a recipe to build a new |
| 1291 | piece of software to be included in a build. |
| 1292 | </para> |
| 1293 | |
| 1294 | <para> |
| 1295 | You can find a complete description of the |
| 1296 | <filename>devtool add</filename> command in the |
| 1297 | "<link linkend='use-devtool-to-integrate-new-code'>Use <filename>devtool add</filename> to Add an Application</link>" |
| 1298 | section. |
| 1299 | </para> |
| 1300 | </section> |
| 1301 | |
| 1302 | <section id='new-recipe-creating-the-base-recipe-using-recipetool'> |
| 1303 | <title>Creating the Base Recipe Using <filename>recipetool create</filename></title> |
| 1304 | |
| 1305 | <para> |
| 1306 | <filename>recipetool create</filename> automates creation |
| 1307 | of a base recipe given a set of source code files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1308 | As long as you can extract or point to the source files, |
| 1309 | the tool will construct a recipe and automatically |
| 1310 | configure all pre-build information into the recipe. |
| 1311 | For example, suppose you have an application that builds |
| 1312 | using Autotools. |
| 1313 | Creating the base recipe using |
| 1314 | <filename>recipetool</filename> results in a recipe |
| 1315 | that has the pre-build dependencies, license requirements, |
| 1316 | and checksums configured. |
| 1317 | </para> |
| 1318 | |
| 1319 | <para> |
| 1320 | To run the tool, you just need to be in your |
| 1321 | <link linkend='build-directory'>Build Directory</link> |
| 1322 | and have sourced the build environment setup script |
| 1323 | (i.e. |
| 1324 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink> |
| 1325 | or |
| 1326 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>). |
| 1327 | Here is the basic <filename>recipetool</filename> syntax: |
| 1328 | <note> |
| 1329 | Running <filename>recipetool -h</filename> or |
| 1330 | <filename>recipetool create -h</filename> produces the |
| 1331 | Python-generated help, which presented differently |
| 1332 | than what follows here. |
| 1333 | </note> |
| 1334 | <literallayout class='monospaced'> |
| 1335 | recipetool -h |
| 1336 | recipetool create [-h] |
| 1337 | recipetool [-d] [-q] [--color auto | always | never ] create -o <replaceable>OUTFILE</replaceable> [-m] [-x <replaceable>EXTERNALSRC</replaceable>] <replaceable>source</replaceable> |
| 1338 | |
| 1339 | -d Enables debug output. |
| 1340 | -q Outputs only errors (quiet mode). |
| 1341 | --color Colorizes the output automatically, always, or never. |
| 1342 | -h Displays Python generated syntax for recipetool. |
| 1343 | create Causes recipetool to create a base recipe. The create |
| 1344 | command is further defined with these options: |
| 1345 | |
| 1346 | -o <replaceable>OUTFILE</replaceable> Specifies the full path and filename for the generated |
| 1347 | recipe. |
| 1348 | -m Causes the recipe to be machine-specific rather than |
| 1349 | architecture-specific (default). |
| 1350 | -x <replaceable>EXTERNALSRC</replaceable> Fetches and extracts source files from <replaceable>source</replaceable> |
| 1351 | and places them in <replaceable>EXTERNALSRC</replaceable>. |
| 1352 | <replaceable>source</replaceable> must be a URL. |
| 1353 | -h Displays Python-generated syntax for create. |
| 1354 | <replaceable>source</replaceable> Specifies the source code on which to base the |
| 1355 | recipe. |
| 1356 | </literallayout> |
| 1357 | </para> |
| 1358 | |
| 1359 | <para> |
| 1360 | Running <filename>recipetool create -o</filename> <replaceable>OUTFILE</replaceable> |
| 1361 | creates the base recipe and locates it properly in the |
| 1362 | layer that contains your source files. |
| 1363 | Following are some syntax examples: |
| 1364 | </para> |
| 1365 | |
| 1366 | <para> |
| 1367 | Use this syntax to generate a recipe based on <replaceable>source</replaceable>. |
| 1368 | Once generated, the recipe resides in the existing source |
| 1369 | code layer: |
| 1370 | <literallayout class='monospaced'> |
| 1371 | recipetool create -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
| 1372 | </literallayout> |
| 1373 | Use this syntax to generate a recipe using code that you |
| 1374 | extract from <replaceable>source</replaceable>. |
| 1375 | The extracted code is placed in its own layer defined |
| 1376 | by <replaceable>EXTERNALSRC</replaceable>. |
| 1377 | <literallayout class='monospaced'> |
| 1378 | recipetool create -o <replaceable>OUTFILE</replaceable> -x <replaceable>EXTERNALSRC</replaceable> <replaceable>source</replaceable> |
| 1379 | </literallayout> |
| 1380 | Use this syntax to generate a recipe based on <replaceable>source</replaceable>. |
| 1381 | The options direct <filename>recipetool</filename> to |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1382 | generate debugging information. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1383 | Once generated, the recipe resides in the existing source |
| 1384 | code layer: |
| 1385 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 1386 | recipetool create -d -o <replaceable>OUTFILE</replaceable> <replaceable>source</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1387 | </literallayout> |
| 1388 | </para> |
| 1389 | </section> |
| 1390 | |
| 1391 | <section id='new-recipe-locating-and-using-a-similar-recipe'> |
| 1392 | <title>Locating and Using a Similar Recipe</title> |
| 1393 | |
| 1394 | <para> |
| 1395 | Before writing a recipe from scratch, it is often useful to |
| 1396 | discover whether someone else has already written one that |
| 1397 | meets (or comes close to meeting) your needs. |
| 1398 | The Yocto Project and OpenEmbedded communities maintain many |
| 1399 | recipes that might be candidates for what you are doing. |
| 1400 | You can find a good central index of these recipes in the |
| 1401 | <ulink url='http://layers.openembedded.org'>OpenEmbedded metadata index</ulink>. |
| 1402 | </para> |
| 1403 | |
| 1404 | <para> |
| 1405 | Working from an existing recipe or a skeleton recipe is the |
| 1406 | best way to get started. |
| 1407 | Here are some points on both methods: |
| 1408 | <itemizedlist> |
| 1409 | <listitem><para><emphasis>Locate and modify a recipe that |
| 1410 | is close to what you want to do:</emphasis> |
| 1411 | This method works when you are familiar with the |
| 1412 | current recipe space. |
| 1413 | The method does not work so well for those new to |
| 1414 | the Yocto Project or writing recipes.</para> |
| 1415 | <para>Some risks associated with this method are |
| 1416 | using a recipe that has areas totally unrelated to |
| 1417 | what you are trying to accomplish with your recipe, |
| 1418 | not recognizing areas of the recipe that you might |
| 1419 | have to add from scratch, and so forth. |
| 1420 | All these risks stem from unfamiliarity with the |
| 1421 | existing recipe space.</para></listitem> |
| 1422 | <listitem><para><emphasis>Use and modify the following |
| 1423 | skeleton recipe:</emphasis> |
| 1424 | If for some reason you do not want to use |
| 1425 | <filename>recipetool</filename> and you cannot |
| 1426 | find an existing recipe that is close to meeting |
| 1427 | your needs, you can use the following structure to |
| 1428 | provide the fundamental areas of a new recipe. |
| 1429 | <literallayout class='monospaced'> |
| 1430 | DESCRIPTION = "" |
| 1431 | HOMEPAGE = "" |
| 1432 | LICENSE = "" |
| 1433 | SECTION = "" |
| 1434 | DEPENDS = "" |
| 1435 | LIC_FILES_CHKSUM = "" |
| 1436 | |
| 1437 | SRC_URI = "" |
| 1438 | </literallayout> |
| 1439 | </para></listitem> |
| 1440 | </itemizedlist> |
| 1441 | </para> |
| 1442 | </section> |
| 1443 | </section> |
| 1444 | |
| 1445 | <section id='new-recipe-storing-and-naming-the-recipe'> |
| 1446 | <title>Storing and Naming the Recipe</title> |
| 1447 | |
| 1448 | <para> |
| 1449 | Once you have your base recipe, you should put it in your |
| 1450 | own layer and name it appropriately. |
| 1451 | Locating it correctly ensures that the OpenEmbedded build |
| 1452 | system can find it when you use BitBake to process the |
| 1453 | recipe. |
| 1454 | </para> |
| 1455 | |
| 1456 | <itemizedlist> |
| 1457 | <listitem><para><emphasis>Storing Your Recipe:</emphasis> |
| 1458 | The OpenEmbedded build system locates your recipe |
| 1459 | through the layer's <filename>conf/layer.conf</filename> |
| 1460 | file and the |
| 1461 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBFILES'><filename>BBFILES</filename></ulink> |
| 1462 | variable. |
| 1463 | This variable sets up a path from which the build system can |
| 1464 | locate recipes. |
| 1465 | Here is the typical use: |
| 1466 | <literallayout class='monospaced'> |
| 1467 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 1468 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 1469 | </literallayout> |
| 1470 | Consequently, you need to be sure you locate your new recipe |
| 1471 | inside your layer such that it can be found.</para> |
| 1472 | <para>You can find more information on how layers are |
| 1473 | structured in the |
| 1474 | "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" |
| 1475 | section.</para></listitem> |
| 1476 | <listitem><para><emphasis>Naming Your Recipe:</emphasis> |
| 1477 | When you name your recipe, you need to follow this naming |
| 1478 | convention: |
| 1479 | <literallayout class='monospaced'> |
| 1480 | <replaceable>basename</replaceable>_<replaceable>version</replaceable>.bb |
| 1481 | </literallayout> |
| 1482 | Use lower-cased characters and do not include the reserved |
| 1483 | suffixes <filename>-native</filename>, |
| 1484 | <filename>-cross</filename>, <filename>-initial</filename>, |
| 1485 | or <filename>-dev</filename> casually (i.e. do not use them |
| 1486 | as part of your recipe name unless the string applies). |
| 1487 | Here are some examples: |
| 1488 | <literallayout class='monospaced'> |
| 1489 | cups_1.7.0.bb |
| 1490 | gawk_4.0.2.bb |
| 1491 | irssi_0.8.16-rc1.bb |
| 1492 | </literallayout></para></listitem> |
| 1493 | </itemizedlist> |
| 1494 | </section> |
| 1495 | |
| 1496 | <section id='understanding-recipe-syntax'> |
| 1497 | <title>Understanding Recipe Syntax</title> |
| 1498 | |
| 1499 | <para> |
| 1500 | Understanding recipe file syntax is important for |
| 1501 | writing recipes. |
| 1502 | The following list overviews the basic items that make up a |
| 1503 | BitBake recipe file. |
| 1504 | For more complete BitBake syntax descriptions, see the |
| 1505 | "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>" |
| 1506 | chapter of the BitBake User Manual. |
| 1507 | <itemizedlist> |
| 1508 | <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis> |
| 1509 | Variable assignments allow a value to be assigned to a |
| 1510 | variable. |
| 1511 | The assignment can be static text or might include |
| 1512 | the contents of other variables. |
| 1513 | In addition to the assignment, appending and prepending |
| 1514 | operations are also supported.</para> |
| 1515 | <para>The following example shows some of the ways |
| 1516 | you can use variables in recipes: |
| 1517 | <literallayout class='monospaced'> |
| 1518 | S = "${WORKDIR}/postfix-${PV}" |
| 1519 | CFLAGS += "-DNO_ASM" |
| 1520 | SRC_URI_append = " file://fixup.patch" |
| 1521 | </literallayout> |
| 1522 | </para></listitem> |
| 1523 | <listitem><para><emphasis>Functions:</emphasis> |
| 1524 | Functions provide a series of actions to be performed. |
| 1525 | You usually use functions to override the default |
| 1526 | implementation of a task function or to complement |
| 1527 | a default function (i.e. append or prepend to an |
| 1528 | existing function). |
| 1529 | Standard functions use <filename>sh</filename> shell |
| 1530 | syntax, although access to OpenEmbedded variables and |
| 1531 | internal methods are also available.</para> |
| 1532 | <para>The following is an example function from the |
| 1533 | <filename>sed</filename> recipe: |
| 1534 | <literallayout class='monospaced'> |
| 1535 | do_install () { |
| 1536 | autotools_do_install |
| 1537 | install -d ${D}${base_bindir} |
| 1538 | mv ${D}${bindir}/sed ${D}${base_bindir}/sed |
| 1539 | rmdir ${D}${bindir}/ |
| 1540 | } |
| 1541 | </literallayout> |
| 1542 | It is also possible to implement new functions that |
| 1543 | are called between existing tasks as long as the |
| 1544 | new functions are not replacing or complementing the |
| 1545 | default functions. |
| 1546 | You can implement functions in Python |
| 1547 | instead of shell. |
| 1548 | Both of these options are not seen in the majority of |
| 1549 | recipes.</para></listitem> |
| 1550 | <listitem><para><emphasis>Keywords:</emphasis> |
| 1551 | BitBake recipes use only a few keywords. |
| 1552 | You use keywords to include common |
| 1553 | functions (<filename>inherit</filename>), load parts |
| 1554 | of a recipe from other files |
| 1555 | (<filename>include</filename> and |
| 1556 | <filename>require</filename>) and export variables |
| 1557 | to the environment (<filename>export</filename>).</para> |
| 1558 | <para>The following example shows the use of some of |
| 1559 | these keywords: |
| 1560 | <literallayout class='monospaced'> |
| 1561 | export POSTCONF = "${STAGING_BINDIR}/postconf" |
| 1562 | inherit autoconf |
| 1563 | require otherfile.inc |
| 1564 | </literallayout> |
| 1565 | </para></listitem> |
| 1566 | <listitem><para><emphasis>Comments:</emphasis> |
| 1567 | Any lines that begin with the hash character |
| 1568 | (<filename>#</filename>) are treated as comment lines |
| 1569 | and are ignored: |
| 1570 | <literallayout class='monospaced'> |
| 1571 | # This is a comment |
| 1572 | </literallayout> |
| 1573 | </para></listitem> |
| 1574 | </itemizedlist> |
| 1575 | </para> |
| 1576 | |
| 1577 | <para> |
| 1578 | This next list summarizes the most important and most commonly |
| 1579 | used parts of the recipe syntax. |
| 1580 | For more information on these parts of the syntax, you can |
| 1581 | reference the |
| 1582 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink> |
| 1583 | chapter in the BitBake User Manual. |
| 1584 | <itemizedlist> |
| 1585 | <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> - |
| 1586 | Use the backward slash (<filename>\</filename>) |
| 1587 | character to split a statement over multiple lines. |
| 1588 | Place the slash character at the end of the line that |
| 1589 | is to be continued on the next line: |
| 1590 | <literallayout class='monospaced'> |
| 1591 | VAR = "A really long \ |
| 1592 | line" |
| 1593 | </literallayout> |
| 1594 | <note> |
| 1595 | You cannot have any characters including spaces |
| 1596 | or tabs after the slash character. |
| 1597 | </note> |
| 1598 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1599 | <listitem><para> |
| 1600 | <emphasis>Using Variables: <filename>${...}</filename></emphasis> - |
| 1601 | Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> syntax to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1602 | access the contents of a variable: |
| 1603 | <literallayout class='monospaced'> |
| 1604 | SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz" |
| 1605 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1606 | <note> |
| 1607 | It is important to understand that the value of a |
| 1608 | variable expressed in this form does not get |
| 1609 | substituted automatically. |
| 1610 | The expansion of these expressions happens |
| 1611 | on-demand later (e.g. usually when a function that |
| 1612 | makes reference to the variable executes). |
| 1613 | This behavior ensures that the values are most |
| 1614 | appropriate for the context in which they are |
| 1615 | finally used. |
| 1616 | On the rare occasion that you do need the variable |
| 1617 | expression to be expanded immediately, you can use |
| 1618 | the <filename>:=</filename> operator instead of |
| 1619 | <filename>=</filename> when you make the |
| 1620 | assignment, but this is not generally needed. |
| 1621 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1622 | </para></listitem> |
| 1623 | <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> - |
| 1624 | Use double quotes around the value in all variable |
| 1625 | assignments. |
| 1626 | <literallayout class='monospaced'> |
| 1627 | VAR1 = "${OTHERVAR}" |
| 1628 | VAR2 = "The version is ${PV}" |
| 1629 | </literallayout> |
| 1630 | </para></listitem> |
| 1631 | <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> - |
| 1632 | Conditional assignment is used to assign a value to |
| 1633 | a variable, but only when the variable is currently |
| 1634 | unset. |
| 1635 | Use the question mark followed by the equal sign |
| 1636 | (<filename>?=</filename>) to make a "soft" assignment |
| 1637 | used for conditional assignment. |
| 1638 | Typically, "soft" assignments are used in the |
| 1639 | <filename>local.conf</filename> file for variables |
| 1640 | that are allowed to come through from the external |
| 1641 | environment. |
| 1642 | </para> |
| 1643 | <para>Here is an example where |
| 1644 | <filename>VAR1</filename> is set to "New value" if |
| 1645 | it is currently empty. |
| 1646 | However, if <filename>VAR1</filename> has already been |
| 1647 | set, it remains unchanged: |
| 1648 | <literallayout class='monospaced'> |
| 1649 | VAR1 ?= "New value" |
| 1650 | </literallayout> |
| 1651 | In this next example, <filename>VAR1</filename> |
| 1652 | is left with the value "Original value": |
| 1653 | <literallayout class='monospaced'> |
| 1654 | VAR1 = "Original value" |
| 1655 | VAR1 ?= "New value" |
| 1656 | </literallayout> |
| 1657 | </para></listitem> |
| 1658 | <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> - |
| 1659 | Use the plus character followed by the equals sign |
| 1660 | (<filename>+=</filename>) to append values to existing |
| 1661 | variables. |
| 1662 | <note> |
| 1663 | This operator adds a space between the existing |
| 1664 | content of the variable and the new content. |
| 1665 | </note></para> |
| 1666 | <para>Here is an example: |
| 1667 | <literallayout class='monospaced'> |
| 1668 | SRC_URI += "file://fix-makefile.patch" |
| 1669 | </literallayout> |
| 1670 | </para></listitem> |
| 1671 | <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> - |
| 1672 | Use the equals sign followed by the plus character |
| 1673 | (<filename>=+</filename>) to prepend values to existing |
| 1674 | variables. |
| 1675 | <note> |
| 1676 | This operator adds a space between the new content |
| 1677 | and the existing content of the variable. |
| 1678 | </note></para> |
| 1679 | <para>Here is an example: |
| 1680 | <literallayout class='monospaced'> |
| 1681 | VAR =+ "Starts" |
| 1682 | </literallayout> |
| 1683 | </para></listitem> |
| 1684 | <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> - |
| 1685 | Use the <filename>_append</filename> operator to |
| 1686 | append values to existing variables. |
| 1687 | This operator does not add any additional space. |
| 1688 | Also, the operator is applied after all the |
| 1689 | <filename>+=</filename>, and |
| 1690 | <filename>=+</filename> operators have been applied and |
| 1691 | after all <filename>=</filename> assignments have |
| 1692 | occurred. |
| 1693 | </para> |
| 1694 | <para>The following example shows the space being |
| 1695 | explicitly added to the start to ensure the appended |
| 1696 | value is not merged with the existing value: |
| 1697 | <literallayout class='monospaced'> |
| 1698 | SRC_URI_append = " file://fix-makefile.patch" |
| 1699 | </literallayout> |
| 1700 | You can also use the <filename>_append</filename> |
| 1701 | operator with overrides, which results in the actions |
| 1702 | only being performed for the specified target or |
| 1703 | machine: |
| 1704 | <literallayout class='monospaced'> |
| 1705 | SRC_URI_append_sh4 = " file://fix-makefile.patch" |
| 1706 | </literallayout> |
| 1707 | </para></listitem> |
| 1708 | <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> - |
| 1709 | Use the <filename>_prepend</filename> operator to |
| 1710 | prepend values to existing variables. |
| 1711 | This operator does not add any additional space. |
| 1712 | Also, the operator is applied after all the |
| 1713 | <filename>+=</filename>, and |
| 1714 | <filename>=+</filename> operators have been applied and |
| 1715 | after all <filename>=</filename> assignments have |
| 1716 | occurred. |
| 1717 | </para> |
| 1718 | <para>The following example shows the space being |
| 1719 | explicitly added to the end to ensure the prepended |
| 1720 | value is not merged with the existing value: |
| 1721 | <literallayout class='monospaced'> |
| 1722 | CFLAGS_prepend = "-I${S}/myincludes " |
| 1723 | </literallayout> |
| 1724 | You can also use the <filename>_prepend</filename> |
| 1725 | operator with overrides, which results in the actions |
| 1726 | only being performed for the specified target or |
| 1727 | machine: |
| 1728 | <literallayout class='monospaced'> |
| 1729 | CFLAGS_prepend_sh4 = "-I${S}/myincludes " |
| 1730 | </literallayout> |
| 1731 | </para></listitem> |
| 1732 | <listitem><para><emphasis>Overrides:</emphasis> - |
| 1733 | You can use overrides to set a value conditionally, |
| 1734 | typically based on how the recipe is being built. |
| 1735 | For example, to set the |
| 1736 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> |
| 1737 | variable's value to "standard/base" for any target |
| 1738 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 1739 | except for qemuarm where it should be set to |
| 1740 | "standard/arm-versatile-926ejs", you would do the |
| 1741 | following: |
| 1742 | <literallayout class='monospaced'> |
| 1743 | KBRANCH = "standard/base" |
| 1744 | KBRANCH_qemuarm = "standard/arm-versatile-926ejs" |
| 1745 | </literallayout> |
| 1746 | Overrides are also used to separate alternate values |
| 1747 | of a variable in other situations. |
| 1748 | For example, when setting variables such as |
| 1749 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 1750 | and |
| 1751 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 1752 | that are specific to individual packages produced by |
| 1753 | a recipe, you should always use an override that |
| 1754 | specifies the name of the package. |
| 1755 | </para></listitem> |
| 1756 | <listitem><para><emphasis>Indentation:</emphasis> |
| 1757 | Use spaces for indentation rather than than tabs. |
| 1758 | For shell functions, both currently work. |
| 1759 | However, it is a policy decision of the Yocto Project |
| 1760 | to use tabs in shell functions. |
| 1761 | Realize that some layers have a policy to use spaces |
| 1762 | for all indentation. |
| 1763 | </para></listitem> |
| 1764 | <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> - |
| 1765 | For more advanced processing, it is possible to use |
| 1766 | Python code during variable assignments (e.g. |
| 1767 | search and replacement on a variable).</para> |
| 1768 | <para>You indicate Python code using the |
| 1769 | <filename>${@<replaceable>python_code</replaceable>}</filename> |
| 1770 | syntax for the variable assignment: |
| 1771 | <literallayout class='monospaced'> |
| 1772 | SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz |
| 1773 | </literallayout> |
| 1774 | </para></listitem> |
| 1775 | <listitem><para><emphasis>Shell Function Syntax:</emphasis> |
| 1776 | Write shell functions as if you were writing a shell |
| 1777 | script when you describe a list of actions to take. |
| 1778 | You should ensure that your script works with a generic |
| 1779 | <filename>sh</filename> and that it does not require |
| 1780 | any <filename>bash</filename> or other shell-specific |
| 1781 | functionality. |
| 1782 | The same considerations apply to various system |
| 1783 | utilities (e.g. <filename>sed</filename>, |
| 1784 | <filename>grep</filename>, <filename>awk</filename>, |
| 1785 | and so forth) that you might wish to use. |
| 1786 | If in doubt, you should check with multiple |
| 1787 | implementations - including those from BusyBox. |
| 1788 | </para></listitem> |
| 1789 | </itemizedlist> |
| 1790 | </para> |
| 1791 | </section> |
| 1792 | |
| 1793 | <section id='new-recipe-running-a-build-on-the-recipe'> |
| 1794 | <title>Running a Build on the Recipe</title> |
| 1795 | |
| 1796 | <para> |
| 1797 | Creating a new recipe is usually an iterative process that |
| 1798 | requires using BitBake to process the recipe multiple times in |
| 1799 | order to progressively discover and add information to the |
| 1800 | recipe file. |
| 1801 | </para> |
| 1802 | |
| 1803 | <para> |
| 1804 | Assuming you have sourced a build environment setup script (i.e. |
| 1805 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 1806 | or |
| 1807 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>) |
| 1808 | and you are in the |
| 1809 | <link linkend='build-directory'>Build Directory</link>, |
| 1810 | use BitBake to process your recipe. |
| 1811 | All you need to provide is the |
| 1812 | <filename><replaceable>basename</replaceable></filename> of the recipe as described |
| 1813 | in the previous section: |
| 1814 | <literallayout class='monospaced'> |
| 1815 | $ bitbake <replaceable>basename</replaceable> |
| 1816 | </literallayout> |
| 1817 | |
| 1818 | </para> |
| 1819 | |
| 1820 | <para> |
| 1821 | During the build, the OpenEmbedded build system creates a |
| 1822 | temporary work directory for each recipe |
| 1823 | (<filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename>) |
| 1824 | where it keeps extracted source files, log files, intermediate |
| 1825 | compilation and packaging files, and so forth. |
| 1826 | </para> |
| 1827 | |
| 1828 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1829 | The path to the per-recipe temporary work directory depends |
| 1830 | on the context in which it is being built. |
| 1831 | The quickest way to find this path is to have BitBake return it |
| 1832 | by running the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1833 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1834 | $ bitbake -e <replaceable>basename</replaceable> | grep ^WORKDIR= |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1835 | </literallayout> |
| 1836 | As an example, assume a Source Directory top-level folder named |
| 1837 | <filename>poky</filename>, a default Build Directory at |
| 1838 | <filename>poky/build</filename>, and a |
| 1839 | <filename>qemux86-poky-linux</filename> machine target system. |
| 1840 | Furthermore, suppose your recipe is named |
| 1841 | <filename>foo_1.3.0.bb</filename>. |
| 1842 | In this case, the work directory the build system uses to |
| 1843 | build the package would be as follows: |
| 1844 | <literallayout class='monospaced'> |
| 1845 | poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0 |
| 1846 | </literallayout> |
| 1847 | Inside this directory you can find sub-directories such as |
| 1848 | <filename>image</filename>, <filename>packages-split</filename>, |
| 1849 | and <filename>temp</filename>. |
| 1850 | After the build, you can examine these to determine how well |
| 1851 | the build went. |
| 1852 | <note> |
| 1853 | You can find log files for each task in the recipe's |
| 1854 | <filename>temp</filename> directory (e.g. |
| 1855 | <filename>poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0/temp</filename>). |
| 1856 | Log files are named <filename>log.<replaceable>taskname</replaceable></filename> |
| 1857 | (e.g. <filename>log.do_configure</filename>, |
| 1858 | <filename>log.do_fetch</filename>, and |
| 1859 | <filename>log.do_compile</filename>). |
| 1860 | </note> |
| 1861 | </para> |
| 1862 | |
| 1863 | <para> |
| 1864 | You can find more information about the build process in the |
| 1865 | "<ulink url='&YOCTO_DOCS_REF_URL;#closer-look'>A Closer Look at the Yocto Project Development Environment</ulink>" |
| 1866 | chapter of the Yocto Project Reference Manual. |
| 1867 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1868 | </section> |
| 1869 | |
| 1870 | <section id='new-recipe-fetching-code'> |
| 1871 | <title>Fetching Code</title> |
| 1872 | |
| 1873 | <para> |
| 1874 | The first thing your recipe must do is specify how to fetch |
| 1875 | the source files. |
| 1876 | Fetching is controlled mainly through the |
| 1877 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1878 | variable. |
| 1879 | Your recipe must have a <filename>SRC_URI</filename> variable |
| 1880 | that points to where the source is located. |
| 1881 | For a graphical representation of source locations, see the |
| 1882 | "<ulink url='&YOCTO_DOCS_REF_URL;#sources-dev-environment'>Sources</ulink>" |
| 1883 | section in the Yocto Project Reference Manual. |
| 1884 | </para> |
| 1885 | |
| 1886 | <para> |
| 1887 | The |
| 1888 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 1889 | task uses the prefix of each entry in the |
| 1890 | <filename>SRC_URI</filename> variable value to determine which |
| 1891 | fetcher to use to get your source files. |
| 1892 | It is the <filename>SRC_URI</filename> variable that triggers |
| 1893 | the fetcher. |
| 1894 | The |
| 1895 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 1896 | task uses the variable after source is fetched to apply |
| 1897 | patches. |
| 1898 | The OpenEmbedded build system uses |
| 1899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESOVERRIDES'><filename>FILESOVERRIDES</filename></ulink> |
| 1900 | for scanning directory locations for local files in |
| 1901 | <filename>SRC_URI</filename>. |
| 1902 | </para> |
| 1903 | |
| 1904 | <para> |
| 1905 | The <filename>SRC_URI</filename> variable in your recipe must |
| 1906 | define each unique location for your source files. |
| 1907 | It is good practice to not hard-code pathnames in an URL used |
| 1908 | in <filename>SRC_URI</filename>. |
| 1909 | Rather than hard-code these paths, use |
| 1910 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 1911 | which causes the fetch process to use the version specified in |
| 1912 | the recipe filename. |
| 1913 | Specifying the version in this manner means that upgrading the |
| 1914 | recipe to a future version is as simple as renaming the recipe |
| 1915 | to match the new version. |
| 1916 | </para> |
| 1917 | |
| 1918 | <para> |
| 1919 | Here is a simple example from the |
| 1920 | <filename>meta/recipes-devtools/cdrtools/cdrtools-native_3.01a20.bb</filename> |
| 1921 | recipe where the source comes from a single tarball. |
| 1922 | Notice the use of the |
| 1923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1924 | variable: |
| 1925 | <literallayout class='monospaced'> |
| 1926 | SRC_URI = "ftp://ftp.berlios.de/pub/cdrecord/alpha/cdrtools-${PV}.tar.bz2" |
| 1927 | </literallayout> |
| 1928 | </para> |
| 1929 | |
| 1930 | <para> |
| 1931 | Files mentioned in <filename>SRC_URI</filename> whose names end |
| 1932 | in a typical archive extension (e.g. <filename>.tar</filename>, |
| 1933 | <filename>.tar.gz</filename>, <filename>.tar.bz2</filename>, |
| 1934 | <filename>.zip</filename>, and so forth), are automatically |
| 1935 | extracted during the |
| 1936 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 1937 | task. |
| 1938 | For another example that specifies these types of files, see |
| 1939 | the |
| 1940 | "<link linkend='new-recipe-autotooled-package'>Autotooled Package</link>" |
| 1941 | section. |
| 1942 | </para> |
| 1943 | |
| 1944 | <para> |
| 1945 | Another way of specifying source is from an SCM. |
| 1946 | For Git repositories, you must specify |
| 1947 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 1948 | and you should specify |
| 1949 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 1950 | to include the revision with |
| 1951 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 1952 | Here is an example from the recipe |
| 1953 | <filename>meta/recipes-kernel/blktrace/blktrace_git.bb</filename>: |
| 1954 | <literallayout class='monospaced'> |
| 1955 | SRCREV = "d6918c8832793b4205ed3bfede78c2f915c23385" |
| 1956 | |
| 1957 | PR = "r6" |
| 1958 | PV = "1.0.5+git${SRCPV}" |
| 1959 | |
| 1960 | SRC_URI = "git://git.kernel.dk/blktrace.git \ |
| 1961 | file://ldflags.patch" |
| 1962 | </literallayout> |
| 1963 | </para> |
| 1964 | |
| 1965 | <para> |
| 1966 | If your <filename>SRC_URI</filename> statement includes |
| 1967 | URLs pointing to individual files fetched from a remote server |
| 1968 | other than a version control system, BitBake attempts to |
| 1969 | verify the files against checksums defined in your recipe to |
| 1970 | ensure they have not been tampered with or otherwise modified |
| 1971 | since the recipe was written. |
| 1972 | Two checksums are used: |
| 1973 | <filename>SRC_URI[md5sum]</filename> and |
| 1974 | <filename>SRC_URI[sha256sum]</filename>. |
| 1975 | </para> |
| 1976 | |
| 1977 | <para> |
| 1978 | If your <filename>SRC_URI</filename> variable points to |
| 1979 | more than a single URL (excluding SCM URLs), you need to |
| 1980 | provide the <filename>md5</filename> and |
| 1981 | <filename>sha256</filename> checksums for each URL. |
| 1982 | For these cases, you provide a name for each URL as part of |
| 1983 | the <filename>SRC_URI</filename> and then reference that name |
| 1984 | in the subsequent checksum statements. |
| 1985 | Here is an example: |
| 1986 | <literallayout class='monospaced'> |
| 1987 | SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_3.2.2.orig.tar.gz;name=tarball \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1988 | ${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.diff.gz;name=patch" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1989 | |
| 1990 | SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8" |
| 1991 | SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d" |
| 1992 | |
| 1993 | SRC_URI[patch.md5sum] = "57e1b689264ea80f78353519eece0c92" |
| 1994 | SRC_URI[patch.sha256sum] = "7905ff96be93d725544d0040e425c42f9c05580db3c272f11cff75b9aa89d430" |
| 1995 | </literallayout> |
| 1996 | </para> |
| 1997 | |
| 1998 | <para> |
| 1999 | Proper values for <filename>md5</filename> and |
| 2000 | <filename>sha256</filename> checksums might be available |
| 2001 | with other signatures on the download page for the upstream |
| 2002 | source (e.g. <filename>md5</filename>, |
| 2003 | <filename>sha1</filename>, <filename>sha256</filename>, |
| 2004 | <filename>GPG</filename>, and so forth). |
| 2005 | Because the OpenEmbedded build system only deals with |
| 2006 | <filename>sha256sum</filename> and <filename>md5sum</filename>, |
| 2007 | you should verify all the signatures you find by hand. |
| 2008 | </para> |
| 2009 | |
| 2010 | <para> |
| 2011 | If no <filename>SRC_URI</filename> checksums are specified |
| 2012 | when you attempt to build the recipe, or you provide an |
| 2013 | incorrect checksum, the build will produce an error for each |
| 2014 | missing or incorrect checksum. |
| 2015 | As part of the error message, the build system provides |
| 2016 | the checksum string corresponding to the fetched file. |
| 2017 | Once you have the correct checksums, you can copy and paste |
| 2018 | them into your recipe and then run the build again to continue. |
| 2019 | <note> |
| 2020 | As mentioned, if the upstream source provides signatures |
| 2021 | for verifying the downloaded source code, you should |
| 2022 | verify those manually before setting the checksum values |
| 2023 | in the recipe and continuing with the build. |
| 2024 | </note> |
| 2025 | </para> |
| 2026 | |
| 2027 | <para> |
| 2028 | This final example is a bit more complicated and is from the |
| 2029 | <filename>meta/recipes-sato/rxvt-unicode/rxvt-unicode_9.20.bb</filename> |
| 2030 | recipe. |
| 2031 | The example's <filename>SRC_URI</filename> statement identifies |
| 2032 | multiple files as the source files for the recipe: a tarball, a |
| 2033 | patch file, a desktop file, and an icon. |
| 2034 | <literallayout class='monospaced'> |
| 2035 | SRC_URI = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${PV}.tar.bz2 \ |
| 2036 | file://xwc.patch \ |
| 2037 | file://rxvt.desktop \ |
| 2038 | file://rxvt.png" |
| 2039 | </literallayout> |
| 2040 | </para> |
| 2041 | |
| 2042 | <para> |
| 2043 | When you specify local files using the |
| 2044 | <filename>file://</filename> URI protocol, the build system |
| 2045 | fetches files from the local machine. |
| 2046 | The path is relative to the |
| 2047 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 2048 | variable and searches specific directories in a certain order: |
| 2049 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink><filename>}</filename>, |
| 2050 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}</filename>, |
| 2051 | and <filename>files</filename>. |
| 2052 | The directories are assumed to be subdirectories of the |
| 2053 | directory in which the recipe or append file resides. |
| 2054 | For another example that specifies these types of files, see the |
| 2055 | "<link linkend='new-recipe-single-c-file-package-hello-world'>Single .c File Package (Hello World!)</link>" |
| 2056 | section. |
| 2057 | </para> |
| 2058 | |
| 2059 | <para> |
| 2060 | The previous example also specifies a patch file. |
| 2061 | Patch files are files whose names usually end in |
| 2062 | <filename>.patch</filename> or <filename>.diff</filename> but |
| 2063 | can end with compressed suffixes such as |
| 2064 | <filename>diff.gz</filename> and |
| 2065 | <filename>patch.bz2</filename>, for example. |
| 2066 | The build system automatically applies patches as described |
| 2067 | in the |
| 2068 | "<link linkend='new-recipe-patching-code'>Patching Code</link>" section. |
| 2069 | </para> |
| 2070 | </section> |
| 2071 | |
| 2072 | <section id='new-recipe-unpacking-code'> |
| 2073 | <title>Unpacking Code</title> |
| 2074 | |
| 2075 | <para> |
| 2076 | During the build, the |
| 2077 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> |
| 2078 | task unpacks the source with |
| 2079 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename> |
| 2080 | pointing to where it is unpacked. |
| 2081 | </para> |
| 2082 | |
| 2083 | <para> |
| 2084 | If you are fetching your source files from an upstream source |
| 2085 | archived tarball and the tarball's internal structure matches |
| 2086 | the common convention of a top-level subdirectory named |
| 2087 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink><filename>}</filename>, |
| 2088 | then you do not need to set <filename>S</filename>. |
| 2089 | However, if <filename>SRC_URI</filename> specifies to fetch |
| 2090 | source from an archive that does not use this convention, |
| 2091 | or from an SCM like Git or Subversion, your recipe needs to |
| 2092 | define <filename>S</filename>. |
| 2093 | </para> |
| 2094 | |
| 2095 | <para> |
| 2096 | If processing your recipe using BitBake successfully unpacks |
| 2097 | the source files, you need to be sure that the directory |
| 2098 | pointed to by <filename>${S}</filename> matches the structure |
| 2099 | of the source. |
| 2100 | </para> |
| 2101 | </section> |
| 2102 | |
| 2103 | <section id='new-recipe-patching-code'> |
| 2104 | <title>Patching Code</title> |
| 2105 | |
| 2106 | <para> |
| 2107 | Sometimes it is necessary to patch code after it has been |
| 2108 | fetched. |
| 2109 | Any files mentioned in <filename>SRC_URI</filename> whose |
| 2110 | names end in <filename>.patch</filename> or |
| 2111 | <filename>.diff</filename> or compressed versions of these |
| 2112 | suffixes (e.g. <filename>diff.gz</filename> are treated as |
| 2113 | patches. |
| 2114 | The |
| 2115 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 2116 | task automatically applies these patches. |
| 2117 | </para> |
| 2118 | |
| 2119 | <para> |
| 2120 | The build system should be able to apply patches with the "-p1" |
| 2121 | option (i.e. one directory level in the path will be stripped |
| 2122 | off). |
| 2123 | If your patch needs to have more directory levels stripped off, |
| 2124 | specify the number of levels using the "striplevel" option in |
| 2125 | the <filename>SRC_URI</filename> entry for the patch. |
| 2126 | Alternatively, if your patch needs to be applied in a specific |
| 2127 | subdirectory that is not specified in the patch file, use the |
| 2128 | "patchdir" option in the entry. |
| 2129 | </para> |
| 2130 | |
| 2131 | <para> |
| 2132 | As with all local files referenced in |
| 2133 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 2134 | using <filename>file://</filename>, you should place |
| 2135 | patch files in a directory next to the recipe either |
| 2136 | named the same as the base name of the recipe |
| 2137 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-BP'><filename>BP</filename></ulink> |
| 2138 | and |
| 2139 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BPN'><filename>BPN</filename></ulink>) |
| 2140 | or "files". |
| 2141 | </para> |
| 2142 | </section> |
| 2143 | |
| 2144 | <section id='new-recipe-licensing'> |
| 2145 | <title>Licensing</title> |
| 2146 | |
| 2147 | <para> |
| 2148 | Your recipe needs to have both the |
| 2149 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 2150 | and |
| 2151 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 2152 | variables: |
| 2153 | <itemizedlist> |
| 2154 | <listitem><para><emphasis><filename>LICENSE</filename>:</emphasis> |
| 2155 | This variable specifies the license for the software. |
| 2156 | If you do not know the license under which the software |
| 2157 | you are building is distributed, you should go to the |
| 2158 | source code and look for that information. |
| 2159 | Typical files containing this information include |
| 2160 | <filename>COPYING</filename>, |
| 2161 | <filename>LICENSE</filename>, and |
| 2162 | <filename>README</filename> files. |
| 2163 | You could also find the information near the top of |
| 2164 | a source file. |
| 2165 | For example, given a piece of software licensed under |
| 2166 | the GNU General Public License version 2, you would |
| 2167 | set <filename>LICENSE</filename> as follows: |
| 2168 | <literallayout class='monospaced'> |
| 2169 | LICENSE = "GPLv2" |
| 2170 | </literallayout></para> |
| 2171 | <para>The licenses you specify within |
| 2172 | <filename>LICENSE</filename> can have any name as long |
| 2173 | as you do not use spaces, since spaces are used as |
| 2174 | separators between license names. |
| 2175 | For standard licenses, use the names of the files in |
| 2176 | <filename>meta/files/common-licenses/</filename> |
| 2177 | or the <filename>SPDXLICENSEMAP</filename> flag names |
| 2178 | defined in <filename>meta/conf/licenses.conf</filename>. |
| 2179 | </para></listitem> |
| 2180 | <listitem><para><emphasis><filename>LIC_FILES_CHKSUM</filename>:</emphasis> |
| 2181 | The OpenEmbedded build system uses this variable to |
| 2182 | make sure the license text has not changed. |
| 2183 | If it has, the build produces an error and it affords |
| 2184 | you the chance to figure it out and correct the problem. |
| 2185 | </para> |
| 2186 | <para>You need to specify all applicable licensing |
| 2187 | files for the software. |
| 2188 | At the end of the configuration step, the build process |
| 2189 | will compare the checksums of the files to be sure |
| 2190 | the text has not changed. |
| 2191 | Any differences result in an error with the message |
| 2192 | containing the current checksum. |
| 2193 | For more explanation and examples of how to set the |
| 2194 | <filename>LIC_FILES_CHKSUM</filename> variable, see the |
| 2195 | "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" |
| 2196 | section in the Yocto Project Reference Manual.</para> |
| 2197 | <para>To determine the correct checksum string, you |
| 2198 | can list the appropriate files in the |
| 2199 | <filename>LIC_FILES_CHKSUM</filename> variable with |
| 2200 | incorrect md5 strings, attempt to build the software, |
| 2201 | and then note the resulting error messages that will |
| 2202 | report the correct md5 strings. |
| 2203 | See the |
| 2204 | "<link linkend='new-recipe-fetching-code'>Fetching Code</link>" |
| 2205 | section for additional information. |
| 2206 | </para> |
| 2207 | |
| 2208 | <para> |
| 2209 | Here is an example that assumes the software has a |
| 2210 | <filename>COPYING</filename> file: |
| 2211 | <literallayout class='monospaced'> |
| 2212 | LIC_FILES_CHKSUM = "file://COPYING;md5=xxx" |
| 2213 | </literallayout> |
| 2214 | When you try to build the software, the build system |
| 2215 | will produce an error and give you the correct string |
| 2216 | that you can substitute into the recipe file for a |
| 2217 | subsequent build. |
| 2218 | </para></listitem> |
| 2219 | </itemizedlist> |
| 2220 | </para> |
| 2221 | |
| 2222 | <!-- |
| 2223 | |
| 2224 | <para> |
| 2225 | For trying this out I created a new recipe named |
| 2226 | <filename>htop_1.0.2.bb</filename> and put it in |
| 2227 | <filename>poky/meta/recipes-extended/htop</filename>. |
| 2228 | There are two license type statements in my very simple |
| 2229 | recipe: |
| 2230 | <literallayout class='monospaced'> |
| 2231 | LICENSE = "" |
| 2232 | |
| 2233 | LIC_FILES_CHKSUM = "" |
| 2234 | |
| 2235 | SRC_URI[md5sum] = "" |
| 2236 | SRC_URI[sha256sum] = "" |
| 2237 | </literallayout> |
| 2238 | Evidently, you need to run a <filename>bitbake -c cleanall htop</filename>. |
| 2239 | Next, you delete or comment out the two <filename>SRC_URI</filename> |
| 2240 | lines at the end and then attempt to build the software with |
| 2241 | <filename>bitbake htop</filename>. |
| 2242 | Doing so causes BitBake to report some errors and and give |
| 2243 | you the actual strings you need for the last two |
| 2244 | <filename>SRC_URI</filename> lines. |
| 2245 | Prior to this, you have to dig around in the home page of the |
| 2246 | source for <filename>htop</filename> and determine that the |
| 2247 | software is released under GPLv2. |
| 2248 | You can provide that in the <filename>LICENSE</filename> |
| 2249 | statement. |
| 2250 | Now you edit your recipe to have those two strings for |
| 2251 | the <filename>SRC_URI</filename> statements: |
| 2252 | <literallayout class='monospaced'> |
| 2253 | LICENSE = "GPLv2" |
| 2254 | |
| 2255 | LIC_FILES_CHKSUM = "" |
| 2256 | |
| 2257 | SRC_URI = "${SOURCEFORGE_MIRROR}/htop/htop-${PV}.tar.gz" |
| 2258 | SRC_URI[md5sum] = "0d01cca8df3349c74569cefebbd9919e" |
| 2259 | SRC_URI[sha256sum] = "ee60657b044ece0df096c053060df7abf3cce3a568ab34d260049e6a37ccd8a1" |
| 2260 | </literallayout> |
| 2261 | At this point, you can build the software again using the |
| 2262 | <filename>bitbake htop</filename> command. |
| 2263 | There is just a set of errors now associated with the |
| 2264 | empty <filename>LIC_FILES_CHKSUM</filename> variable now. |
| 2265 | </para> |
| 2266 | --> |
| 2267 | |
| 2268 | </section> |
| 2269 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2270 | <section id='new-dependencies'> |
| 2271 | <title>Dependencies</title> |
| 2272 | |
| 2273 | <para> |
| 2274 | Most software packages have a short list of other packages |
| 2275 | that they require, which are called dependencies. |
| 2276 | These dependencies fall into two main categories: build-time |
| 2277 | dependencies, which are required when the software is built; |
| 2278 | and runtime dependencies, which are required to be installed |
| 2279 | on the target in order for the software to run. |
| 2280 | </para> |
| 2281 | |
| 2282 | <para> |
| 2283 | Within a recipe, you specify build-time dependencies using the |
| 2284 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2285 | variable. |
| 2286 | Although nuances exist, items specified in |
| 2287 | <filename>DEPENDS</filename> should be names of other recipes. |
| 2288 | It is important that you specify all build-time dependencies |
| 2289 | explicitly. |
| 2290 | If you do not, due to the parallel nature of BitBake's |
| 2291 | execution, you can end up with a race condition where the |
| 2292 | dependency is present for one task of a recipe (e.g. |
| 2293 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink>) |
| 2294 | and then gone when the next task runs (e.g. |
| 2295 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>). |
| 2296 | </para> |
| 2297 | |
| 2298 | <para> |
| 2299 | Another consideration is that configure scripts might |
| 2300 | automatically check for optional dependencies and enable |
| 2301 | corresponding functionality if those dependencies are found. |
| 2302 | This behavior means that to ensure deterministic results and |
| 2303 | thus avoid more race conditions, you need to either explicitly |
| 2304 | specify these dependencies as well, or tell the configure |
| 2305 | script explicitly to disable the functionality. |
| 2306 | If you wish to make a recipe that is more generally useful |
| 2307 | (e.g. publish the recipe in a layer for others to use), |
| 2308 | instead of hard-disabling the functionality, you can use the |
| 2309 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG'><filename>PACKAGECONFIG</filename></ulink> |
| 2310 | variable to allow functionality and the corresponding |
| 2311 | dependencies to be enabled and disabled easily by other |
| 2312 | users of the recipe. |
| 2313 | </para> |
| 2314 | |
| 2315 | <para> |
| 2316 | Similar to build-time dependencies, you specify runtime |
| 2317 | dependencies through a variable - |
| 2318 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 2319 | which is package-specific. |
| 2320 | All variables that are package-specific need to have the name |
| 2321 | of the package added to the end as an override. |
| 2322 | Since the main package for a recipe has the same name as the |
| 2323 | recipe, and the recipe's name can be found through the |
| 2324 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2325 | variable, then you specify the dependencies for the main |
| 2326 | package by setting <filename>RDEPENDS_${PN}</filename>. |
| 2327 | If the package were named <filename>${PN}-tools</filename>, |
| 2328 | then you would set <filename>RDEPENDS_${PN}-tools</filename>, |
| 2329 | and so forth. |
| 2330 | </para> |
| 2331 | |
| 2332 | <para> |
| 2333 | Some runtime dependencies will be set automatically at |
| 2334 | packaging time. |
| 2335 | These dependencies include any shared library dependencies |
| 2336 | (i.e. if a package "example" contains "libexample" and |
| 2337 | another package "mypackage" contains a binary that links to |
| 2338 | "libexample" then the OpenEmbedded build system will |
| 2339 | automatically add a runtime dependency to "mypackage" on |
| 2340 | "example"). |
| 2341 | See the |
| 2342 | "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 2343 | in the Yocto Project Reference Manual for further details. |
| 2344 | </para> |
| 2345 | </section> |
| 2346 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2347 | <section id='new-recipe-configuring-the-recipe'> |
| 2348 | <title>Configuring the Recipe</title> |
| 2349 | |
| 2350 | <para> |
| 2351 | Most software provides some means of setting build-time |
| 2352 | configuration options before compilation. |
| 2353 | Typically, setting these options is accomplished by running a |
| 2354 | configure script with some options, or by modifying a build |
| 2355 | configuration file. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2356 | <note> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2357 | As of Yocto Project Release 1.7, some of the core recipes |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2358 | that package binary configuration scripts now disable the |
| 2359 | scripts due to the scripts previously requiring error-prone |
| 2360 | path substitution. |
| 2361 | The OpenEmbedded build system uses |
| 2362 | <filename>pkg-config</filename> now, which is much more |
| 2363 | robust. |
| 2364 | You can find a list of the <filename>*-config</filename> |
| 2365 | scripts that are disabled list in the |
| 2366 | "<ulink url='&YOCTO_DOCS_REF_URL;#migration-1.7-binary-configuration-scripts-disabled'>Binary Configuration Scripts Disabled</ulink>" |
| 2367 | section in the Yocto Project Reference Manual. |
| 2368 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2369 | </para> |
| 2370 | |
| 2371 | <para> |
| 2372 | A major part of build-time configuration is about checking for |
| 2373 | build-time dependencies and possibly enabling optional |
| 2374 | functionality as a result. |
| 2375 | You need to specify any build-time dependencies for the |
| 2376 | software you are building in your recipe's |
| 2377 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 2378 | value, in terms of other recipes that satisfy those |
| 2379 | dependencies. |
| 2380 | You can often find build-time or runtime |
| 2381 | dependencies described in the software's documentation. |
| 2382 | </para> |
| 2383 | |
| 2384 | <para> |
| 2385 | The following list provides configuration items of note based |
| 2386 | on how your software is built: |
| 2387 | <itemizedlist> |
| 2388 | <listitem><para><emphasis>Autotools:</emphasis> |
| 2389 | If your source files have a |
| 2390 | <filename>configure.ac</filename> file, then your |
| 2391 | software is built using Autotools. |
| 2392 | If this is the case, you just need to worry about |
| 2393 | modifying the configuration.</para> |
| 2394 | <para>When using Autotools, your recipe needs to inherit |
| 2395 | the |
| 2396 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2397 | class and your recipe does not have to contain a |
| 2398 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2399 | task. |
| 2400 | However, you might still want to make some adjustments. |
| 2401 | For example, you can set |
| 2402 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2403 | or |
| 2404 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2405 | to pass any needed configure options that are specific |
| 2406 | to the recipe.</para></listitem> |
| 2407 | <listitem><para><emphasis>CMake:</emphasis> |
| 2408 | If your source files have a |
| 2409 | <filename>CMakeLists.txt</filename> file, then your |
| 2410 | software is built using CMake. |
| 2411 | If this is the case, you just need to worry about |
| 2412 | modifying the configuration.</para> |
| 2413 | <para>When you use CMake, your recipe needs to inherit |
| 2414 | the |
| 2415 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2416 | class and your recipe does not have to contain a |
| 2417 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2418 | task. |
| 2419 | You can make some adjustments by setting |
| 2420 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink> |
| 2421 | to pass any needed configure options that are specific |
| 2422 | to the recipe.</para></listitem> |
| 2423 | <listitem><para><emphasis>Other:</emphasis> |
| 2424 | If your source files do not have a |
| 2425 | <filename>configure.ac</filename> or |
| 2426 | <filename>CMakeLists.txt</filename> file, then your |
| 2427 | software is built using some method other than Autotools |
| 2428 | or CMake. |
| 2429 | If this is the case, you normally need to provide a |
| 2430 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 2431 | task in your recipe |
| 2432 | unless, of course, there is nothing to configure. |
| 2433 | </para> |
| 2434 | <para>Even if your software is not being built by |
| 2435 | Autotools or CMake, you still might not need to deal |
| 2436 | with any configuration issues. |
| 2437 | You need to determine if configuration is even a required step. |
| 2438 | You might need to modify a Makefile or some configuration file |
| 2439 | used for the build to specify necessary build options. |
| 2440 | Or, perhaps you might need to run a provided, custom |
| 2441 | configure script with the appropriate options.</para> |
| 2442 | <para>For the case involving a custom configure |
| 2443 | script, you would run |
| 2444 | <filename>./configure --help</filename> and look for |
| 2445 | the options you need to set.</para></listitem> |
| 2446 | </itemizedlist> |
| 2447 | </para> |
| 2448 | |
| 2449 | <para> |
| 2450 | Once configuration succeeds, it is always good practice to |
| 2451 | look at the <filename>log.do_configure</filename> file to |
| 2452 | ensure that the appropriate options have been enabled and no |
| 2453 | additional build-time dependencies need to be added to |
| 2454 | <filename>DEPENDS</filename>. |
| 2455 | For example, if the configure script reports that it found |
| 2456 | something not mentioned in <filename>DEPENDS</filename>, or |
| 2457 | that it did not find something that it needed for some |
| 2458 | desired optional functionality, then you would need to add |
| 2459 | those to <filename>DEPENDS</filename>. |
| 2460 | Looking at the log might also reveal items being checked for, |
| 2461 | enabled, or both that you do not want, or items not being found |
| 2462 | that are in <filename>DEPENDS</filename>, in which case |
| 2463 | you would need to look at passing extra options to the |
| 2464 | configure script as needed. |
| 2465 | For reference information on configure options specific to the |
| 2466 | software you are building, you can consult the output of the |
| 2467 | <filename>./configure --help</filename> command within |
| 2468 | <filename>${S}</filename> or consult the software's upstream |
| 2469 | documentation. |
| 2470 | </para> |
| 2471 | </section> |
| 2472 | |
| 2473 | <section id='new-recipe-compilation'> |
| 2474 | <title>Compilation</title> |
| 2475 | |
| 2476 | <para> |
| 2477 | During a build, the <filename>do_compile</filename> task |
| 2478 | happens after source is fetched, unpacked, and configured. |
| 2479 | If the recipe passes through <filename>do_compile</filename> |
| 2480 | successfully, nothing needs to be done. |
| 2481 | </para> |
| 2482 | |
| 2483 | <para> |
| 2484 | However, if the compile step fails, you need to diagnose the |
| 2485 | failure. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2486 | Here are some common issues that cause failures. |
| 2487 | <note> |
| 2488 | For cases where improper paths are detected for |
| 2489 | configuration files or for when libraries/headers cannot |
| 2490 | be found, be sure you are using the more robust |
| 2491 | <filename>pkg-config</filename>. |
| 2492 | See the note in section |
| 2493 | "<link linkend='new-recipe-configuring-the-recipe'>Configuring the Recipe</link>" |
| 2494 | for additional information. |
| 2495 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2496 | <itemizedlist> |
| 2497 | <listitem><para><emphasis>Parallel build failures:</emphasis> |
| 2498 | These failures manifest themselves as intermittent |
| 2499 | errors, or errors reporting that a file or directory |
| 2500 | that should be created by some other part of the build |
| 2501 | process could not be found. |
| 2502 | This type of failure can occur even if, upon inspection, |
| 2503 | the file or directory does exist after the build has |
| 2504 | failed, because that part of the build process happened |
| 2505 | in the wrong order.</para> |
| 2506 | <para>To fix the problem, you need to either satisfy |
| 2507 | the missing dependency in the Makefile or whatever |
| 2508 | script produced the Makefile, or (as a workaround) |
| 2509 | set |
| 2510 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 2511 | to an empty string: |
| 2512 | <literallayout class='monospaced'> |
| 2513 | PARALLEL_MAKE = "" |
| 2514 | </literallayout></para> |
| 2515 | <para> |
| 2516 | For information on parallel Makefile issues, see the |
| 2517 | "<link linkend='debugging-parallel-make-races'>Debugging Parallel Make Races</link>" |
| 2518 | section. |
| 2519 | </para></listitem> |
| 2520 | <listitem><para><emphasis>Improper host path usage:</emphasis> |
| 2521 | This failure applies to recipes building for the target |
| 2522 | or <filename>nativesdk</filename> only. |
| 2523 | The failure occurs when the compilation process uses |
| 2524 | improper headers, libraries, or other files from the |
| 2525 | host system when cross-compiling for the target. |
| 2526 | </para> |
| 2527 | <para>To fix the problem, examine the |
| 2528 | <filename>log.do_compile</filename> file to identify |
| 2529 | the host paths being used (e.g. |
| 2530 | <filename>/usr/include</filename>, |
| 2531 | <filename>/usr/lib</filename>, and so forth) and then |
| 2532 | either add configure options, apply a patch, or do both. |
| 2533 | </para></listitem> |
| 2534 | <listitem><para><emphasis>Failure to find required |
| 2535 | libraries/headers:</emphasis> |
| 2536 | If a build-time dependency is missing because it has |
| 2537 | not been declared in |
| 2538 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 2539 | or because the dependency exists but the path used by |
| 2540 | the build process to find the file is incorrect and the |
| 2541 | configure step did not detect it, the compilation |
| 2542 | process could fail. |
| 2543 | For either of these failures, the compilation process |
| 2544 | notes that files could not be found. |
| 2545 | In these cases, you need to go back and add additional |
| 2546 | options to the configure script as well as possibly |
| 2547 | add additional build-time dependencies to |
| 2548 | <filename>DEPENDS</filename>.</para> |
| 2549 | <para>Occasionally, it is necessary to apply a patch |
| 2550 | to the source to ensure the correct paths are used. |
| 2551 | If you need to specify paths to find files staged |
| 2552 | into the sysroot from other recipes, use the variables |
| 2553 | that the OpenEmbedded build system provides |
| 2554 | (e.g. |
| 2555 | <filename>STAGING_BINDIR</filename>, |
| 2556 | <filename>STAGING_INCDIR</filename>, |
| 2557 | <filename>STAGING_DATADIR</filename>, and so forth). |
| 2558 | <!-- |
| 2559 | (e.g. |
| 2560 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_BINDIR'><filename>STAGING_BINDIR</filename></ulink>, |
| 2561 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_INCDIR'><filename>STAGING_INCDIR</filename></ulink>, |
| 2562 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DATADIR'><filename>STAGING_DATADIR</filename></ulink>, |
| 2563 | and so forth). |
| 2564 | --> |
| 2565 | </para></listitem> |
| 2566 | </itemizedlist> |
| 2567 | </para> |
| 2568 | </section> |
| 2569 | |
| 2570 | <section id='new-recipe-installing'> |
| 2571 | <title>Installing</title> |
| 2572 | |
| 2573 | <para> |
| 2574 | During <filename>do_install</filename>, the task copies the |
| 2575 | built files along with their hierarchy to locations that |
| 2576 | would mirror their locations on the target device. |
| 2577 | The installation process copies files from the |
| 2578 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>, |
| 2579 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>, |
| 2580 | and |
| 2581 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> |
| 2582 | directories to the |
| 2583 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2584 | directory to create the structure as it should appear on the |
| 2585 | target system. |
| 2586 | </para> |
| 2587 | |
| 2588 | <para> |
| 2589 | How your software is built affects what you must do to be |
| 2590 | sure your software is installed correctly. |
| 2591 | The following list describes what you must do for installation |
| 2592 | depending on the type of build system used by the software |
| 2593 | being built: |
| 2594 | <itemizedlist> |
| 2595 | <listitem><para><emphasis>Autotools and CMake:</emphasis> |
| 2596 | If the software your recipe is building uses Autotools |
| 2597 | or CMake, the OpenEmbedded build |
| 2598 | system understands how to install the software. |
| 2599 | Consequently, you do not have to have a |
| 2600 | <filename>do_install</filename> task as part of your |
| 2601 | recipe. |
| 2602 | You just need to make sure the install portion of the |
| 2603 | build completes with no issues. |
| 2604 | However, if you wish to install additional files not |
| 2605 | already being installed by |
| 2606 | <filename>make install</filename>, you should do this |
| 2607 | using a <filename>do_install_append</filename> function |
| 2608 | using the install command as described in |
| 2609 | the "Manual" bulleted item later in this list. |
| 2610 | </para></listitem> |
| 2611 | <listitem><para><emphasis>Other (using |
| 2612 | <filename>make install</filename>):</emphasis> |
| 2613 | You need to define a |
| 2614 | <filename>do_install</filename> function in your |
| 2615 | recipe. |
| 2616 | The function should call |
| 2617 | <filename>oe_runmake install</filename> and will likely |
| 2618 | need to pass in the destination directory as well. |
| 2619 | How you pass that path is dependent on how the |
| 2620 | <filename>Makefile</filename> being run is written |
| 2621 | (e.g. <filename>DESTDIR=${D}</filename>, |
| 2622 | <filename>PREFIX=${D}</filename>, |
| 2623 | <filename>INSTALLROOT=${D}</filename>, and so forth). |
| 2624 | </para> |
| 2625 | <para>For an example recipe using |
| 2626 | <filename>make install</filename>, see the |
| 2627 | "<link linkend='new-recipe-makefile-based-package'>Makefile-Based Package</link>" |
| 2628 | section.</para></listitem> |
| 2629 | <listitem><para><emphasis>Manual:</emphasis> |
| 2630 | You need to define a |
| 2631 | <filename>do_install</filename> function in your |
| 2632 | recipe. |
| 2633 | The function must first use |
| 2634 | <filename>install -d</filename> to create the |
| 2635 | directories under |
| 2636 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>. |
| 2637 | Once the directories exist, your function can use |
| 2638 | <filename>install</filename> to manually install the |
| 2639 | built software into the directories.</para> |
| 2640 | <para>You can find more information on |
| 2641 | <filename>install</filename> at |
| 2642 | <ulink url='http://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html'></ulink>. |
| 2643 | </para></listitem> |
| 2644 | </itemizedlist> |
| 2645 | </para> |
| 2646 | |
| 2647 | <para> |
| 2648 | For the scenarios that do not use Autotools or |
| 2649 | CMake, you need to track the installation |
| 2650 | and diagnose and fix any issues until everything installs |
| 2651 | correctly. |
| 2652 | You need to look in the default location of |
| 2653 | <filename>${D}</filename>, which is |
| 2654 | <filename>${WORKDIR}/image</filename>, to be sure your |
| 2655 | files have been installed correctly. |
| 2656 | </para> |
| 2657 | |
| 2658 | <note><title>Notes</title> |
| 2659 | <itemizedlist> |
| 2660 | <listitem><para> |
| 2661 | During the installation process, you might need to |
| 2662 | modify some of the installed files to suit the target |
| 2663 | layout. |
| 2664 | For example, you might need to replace hard-coded paths |
| 2665 | in an initscript with values of variables provided by |
| 2666 | the build system, such as replacing |
| 2667 | <filename>/usr/bin/</filename> with |
| 2668 | <filename>${bindir}</filename>. |
| 2669 | If you do perform such modifications during |
| 2670 | <filename>do_install</filename>, be sure to modify the |
| 2671 | destination file after copying rather than before |
| 2672 | copying. |
| 2673 | Modifying after copying ensures that the build system |
| 2674 | can re-execute <filename>do_install</filename> if |
| 2675 | needed. |
| 2676 | </para></listitem> |
| 2677 | <listitem><para> |
| 2678 | <filename>oe_runmake install</filename>, which can be |
| 2679 | run directly or can be run indirectly by the |
| 2680 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 2681 | and |
| 2682 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-cmake'><filename>cmake</filename></ulink> |
| 2683 | classes, runs <filename>make install</filename> in |
| 2684 | parallel. |
| 2685 | Sometimes, a Makefile can have missing dependencies |
| 2686 | between targets that can result in race conditions. |
| 2687 | If you experience intermittent failures during |
| 2688 | <filename>do_install</filename>, you might be able to |
| 2689 | work around them by disabling parallel Makefile |
| 2690 | installs by adding the following to the recipe: |
| 2691 | <literallayout class='monospaced'> |
| 2692 | PARALLEL_MAKEINST = "" |
| 2693 | </literallayout> |
| 2694 | See |
| 2695 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 2696 | for additional information. |
| 2697 | </para></listitem> |
| 2698 | </itemizedlist> |
| 2699 | </note> |
| 2700 | </section> |
| 2701 | |
| 2702 | <section id='new-recipe-enabling-system-services'> |
| 2703 | <title>Enabling System Services</title> |
| 2704 | |
| 2705 | <para> |
| 2706 | If you want to install a service, which is a process that |
| 2707 | usually starts on boot and runs in the background, then |
| 2708 | you must include some additional definitions in your recipe. |
| 2709 | </para> |
| 2710 | |
| 2711 | <para> |
| 2712 | If you are adding services and the service initialization |
| 2713 | script or the service file itself is not installed, you must |
| 2714 | provide for that installation in your recipe using a |
| 2715 | <filename>do_install_append</filename> function. |
| 2716 | If your recipe already has a <filename>do_install</filename> |
| 2717 | function, update the function near its end rather than |
| 2718 | adding an additional <filename>do_install_append</filename> |
| 2719 | function. |
| 2720 | </para> |
| 2721 | |
| 2722 | <para> |
| 2723 | When you create the installation for your services, you need |
| 2724 | to accomplish what is normally done by |
| 2725 | <filename>make install</filename>. |
| 2726 | In other words, make sure your installation arranges the output |
| 2727 | similar to how it is arranged on the target system. |
| 2728 | </para> |
| 2729 | |
| 2730 | <para> |
| 2731 | The OpenEmbedded build system provides support for starting |
| 2732 | services two different ways: |
| 2733 | <itemizedlist> |
| 2734 | <listitem><para><emphasis>SysVinit:</emphasis> |
| 2735 | SysVinit is a system and service manager that |
| 2736 | manages the init system used to control the very basic |
| 2737 | functions of your system. |
| 2738 | The init program is the first program |
| 2739 | started by the Linux kernel when the system boots. |
| 2740 | Init then controls the startup, running and shutdown |
| 2741 | of all other programs.</para> |
| 2742 | <para>To enable a service using SysVinit, your recipe |
| 2743 | needs to inherit the |
| 2744 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-update-rc.d'><filename>update-rc.d</filename></ulink> |
| 2745 | class. |
| 2746 | The class helps facilitate safely installing the |
| 2747 | package on the target.</para> |
| 2748 | <para>You will need to set the |
| 2749 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PACKAGES'><filename>INITSCRIPT_PACKAGES</filename></ulink>, |
| 2750 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_NAME'><filename>INITSCRIPT_NAME</filename></ulink>, |
| 2751 | and |
| 2752 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITSCRIPT_PARAMS'><filename>INITSCRIPT_PARAMS</filename></ulink> |
| 2753 | variables within your recipe.</para></listitem> |
| 2754 | <listitem><para><emphasis>systemd:</emphasis> |
| 2755 | System Management Daemon (systemd) was designed to |
| 2756 | replace SysVinit and to provide |
| 2757 | enhanced management of services. |
| 2758 | For more information on systemd, see the systemd |
| 2759 | homepage at |
| 2760 | <ulink url='http://freedesktop.org/wiki/Software/systemd/'></ulink>. |
| 2761 | </para> |
| 2762 | <para>To enable a service using systemd, your recipe |
| 2763 | needs to inherit the |
| 2764 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-systemd'><filename>systemd</filename></ulink> |
| 2765 | class. |
| 2766 | See the <filename>systemd.bbclass</filename> file |
| 2767 | located in your |
| 2768 | <link linkend='source-directory'>Source Directory</link>. |
| 2769 | section for more information. |
| 2770 | </para></listitem> |
| 2771 | </itemizedlist> |
| 2772 | </para> |
| 2773 | </section> |
| 2774 | |
| 2775 | <section id='new-recipe-packaging'> |
| 2776 | <title>Packaging</title> |
| 2777 | |
| 2778 | <para> |
| 2779 | Successful packaging is a combination of automated processes |
| 2780 | performed by the OpenEmbedded build system and some |
| 2781 | specific steps you need to take. |
| 2782 | The following list describes the process: |
| 2783 | <itemizedlist> |
| 2784 | <listitem><para><emphasis>Splitting Files</emphasis>: |
| 2785 | The <filename>do_package</filename> task splits the |
| 2786 | files produced by the recipe into logical components. |
| 2787 | Even software that produces a single binary might |
| 2788 | still have debug symbols, documentation, and other |
| 2789 | logical components that should be split out. |
| 2790 | The <filename>do_package</filename> task ensures |
| 2791 | that files are split up and packaged correctly. |
| 2792 | </para></listitem> |
| 2793 | <listitem><para><emphasis>Running QA Checks</emphasis>: |
| 2794 | The |
| 2795 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2796 | class adds a step to |
| 2797 | the package generation process so that output quality |
| 2798 | assurance checks are generated by the OpenEmbedded |
| 2799 | build system. |
| 2800 | This step performs a range of checks to be sure the |
| 2801 | build's output is free of common problems that show |
| 2802 | up during runtime. |
| 2803 | For information on these checks, see the |
| 2804 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> |
| 2805 | class and the |
| 2806 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-qa-checks'>QA Error and Warning Messages</ulink>" |
| 2807 | chapter in the Yocto Project Reference Manual. |
| 2808 | </para></listitem> |
| 2809 | <listitem><para><emphasis>Hand-Checking Your Packages</emphasis>: |
| 2810 | After you build your software, you need to be sure |
| 2811 | your packages are correct. |
| 2812 | Examine the |
| 2813 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}/packages-split</filename> |
| 2814 | directory and make sure files are where you expect |
| 2815 | them to be. |
| 2816 | If you discover problems, you can set |
| 2817 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, |
| 2818 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 2819 | <filename>do_install(_append)</filename>, and so forth as |
| 2820 | needed. |
| 2821 | </para></listitem> |
| 2822 | <listitem><para><emphasis>Splitting an Application into Multiple Packages</emphasis>: |
| 2823 | If you need to split an application into several |
| 2824 | packages, see the |
| 2825 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 2826 | section for an example. |
| 2827 | </para></listitem> |
| 2828 | <listitem><para><emphasis>Installing a Post-Installation Script</emphasis>: |
| 2829 | For an example showing how to install a |
| 2830 | post-installation script, see the |
| 2831 | "<link linkend='new-recipe-post-installation-scripts'>Post-Installation Scripts</link>" |
| 2832 | section. |
| 2833 | </para></listitem> |
| 2834 | <listitem><para><emphasis>Marking Package Architecture</emphasis>: |
| 2835 | Depending on what your recipe is building and how it |
| 2836 | is configured, it might be important to mark the |
| 2837 | packages produced as being specific to a particular |
| 2838 | machine, or to mark them as not being specific to |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2839 | a particular machine or architecture at all.</para> |
| 2840 | <para>By default, packages apply to any machine with the |
| 2841 | same architecture as the target machine. |
| 2842 | When a recipe produces packages that are |
| 2843 | machine-specific (e.g. the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2844 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 2845 | value is passed into the configure script or a patch |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2846 | is applied only for a particular machine), you should |
| 2847 | mark them as such by adding the following to the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2848 | recipe: |
| 2849 | <literallayout class='monospaced'> |
| 2850 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 2851 | </literallayout></para> |
| 2852 | <para>On the other hand, if the recipe produces packages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2853 | that do not contain anything specific to the target |
| 2854 | machine or architecture at all (e.g. recipes |
| 2855 | that simply package script files or configuration |
| 2856 | files), you should use the |
| 2857 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 2858 | class to do this for you by adding this to your |
| 2859 | recipe: |
| 2860 | <literallayout class='monospaced'> |
| 2861 | inherit allarch |
| 2862 | </literallayout> |
| 2863 | Ensuring that the package architecture is correct is |
| 2864 | not critical while you are doing the first few builds |
| 2865 | of your recipe. |
| 2866 | However, it is important in order |
| 2867 | to ensure that your recipe rebuilds (or does not |
| 2868 | rebuild) appropriately in response to changes in |
| 2869 | configuration, and to ensure that you get the |
| 2870 | appropriate packages installed on the target machine, |
| 2871 | particularly if you run separate builds for more |
| 2872 | than one target machine. |
| 2873 | </para></listitem> |
| 2874 | </itemizedlist> |
| 2875 | </para> |
| 2876 | </section> |
| 2877 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2878 | <section id='new-sharing-files-between-recipes'> |
| 2879 | <title>Sharing Files Between Recipes</title> |
| 2880 | |
| 2881 | <para> |
| 2882 | Recipes often need to use files provided by other recipes on |
| 2883 | the build host. |
| 2884 | For example, an application linking to a common library needs |
| 2885 | access to the library itself and its associated headers. |
| 2886 | The way this access is accomplished is by populating sysroot |
| 2887 | with files. |
| 2888 | One sysroot exists per "machine" for which the image is |
| 2889 | being built. |
| 2890 | In practical terms, this means a sysroot exists for the target |
| 2891 | machine, and a sysroot exists for the build host. |
| 2892 | <note> |
| 2893 | You could find the term "staging" used within the Yocto |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 2894 | project regarding files populating sysroot (e.g. the |
| 2895 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_DIR'><filename>STAGING_DIR</filename></ulink> |
| 2896 | variable). |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2897 | </note> |
| 2898 | </para> |
| 2899 | |
| 2900 | <para> |
| 2901 | Recipes should never populate the sysroot directly (i.e. write |
| 2902 | files into sysroot). |
| 2903 | Instead, files should be installed into standard locations |
| 2904 | during the |
| 2905 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 2906 | task within the |
| 2907 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 2908 | directory. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 2909 | </para> |
| 2910 | |
| 2911 | <para> |
| 2912 | A subset of these files, as defined by the |
| 2913 | the <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink> |
| 2914 | variable, automatically populates the sysroot. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2915 | The reason for this limitation is that almost all files that |
| 2916 | populate the sysroot are cataloged in manifests in order to |
| 2917 | ensure the files can be removed later when a recipe is either |
| 2918 | modified or removed. |
| 2919 | Thus, the sysroot is able to remain free from stale files. |
| 2920 | </para> |
| 2921 | |
| 2922 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 2923 | It is possible to modify the list of directories that populate |
| 2924 | the sysroot. |
| 2925 | The following example shows how you could add the |
| 2926 | <filename>/opt</filename> directory to the list of |
| 2927 | directories: |
| 2928 | <literallayout class='monospaced'> |
| 2929 | SYSROOT_DIRS += "/opt" |
| 2930 | </literallayout> |
| 2931 | </para> |
| 2932 | |
| 2933 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 2934 | For information on variables you can use to help control how |
| 2935 | files sysroot is populated, see the |
| 2936 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS'><filename>SYSROOT_DIRS</filename></ulink>, |
| 2937 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS_NATIVE'><filename>SYSROOT_DIRS_NATIVE</filename></ulink>, |
| 2938 | and |
| 2939 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SYSROOT_DIRS_BLACKLIST'><filename>SYSROOT_DIRS_BLACKLIST</filename></ulink> |
| 2940 | variables. |
| 2941 | </para> |
| 2942 | </section> |
| 2943 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2944 | <section id='properly-versioning-pre-release-recipes'> |
| 2945 | <title>Properly Versioning Pre-Release Recipes</title> |
| 2946 | |
| 2947 | <para> |
| 2948 | Sometimes the name of a recipe can lead to versioning |
| 2949 | problems when the recipe is upgraded to a final release. |
| 2950 | For example, consider the |
| 2951 | <filename>irssi_0.8.16-rc1.bb</filename> recipe file in |
| 2952 | the list of example recipes in the |
| 2953 | "<link linkend='new-recipe-storing-and-naming-the-recipe'>Storing and Naming the Recipe</link>" |
| 2954 | section. |
| 2955 | This recipe is at a release candidate stage (i.e. |
| 2956 | "rc1"). |
| 2957 | When the recipe is released, the recipe filename becomes |
| 2958 | <filename>irssi_0.8.16.bb</filename>. |
| 2959 | The version change from <filename>0.8.16-rc1</filename> |
| 2960 | to <filename>0.8.16</filename> is seen as a decrease by the |
| 2961 | build system and package managers, so the resulting packages |
| 2962 | will not correctly trigger an upgrade. |
| 2963 | </para> |
| 2964 | |
| 2965 | <para> |
| 2966 | In order to ensure the versions compare properly, the |
| 2967 | recommended convention is to set |
| 2968 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 2969 | within the recipe to |
| 2970 | "<replaceable>previous_version</replaceable>+<replaceable>current_version</replaceable>". |
| 2971 | You can use an additional variable so that you can use the |
| 2972 | current version elsewhere. |
| 2973 | Here is an example: |
| 2974 | <literallayout class='monospaced'> |
| 2975 | REALPV = "0.8.16-rc1" |
| 2976 | PV = "0.8.15+${REALPV}" |
| 2977 | </literallayout> |
| 2978 | </para> |
| 2979 | </section> |
| 2980 | |
| 2981 | <section id='new-recipe-post-installation-scripts'> |
| 2982 | <title>Post-Installation Scripts</title> |
| 2983 | |
| 2984 | <para> |
| 2985 | Post-installation scripts run immediately after installing |
| 2986 | a package on the target or during image creation when a |
| 2987 | package is included in an image. |
| 2988 | To add a post-installation script to a package, add a |
| 2989 | <filename>pkg_postinst_PACKAGENAME()</filename> function to |
| 2990 | the recipe file (<filename>.bb</filename>) and replace |
| 2991 | <filename>PACKAGENAME</filename> with the name of the package |
| 2992 | you want to attach to the <filename>postinst</filename> |
| 2993 | script. |
| 2994 | To apply the post-installation script to the main package |
| 2995 | for the recipe, which is usually what is required, specify |
| 2996 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 2997 | in place of <filename>PACKAGENAME</filename>. |
| 2998 | </para> |
| 2999 | |
| 3000 | <para> |
| 3001 | A post-installation function has the following structure: |
| 3002 | <literallayout class='monospaced'> |
| 3003 | pkg_postinst_PACKAGENAME() { |
| 3004 | # Commands to carry out |
| 3005 | } |
| 3006 | </literallayout> |
| 3007 | </para> |
| 3008 | |
| 3009 | <para> |
| 3010 | The script defined in the post-installation function is |
| 3011 | called when the root filesystem is created. |
| 3012 | If the script succeeds, the package is marked as installed. |
| 3013 | If the script fails, the package is marked as unpacked and |
| 3014 | the script is executed when the image boots again. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3015 | <note> |
| 3016 | Any RPM post-installation script that runs on the target |
| 3017 | should return a 0 exit code. |
| 3018 | RPM does not allow non-zero exit codes for these scripts, |
| 3019 | and the RPM package manager will cause the package to fail |
| 3020 | installation on the target. |
| 3021 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3022 | </para> |
| 3023 | |
| 3024 | <para> |
| 3025 | Sometimes it is necessary for the execution of a |
| 3026 | post-installation script to be delayed until the first boot. |
| 3027 | For example, the script might need to be executed on the |
| 3028 | device itself. |
| 3029 | To delay script execution until boot time, use the following |
| 3030 | structure in the post-installation script: |
| 3031 | <literallayout class='monospaced'> |
| 3032 | pkg_postinst_PACKAGENAME() { |
| 3033 | if [ x"$D" = "x" ]; then |
| 3034 | # Actions to carry out on the device go here |
| 3035 | else |
| 3036 | exit 1 |
| 3037 | fi |
| 3038 | } |
| 3039 | </literallayout> |
| 3040 | </para> |
| 3041 | |
| 3042 | <para> |
| 3043 | The previous example delays execution until the image boots |
| 3044 | again because the environment variable <filename>D</filename> |
| 3045 | points to the directory containing the image when |
| 3046 | the root filesystem is created at build time but is unset |
| 3047 | when executed on the first boot. |
| 3048 | </para> |
| 3049 | |
| 3050 | <note> |
| 3051 | Equivalent support for pre-install, pre-uninstall, and |
| 3052 | post-uninstall scripts exist by way of |
| 3053 | <filename>pkg_preinst</filename>, |
| 3054 | <filename>pkg_prerm</filename>, and |
| 3055 | <filename>pkg_postrm</filename>, respectively. |
| 3056 | These scrips work in exactly the same way as does |
| 3057 | <filename>pkg_postinst</filename> with the exception that they |
| 3058 | run at different times. |
| 3059 | Also, because of when they run, they are not applicable to |
| 3060 | being run at image creation time like |
| 3061 | <filename>pkg_postinst</filename>. |
| 3062 | </note> |
| 3063 | </section> |
| 3064 | |
| 3065 | <section id='new-recipe-testing'> |
| 3066 | <title>Testing</title> |
| 3067 | |
| 3068 | <para> |
| 3069 | The final step for completing your recipe is to be sure that |
| 3070 | the software you built runs correctly. |
| 3071 | To accomplish runtime testing, add the build's output |
| 3072 | packages to your image and test them on the target. |
| 3073 | </para> |
| 3074 | |
| 3075 | <para> |
| 3076 | For information on how to customize your image by adding |
| 3077 | specific packages, see the |
| 3078 | "<link linkend='usingpoky-extend-customimage'>Customizing Images</link>" |
| 3079 | section. |
| 3080 | </para> |
| 3081 | </section> |
| 3082 | |
| 3083 | <section id='new-recipe-testing-examples'> |
| 3084 | <title>Examples</title> |
| 3085 | |
| 3086 | <para> |
| 3087 | To help summarize how to write a recipe, this section provides |
| 3088 | some examples given various scenarios: |
| 3089 | <itemizedlist> |
| 3090 | <listitem><para>Recipes that use local files</para></listitem> |
| 3091 | <listitem><para>Using an Autotooled package</para></listitem> |
| 3092 | <listitem><para>Using a Makefile-based package</para></listitem> |
| 3093 | <listitem><para>Splitting an application into multiple packages</para></listitem> |
| 3094 | <listitem><para>Adding binaries to an image</para></listitem> |
| 3095 | </itemizedlist> |
| 3096 | </para> |
| 3097 | |
| 3098 | <section id='new-recipe-single-c-file-package-hello-world'> |
| 3099 | <title>Single .c File Package (Hello World!)</title> |
| 3100 | |
| 3101 | <para> |
| 3102 | Building an application from a single file that is stored |
| 3103 | locally (e.g. under <filename>files</filename>) requires |
| 3104 | a recipe that has the file listed in the |
| 3105 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> |
| 3106 | variable. |
| 3107 | Additionally, you need to manually write the |
| 3108 | <filename>do_compile</filename> and |
| 3109 | <filename>do_install</filename> tasks. |
| 3110 | The <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3111 | variable defines the directory containing the source code, |
| 3112 | which is set to |
| 3113 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 3114 | in this case - the directory BitBake uses for the build. |
| 3115 | <literallayout class='monospaced'> |
| 3116 | SUMMARY = "Simple helloworld application" |
| 3117 | SECTION = "examples" |
| 3118 | LICENSE = "MIT" |
| 3119 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" |
| 3120 | |
| 3121 | SRC_URI = "file://helloworld.c" |
| 3122 | |
| 3123 | S = "${WORKDIR}" |
| 3124 | |
| 3125 | do_compile() { |
| 3126 | ${CC} helloworld.c -o helloworld |
| 3127 | } |
| 3128 | |
| 3129 | do_install() { |
| 3130 | install -d ${D}${bindir} |
| 3131 | install -m 0755 helloworld ${D}${bindir} |
| 3132 | } |
| 3133 | </literallayout> |
| 3134 | </para> |
| 3135 | |
| 3136 | <para> |
| 3137 | By default, the <filename>helloworld</filename>, |
| 3138 | <filename>helloworld-dbg</filename>, and |
| 3139 | <filename>helloworld-dev</filename> packages are built. |
| 3140 | For information on how to customize the packaging process, |
| 3141 | see the |
| 3142 | "<link linkend='splitting-an-application-into-multiple-packages'>Splitting an Application into Multiple Packages</link>" |
| 3143 | section. |
| 3144 | </para> |
| 3145 | </section> |
| 3146 | |
| 3147 | <section id='new-recipe-autotooled-package'> |
| 3148 | <title>Autotooled Package</title> |
| 3149 | <para> |
| 3150 | Applications that use Autotools such as <filename>autoconf</filename> and |
| 3151 | <filename>automake</filename> require a recipe that has a source archive listed in |
| 3152 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename> and |
| 3153 | also inherit the |
| 3154 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> |
| 3155 | class, which contains the definitions of all the steps |
| 3156 | needed to build an Autotool-based application. |
| 3157 | The result of the build is automatically packaged. |
| 3158 | And, if the application uses NLS for localization, packages with local information are |
| 3159 | generated (one package per language). |
| 3160 | Following is one example: (<filename>hello_2.3.bb</filename>) |
| 3161 | <literallayout class='monospaced'> |
| 3162 | SUMMARY = "GNU Helloworld application" |
| 3163 | SECTION = "examples" |
| 3164 | LICENSE = "GPLv2+" |
| 3165 | LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" |
| 3166 | |
| 3167 | SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz" |
| 3168 | |
| 3169 | inherit autotools gettext |
| 3170 | </literallayout> |
| 3171 | </para> |
| 3172 | |
| 3173 | <para> |
| 3174 | The variable |
| 3175 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'>LIC_FILES_CHKSUM</ulink></filename> |
| 3176 | is used to track source license changes as described in the |
| 3177 | "<ulink url='&YOCTO_DOCS_REF_URL;#usingpoky-configuring-LIC_FILES_CHKSUM'>Tracking License Changes</ulink>" section. |
| 3178 | You can quickly create Autotool-based recipes in a manner similar to the previous example. |
| 3179 | </para> |
| 3180 | </section> |
| 3181 | |
| 3182 | <section id='new-recipe-makefile-based-package'> |
| 3183 | <title>Makefile-Based Package</title> |
| 3184 | |
| 3185 | <para> |
| 3186 | Applications that use GNU <filename>make</filename> also require a recipe that has |
| 3187 | the source archive listed in |
| 3188 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3189 | You do not need to add a <filename>do_compile</filename> step since by default BitBake |
| 3190 | starts the <filename>make</filename> command to compile the application. |
| 3191 | If you need additional <filename>make</filename> options, you should store them in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3192 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink> |
| 3193 | or |
| 3194 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 3195 | variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3196 | BitBake passes these options into the GNU <filename>make</filename> invocation. |
| 3197 | Note that a <filename>do_install</filename> task is still required. |
| 3198 | Otherwise, BitBake runs an empty <filename>do_install</filename> task by default. |
| 3199 | </para> |
| 3200 | |
| 3201 | <para> |
| 3202 | Some applications might require extra parameters to be passed to the compiler. |
| 3203 | For example, the application might need an additional header path. |
| 3204 | You can accomplish this by adding to the |
| 3205 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink></filename> variable. |
| 3206 | The following example shows this: |
| 3207 | <literallayout class='monospaced'> |
| 3208 | CFLAGS_prepend = "-I ${S}/include " |
| 3209 | </literallayout> |
| 3210 | </para> |
| 3211 | |
| 3212 | <para> |
| 3213 | In the following example, <filename>mtd-utils</filename> is a makefile-based package: |
| 3214 | <literallayout class='monospaced'> |
| 3215 | SUMMARY = "Tools for managing memory technology devices" |
| 3216 | SECTION = "base" |
| 3217 | DEPENDS = "zlib lzo e2fsprogs util-linux" |
| 3218 | HOMEPAGE = "http://www.linux-mtd.infradead.org/" |
| 3219 | LICENSE = "GPLv2+" |
| 3220 | LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ |
| 3221 | file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c" |
| 3222 | |
| 3223 | # Use the latest version at 26 Oct, 2013 |
| 3224 | SRCREV = "9f107132a6a073cce37434ca9cda6917dd8d866b" |
| 3225 | SRC_URI = "git://git.infradead.org/mtd-utils.git \ |
| 3226 | file://add-exclusion-to-mkfs-jffs2-git-2.patch \ |
| 3227 | " |
| 3228 | |
| 3229 | PV = "1.5.1+git${SRCPV}" |
| 3230 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3231 | S = "${WORKDIR}/git" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3232 | |
| 3233 | EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}/include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" |
| 3234 | |
| 3235 | do_install () { |
| 3236 | oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir} |
| 3237 | } |
| 3238 | |
| 3239 | PACKAGES =+ "mtd-utils-jffs2 mtd-utils-ubifs mtd-utils-misc" |
| 3240 | |
| 3241 | FILES_mtd-utils-jffs2 = "${sbindir}/mkfs.jffs2 ${sbindir}/jffs2dump ${sbindir}/jffs2reader ${sbindir}/sumtool" |
| 3242 | FILES_mtd-utils-ubifs = "${sbindir}/mkfs.ubifs ${sbindir}/ubi*" |
| 3243 | FILES_mtd-utils-misc = "${sbindir}/nftl* ${sbindir}/ftl* ${sbindir}/rfd* ${sbindir}/doc* ${sbindir}/serve_image ${sbindir}/recv_image" |
| 3244 | |
| 3245 | PARALLEL_MAKE = "" |
| 3246 | |
| 3247 | BBCLASSEXTEND = "native" |
| 3248 | </literallayout> |
| 3249 | </para> |
| 3250 | </section> |
| 3251 | |
| 3252 | <section id='splitting-an-application-into-multiple-packages'> |
| 3253 | <title>Splitting an Application into Multiple Packages</title> |
| 3254 | |
| 3255 | <para> |
| 3256 | You can use the variables |
| 3257 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'>PACKAGES</ulink></filename> and |
| 3258 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'>FILES</ulink></filename> |
| 3259 | to split an application into multiple packages. |
| 3260 | </para> |
| 3261 | |
| 3262 | <para> |
| 3263 | Following is an example that uses the <filename>libxpm</filename> recipe. |
| 3264 | By default, this recipe generates a single package that contains the library along |
| 3265 | with a few binaries. |
| 3266 | You can modify the recipe to split the binaries into separate packages: |
| 3267 | <literallayout class='monospaced'> |
| 3268 | require xorg-lib-common.inc |
| 3269 | |
| 3270 | SUMMARY = "Xpm: X Pixmap extension library" |
| 3271 | LICENSE = "BSD" |
| 3272 | LIC_FILES_CHKSUM = "file://COPYING;md5=51f4270b012ecd4ab1a164f5f4ed6cf7" |
| 3273 | DEPENDS += "libxext libsm libxt" |
| 3274 | PE = "1" |
| 3275 | |
| 3276 | XORG_PN = "libXpm" |
| 3277 | |
| 3278 | PACKAGES =+ "sxpm cxpm" |
| 3279 | FILES_cxpm = "${bindir}/cxpm" |
| 3280 | FILES_sxpm = "${bindir}/sxpm" |
| 3281 | </literallayout> |
| 3282 | </para> |
| 3283 | |
| 3284 | <para> |
| 3285 | In the previous example, we want to ship the <filename>sxpm</filename> |
| 3286 | and <filename>cxpm</filename> binaries in separate packages. |
| 3287 | Since <filename>bindir</filename> would be packaged into the main |
| 3288 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'>PN</ulink></filename> |
| 3289 | package by default, we prepend the <filename>PACKAGES</filename> |
| 3290 | variable so additional package names are added to the start of list. |
| 3291 | This results in the extra <filename>FILES_*</filename> |
| 3292 | variables then containing information that define which files and |
| 3293 | directories go into which packages. |
| 3294 | Files included by earlier packages are skipped by latter packages. |
| 3295 | Thus, the main <filename>PN</filename> package |
| 3296 | does not include the above listed files. |
| 3297 | </para> |
| 3298 | </section> |
| 3299 | |
| 3300 | <section id='packaging-externally-produced-binaries'> |
| 3301 | <title>Packaging Externally Produced Binaries</title> |
| 3302 | |
| 3303 | <para> |
| 3304 | Sometimes, you need to add pre-compiled binaries to an |
| 3305 | image. |
| 3306 | For example, suppose that binaries for proprietary code |
| 3307 | exist, which are created by a particular division of a |
| 3308 | company. |
| 3309 | Your part of the company needs to use those binaries as |
| 3310 | part of an image that you are building using the |
| 3311 | OpenEmbedded build system. |
| 3312 | Since you only have the binaries and not the source code, |
| 3313 | you cannot use a typical recipe that expects to fetch the |
| 3314 | source specified in |
| 3315 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 3316 | and then compile it. |
| 3317 | </para> |
| 3318 | |
| 3319 | <para> |
| 3320 | One method is to package the binaries and then install them |
| 3321 | as part of the image. |
| 3322 | Generally, it is not a good idea to package binaries |
| 3323 | since, among other things, it can hinder the ability to |
| 3324 | reproduce builds and could lead to compatibility problems |
| 3325 | with ABI in the future. |
| 3326 | However, sometimes you have no choice. |
| 3327 | </para> |
| 3328 | |
| 3329 | <para> |
| 3330 | The easiest solution is to create a recipe that uses |
| 3331 | the |
| 3332 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-bin-package'><filename>bin_package</filename></ulink> |
| 3333 | class and to be sure that you are using default locations |
| 3334 | for build artifacts. |
| 3335 | In most cases, the <filename>bin_package</filename> class |
| 3336 | handles "skipping" the configure and compile steps as well |
| 3337 | as sets things up to grab packages from the appropriate |
| 3338 | area. |
| 3339 | In particular, this class sets <filename>noexec</filename> |
| 3340 | on both the |
| 3341 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3342 | and |
| 3343 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3344 | tasks, sets |
| 3345 | <filename>FILES_${PN}</filename> to "/" so that it picks |
| 3346 | up all files, and sets up a |
| 3347 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3348 | task, which effectively copies all files from |
| 3349 | <filename>${S}</filename> to <filename>${D}</filename>. |
| 3350 | The <filename>bin_package</filename> class works well when |
| 3351 | the files extracted into <filename>${S}</filename> are |
| 3352 | already laid out in the way they should be laid out |
| 3353 | on the target. |
| 3354 | For more information on these variables, see the |
| 3355 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink>, |
| 3356 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink>, |
| 3357 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink>, |
| 3358 | and |
| 3359 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 3360 | variables in the Yocto Project Reference Manual's variable |
| 3361 | glossary. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3362 | <note><title>Notes</title> |
| 3363 | <itemizedlist> |
| 3364 | <listitem><para> |
| 3365 | Using |
| 3366 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 3367 | is a good idea even for components distributed |
| 3368 | in binary form, and is often necessary for |
| 3369 | shared libraries. |
| 3370 | For a shared library, listing the library |
| 3371 | dependencies in |
| 3372 | <filename>DEPENDS</filename> makes sure that |
| 3373 | the libraries are available in the staging |
| 3374 | sysroot when other recipes link against the |
| 3375 | library, which might be necessary for |
| 3376 | successful linking. |
| 3377 | </para></listitem> |
| 3378 | <listitem><para> |
| 3379 | Using <filename>DEPENDS</filename> also |
| 3380 | allows runtime dependencies between packages |
| 3381 | to be added automatically. |
| 3382 | See the |
| 3383 | "<ulink url='&YOCTO_DOCS_REF_URL;#automatically-added-runtime-dependencies'>Automatically Added Runtime Dependencies</ulink>" |
| 3384 | section in the Yocto Project Reference Manual |
| 3385 | for more information. |
| 3386 | </para></listitem> |
| 3387 | </itemizedlist> |
| 3388 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3389 | </para> |
| 3390 | |
| 3391 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3392 | If you cannot use the <filename>bin_package</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3393 | class, you need to be sure you are doing the following: |
| 3394 | <itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3395 | <listitem><para> |
| 3396 | Create a recipe where the |
| 3397 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> |
| 3398 | and |
| 3399 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> |
| 3400 | tasks do nothing: |
| 3401 | It is usually sufficient to just not define these |
| 3402 | tasks in the recipe, because the default |
| 3403 | implementations do nothing unless a Makefile is |
| 3404 | found in |
| 3405 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink><filename>}</filename>. |
| 3406 | </para> |
| 3407 | |
| 3408 | <para>If |
| 3409 | <filename>${S}</filename> might contain a Makefile, |
| 3410 | or if you inherit some class that replaces |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3411 | <filename>do_configure</filename> and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3412 | <filename>do_compile</filename> with custom |
| 3413 | versions, then you can use the |
| 3414 | <filename>[</filename><ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>noexec</filename></ulink><filename>]</filename> |
| 3415 | flag to turn the tasks into no-ops, as follows: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3416 | <literallayout class='monospaced'> |
| 3417 | do_configure[noexec] = "1" |
| 3418 | do_compile[noexec] = "1" |
| 3419 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3420 | Unlike |
| 3421 | <ulink url='&YOCTO_DOCS_BB_URL;#deleting-a-task'><filename>deleting the tasks</filename></ulink>, |
| 3422 | using the flag preserves the dependency chain from |
| 3423 | the |
| 3424 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink>, <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink>, |
| 3425 | and |
| 3426 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> |
| 3427 | tasks to the |
| 3428 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 3429 | task. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3430 | </para></listitem> |
| 3431 | <listitem><para>Make sure your |
| 3432 | <filename>do_install</filename> task installs the |
| 3433 | binaries appropriately. |
| 3434 | </para></listitem> |
| 3435 | <listitem><para>Ensure that you set up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3436 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 3437 | (usually |
| 3438 | <filename>FILES_${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>) |
| 3439 | to point to the files you have installed, which of |
| 3440 | course depends on where you have installed them |
| 3441 | and whether those files are in different locations |
| 3442 | than the defaults. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3443 | </para></listitem> |
| 3444 | </itemizedlist> |
| 3445 | </para> |
| 3446 | </section> |
| 3447 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3448 | |
| 3449 | <section id="following-recipe-style-guidelines"> |
| 3450 | <title>Following Recipe Style Guidelines</title> |
| 3451 | |
| 3452 | <para> |
| 3453 | When writing recipes, it is good to conform to existing |
| 3454 | style guidelines. |
| 3455 | The |
| 3456 | <ulink url='http://www.openembedded.org/wiki/Styleguide'>OpenEmbedded Styleguide</ulink> |
| 3457 | wiki page provides rough guidelines for preferred recipe style. |
| 3458 | </para> |
| 3459 | |
| 3460 | <para> |
| 3461 | It is common for existing recipes to deviate a bit from this |
| 3462 | style. |
| 3463 | However, aiming for at least a consistent style is a good idea. |
| 3464 | Some practices, such as omitting spaces around |
| 3465 | <filename>=</filename> operators in assignments or ordering |
| 3466 | recipe components in an erratic way, are widely seen as poor |
| 3467 | style. |
| 3468 | </para> |
| 3469 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3470 | </section> |
| 3471 | |
| 3472 | <section id="platdev-newmachine"> |
| 3473 | <title>Adding a New Machine</title> |
| 3474 | |
| 3475 | <para> |
| 3476 | Adding a new machine to the Yocto Project is a straightforward |
| 3477 | process. |
| 3478 | This section describes how to add machines that are similar |
| 3479 | to those that the Yocto Project already supports. |
| 3480 | <note> |
| 3481 | Although well within the capabilities of the Yocto Project, |
| 3482 | adding a totally new architecture might require |
| 3483 | changes to <filename>gcc/glibc</filename> and to the site |
| 3484 | information, which is beyond the scope of this manual. |
| 3485 | </note> |
| 3486 | </para> |
| 3487 | |
| 3488 | <para> |
| 3489 | For a complete example that shows how to add a new machine, |
| 3490 | see the |
| 3491 | "<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>" |
| 3492 | section in the Yocto Project Board Support Package (BSP) Developer's Guide. |
| 3493 | </para> |
| 3494 | |
| 3495 | <section id="platdev-newmachine-conffile"> |
| 3496 | <title>Adding the Machine Configuration File</title> |
| 3497 | |
| 3498 | <para> |
| 3499 | To add a new machine, you need to add a new machine |
| 3500 | configuration file to the layer's |
| 3501 | <filename>conf/machine</filename> directory. |
| 3502 | This configuration file provides details about the device |
| 3503 | you are adding. |
| 3504 | </para> |
| 3505 | |
| 3506 | <para> |
| 3507 | The OpenEmbedded build system uses the root name of the |
| 3508 | machine configuration file to reference the new machine. |
| 3509 | For example, given a machine configuration file named |
| 3510 | <filename>crownbay.conf</filename>, the build system |
| 3511 | recognizes the machine as "crownbay". |
| 3512 | </para> |
| 3513 | |
| 3514 | <para> |
| 3515 | The most important variables you must set in your machine |
| 3516 | configuration file or include from a lower-level configuration |
| 3517 | file are as follows: |
| 3518 | <itemizedlist> |
| 3519 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_ARCH'>TARGET_ARCH</ulink></filename> |
| 3520 | (e.g. "arm")</para></listitem> |
| 3521 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</ulink>_virtual/kernel</filename> |
| 3522 | </para></listitem> |
| 3523 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'>MACHINE_FEATURES</ulink></filename> |
| 3524 | (e.g. "apm screen wifi")</para></listitem> |
| 3525 | </itemizedlist> |
| 3526 | </para> |
| 3527 | |
| 3528 | <para> |
| 3529 | You might also need these variables: |
| 3530 | <itemizedlist> |
| 3531 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLES'>SERIAL_CONSOLES</ulink></filename> |
| 3532 | (e.g. "115200;ttyS0 115200;ttyS1")</para></listitem> |
| 3533 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'>KERNEL_IMAGETYPE</ulink></filename> |
| 3534 | (e.g. "zImage")</para></listitem> |
| 3535 | <listitem><para><filename><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'>IMAGE_FSTYPES</ulink></filename> |
| 3536 | (e.g. "tar.gz jffs2")</para></listitem> |
| 3537 | </itemizedlist> |
| 3538 | </para> |
| 3539 | |
| 3540 | <para> |
| 3541 | You can find full details on these variables in the reference |
| 3542 | section. |
| 3543 | You can leverage existing machine <filename>.conf</filename> |
| 3544 | files from <filename>meta-yocto-bsp/conf/machine/</filename>. |
| 3545 | </para> |
| 3546 | </section> |
| 3547 | |
| 3548 | <section id="platdev-newmachine-kernel"> |
| 3549 | <title>Adding a Kernel for the Machine</title> |
| 3550 | |
| 3551 | <para> |
| 3552 | The OpenEmbedded build system needs to be able to build a kernel |
| 3553 | for the machine. |
| 3554 | You need to either create a new kernel recipe for this machine, |
| 3555 | or extend an existing kernel recipe. |
| 3556 | You can find several kernel recipe examples in the |
| 3557 | Source Directory at |
| 3558 | <filename>meta/recipes-kernel/linux</filename> |
| 3559 | that you can use as references. |
| 3560 | </para> |
| 3561 | |
| 3562 | <para> |
| 3563 | If you are creating a new kernel recipe, normal recipe-writing |
| 3564 | rules apply for setting up a |
| 3565 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'>SRC_URI</ulink></filename>. |
| 3566 | Thus, you need to specify any necessary patches and set |
| 3567 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-S'>S</ulink></filename> |
| 3568 | to point at the source code. |
| 3569 | You need to create a <filename>do_configure</filename> task that |
| 3570 | configures the unpacked kernel with a |
| 3571 | <filename>defconfig</filename> file. |
| 3572 | You can do this by using a <filename>make defconfig</filename> |
| 3573 | command or, more commonly, by copying in a suitable |
| 3574 | <filename>defconfig</filename> file and then running |
| 3575 | <filename>make oldconfig</filename>. |
| 3576 | By making use of <filename>inherit kernel</filename> and |
| 3577 | potentially some of the <filename>linux-*.inc</filename> files, |
| 3578 | most other functionality is centralized and the defaults of the |
| 3579 | class normally work well. |
| 3580 | </para> |
| 3581 | |
| 3582 | <para> |
| 3583 | If you are extending an existing kernel recipe, it is usually |
| 3584 | a matter of adding a suitable <filename>defconfig</filename> |
| 3585 | file. |
| 3586 | The file needs to be added into a location similar to |
| 3587 | <filename>defconfig</filename> files used for other machines |
| 3588 | in a given kernel recipe. |
| 3589 | A possible way to do this is by listing the file in the |
| 3590 | <filename>SRC_URI</filename> and adding the machine to the |
| 3591 | expression in |
| 3592 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'>COMPATIBLE_MACHINE</ulink></filename>: |
| 3593 | <literallayout class='monospaced'> |
| 3594 | COMPATIBLE_MACHINE = '(qemux86|qemumips)' |
| 3595 | </literallayout> |
| 3596 | For more information on <filename>defconfig</filename> files, |
| 3597 | see the |
| 3598 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 3599 | section in the Yocto Project Linux Kernel Development Manual. |
| 3600 | </para> |
| 3601 | </section> |
| 3602 | |
| 3603 | <section id="platdev-newmachine-formfactor"> |
| 3604 | <title>Adding a Formfactor Configuration File</title> |
| 3605 | |
| 3606 | <para> |
| 3607 | A formfactor configuration file provides information about the |
| 3608 | target hardware for which the image is being built and information that |
| 3609 | the build system cannot obtain from other sources such as the kernel. |
| 3610 | Some examples of information contained in a formfactor configuration file include |
| 3611 | framebuffer orientation, whether or not the system has a keyboard, |
| 3612 | the positioning of the keyboard in relation to the screen, and |
| 3613 | the screen resolution. |
| 3614 | </para> |
| 3615 | |
| 3616 | <para> |
| 3617 | The build system uses reasonable defaults in most cases. |
| 3618 | However, if customization is |
| 3619 | necessary, you need to create a <filename>machconfig</filename> file |
| 3620 | in the <filename>meta/recipes-bsp/formfactor/files</filename> |
| 3621 | directory. |
| 3622 | This directory contains directories for specific machines such as |
| 3623 | <filename>qemuarm</filename> and <filename>qemux86</filename>. |
| 3624 | For information about the settings available and the defaults, see the |
| 3625 | <filename>meta/recipes-bsp/formfactor/files/config</filename> file found in the |
| 3626 | same area. |
| 3627 | </para> |
| 3628 | |
| 3629 | <para> |
| 3630 | Following is an example for "qemuarm" machine: |
| 3631 | <literallayout class='monospaced'> |
| 3632 | HAVE_TOUCHSCREEN=1 |
| 3633 | HAVE_KEYBOARD=1 |
| 3634 | |
| 3635 | DISPLAY_CAN_ROTATE=0 |
| 3636 | DISPLAY_ORIENTATION=0 |
| 3637 | #DISPLAY_WIDTH_PIXELS=640 |
| 3638 | #DISPLAY_HEIGHT_PIXELS=480 |
| 3639 | #DISPLAY_BPP=16 |
| 3640 | DISPLAY_DPI=150 |
| 3641 | DISPLAY_SUBPIXEL_ORDER=vrgb |
| 3642 | </literallayout> |
| 3643 | </para> |
| 3644 | </section> |
| 3645 | </section> |
| 3646 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 3647 | <section id='platdev-building-targets-with-multiple-configurations'> |
| 3648 | <title>Building Targets with Multiple Configurations</title> |
| 3649 | |
| 3650 | <para> |
| 3651 | Bitbake also has functionality that allows you to build |
| 3652 | multiple targets at the same time, where each target uses |
| 3653 | a different configuration. |
| 3654 | </para> |
| 3655 | |
| 3656 | <para> |
| 3657 | In order to accomplish this, you setup each of the configurations |
| 3658 | you need to use in parallel by placing the configuration files in |
| 3659 | your current build directory alongside the usual |
| 3660 | <filename>local.conf</filename> file. |
| 3661 | </para> |
| 3662 | |
| 3663 | <para> |
| 3664 | Follow these guidelines to create an environment that supports |
| 3665 | multiple configurations: |
| 3666 | <itemizedlist> |
| 3667 | <listitem><para> |
| 3668 | <emphasis>Create Configuration Files</emphasis>: |
| 3669 | You need to create a single configuration file for each |
| 3670 | configuration for which you want to add support. |
| 3671 | These files would contain lines such as the following: |
| 3672 | <literallayout class='monospaced'> |
| 3673 | MACHINE = "A" |
| 3674 | </literallayout> |
| 3675 | The files would contain any other variables that can |
| 3676 | be set and built in the same directory. |
| 3677 | <note> |
| 3678 | You can change the |
| 3679 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 3680 | to not conflict. |
| 3681 | </note></para> |
| 3682 | |
| 3683 | <para> |
| 3684 | Furthermore, the configuration file must be located in the |
| 3685 | current build directory in a directory named |
| 3686 | <filename>multiconfig</filename> under the build's |
| 3687 | <filename>conf</filename> directory where |
| 3688 | <filename>local.conf</filename> resides. |
| 3689 | The reason for this restriction is because the |
| 3690 | <filename>BBPATH</filename> variable is not constructed |
| 3691 | until the layers are parsed. |
| 3692 | Consequently, using the configuration file as a |
| 3693 | pre-configuration file is not possible unless it is |
| 3694 | located in the current working directory. |
| 3695 | </para></listitem> |
| 3696 | <listitem><para> |
| 3697 | <emphasis>Add the BitBake Multi-Config Variable to you Local Configuration File</emphasis>: |
| 3698 | Use the |
| 3699 | <filename>BBMULTICONFIG</filename> |
| 3700 | variable in your <filename>conf/local.conf</filename> |
| 3701 | configuration file to specify each separate configuration. |
| 3702 | For example, the following line tells BitBake it should load |
| 3703 | <filename>conf/multiconfig/configA.conf</filename>, |
| 3704 | <filename>conf/multiconfig/configB.conf</filename>, and |
| 3705 | <filename>conf/multiconfig/configC.conf</filename>. |
| 3706 | <literallayout class='monospaced'> |
| 3707 | BBMULTICONFIG = "configA configB configC" |
| 3708 | </literallayout> |
| 3709 | </para></listitem> |
| 3710 | <listitem><para> |
| 3711 | <emphasis>Launch BitBake</emphasis>: |
| 3712 | Use the following BitBake command form to launch the |
| 3713 | build: |
| 3714 | <literallayout class='monospaced'> |
| 3715 | $ bitbake [multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[multiconfig:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ] |
| 3716 | </literallayout> |
| 3717 | Following is an example that supports building a minimal |
| 3718 | image for configuration A alongside a standard |
| 3719 | <filename>core-image-sato</filename>, which takes its |
| 3720 | configuration from <filename>local.conf</filename>: |
| 3721 | <literallayout class='monospaced'> |
| 3722 | $ bitbake multiconfig:configA:core-image-minimal core-image-sato |
| 3723 | </literallayout> |
| 3724 | </para></listitem> |
| 3725 | </itemizedlist> |
| 3726 | </para> |
| 3727 | |
| 3728 | <para> |
| 3729 | Support for multiple configurations in this current release of |
| 3730 | the Yocto Project (&DISTRO_NAME; &DISTRO;) has some known issues: |
| 3731 | <itemizedlist> |
| 3732 | <listitem><para> |
| 3733 | No inter-multi-configuration dependencies exist. |
| 3734 | </para></listitem> |
| 3735 | <listitem><para> |
| 3736 | Shared State (sstate) optimizations do not exist. |
| 3737 | Consequently, if the build uses the same object twice |
| 3738 | in, for example, two different |
| 3739 | <filename>TMPDIR</filename> directories, the build |
| 3740 | will either load from an existing sstate cache at the |
| 3741 | start or build the object twice. |
| 3742 | </para></listitem> |
| 3743 | </itemizedlist> |
| 3744 | </para> |
| 3745 | </section> |
| 3746 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3747 | <section id="platdev-working-with-libraries"> |
| 3748 | <title>Working With Libraries</title> |
| 3749 | |
| 3750 | <para> |
| 3751 | Libraries are an integral part of your system. |
| 3752 | This section describes some common practices you might find |
| 3753 | helpful when working with libraries to build your system: |
| 3754 | <itemizedlist> |
| 3755 | <listitem><para><link linkend='including-static-library-files'>How to include static library files</link> |
| 3756 | </para></listitem> |
| 3757 | <listitem><para><link linkend='combining-multiple-versions-library-files-into-one-image'>How to use the Multilib feature to combine multiple versions of library files into a single image</link> |
| 3758 | </para></listitem> |
| 3759 | <listitem><para><link linkend='installing-multiple-versions-of-the-same-library'>How to install multiple versions of the same library in parallel on the same system</link> |
| 3760 | </para></listitem> |
| 3761 | </itemizedlist> |
| 3762 | </para> |
| 3763 | |
| 3764 | <section id='including-static-library-files'> |
| 3765 | <title>Including Static Library Files</title> |
| 3766 | |
| 3767 | <para> |
| 3768 | If you are building a library and the library offers static linking, you can control |
| 3769 | which static library files (<filename>*.a</filename> files) get included in the |
| 3770 | built library. |
| 3771 | </para> |
| 3772 | |
| 3773 | <para> |
| 3774 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 3775 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES_*</filename></ulink> |
| 3776 | variables in the |
| 3777 | <filename>meta/conf/bitbake.conf</filename> configuration file define how files installed |
| 3778 | by the <filename>do_install</filename> task are packaged. |
| 3779 | By default, the <filename>PACKAGES</filename> variable includes |
| 3780 | <filename>${PN}-staticdev</filename>, which represents all static library files. |
| 3781 | <note> |
| 3782 | Some previously released versions of the Yocto Project |
| 3783 | defined the static library files through |
| 3784 | <filename>${PN}-dev</filename>. |
| 3785 | </note> |
| 3786 | Following is part of the BitBake configuration file, where |
| 3787 | you can see how the static library files are defined: |
| 3788 | <literallayout class='monospaced'> |
| 3789 | PACKAGE_BEFORE_PN ?= "" |
| 3790 | PACKAGES = "${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}" |
| 3791 | PACKAGES_DYNAMIC = "^${PN}-locale-.*" |
| 3792 | FILES = "" |
| 3793 | |
| 3794 | FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ |
| 3795 | ${sysconfdir} ${sharedstatedir} ${localstatedir} \ |
| 3796 | ${base_bindir}/* ${base_sbindir}/* \ |
| 3797 | ${base_libdir}/*${SOLIBS} \ |
| 3798 | ${base_prefix}/lib/udev/rules.d ${prefix}/lib/udev/rules.d \ |
| 3799 | ${datadir}/${BPN} ${libdir}/${BPN}/* \ |
| 3800 | ${datadir}/pixmaps ${datadir}/applications \ |
| 3801 | ${datadir}/idl ${datadir}/omf ${datadir}/sounds \ |
| 3802 | ${libdir}/bonobo/servers" |
| 3803 | |
| 3804 | FILES_${PN}-bin = "${bindir}/* ${sbindir}/*" |
| 3805 | |
| 3806 | FILES_${PN}-doc = "${docdir} ${mandir} ${infodir} ${datadir}/gtk-doc \ |
| 3807 | ${datadir}/gnome/help" |
| 3808 | SECTION_${PN}-doc = "doc" |
| 3809 | |
| 3810 | FILES_SOLIBSDEV ?= "${base_libdir}/lib*${SOLIBSDEV} ${libdir}/lib*${SOLIBSDEV}" |
| 3811 | FILES_${PN}-dev = "${includedir} ${FILES_SOLIBSDEV} ${libdir}/*.la \ |
| 3812 | ${libdir}/*.o ${libdir}/pkgconfig ${datadir}/pkgconfig \ |
| 3813 | ${datadir}/aclocal ${base_libdir}/*.o \ |
| 3814 | ${libdir}/${BPN}/*.la ${base_libdir}/*.la" |
| 3815 | SECTION_${PN}-dev = "devel" |
| 3816 | ALLOW_EMPTY_${PN}-dev = "1" |
| 3817 | RDEPENDS_${PN}-dev = "${PN} (= ${EXTENDPKGV})" |
| 3818 | |
| 3819 | FILES_${PN}-staticdev = "${libdir}/*.a ${base_libdir}/*.a ${libdir}/${BPN}/*.a" |
| 3820 | SECTION_${PN}-staticdev = "devel" |
| 3821 | RDEPENDS_${PN}-staticdev = "${PN}-dev (= ${EXTENDPKGV})" |
| 3822 | </literallayout> |
| 3823 | </para> |
| 3824 | </section> |
| 3825 | |
| 3826 | <section id="combining-multiple-versions-library-files-into-one-image"> |
| 3827 | <title>Combining Multiple Versions of Library Files into One Image</title> |
| 3828 | |
| 3829 | <para> |
| 3830 | The build system offers the ability to build libraries with different |
| 3831 | target optimizations or architecture formats and combine these together |
| 3832 | into one system image. |
| 3833 | You can link different binaries in the image |
| 3834 | against the different libraries as needed for specific use cases. |
| 3835 | This feature is called "Multilib." |
| 3836 | </para> |
| 3837 | |
| 3838 | <para> |
| 3839 | An example would be where you have most of a system compiled in 32-bit |
| 3840 | mode using 32-bit libraries, but you have something large, like a database |
| 3841 | engine, that needs to be a 64-bit application and uses 64-bit libraries. |
| 3842 | Multilib allows you to get the best of both 32-bit and 64-bit libraries. |
| 3843 | </para> |
| 3844 | |
| 3845 | <para> |
| 3846 | While the Multilib feature is most commonly used for 32 and 64-bit differences, |
| 3847 | the approach the build system uses facilitates different target optimizations. |
| 3848 | You could compile some binaries to use one set of libraries and other binaries |
| 3849 | to use a different set of libraries. |
| 3850 | The libraries could differ in architecture, compiler options, or other |
| 3851 | optimizations. |
| 3852 | </para> |
| 3853 | |
| 3854 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3855 | Several examples exist in the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3856 | <filename>meta-skeleton</filename> layer found in the |
| 3857 | <link linkend='source-directory'>Source Directory</link>: |
| 3858 | <itemizedlist> |
| 3859 | <listitem><para><filename>conf/multilib-example.conf</filename> |
| 3860 | configuration file</para></listitem> |
| 3861 | <listitem><para><filename>conf/multilib-example2.conf</filename> |
| 3862 | configuration file</para></listitem> |
| 3863 | <listitem><para><filename>recipes-multilib/images/core-image-multilib-example.bb</filename> |
| 3864 | recipe</para></listitem> |
| 3865 | </itemizedlist> |
| 3866 | </para> |
| 3867 | |
| 3868 | <section id='preparing-to-use-multilib'> |
| 3869 | <title>Preparing to Use Multilib</title> |
| 3870 | |
| 3871 | <para> |
| 3872 | User-specific requirements drive the Multilib feature. |
| 3873 | Consequently, there is no one "out-of-the-box" configuration that likely |
| 3874 | exists to meet your needs. |
| 3875 | </para> |
| 3876 | |
| 3877 | <para> |
| 3878 | In order to enable Multilib, you first need to ensure your recipe is |
| 3879 | extended to support multiple libraries. |
| 3880 | Many standard recipes are already extended and support multiple libraries. |
| 3881 | You can check in the <filename>meta/conf/multilib.conf</filename> |
| 3882 | configuration file in the |
| 3883 | <link linkend='source-directory'>Source Directory</link> to see how this is |
| 3884 | done using the |
| 3885 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBCLASSEXTEND'><filename>BBCLASSEXTEND</filename></ulink> |
| 3886 | variable. |
| 3887 | Eventually, all recipes will be covered and this list will |
| 3888 | not be needed. |
| 3889 | </para> |
| 3890 | |
| 3891 | <para> |
| 3892 | For the most part, the Multilib class extension works automatically to |
| 3893 | extend the package name from <filename>${PN}</filename> to |
| 3894 | <filename>${MLPREFIX}${PN}</filename>, where <filename>MLPREFIX</filename> |
| 3895 | is the particular multilib (e.g. "lib32-" or "lib64-"). |
| 3896 | Standard variables such as |
| 3897 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 3898 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 3899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RPROVIDES'><filename>RPROVIDES</filename></ulink>, |
| 3900 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 3901 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>, and |
| 3902 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> |
| 3903 | are automatically extended by the system. |
| 3904 | If you are extending any manual code in the recipe, you can use the |
| 3905 | <filename>${MLPREFIX}</filename> variable to ensure those names are extended |
| 3906 | correctly. |
| 3907 | This automatic extension code resides in <filename>multilib.bbclass</filename>. |
| 3908 | </para> |
| 3909 | </section> |
| 3910 | |
| 3911 | <section id='using-multilib'> |
| 3912 | <title>Using Multilib</title> |
| 3913 | |
| 3914 | <para> |
| 3915 | After you have set up the recipes, you need to define the actual |
| 3916 | combination of multiple libraries you want to build. |
| 3917 | You accomplish this through your <filename>local.conf</filename> |
| 3918 | configuration file in the |
| 3919 | <link linkend='build-directory'>Build Directory</link>. |
| 3920 | An example configuration would be as follows: |
| 3921 | <literallayout class='monospaced'> |
| 3922 | MACHINE = "qemux86-64" |
| 3923 | require conf/multilib.conf |
| 3924 | MULTILIBS = "multilib:lib32" |
| 3925 | DEFAULTTUNE_virtclass-multilib-lib32 = "x86" |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3926 | IMAGE_INSTALL_append = " lib32-glib-2.0" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3927 | </literallayout> |
| 3928 | This example enables an |
| 3929 | additional library named <filename>lib32</filename> alongside the |
| 3930 | normal target packages. |
| 3931 | When combining these "lib32" alternatives, the example uses "x86" for tuning. |
| 3932 | For information on this particular tuning, see |
| 3933 | <filename>meta/conf/machine/include/ia32/arch-ia32.inc</filename>. |
| 3934 | </para> |
| 3935 | |
| 3936 | <para> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3937 | The example then includes <filename>lib32-glib-2.0</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3938 | in all the images, which illustrates one method of including a |
| 3939 | multiple library dependency. |
| 3940 | You can use a normal image build to include this dependency, |
| 3941 | for example: |
| 3942 | <literallayout class='monospaced'> |
| 3943 | $ bitbake core-image-sato |
| 3944 | </literallayout> |
| 3945 | You can also build Multilib packages specifically with a command like this: |
| 3946 | <literallayout class='monospaced'> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 3947 | $ bitbake lib32-glib-2.0 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3948 | </literallayout> |
| 3949 | </para> |
| 3950 | </section> |
| 3951 | |
| 3952 | <section id='additional-implementation-details'> |
| 3953 | <title>Additional Implementation Details</title> |
| 3954 | |
| 3955 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3956 | Generic implementation details as well as details that are |
| 3957 | specific to package management systems exist. |
| 3958 | Following are implementation details that exist regardless |
| 3959 | of the package management system: |
| 3960 | <itemizedlist> |
| 3961 | <listitem><para>The typical convention used for the |
| 3962 | class extension code as used by |
| 3963 | Multilib assumes that all package names specified |
| 3964 | in |
| 3965 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 3966 | that contain <filename>${PN}</filename> have |
| 3967 | <filename>${PN}</filename> at the start of the name. |
| 3968 | When that convention is not followed and |
| 3969 | <filename>${PN}</filename> appears at |
| 3970 | the middle or the end of a name, problems occur. |
| 3971 | </para></listitem> |
| 3972 | <listitem><para>The |
| 3973 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_VENDOR'><filename>TARGET_VENDOR</filename></ulink> |
| 3974 | value under Multilib will be extended to |
| 3975 | "-<replaceable>vendor</replaceable>ml<replaceable>multilib</replaceable>" |
| 3976 | (e.g. "-pokymllib32" for a "lib32" Multilib with |
| 3977 | Poky). |
| 3978 | The reason for this slightly unwieldy contraction |
| 3979 | is that any "-" characters in the vendor |
| 3980 | string presently break Autoconf's |
| 3981 | <filename>config.sub</filename>, and |
| 3982 | other separators are problematic for different |
| 3983 | reasons. |
| 3984 | </para></listitem> |
| 3985 | </itemizedlist> |
| 3986 | </para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 3987 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3988 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3989 | For the RPM Package Management System, the following implementation details |
| 3990 | exist: |
| 3991 | <itemizedlist> |
| 3992 | <listitem><para>A unique architecture is defined for the Multilib packages, |
| 3993 | along with creating a unique deploy folder under |
| 3994 | <filename>tmp/deploy/rpm</filename> in the |
| 3995 | <link linkend='build-directory'>Build Directory</link>. |
| 3996 | For example, consider <filename>lib32</filename> in a |
| 3997 | <filename>qemux86-64</filename> image. |
| 3998 | The possible architectures in the system are "all", "qemux86_64", |
| 3999 | "lib32_qemux86_64", and "lib32_x86".</para></listitem> |
| 4000 | <listitem><para>The <filename>${MLPREFIX}</filename> variable is stripped from |
| 4001 | <filename>${PN}</filename> during RPM packaging. |
| 4002 | The naming for a normal RPM package and a Multilib RPM package in a |
| 4003 | <filename>qemux86-64</filename> system resolves to something similar to |
| 4004 | <filename>bash-4.1-r2.x86_64.rpm</filename> and |
| 4005 | <filename>bash-4.1.r2.lib32_x86.rpm</filename>, respectively. |
| 4006 | </para></listitem> |
| 4007 | <listitem><para>When installing a Multilib image, the RPM backend first |
| 4008 | installs the base image and then installs the Multilib libraries. |
| 4009 | </para></listitem> |
| 4010 | <listitem><para>The build system relies on RPM to resolve the identical files in the |
| 4011 | two (or more) Multilib packages.</para></listitem> |
| 4012 | </itemizedlist> |
| 4013 | </para> |
| 4014 | |
| 4015 | <para> |
| 4016 | For the IPK Package Management System, the following implementation details exist: |
| 4017 | <itemizedlist> |
| 4018 | <listitem><para>The <filename>${MLPREFIX}</filename> is not stripped from |
| 4019 | <filename>${PN}</filename> during IPK packaging. |
| 4020 | The naming for a normal RPM package and a Multilib IPK package in a |
| 4021 | <filename>qemux86-64</filename> system resolves to something like |
| 4022 | <filename>bash_4.1-r2.x86_64.ipk</filename> and |
| 4023 | <filename>lib32-bash_4.1-rw_x86.ipk</filename>, respectively. |
| 4024 | </para></listitem> |
| 4025 | <listitem><para>The IPK deploy folder is not modified with |
| 4026 | <filename>${MLPREFIX}</filename> because packages with and without |
| 4027 | the Multilib feature can exist in the same folder due to the |
| 4028 | <filename>${PN}</filename> differences.</para></listitem> |
| 4029 | <listitem><para>IPK defines a sanity check for Multilib installation |
| 4030 | using certain rules for file comparison, overridden, etc. |
| 4031 | </para></listitem> |
| 4032 | </itemizedlist> |
| 4033 | </para> |
| 4034 | </section> |
| 4035 | </section> |
| 4036 | |
| 4037 | <section id='installing-multiple-versions-of-the-same-library'> |
| 4038 | <title>Installing Multiple Versions of the Same Library</title> |
| 4039 | |
| 4040 | <para> |
| 4041 | Situations can exist where you need to install and use |
| 4042 | multiple versions of the same library on the same system |
| 4043 | at the same time. |
| 4044 | These situations almost always exist when a library API |
| 4045 | changes and you have multiple pieces of software that |
| 4046 | depend on the separate versions of the library. |
| 4047 | To accommodate these situations, you can install multiple |
| 4048 | versions of the same library in parallel on the same system. |
| 4049 | </para> |
| 4050 | |
| 4051 | <para> |
| 4052 | The process is straightforward as long as the libraries use |
| 4053 | proper versioning. |
| 4054 | With properly versioned libraries, all you need to do to |
| 4055 | individually specify the libraries is create separate, |
| 4056 | appropriately named recipes where the |
| 4057 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> part of the |
| 4058 | name includes a portion that differentiates each library version |
| 4059 | (e.g.the major part of the version number). |
| 4060 | Thus, instead of having a single recipe that loads one version |
| 4061 | of a library (e.g. <filename>clutter</filename>), you provide |
| 4062 | multiple recipes that result in different versions |
| 4063 | of the libraries you want. |
| 4064 | As an example, the following two recipes would allow the |
| 4065 | two separate versions of the <filename>clutter</filename> |
| 4066 | library to co-exist on the same system: |
| 4067 | <literallayout class='monospaced'> |
| 4068 | clutter-1.6_1.6.20.bb |
| 4069 | clutter-1.8_1.8.4.bb |
| 4070 | </literallayout> |
| 4071 | Additionally, if you have other recipes that depend on a given |
| 4072 | library, you need to use the |
| 4073 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 4074 | variable to create the dependency. |
| 4075 | Continuing with the same example, if you want to have a recipe |
| 4076 | depend on the 1.8 version of the <filename>clutter</filename> |
| 4077 | library, use the following in your recipe: |
| 4078 | <literallayout class='monospaced'> |
| 4079 | DEPENDS = "clutter-1.8" |
| 4080 | </literallayout> |
| 4081 | </para> |
| 4082 | </section> |
| 4083 | </section> |
| 4084 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 4085 | <section id='enabling-gobject-introspection-support'> |
| 4086 | <title>Enabling GObject Introspection Support</title> |
| 4087 | |
| 4088 | <para> |
| 4089 | <ulink url='https://wiki.gnome.org/Projects/GObjectIntrospection'>GObject introspection</ulink> |
| 4090 | is the standard mechanism for accessing GObject-based software |
| 4091 | from runtime environments. |
| 4092 | GObject is a feature of the GLib library that provides an object |
| 4093 | framework for the GNOME desktop and related software. |
| 4094 | GObject Introspection adds information to GObject that allows |
| 4095 | objects created within it to be represented across different |
| 4096 | programming languages. |
| 4097 | If you want to construct GStreamer pipelines using Python, or |
| 4098 | control UPnP infrastructure using Javascript and GUPnP, |
| 4099 | GObject introspection is the only way to do it. |
| 4100 | </para> |
| 4101 | |
| 4102 | <para> |
| 4103 | This section describes the Yocto Project support for generating |
| 4104 | and packaging GObject introspection data. |
| 4105 | GObject introspection data is a description of the |
| 4106 | API provided by libraries built on top of GLib framework, |
| 4107 | and, in particular, that framework's GObject mechanism. |
| 4108 | GObject Introspection Repository (GIR) files go to |
| 4109 | <filename>-dev</filename> packages, |
| 4110 | <filename>typelib</filename> files go to main packages as they |
| 4111 | are packaged together with libraries that are introspected. |
| 4112 | </para> |
| 4113 | |
| 4114 | <para> |
| 4115 | The data is generated when building such a library, by linking |
| 4116 | the library with a small executable binary that asks the library |
| 4117 | to describe itself, and then executing the binary and |
| 4118 | processing its output. |
| 4119 | </para> |
| 4120 | |
| 4121 | <para> |
| 4122 | Generating this data in a cross-compilation environment |
| 4123 | is difficult because the library is produced for the target |
| 4124 | architecture, but its code needs to be executed on the build host. |
| 4125 | This problem is solved with the OpenEmbedded build system by |
| 4126 | running the code through QEMU, which allows precisely that. |
| 4127 | Unfortunately, QEMU does not always work perfectly as mentioned |
| 4128 | in the xxx section. |
| 4129 | </para> |
| 4130 | |
| 4131 | <section id='enabling-the-generation-of-introspection-data'> |
| 4132 | <title>Enabling the Generation of Introspection Data</title> |
| 4133 | |
| 4134 | <para> |
| 4135 | Enabling the generation of introspection data (GIR files) |
| 4136 | in your library package involves the following: |
| 4137 | <orderedlist> |
| 4138 | <listitem><para> |
| 4139 | Inherit the |
| 4140 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-gobject-introspection'><filename>gobject-introspection</filename></ulink> |
| 4141 | class. |
| 4142 | </para></listitem> |
| 4143 | <listitem><para> |
| 4144 | Make sure introspection is not disabled anywhere in |
| 4145 | the recipe or from anything the recipe includes. |
| 4146 | Also, make sure that "gobject-introspection-data" is |
| 4147 | not in |
| 4148 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 4149 | and that "qemu-usermode" is not in |
| 4150 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 4151 | If either of these conditions exist, nothing will |
| 4152 | happen. |
| 4153 | </para></listitem> |
| 4154 | <listitem><para> |
| 4155 | Try to build the recipe. |
| 4156 | If you encounter build errors that look like |
| 4157 | something is unable to find |
| 4158 | <filename>.so</filename> libraries, check where these |
| 4159 | libraries are located in the source tree and add |
| 4160 | the following to the recipe: |
| 4161 | <literallayout class='monospaced'> |
| 4162 | GIR_EXTRA_LIBS_PATH = "${B}/<replaceable>something</replaceable>/.libs" |
| 4163 | </literallayout> |
| 4164 | <note> |
| 4165 | See recipes in the <filename>oe-core</filename> |
| 4166 | repository that use that |
| 4167 | <filename>GIR_EXTRA_LIBS_PATH</filename> variable |
| 4168 | as an example. |
| 4169 | </note> |
| 4170 | </para></listitem> |
| 4171 | <listitem><para> |
| 4172 | Look for any other errors, which probably mean that |
| 4173 | introspection support in a package is not entirely |
| 4174 | standard, and thus breaks down in a cross-compilation |
| 4175 | environment. |
| 4176 | For such cases, custom-made fixes are needed. |
| 4177 | A good place to ask and receive help in these cases |
| 4178 | is the |
| 4179 | <ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Yocto Project mailing lists</ulink>. |
| 4180 | </para></listitem> |
| 4181 | </orderedlist> |
| 4182 | <note> |
| 4183 | Using a library that no longer builds against the latest |
| 4184 | Yocto Project release and prints introspection related |
| 4185 | errors is a good candidate for the previous procedure. |
| 4186 | </note> |
| 4187 | </para> |
| 4188 | </section> |
| 4189 | |
| 4190 | <section id='disabling-the-generation-of-introspection-data'> |
| 4191 | <title>Disabling the Generation of Introspection Data</title> |
| 4192 | |
| 4193 | <para> |
| 4194 | You might find that you do not want to generate |
| 4195 | introspection data. |
| 4196 | Or, perhaps QEMU does not work on your build host and |
| 4197 | target architecture combination. |
| 4198 | If so, you can use either of the following methods to |
| 4199 | disable GIR file generations: |
| 4200 | <itemizedlist> |
| 4201 | <listitem><para> |
| 4202 | Add the following to your distro configuration: |
| 4203 | <literallayout class='monospaced'> |
| 4204 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "gobject-introspection-data" |
| 4205 | </literallayout> |
| 4206 | Adding this statement disables generating |
| 4207 | introspection data using QEMU but will still enable |
| 4208 | building introspection tools and libraries |
| 4209 | (i.e. building them does not require the use of QEMU). |
| 4210 | </para></listitem> |
| 4211 | <listitem><para> |
| 4212 | Add the following to your machine configuration: |
| 4213 | <literallayout class='monospaced'> |
| 4214 | MACHINE_FEATURES_BACKFILL_CONSIDERED = "qemu-usermode" |
| 4215 | </literallayout> |
| 4216 | Adding this statement disables the use of QEMU |
| 4217 | when building packages for your machine. |
| 4218 | Currently, this feature is used only by introspection |
| 4219 | recipes and has the same effect as the previously |
| 4220 | described option. |
| 4221 | <note> |
| 4222 | Future releases of the Yocto Project might have |
| 4223 | other features affected by this option. |
| 4224 | </note> |
| 4225 | </para></listitem> |
| 4226 | </itemizedlist> |
| 4227 | If you disable introspection data, you can still |
| 4228 | obtain it through other means such as copying the data |
| 4229 | from a suitable sysroot, or by generating it on the |
| 4230 | target hardware. |
| 4231 | The OpenEmbedded build system does not currently |
| 4232 | provide specific support for these techniques. |
| 4233 | </para> |
| 4234 | </section> |
| 4235 | |
| 4236 | <section id='testing-that-introspection-works-in-an-image'> |
| 4237 | <title>Testing that Introspection Works in an Image</title> |
| 4238 | |
| 4239 | <para> |
| 4240 | Use the following procedure to test if generating |
| 4241 | introspection data is working in an image: |
| 4242 | <orderedlist> |
| 4243 | <listitem><para> |
| 4244 | Make sure that "gobject-introspection-data" is not in |
| 4245 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink> |
| 4246 | and that "qemu-usermode" is not in |
| 4247 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES_BACKFILL_CONSIDERED'><filename>MACHINE_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 4248 | </para></listitem> |
| 4249 | <listitem><para> |
| 4250 | Build <filename>core-image-sato</filename>. |
| 4251 | </para></listitem> |
| 4252 | <listitem><para> |
| 4253 | Launch a Terminal and then start Python in the |
| 4254 | terminal. |
| 4255 | </para></listitem> |
| 4256 | <listitem><para> |
| 4257 | Enter the following in the terminal: |
| 4258 | <literallayout class='monospaced'> |
| 4259 | >>> from gi.repository import GLib |
| 4260 | >>> GLib.get_host_name() |
| 4261 | </literallayout> |
| 4262 | </para></listitem> |
| 4263 | <listitem><para> |
| 4264 | For something a little more advanced, enter the |
| 4265 | following: |
| 4266 | <literallayout class='monospaced'> |
| 4267 | http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html |
| 4268 | </literallayout> |
| 4269 | </para></listitem> |
| 4270 | </orderedlist> |
| 4271 | </para> |
| 4272 | </section> |
| 4273 | |
| 4274 | <section id='known-issues'> |
| 4275 | <title>Known Issues</title> |
| 4276 | |
| 4277 | <para> |
| 4278 | The following know issues exist for |
| 4279 | GObject Introspection Support: |
| 4280 | <itemizedlist> |
| 4281 | <listitem><para> |
| 4282 | <filename>qemu-ppc64</filename> immediately crashes. |
| 4283 | Consequently, you cannot build introspection data on |
| 4284 | that architecture. |
| 4285 | </para></listitem> |
| 4286 | <listitem><para> |
| 4287 | x32 is not supported by QEMU. |
| 4288 | Consequently, introspection data is disabled. |
| 4289 | </para></listitem> |
| 4290 | <listitem><para> |
| 4291 | musl causes transient GLib binaries to crash on |
| 4292 | assertion failures. |
| 4293 | Consequently, generating introspection data is |
| 4294 | disabled. |
| 4295 | </para></listitem> |
| 4296 | <listitem><para> |
| 4297 | Because QEMU is not able to run the binaries correctly, |
| 4298 | introspection is disabled for some specific packages |
| 4299 | under specific architectures (e.g. |
| 4300 | <filename>gcr</filename>, |
| 4301 | <filename>libsecret</filename>, and |
| 4302 | <filename>webkit</filename>). |
| 4303 | </para></listitem> |
| 4304 | <listitem><para> |
| 4305 | QEMU usermode might not work properly when running |
| 4306 | 64-bit binaries under 32-bit host machines. |
| 4307 | In particular, "qemumips64" is known to not work under |
| 4308 | i686. |
| 4309 | </para></listitem> |
| 4310 | </itemizedlist> |
| 4311 | </para> |
| 4312 | </section> |
| 4313 | </section> |
| 4314 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4315 | <section id='dev-optionally-using-an-external-toolchain'> |
| 4316 | <title>Optionally Using an External Toolchain</title> |
| 4317 | |
| 4318 | <para> |
| 4319 | You might want to use an external toolchain as part of your |
| 4320 | development. |
| 4321 | If this is the case, the fundamental steps you need to accomplish |
| 4322 | are as follows: |
| 4323 | <itemizedlist> |
| 4324 | <listitem><para> |
| 4325 | Understand where the installed toolchain resides. |
| 4326 | For cases where you need to build the external toolchain, |
| 4327 | you would need to take separate steps to build and install |
| 4328 | the toolchain. |
| 4329 | </para></listitem> |
| 4330 | <listitem><para> |
| 4331 | Make sure you add the layer that contains the toolchain to |
| 4332 | your <filename>bblayers.conf</filename> file through the |
| 4333 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 4334 | variable. |
| 4335 | </para></listitem> |
| 4336 | <listitem><para> |
| 4337 | Set the |
| 4338 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink> |
| 4339 | variable in your <filename>local.conf</filename> file |
| 4340 | to the location in which you installed the toolchain. |
| 4341 | </para></listitem> |
| 4342 | </itemizedlist> |
| 4343 | A good example of an external toolchain used with the Yocto Project |
| 4344 | is <trademark class='registered'>Mentor Graphics</trademark> |
| 4345 | Sourcery G++ Toolchain. |
| 4346 | You can see information on how to use that particular layer in the |
| 4347 | <filename>README</filename> file at |
| 4348 | <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>. |
| 4349 | You can find further information by reading about the |
| 4350 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink> |
| 4351 | variable in the Yocto Project Reference Manual's variable glossary. |
| 4352 | </para> |
| 4353 | </section> |
| 4354 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4355 | <section id='creating-partitioned-images'> |
| 4356 | <title>Creating Partitioned Images</title> |
| 4357 | |
| 4358 | <para> |
| 4359 | Creating an image for a particular hardware target using the |
| 4360 | OpenEmbedded build system does not necessarily mean you can boot |
| 4361 | that image as is on your device. |
| 4362 | Physical devices accept and boot images in various ways depending |
| 4363 | on the specifics of the device. |
| 4364 | Usually, information about the hardware can tell you what image |
| 4365 | format the device requires. |
| 4366 | Should your device require multiple partitions on an SD card, flash, |
| 4367 | or an HDD, you can use the OpenEmbedded Image Creator, |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4368 | Wic, to create the properly partitioned image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4369 | </para> |
| 4370 | |
| 4371 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4372 | You can generate partitioned images |
| 4373 | (<replaceable>image</replaceable><filename>.wic</filename>) |
| 4374 | two ways: using the OpenEmbedded build system and by running |
| 4375 | the OpenEmbedded Image Creator Wic directly. |
| 4376 | The former way is preferable as it is easier to use and understand. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4377 | </para> |
| 4378 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4379 | <section id='creating-wic-images-oe'> |
| 4380 | <title>Creating Partitioned Images</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4381 | |
| 4382 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4383 | The OpenEmbedded build system can generate |
| 4384 | partitioned images the same way as it generates |
| 4385 | any other image type. |
| 4386 | To generate a partitioned image, you need to modify |
| 4387 | two variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4388 | <itemizedlist> |
| 4389 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4390 | Include "wic" as part of the |
| 4391 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> |
| 4392 | variable. |
| 4393 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4394 | <listitem><para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4395 | Include the name of the |
| 4396 | <link linkend='openembedded-kickstart-wks-reference'>wic kickstart file</link> |
| 4397 | as part of the |
| 4398 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WKS_FILE'><filename>WKS_FILE</filename></ulink> |
| 4399 | variable |
| 4400 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4401 | </itemizedlist> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4402 | Further steps to generate a partitioned image |
| 4403 | are the same as for any other image type. |
| 4404 | For information on image types, see the |
| 4405 | "<link linkend='building-images'>Building Images</link>" |
| 4406 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4407 | </para> |
| 4408 | </section> |
| 4409 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4410 | <section id='create-wic-images-wic'> |
| 4411 | <title>Using OpenEmbedded Image Creator Wic to Generate Partitioned Images</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4412 | |
| 4413 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4414 | The <filename>wic</filename> command generates partitioned |
| 4415 | images from existing OpenEmbedded build artifacts. |
| 4416 | Image generation is driven by partitioning commands |
| 4417 | contained in an Openembedded kickstart file |
| 4418 | (<filename>.wks</filename>) specified either directly on |
| 4419 | the command line or as one of a selection of canned |
| 4420 | <filename>.wks</filename> files as shown with the |
| 4421 | <filename>wic list images</filename> command in the |
| 4422 | "<link linkend='using-a-provided-kickstart-file'>Using an Existing Kickstart File</link>" |
| 4423 | section. |
| 4424 | When you apply the command to a given set of build |
| 4425 | artifacts, the result is an image or set of images that |
| 4426 | can be directly written onto media and used on a particular |
| 4427 | system. |
| 4428 | </para> |
| 4429 | |
| 4430 | <para> |
| 4431 | The <filename>wic</filename> command and the infrastructure |
| 4432 | it is based on is by definition incomplete. |
| 4433 | The purpose of the command is to allow the generation of |
| 4434 | customized images, and as such, was designed to be |
| 4435 | completely extensible through a plug-in interface. |
| 4436 | See the |
| 4437 | "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>" |
| 4438 | section for information on these plug-ins. |
| 4439 | </para> |
| 4440 | |
| 4441 | <para> |
| 4442 | This section provides some background information on Wic, |
| 4443 | describes what you need to have in |
| 4444 | place to run the tool, provides instruction on how to use |
| 4445 | the <filename>wic</filename> utility, |
| 4446 | and provides several examples. |
| 4447 | </para> |
| 4448 | |
| 4449 | <section id='wic-background'> |
| 4450 | <title>Background</title> |
| 4451 | |
| 4452 | <para> |
| 4453 | This section provides some background on the |
| 4454 | <filename>wic</filename> utility. |
| 4455 | While none of this information is required to use |
| 4456 | Wic, you might find it interesting. |
| 4457 | <itemizedlist> |
| 4458 | <listitem><para> |
| 4459 | The name "Wic" is derived from OpenEmbedded |
| 4460 | Image Creator (oeic). |
| 4461 | The "oe" diphthong in "oeic" was promoted to the |
| 4462 | letter "w", because "oeic" is both difficult to |
| 4463 | remember and to pronounce. |
| 4464 | </para></listitem> |
| 4465 | <listitem><para> |
| 4466 | Wic is loosely based on the |
| 4467 | Meego Image Creator (<filename>mic</filename>) |
| 4468 | framework. |
| 4469 | The Wic implementation has been |
| 4470 | heavily modified to make direct use of OpenEmbedded |
| 4471 | build artifacts instead of package installation and |
| 4472 | configuration, which are already incorporated within |
| 4473 | the OpenEmbedded artifacts. |
| 4474 | </para></listitem> |
| 4475 | <listitem><para> |
| 4476 | Wic is a completely independent |
| 4477 | standalone utility that initially provides |
| 4478 | easier-to-use and more flexible replacements for a |
| 4479 | existing functionality in OE Core's |
| 4480 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image-live'><filename>image-live</filename></ulink> |
| 4481 | class and <filename>mkefidisk.sh</filename> script. |
| 4482 | The difference between |
| 4483 | Wic and those examples is |
| 4484 | that with Wic the |
| 4485 | functionality of those scripts is implemented |
| 4486 | by a general-purpose partitioning language, which is |
| 4487 | based on Redhat kickstart syntax.</para></listitem> |
| 4488 | </itemizedlist> |
| 4489 | </para> |
| 4490 | </section> |
| 4491 | |
| 4492 | <section id='wic-requirements'> |
| 4493 | <title>Requirements</title> |
| 4494 | |
| 4495 | <para> |
| 4496 | In order to use the <filename>wic</filename> utility |
| 4497 | with the OpenEmbedded Build system, your system needs |
| 4498 | to meet the following requirements: |
| 4499 | <itemizedlist> |
| 4500 | <listitem><para>The Linux distribution on your |
| 4501 | development host must support the Yocto Project. |
| 4502 | See the |
| 4503 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" |
| 4504 | section in the Yocto Project Reference Manual for |
| 4505 | the list of distributions that support the |
| 4506 | Yocto Project. |
| 4507 | </para></listitem> |
| 4508 | <listitem><para> |
| 4509 | The standard system utilities, such as |
| 4510 | <filename>cp</filename>, must be installed on your |
| 4511 | development host system. |
| 4512 | </para></listitem> |
| 4513 | <listitem><para> |
| 4514 | You need to have the build artifacts already |
| 4515 | available, which typically means that you must |
| 4516 | have already created an image using the |
| 4517 | Openembedded build system (e.g. |
| 4518 | <filename>core-image-minimal</filename>). |
| 4519 | While it might seem redundant to generate an image |
| 4520 | in order to create an image using |
| 4521 | Wic, the current version of |
| 4522 | Wic requires the artifacts |
| 4523 | in the form generated by the build system. |
| 4524 | </para></listitem> |
| 4525 | <listitem><para> |
| 4526 | You must build several native tools, which are tools |
| 4527 | built to run on the build system: |
| 4528 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4529 | $ bitbake parted-native dosfstools-native mtools-native |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4530 | </literallayout> |
| 4531 | </para></listitem> |
| 4532 | <listitem><para> |
| 4533 | You must have sourced one of the build environment |
| 4534 | setup scripts (i.e. |
| 4535 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 4536 | or |
| 4537 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>) |
| 4538 | found in the |
| 4539 | <link linkend='build-directory'>Build Directory</link>. |
| 4540 | </para></listitem> |
| 4541 | </itemizedlist> |
| 4542 | </para> |
| 4543 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4544 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4545 | <section id='wic-getting-help'> |
| 4546 | <title>Getting Help</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4547 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4548 | <para> |
| 4549 | You can get general help for the <filename>wic</filename> |
| 4550 | command by entering the <filename>wic</filename> command |
| 4551 | by itself or by entering the command with a help argument |
| 4552 | as follows: |
| 4553 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4554 | $ wic -h |
| 4555 | $ wic --help |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4556 | </literallayout> |
| 4557 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4558 | |
| 4559 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4560 | Currently, Wic supports two commands: |
| 4561 | <filename>create</filename> and <filename>list</filename>. |
| 4562 | You can get help for these commands as follows: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4563 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4564 | $ wic help <replaceable>command</replaceable> |
| 4565 | with <replaceable>command</replaceable> being either |
| 4566 | <filename>create</filename> or <filename>list</filename>. |
| 4567 | </literallayout> |
| 4568 | </para> |
| 4569 | |
| 4570 | <para> |
| 4571 | You can also get detailed help on a number of topics |
| 4572 | from the help system. |
| 4573 | The output of <filename>wic --help</filename> |
| 4574 | displays a list of available help |
| 4575 | topics under a "Help topics" heading. |
| 4576 | You can have the help system display the help text for |
| 4577 | a given topic by prefacing the topic with |
| 4578 | <filename>wic help</filename>: |
| 4579 | <literallayout class='monospaced'> |
| 4580 | $ wic help <replaceable>help_topic</replaceable> |
| 4581 | </literallayout> |
| 4582 | </para> |
| 4583 | |
| 4584 | <para> |
| 4585 | You can find out more about the images |
| 4586 | Wic creates using the existing |
| 4587 | kickstart files with the following form of the command: |
| 4588 | <literallayout class='monospaced'> |
| 4589 | $ wic list <replaceable>image</replaceable> help |
| 4590 | </literallayout> |
| 4591 | with <filename><replaceable>image</replaceable></filename> |
| 4592 | being either <filename>directdisk</filename> or |
| 4593 | <filename>mkefidisk</filename>. |
| 4594 | </para> |
| 4595 | </section> |
| 4596 | |
| 4597 | <section id='operational-modes'> |
| 4598 | <title>Operational Modes</title> |
| 4599 | |
| 4600 | <para> |
| 4601 | You can use Wic in two different |
| 4602 | modes, depending on how much control you need for |
| 4603 | specifying the Openembedded build artifacts that are |
| 4604 | used for creating the image: Raw and Cooked: |
| 4605 | <itemizedlist> |
| 4606 | <listitem><para> |
| 4607 | <emphasis>Raw Mode:</emphasis> |
| 4608 | You explicitly specify build artifacts through |
| 4609 | command-line arguments. |
| 4610 | </para></listitem> |
| 4611 | <listitem><para> |
| 4612 | <emphasis>Cooked Mode:</emphasis> |
| 4613 | The current |
| 4614 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4615 | setting and image name are used to automatically |
| 4616 | locate and provide the build artifacts. |
| 4617 | </para></listitem> |
| 4618 | </itemizedlist> |
| 4619 | </para> |
| 4620 | |
| 4621 | <para> |
| 4622 | Regardless of the mode you use, you need to have the build |
| 4623 | artifacts ready and available. |
| 4624 | Additionally, the environment must be set up using the |
| 4625 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 4626 | or |
| 4627 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink> |
| 4628 | script found in the |
| 4629 | <link linkend='build-directory'>Build Directory</link>. |
| 4630 | </para> |
| 4631 | |
| 4632 | <section id='raw-mode'> |
| 4633 | <title>Raw Mode</title> |
| 4634 | |
| 4635 | <para> |
| 4636 | The general form of the |
| 4637 | <filename>wic</filename> command in raw mode is: |
| 4638 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4639 | $ wic create <replaceable>image_name</replaceable>.wks [<replaceable>options</replaceable>] [...] |
| 4640 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4641 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4642 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4643 | <replaceable>image_name</replaceable>.wks |
| 4644 | An OpenEmbedded kickstart file. You can provide |
| 4645 | your own custom file or use a file from a set of |
| 4646 | existing files as described by further options. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4647 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4648 | -o <replaceable>OUTDIR</replaceable>, --outdir=<replaceable>OUTDIR</replaceable> |
| 4649 | The name of a directory in which to create image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4650 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4651 | -i <replaceable>PROPERTIES_FILE</replaceable>, --infile=<replaceable>PROPERTIES_FILE</replaceable> |
| 4652 | The name of a file containing the values for image |
| 4653 | properties as a JSON file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4654 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4655 | -e <replaceable>IMAGE_NAME</replaceable>, --image-name=<replaceable>IMAGE_NAME</replaceable> |
| 4656 | The name of the image from which to use the artifacts |
| 4657 | (e.g. <filename>core-image-sato</filename>). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4658 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4659 | -r <replaceable>ROOTFS_DIR</replaceable>, --rootfs-dir=<replaceable>ROOTFS_DIR</replaceable> |
| 4660 | The path to the <filename>/rootfs</filename> directory to use as the |
| 4661 | <filename>.wks</filename> rootfs source. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4662 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4663 | -b <replaceable>BOOTIMG_DIR</replaceable>, --bootimg-dir=<replaceable>BOOTIMG_DIR</replaceable> |
| 4664 | The path to the directory containing the boot artifacts |
| 4665 | (e.g. <filename>/EFI</filename> or <filename>/syslinux</filename>) to use as the <filename>.wks</filename> bootimg |
| 4666 | source. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4667 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4668 | -k <replaceable>KERNEL_DIR</replaceable>, --kernel-dir=<replaceable>KERNEL_DIR</replaceable> |
| 4669 | The path to the directory containing the kernel to use |
| 4670 | in the <filename>.wks</filename> boot image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4671 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4672 | -n <replaceable>NATIVE_SYSROOT</replaceable>, --native-sysroot=<replaceable>NATIVE_SYSROOT</replaceable> |
| 4673 | The path to the native sysroot containing the tools to use |
| 4674 | to build the image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4675 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4676 | -s, --skip-build-check |
| 4677 | Skips the build check. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4678 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4679 | -D, --debug |
| 4680 | Output debug information. |
| 4681 | </literallayout> |
| 4682 | <note> |
| 4683 | You do not need root privileges to run |
| 4684 | Wic. |
| 4685 | In fact, you should not run as root when using the |
| 4686 | utility. |
| 4687 | </note> |
| 4688 | </para> |
| 4689 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4690 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4691 | <section id='cooked-mode'> |
| 4692 | <title>Cooked Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4693 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4694 | <para> |
| 4695 | The general form of the <filename>wic</filename> command |
| 4696 | using Cooked Mode is: |
| 4697 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4698 | $ wic create <replaceable>kickstart_file</replaceable> -e <replaceable>image_name</replaceable> |
| 4699 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4700 | Where: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4701 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4702 | <replaceable>kickstart_file</replaceable> |
| 4703 | An OpenEmbedded kickstart file. You can provide your own |
| 4704 | custom file or a supplied file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4705 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4706 | <replaceable>image_name</replaceable> |
| 4707 | Specifies the image built using the OpenEmbedded build |
| 4708 | system. |
| 4709 | </literallayout> |
| 4710 | This form is the simplest and most user-friendly, as it |
| 4711 | does not require specifying all individual parameters. |
| 4712 | All you need to provide is your own |
| 4713 | <filename>.wks</filename> file or one provided with the |
| 4714 | release. |
| 4715 | </para> |
| 4716 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4717 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4718 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4719 | <section id='using-a-provided-kickstart-file'> |
| 4720 | <title>Using an Existing Kickstart File</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4721 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4722 | <para> |
| 4723 | If you do not want to create your own |
| 4724 | <filename>.wks</filename> file, you can use an existing |
| 4725 | file provided by the Wic installation. |
| 4726 | Use the following command to list the available files: |
| 4727 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4728 | $ wic list images |
| 4729 | directdisk Create a 'pcbios' direct disk image |
| 4730 | mkefidisk Create an EFI disk image |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4731 | </literallayout> |
| 4732 | When you use an existing file, you do not have to use the |
| 4733 | <filename>.wks</filename> extension. |
| 4734 | Here is an example in Raw Mode that uses the |
| 4735 | <filename>directdisk</filename> file: |
| 4736 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4737 | $ wic create directdisk -r <replaceable>rootfs_dir</replaceable> -b <replaceable>bootimg_dir</replaceable> \ |
| 4738 | -k <replaceable>kernel_dir</replaceable> -n <replaceable>native_sysroot</replaceable> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4739 | </literallayout> |
| 4740 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4741 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4742 | <para> |
| 4743 | Here are the actual partition language commands |
| 4744 | used in the <filename>mkefidisk.wks</filename> file to |
| 4745 | generate an image: |
| 4746 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4747 | # short-description: Create an EFI disk image |
| 4748 | # long-description: Creates a partitioned EFI disk image that the user |
| 4749 | # can directly dd to boot media. |
| 4750 | |
| 4751 | part /boot --source bootimg-efi --ondisk sda --label msdos --active --align 1024 |
| 4752 | |
| 4753 | part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024 |
| 4754 | |
| 4755 | part swap --ondisk sda --size 44 --label swap1 --fstype=swap |
| 4756 | |
| 4757 | bootloader --timeout=10 --append="rootwait rootfstype=ext3 console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0" |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4758 | </literallayout> |
| 4759 | </para> |
| 4760 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4761 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4762 | <section id='wic-usage-examples'> |
| 4763 | <title>Examples</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4764 | |
| 4765 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4766 | This section provides several examples that show how to use |
| 4767 | the <filename>wic</filename> utility. |
| 4768 | All the examples assume the list of requirements in the |
| 4769 | "<link linkend='wic-requirements'>Requirements</link>" |
| 4770 | section have been met. |
| 4771 | The examples assume the previously generated image is |
| 4772 | <filename>core-image-minimal</filename>. |
| 4773 | </para> |
| 4774 | |
| 4775 | <section id='generate-an-image-using-a-provided-kickstart-file'> |
| 4776 | <title>Generate an Image using an Existing Kickstart File</title> |
| 4777 | |
| 4778 | <para> |
| 4779 | This example runs in Cooked Mode and uses the |
| 4780 | <filename>mkefidisk</filename> kickstart file: |
| 4781 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4782 | $ wic create mkefidisk -e core-image-minimal |
| 4783 | Checking basic build environment... |
| 4784 | Done. |
| 4785 | |
| 4786 | Creating image(s)... |
| 4787 | |
| 4788 | Info: The new image(s) can be found here: |
| 4789 | /var/tmp/wic/build/mkefidisk-201310230946-sda.direct |
| 4790 | |
| 4791 | The following build artifacts were used to create the image(s): |
| 4792 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4793 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/work/minnow-poky-linux/core-image-minimal/1.0-r0/core-image-minimal-1.0/hddimg |
| 4794 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/minnow/usr/src/kernel |
| 4795 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4796 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4797 | The image(s) were created using OE kickstart file: |
| 4798 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/mkefidisk.wks |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4799 | </literallayout> |
| 4800 | The previous example shows the easiest way to create |
| 4801 | an image by running in Cooked Mode and using the |
| 4802 | <filename>-e</filename> option with an existing |
| 4803 | kickstart file. |
| 4804 | All that is necessary is to specify the image used to |
| 4805 | generate the artifacts. |
| 4806 | Your <filename>local.conf</filename> needs to have the |
| 4807 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4808 | variable set to the machine you are using, which is |
| 4809 | "minnow" in this example. |
| 4810 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4811 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4812 | <para> |
| 4813 | The output specifies the exact image created as well as |
| 4814 | where it was created. |
| 4815 | The output also names the artifacts used and the exact |
| 4816 | <filename>.wks</filename> script that was used to |
| 4817 | generate the image. |
| 4818 | <note> |
| 4819 | You should always verify the details provided in the |
| 4820 | output to make sure that the image was indeed |
| 4821 | created exactly as expected. |
| 4822 | </note> |
| 4823 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4824 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4825 | <para> |
| 4826 | Continuing with the example, you can now directly |
| 4827 | <filename>dd</filename> the image to a USB stick, or |
| 4828 | whatever media for which you built your image, |
| 4829 | and boot the resulting media: |
| 4830 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4831 | $ sudo dd if=/var/tmp/wic/build/mkefidisk-201310230946-sda.direct of=/dev/sdb |
| 4832 | [sudo] password for trz: |
| 4833 | 182274+0 records in |
| 4834 | 182274+0 records out |
| 4835 | 93324288 bytes (93 MB) copied, 14.4777 s, 6.4 MB/s |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4836 | [trz at empanada ~]$ sudo eject /dev/sdb |
| 4837 | </literallayout> |
| 4838 | </para> |
| 4839 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4840 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4841 | <section id='using-a-modified-kickstart-file'> |
| 4842 | <title>Using a Modified Kickstart File</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4843 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4844 | <para> |
| 4845 | Because partitioned image creation is |
| 4846 | driven by the kickstart file, it is easy to affect |
| 4847 | image creation by changing the parameters in the file. |
| 4848 | This next example demonstrates that through modification |
| 4849 | of the <filename>directdisk</filename> kickstart file. |
| 4850 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4851 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4852 | <para> |
| 4853 | As mentioned earlier, you can use the command |
| 4854 | <filename>wic list images</filename> to show the list |
| 4855 | of existing kickstart files. |
| 4856 | The directory in which these files reside is |
| 4857 | <filename>scripts/lib/image/canned-wks/</filename> |
| 4858 | located in the |
| 4859 | <link linkend='source-directory'>Source Directory</link>. |
| 4860 | Because the available files reside in this directory, |
| 4861 | you can create and add your own custom files to the |
| 4862 | directory. |
| 4863 | Subsequent use of the |
| 4864 | <filename>wic list images</filename> command would then |
| 4865 | include your kickstart files. |
| 4866 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4867 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4868 | <para> |
| 4869 | In this example, the existing |
| 4870 | <filename>directdisk</filename> file already does most |
| 4871 | of what is needed. |
| 4872 | However, for the hardware in this example, the image |
| 4873 | will need to boot from <filename>sdb</filename> instead |
| 4874 | of <filename>sda</filename>, which is what the |
| 4875 | <filename>directdisk</filename> kickstart file uses. |
| 4876 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4877 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4878 | <para> |
| 4879 | The example begins by making a copy of the |
| 4880 | <filename>directdisk.wks</filename> file in the |
| 4881 | <filename>scripts/lib/image/canned-wks</filename> |
| 4882 | directory and then by changing the lines that specify |
| 4883 | the target disk from which to boot. |
| 4884 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4885 | $ cp /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks \ |
| 4886 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4887 | </literallayout> |
| 4888 | Next, the example modifies the |
| 4889 | <filename>directdisksdb.wks</filename> file and changes |
| 4890 | all instances of "<filename>--ondisk sda</filename>" |
| 4891 | to "<filename>--ondisk sdb</filename>". |
| 4892 | The example changes the following two lines and leaves |
| 4893 | the remaining lines untouched: |
| 4894 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4895 | part /boot --source bootimg-pcbios --ondisk sdb --label boot --active --align 1024 |
| 4896 | part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024 |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4897 | </literallayout> |
| 4898 | Once the lines are changed, the example generates the |
| 4899 | <filename>directdisksdb</filename> image. |
| 4900 | The command points the process at the |
| 4901 | <filename>core-image-minimal</filename> artifacts for |
| 4902 | the Next Unit of Computing (nuc) |
| 4903 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4904 | the <filename>local.conf</filename>. |
| 4905 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4906 | $ wic create directdisksdb -e core-image-minimal |
| 4907 | Checking basic build environment... |
| 4908 | Done. |
| 4909 | |
| 4910 | Creating image(s)... |
| 4911 | |
| 4912 | Info: The new image(s) can be found here: |
| 4913 | /var/tmp/wic/build/directdisksdb-201310231131-sdb.direct |
| 4914 | |
| 4915 | The following build artifacts were used to create the image(s): |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4916 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4917 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/nuc-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4918 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/share |
| 4919 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/nuc/usr/src/kernel |
| 4920 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4921 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4922 | The image(s) were created using OE kickstart file: |
| 4923 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisksdb.wks |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4924 | </literallayout> |
| 4925 | Continuing with the example, you can now directly |
| 4926 | <filename>dd</filename> the image to a USB stick, or |
| 4927 | whatever media for which you built your image, |
| 4928 | and boot the resulting media: |
| 4929 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4930 | $ sudo dd if=/var/tmp/wic/build/directdisksdb-201310231131-sdb.direct of=/dev/sdb |
| 4931 | 86018+0 records in |
| 4932 | 86018+0 records out |
| 4933 | 44041216 bytes (44 MB) copied, 13.0734 s, 3.4 MB/s |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4934 | [trz at empanada tmp]$ sudo eject /dev/sdb |
| 4935 | </literallayout> |
| 4936 | </para> |
| 4937 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4938 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4939 | <section id='creating-an-image-based-on-core-image-minimal-and-crownbay-noemgd'> |
| 4940 | <title>Creating an Image Based on <filename>core-image-minimal</filename> and <filename>crownbay-noemgd</filename></title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4941 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4942 | <para> |
| 4943 | This example creates an image based on |
| 4944 | <filename>core-image-minimal</filename> and a |
| 4945 | <filename>crownbay-noemgd</filename> |
| 4946 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 4947 | that works right out of the box. |
| 4948 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4949 | $ wic create directdisk -e core-image-minimal |
| 4950 | |
| 4951 | Checking basic build environment... |
| 4952 | Done. |
| 4953 | |
| 4954 | Creating image(s)... |
| 4955 | |
| 4956 | Info: The new image(s) can be found here: |
| 4957 | /var/tmp/wic/build/directdisk-201309252350-sda.direct |
| 4958 | |
| 4959 | The following build artifacts were used to create the image(s): |
| 4960 | |
| 4961 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4962 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share |
| 4963 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4964 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4965 | |
| 4966 | The image(s) were created using OE kickstart file: |
| 4967 | /home/trz/yocto/yocto-image/scripts/lib/image/canned-wks/directdisk.wks |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4968 | </literallayout> |
| 4969 | </para> |
| 4970 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4971 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4972 | <section id='using-a-modified-kickstart-file-and-running-in-raw-mode'> |
| 4973 | <title>Using a Modified Kickstart File and Running in Raw Mode</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4974 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 4975 | <para> |
| 4976 | This next example manually specifies each build artifact |
| 4977 | (runs in Raw Mode) and uses a modified kickstart file. |
| 4978 | The example also uses the <filename>-o</filename> option |
| 4979 | to cause Wic to create the output |
| 4980 | somewhere other than the default |
| 4981 | <filename>/var/tmp/wic</filename> directory: |
| 4982 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4983 | $ wic create ~/test.wks -o /home/trz/testwic --rootfs-dir \ |
| 4984 | /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs \ |
| 4985 | --bootimg-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share \ |
| 4986 | --kernel-dir /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel \ |
| 4987 | --native-sysroot /home/trz/yocto/yocto-image/build/tmp/sysroots/x86_64-linux |
| 4988 | |
| 4989 | Creating image(s)... |
| 4990 | |
| 4991 | Info: The new image(s) can be found here: |
| 4992 | /home/trz/testwic/build/test-201309260032-sda.direct |
| 4993 | |
| 4994 | The following build artifacts were used to create the image(s): |
| 4995 | |
| 4996 | ROOTFS_DIR: /home/trz/yocto/yocto-image/build/tmp/work/crownbay_noemgd-poky-linux/core-image-minimal/1.0-r0/rootfs |
| 4997 | BOOTIMG_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/share |
| 4998 | KERNEL_DIR: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 4999 | NATIVE_SYSROOT: /home/trz/yocto/yocto-image/build/tmp/sysroots/crownbay-noemgd/usr/src/kernel |
| 5000 | |
| 5001 | The image(s) were created using OE kickstart file: |
| 5002 | /home/trz/test.wks |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5003 | </literallayout> |
| 5004 | For this example, |
| 5005 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 5006 | did not have to be specified in the |
| 5007 | <filename>local.conf</filename> file since the |
| 5008 | artifact is manually specified. |
| 5009 | </para> |
| 5010 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5011 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5012 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5013 | <section id='openembedded-kickstart-plugins'> |
| 5014 | <title>Plug-ins</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5015 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5016 | <para> |
| 5017 | Plug-ins allow Wic functionality to |
| 5018 | be extended and specialized by users. |
| 5019 | This section documents the plug-in interface, which is |
| 5020 | currently restricted to source plug-ins. |
| 5021 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5022 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5023 | <para> |
| 5024 | Source plug-ins provide a mechanism to customize |
| 5025 | various aspects of the image generation process in |
| 5026 | Wic, mainly the contents of |
| 5027 | partitions. |
| 5028 | The plug-ins provide a mechanism for mapping values |
| 5029 | specified in <filename>.wks</filename> files using the |
| 5030 | <filename>--source</filename> keyword to a |
| 5031 | particular plug-in implementation that populates a |
| 5032 | corresponding partition. |
| 5033 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5034 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5035 | <para> |
| 5036 | A source plug-in is created as a subclass of |
| 5037 | <filename>SourcePlugin</filename>. |
| 5038 | The plug-in file containing it is added to |
| 5039 | <filename>scripts/lib/wic/plugins/source/</filename> to |
| 5040 | make the plug-in implementation available to the |
| 5041 | Wic implementation. |
| 5042 | For more information, see |
| 5043 | <filename>scripts/lib/wic/pluginbase.py</filename>. |
| 5044 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5045 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5046 | <para> |
| 5047 | Source plug-ins can also be implemented and added by |
| 5048 | external layers. |
| 5049 | As such, any plug-ins found in a |
| 5050 | <filename>scripts/lib/wic/plugins/source/</filename> |
| 5051 | directory in an external layer are also made |
| 5052 | available. |
| 5053 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5054 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5055 | <para> |
| 5056 | When the Wic implementation needs |
| 5057 | to invoke a partition-specific implementation, it looks |
| 5058 | for the plug-in that has the same name as the |
| 5059 | <filename>--source</filename> parameter given to |
| 5060 | that partition. |
| 5061 | For example, if the partition is set up as follows: |
| 5062 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5063 | part /boot --source bootimg-pcbios ... |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5064 | </literallayout> |
| 5065 | The methods defined as class members of the plug-in |
| 5066 | having the matching <filename>bootimg-pcbios.name</filename> |
| 5067 | class member are used. |
| 5068 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5069 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5070 | <para> |
| 5071 | To be more concrete, here is the plug-in definition that |
| 5072 | matches a |
| 5073 | <filename>--source bootimg-pcbios</filename> usage, |
| 5074 | along with an example |
| 5075 | method called by the Wic implementation |
| 5076 | when it needs to invoke an implementation-specific |
| 5077 | partition-preparation function: |
| 5078 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5079 | class BootimgPcbiosPlugin(SourcePlugin): |
| 5080 | name = 'bootimg-pcbios' |
| 5081 | |
| 5082 | @classmethod |
| 5083 | def do_prepare_partition(self, part, ...) |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5084 | </literallayout> |
| 5085 | If the subclass itself does not implement a function, a |
| 5086 | default version in a superclass is located and |
| 5087 | used, which is why all plug-ins must be derived from |
| 5088 | <filename>SourcePlugin</filename>. |
| 5089 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5090 | |
| 5091 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5092 | The <filename>SourcePlugin</filename> class defines the |
| 5093 | following methods, which is the current set of methods |
| 5094 | that can be implemented or overridden by |
| 5095 | <filename>--source</filename> plug-ins. |
| 5096 | Any methods not implemented by a |
| 5097 | <filename>SourcePlugin</filename> subclass inherit the |
| 5098 | implementations present in the |
| 5099 | <filename>SourcePlugin</filename> class. |
| 5100 | For more information, see the |
| 5101 | <filename>SourcePlugin</filename> source for details: |
| 5102 | </para> |
| 5103 | |
| 5104 | <para> |
| 5105 | <itemizedlist> |
| 5106 | <listitem><para> |
| 5107 | <emphasis><filename>do_prepare_partition()</filename>:</emphasis> |
| 5108 | Called to do the actual content population for a |
| 5109 | partition. |
| 5110 | In other words, the method prepares the final |
| 5111 | partition image that is incorporated into the |
| 5112 | disk image. |
| 5113 | </para></listitem> |
| 5114 | <listitem><para> |
| 5115 | <emphasis><filename>do_configure_partition()</filename>:</emphasis> |
| 5116 | Called before |
| 5117 | <filename>do_prepare_partition()</filename>. |
| 5118 | This method is typically used to create custom |
| 5119 | configuration files for a partition (e.g. syslinux |
| 5120 | or grub configuration files). |
| 5121 | </para></listitem> |
| 5122 | <listitem><para> |
| 5123 | <emphasis><filename>do_install_disk()</filename>:</emphasis> |
| 5124 | Called after all partitions have been prepared and |
| 5125 | assembled into a disk image. |
| 5126 | This method provides a hook to allow finalization |
| 5127 | of a disk image, (e.g. writing an MBR). |
| 5128 | </para></listitem> |
| 5129 | <listitem><para> |
| 5130 | <emphasis><filename>do_stage_partition()</filename>:</emphasis> |
| 5131 | Special content-staging hook called before |
| 5132 | <filename>do_prepare_partition()</filename>. |
| 5133 | This method is normally empty.</para> |
| 5134 | <para>Typically, a partition just uses the passed-in |
| 5135 | parameters (e.g. the unmodified value of |
| 5136 | <filename>bootimg_dir</filename>). |
| 5137 | However, in some cases things might need to be |
| 5138 | more tailored. |
| 5139 | As an example, certain files might additionally |
| 5140 | need to be taken from |
| 5141 | <filename>bootimg_dir + /boot</filename>. |
| 5142 | This hook allows those files to be staged in a |
| 5143 | customized fashion. |
| 5144 | <note> |
| 5145 | <filename>get_bitbake_var()</filename> |
| 5146 | allows you to access non-standard variables |
| 5147 | that you might want to use for this. |
| 5148 | </note> |
| 5149 | </para></listitem> |
| 5150 | </itemizedlist> |
| 5151 | </para> |
| 5152 | |
| 5153 | <para> |
| 5154 | This scheme is extensible. |
| 5155 | Adding more hooks is a simple matter of adding more |
| 5156 | plug-in methods to <filename>SourcePlugin</filename> and |
| 5157 | derived classes. |
| 5158 | The code that then needs to call the plug-in methods uses |
| 5159 | <filename>plugin.get_source_plugin_methods()</filename> |
| 5160 | to find the method or methods needed by the call. |
| 5161 | Retrieval of those methods is accomplished |
| 5162 | by filling up a dict with keys |
| 5163 | containing the method names of interest. |
| 5164 | On success, these will be filled in with the actual |
| 5165 | methods. |
| 5166 | Please see the Wic |
| 5167 | implementation for examples and details. |
| 5168 | </para> |
| 5169 | </section> |
| 5170 | |
| 5171 | <section id='openembedded-kickstart-wks-reference'> |
| 5172 | <title>OpenEmbedded Kickstart (<filename>.wks</filename>) Reference</title> |
| 5173 | |
| 5174 | <para> |
| 5175 | The current Wic implementation supports |
| 5176 | only the basic kickstart partitioning commands: |
| 5177 | <filename>partition</filename> (or <filename>part</filename> |
| 5178 | for short) and <filename>bootloader</filename>. |
| 5179 | <note> |
| 5180 | Future updates will implement more commands and options. |
| 5181 | If you use anything that is not specifically |
| 5182 | supported, results can be unpredictable. |
| 5183 | </note> |
| 5184 | </para> |
| 5185 | |
| 5186 | <para> |
| 5187 | The following is a list of the commands, their syntax, |
| 5188 | and meanings. |
| 5189 | The commands are based on the Fedora |
| 5190 | kickstart versions but with modifications to |
| 5191 | reflect Wic capabilities. |
| 5192 | You can see the original documentation for those commands |
| 5193 | at the following links: |
| 5194 | <itemizedlist> |
| 5195 | <listitem><para> |
| 5196 | <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition'>http://fedoraproject.org/wiki/Anaconda/Kickstart#part_or_partition</ulink> |
| 5197 | </para></listitem> |
| 5198 | <listitem><para> |
| 5199 | <ulink url='http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader'>http://fedoraproject.org/wiki/Anaconda/Kickstart#bootloader</ulink> |
| 5200 | </para></listitem> |
| 5201 | </itemizedlist> |
| 5202 | </para> |
| 5203 | |
| 5204 | <section id='command-part-or-partition'> |
| 5205 | <title>Command: part or partition</title> |
| 5206 | |
| 5207 | <para> |
| 5208 | Either of these commands create a partition on the system |
| 5209 | and use the following syntax: |
| 5210 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5211 | part [<replaceable>mntpoint</replaceable>] |
| 5212 | partition [<replaceable>mntpoint</replaceable>] |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5213 | </literallayout> |
| 5214 | If you do not provide |
| 5215 | <replaceable>mntpoint</replaceable>, Wic creates a |
| 5216 | partition but does not mount it. |
| 5217 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5218 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5219 | <para> |
| 5220 | The |
| 5221 | <filename><replaceable>mntpoint</replaceable></filename> |
| 5222 | is where the partition will be mounted and must be of |
| 5223 | one of the following forms: |
| 5224 | <itemizedlist> |
| 5225 | <listitem><para> |
| 5226 | <filename>/<replaceable>path</replaceable></filename>: |
| 5227 | For example, <filename>/</filename>, |
| 5228 | <filename>/usr</filename>, or |
| 5229 | <filename>/home</filename> |
| 5230 | </para></listitem> |
| 5231 | <listitem><para> |
| 5232 | <filename>swap</filename>: |
| 5233 | The created partition is used as swap space. |
| 5234 | </para></listitem> |
| 5235 | </itemizedlist> |
| 5236 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5237 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5238 | <para> |
| 5239 | Specifying a <replaceable>mntpoint</replaceable> causes |
| 5240 | the partition to automatically be mounted. |
| 5241 | Wic achieves this by adding entries to the filesystem |
| 5242 | table (fstab) during image generation. |
| 5243 | In order for wic to generate a valid fstab, you must |
| 5244 | also provide one of the <filename>--ondrive</filename>, |
| 5245 | <filename>--ondisk</filename>, or |
| 5246 | <filename>--use-uuid</filename> partition options as |
| 5247 | part of the command. |
| 5248 | Here is an example using "/" as the mountpoint. |
| 5249 | The command uses "--ondisk" to force the partition onto |
| 5250 | the <filename>sdb</filename> disk: |
| 5251 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5252 | part / --source rootfs --ondisk sdb --fstype=ext3 --label platform --align 1024 |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5253 | </literallayout> |
| 5254 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5255 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5256 | <para> |
| 5257 | Here is a list that describes other supported options |
| 5258 | you can use with the <filename>part</filename> and |
| 5259 | <filename>partition</filename> commands: |
| 5260 | <itemizedlist> |
| 5261 | <listitem><para> |
| 5262 | <emphasis><filename>--size</filename>:</emphasis> |
| 5263 | The minimum partition size in MBytes. |
| 5264 | Specify an integer value such as 500. |
| 5265 | Do not append the number with "MB". |
| 5266 | You do not need this option if you use |
| 5267 | <filename>--source</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5268 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5269 | <listitem><para> |
| 5270 | <emphasis><filename>--source</filename>:</emphasis> |
| 5271 | This option is a |
| 5272 | Wic-specific option that |
| 5273 | names the source of the data that populates |
| 5274 | the partition. |
| 5275 | The most common value for this option is |
| 5276 | "rootfs", but you can use any value that maps to |
| 5277 | a valid source plug-in. |
| 5278 | For information on the source plug-ins, see the |
| 5279 | "<link linkend='openembedded-kickstart-plugins'>Plug-ins</link>" |
| 5280 | section.</para> |
| 5281 | <para>If you use |
| 5282 | <filename>--source rootfs</filename>, |
| 5283 | Wic creates a partition as |
| 5284 | large as needed and to fill it with the contents |
| 5285 | of the root filesystem pointed to by the |
| 5286 | <filename>-r</filename> command-line option |
| 5287 | or the equivalent rootfs derived from the |
| 5288 | <filename>-e</filename> command-line |
| 5289 | option. |
| 5290 | The filesystem type used to create the |
| 5291 | partition is driven by the value of the |
| 5292 | <filename>--fstype</filename> option |
| 5293 | specified for the partition. |
| 5294 | See the entry on |
| 5295 | <filename>--fstype</filename> that |
| 5296 | follows for more information. |
| 5297 | </para> |
| 5298 | <para>If you use |
| 5299 | <filename>--source <replaceable>plugin-name</replaceable></filename>, |
| 5300 | Wic creates a partition as |
| 5301 | large as needed and fills it with the contents |
| 5302 | of the partition that is generated by the |
| 5303 | specified plug-in name using the data pointed |
| 5304 | to by the <filename>-r</filename> command-line |
| 5305 | option or the equivalent rootfs derived from the |
| 5306 | <filename>-e</filename> command-line |
| 5307 | option. |
| 5308 | Exactly what those contents and filesystem type |
| 5309 | end up being are dependent on the given plug-in |
| 5310 | implementation. |
| 5311 | </para> |
| 5312 | <para>If you do not use the |
| 5313 | <filename>--source</filename> option, the |
| 5314 | <filename>wic</filename> command creates an |
| 5315 | empty partition. |
| 5316 | Consequently, you must use the |
| 5317 | <filename>--size</filename> option to specify |
| 5318 | the size of the empty partition. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5319 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5320 | <listitem><para> |
| 5321 | <emphasis><filename>--ondisk</filename> or <filename>--ondrive</filename>:</emphasis> |
| 5322 | Forces the partition to be created on a |
| 5323 | particular disk. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5324 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5325 | <listitem><para> |
| 5326 | <emphasis><filename>--fstype</filename>:</emphasis> |
| 5327 | Sets the file system type for the partition. |
| 5328 | Valid values are: |
| 5329 | <itemizedlist> |
| 5330 | <listitem><para><filename>ext4</filename> |
| 5331 | </para></listitem> |
| 5332 | <listitem><para><filename>ext3</filename> |
| 5333 | </para></listitem> |
| 5334 | <listitem><para><filename>ext2</filename> |
| 5335 | </para></listitem> |
| 5336 | <listitem><para><filename>btrfs</filename> |
| 5337 | </para></listitem> |
| 5338 | <listitem><para><filename>squashfs</filename> |
| 5339 | </para></listitem> |
| 5340 | <listitem><para><filename>swap</filename> |
| 5341 | </para></listitem> |
| 5342 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5343 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5344 | <listitem><para> |
| 5345 | <emphasis><filename>--fsoptions</filename>:</emphasis> |
| 5346 | Specifies a free-form string of options to be |
| 5347 | used when mounting the filesystem. |
| 5348 | This string will be copied into the |
| 5349 | <filename>/etc/fstab</filename> file of the |
| 5350 | installed system and should be enclosed in |
| 5351 | quotes. |
| 5352 | If not specified, the default string |
| 5353 | is "defaults". |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5354 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5355 | <listitem><para> |
| 5356 | <emphasis><filename>--label label</filename>:</emphasis> |
| 5357 | Specifies the label to give to the filesystem to |
| 5358 | be made on the partition. |
| 5359 | If the given label is already in use by another |
| 5360 | filesystem, a new label is created for the |
| 5361 | partition. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5362 | </para></listitem> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5363 | <listitem><para> |
| 5364 | <emphasis><filename>--active</filename>:</emphasis> |
| 5365 | Marks the partition as active. |
| 5366 | </para></listitem> |
| 5367 | <listitem><para> |
| 5368 | <emphasis><filename>--align (in KBytes)</filename>:</emphasis> |
| 5369 | This option is a |
| 5370 | Wic-specific option that |
| 5371 | says to start a partition on an |
| 5372 | <replaceable>x</replaceable> KBytes |
| 5373 | boundary.</para></listitem> |
| 5374 | <listitem><para> |
| 5375 | <emphasis><filename>--no-table</filename>:</emphasis> |
| 5376 | This option is a |
| 5377 | Wic-specific option. |
| 5378 | Using the option reserves space for the |
| 5379 | partition and causes it to become populated. |
| 5380 | However, the partition is not added to the |
| 5381 | partition table. |
| 5382 | </para></listitem> |
| 5383 | <listitem><para> |
| 5384 | <emphasis><filename>--extra-space</filename>:</emphasis> |
| 5385 | This option is a |
| 5386 | Wic-specific option that |
| 5387 | adds extra space after the space filled by the |
| 5388 | content of the partition. |
| 5389 | The final size can go beyond the size specified |
| 5390 | by the <filename>--size</filename> option. |
| 5391 | The default value is 10 Mbytes. |
| 5392 | </para></listitem> |
| 5393 | <listitem><para> |
| 5394 | <emphasis><filename>--overhead-factor</filename>:</emphasis> |
| 5395 | This option is a |
| 5396 | Wic-specific option that |
| 5397 | multiplies the size of the partition by the |
| 5398 | option's value. |
| 5399 | You must supply a value greater than or equal to |
| 5400 | "1". |
| 5401 | The default value is "1.3". |
| 5402 | </para></listitem> |
| 5403 | <listitem><para> |
| 5404 | <emphasis><filename>--part-type</filename>:</emphasis> |
| 5405 | This option is a |
| 5406 | Wic-specific option that |
| 5407 | specifies the partition type globally |
| 5408 | unique identifier (GUID) for GPT partitions. |
| 5409 | You can find the list of partition type GUIDs |
| 5410 | at |
| 5411 | <ulink url='http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs'></ulink>. |
| 5412 | </para></listitem> |
| 5413 | <listitem><para> |
| 5414 | <emphasis><filename>--use-uuid</filename>:</emphasis> |
| 5415 | This option is a |
| 5416 | Wic-specific option that |
| 5417 | causes Wic to generate a |
| 5418 | random GUID for the partition. |
| 5419 | The generated identifier is used in the |
| 5420 | bootloader configuration to specify the root |
| 5421 | partition. |
| 5422 | </para></listitem> |
| 5423 | <listitem><para> |
| 5424 | <emphasis><filename>--uuid</filename>:</emphasis> |
| 5425 | This option is a |
| 5426 | Wic-specific |
| 5427 | option that specifies the partition UUID. |
| 5428 | </para></listitem> |
| 5429 | </itemizedlist> |
| 5430 | </para> |
| 5431 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5432 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5433 | <section id='command-bootloader'> |
| 5434 | <title>Command: bootloader</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5435 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5436 | <para> |
| 5437 | This command specifies how the bootloader should be |
| 5438 | configured and supports the following options: |
| 5439 | <note> |
| 5440 | Bootloader functionality and boot partitions are |
| 5441 | implemented by the various |
| 5442 | <filename>--source</filename> |
| 5443 | plug-ins that implement bootloader functionality. |
| 5444 | The bootloader command essentially provides a |
| 5445 | means of modifying bootloader configuration. |
| 5446 | </note> |
| 5447 | <itemizedlist> |
| 5448 | <listitem><para> |
| 5449 | <emphasis><filename>--timeout</filename>:</emphasis> |
| 5450 | Specifies the number of seconds before the |
| 5451 | bootloader times out and boots the default |
| 5452 | option. |
| 5453 | </para></listitem> |
| 5454 | <listitem><para> |
| 5455 | <emphasis><filename>--append</filename>:</emphasis> |
| 5456 | Specifies kernel parameters. |
| 5457 | These parameters will be added to the syslinux |
| 5458 | <filename>APPEND</filename> or |
| 5459 | <filename>grub</filename> kernel command line. |
| 5460 | </para></listitem> |
| 5461 | <listitem><para> |
| 5462 | <emphasis><filename>--configfile</filename>:</emphasis> |
| 5463 | Specifies a user-defined configuration file for |
| 5464 | the bootloader. |
| 5465 | You can provide a full pathname for the file or |
| 5466 | a file that exists in the |
| 5467 | <filename>canned-wks</filename> folder. |
| 5468 | This option overrides all other bootloader |
| 5469 | options. |
| 5470 | </para></listitem> |
| 5471 | </itemizedlist> |
| 5472 | </para> |
| 5473 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5474 | </section> |
| 5475 | </section> |
| 5476 | </section> |
| 5477 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 5478 | <section id='building-an-initramfs-image'> |
| 5479 | <title>Building an Initial RAM Filesystem (initramfs) Image</title> |
| 5480 | |
| 5481 | <para> |
| 5482 | initramfs is the successor of Initial RAM Disk (initrd). |
| 5483 | It is a "copy in and out" (cpio) archive of the initial file system |
| 5484 | that gets loaded into memory during the Linux startup process. |
| 5485 | Because Linux uses the contents of the archive during |
| 5486 | initialization, the initramfs needs to contain all of the device |
| 5487 | drivers and tools needed to mount the final root filesystem. |
| 5488 | </para> |
| 5489 | |
| 5490 | <para> |
| 5491 | To build an initramfs image and bundle it into the kernel, set the |
| 5492 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5493 | variable in your <filename>local.conf</filename> file, and set the |
| 5494 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE'><filename>INITRAMFS_IMAGE</filename></ulink> |
| 5495 | variable in your <filename>machine.conf</filename> file: |
| 5496 | <literallayout class='monospaced'> |
| 5497 | INITRAMFS_IMAGE_BUNDLE = "1" |
| 5498 | INITRAMFS_IMAGE = "<replaceable>image_recipe_name</replaceable>" |
| 5499 | </literallayout> |
| 5500 | Setting the <filename>INITRAMFS_IMAGE_BUNDLE</filename> |
| 5501 | flag causes the initramfs created by the recipe and defined by |
| 5502 | <filename>INITRAMFS_IMAGE</filename> to be unpacked into the |
| 5503 | <filename>${B}/usr/</filename> directory. |
| 5504 | The unpacked initramfs is then passed to the kernel's |
| 5505 | <filename>Makefile</filename> using the |
| 5506 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_INITRAMFS_SOURCE'><filename>CONFIG_INITRAMFS_SOURCE</filename></ulink> |
| 5507 | variable, allowing initramfs to be built in to the kernel |
| 5508 | normally. |
| 5509 | <note> |
| 5510 | The preferred method is to use the |
| 5511 | <filename>INITRAMFS_IMAGE</filename> variable rather than the |
| 5512 | <filename>INITRAMFS_TASK</filename> variable. |
| 5513 | Setting <filename>INITRAMFS_TASK</filename> is supported for |
| 5514 | backward compatibility. |
| 5515 | However, use of this variable has circular dependency |
| 5516 | problems. |
| 5517 | See the |
| 5518 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_IMAGE_BUNDLE'><filename>INITRAMFS_IMAGE_BUNDLE</filename></ulink> |
| 5519 | variable for additional information on these dependency |
| 5520 | problems. |
| 5521 | </note> |
| 5522 | </para> |
| 5523 | |
| 5524 | <para> |
| 5525 | The recipe that <filename>INITRAMFS_IMAGE</filename> |
| 5526 | points to must produce a <filename>.cpio.gz</filename>, |
| 5527 | <filename>.cpio.tar</filename>, <filename>.cpio.lz4</filename>, |
| 5528 | <filename>.cpio.lzma</filename>, or |
| 5529 | <filename>.cpio.xz</filename> file. |
| 5530 | You can ensure you produce one of these <filename>.cpio.*</filename> |
| 5531 | files by setting the |
| 5532 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INITRAMFS_FSTYPES'><filename>INITRAMFS_FSTYPES</filename></ulink> |
| 5533 | variable in your configuration file to one or more of the above |
| 5534 | file types. |
| 5535 | <note> |
| 5536 | If you add items to the initramfs image by way of its recipe, |
| 5537 | you should use |
| 5538 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink> |
| 5539 | rather than |
| 5540 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>. |
| 5541 | <filename>PACKAGE_INSTALL</filename> gives more direct control |
| 5542 | of what is added to the image as compared to the defaults you |
| 5543 | might not necessarily want that are set by the |
| 5544 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-image'><filename>image</filename></ulink> |
| 5545 | or |
| 5546 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-core-image'><filename>core-image</filename></ulink> |
| 5547 | classes. |
| 5548 | </note> |
| 5549 | </para> |
| 5550 | </section> |
| 5551 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5552 | <section id='configuring-the-kernel'> |
| 5553 | <title>Configuring the Kernel</title> |
| 5554 | |
| 5555 | <para> |
| 5556 | Configuring the Yocto Project kernel consists of making sure the |
| 5557 | <filename>.config</filename> file has all the right information |
| 5558 | in it for the image you are building. |
| 5559 | You can use the <filename>menuconfig</filename> tool and |
| 5560 | configuration fragments to make sure your |
| 5561 | <filename>.config</filename> file is just how you need it. |
| 5562 | You can also save known configurations in a |
| 5563 | <filename>defconfig</filename> file that the build system can use |
| 5564 | for kernel configuration. |
| 5565 | </para> |
| 5566 | |
| 5567 | <para> |
| 5568 | This section describes how to use <filename>menuconfig</filename>, |
| 5569 | create and use configuration fragments, and how to interactively |
| 5570 | modify your <filename>.config</filename> file to create the |
| 5571 | leanest kernel configuration file possible. |
| 5572 | </para> |
| 5573 | |
| 5574 | <para> |
| 5575 | For more information on kernel configuration, see the |
| 5576 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 5577 | section in the Yocto Project Linux Kernel Development Manual. |
| 5578 | </para> |
| 5579 | |
| 5580 | <section id='using-menuconfig'> |
| 5581 | <title>Using <filename>menuconfig</filename></title> |
| 5582 | |
| 5583 | <para> |
| 5584 | The easiest way to define kernel configurations is to set them through the |
| 5585 | <filename>menuconfig</filename> tool. |
| 5586 | This tool provides an interactive method with which |
| 5587 | to set kernel configurations. |
| 5588 | For general information on <filename>menuconfig</filename>, see |
| 5589 | <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>. |
| 5590 | </para> |
| 5591 | |
| 5592 | <para> |
| 5593 | To use the <filename>menuconfig</filename> tool in the Yocto Project development |
| 5594 | environment, you must launch it using BitBake. |
| 5595 | Thus, the environment must be set up using the |
| 5596 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 5597 | or |
| 5598 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink> |
| 5599 | script found in the |
| 5600 | <link linkend='build-directory'>Build Directory</link>. |
| 5601 | You must also be sure of the state of your build in the |
| 5602 | <link linkend='source-directory'>Source Directory</link>. |
| 5603 | The following commands run <filename>menuconfig</filename> |
| 5604 | assuming the Source Directory's top-level folder is |
| 5605 | <filename>~/poky</filename>: |
| 5606 | <literallayout class='monospaced'> |
| 5607 | $ cd poky |
| 5608 | $ source oe-init-build-env |
| 5609 | $ bitbake linux-yocto -c kernel_configme -f |
| 5610 | $ bitbake linux-yocto -c menuconfig |
| 5611 | </literallayout> |
| 5612 | Once <filename>menuconfig</filename> comes up, its standard |
| 5613 | interface allows you to interactively examine and configure |
| 5614 | all the kernel configuration parameters. |
| 5615 | After making your changes, simply exit the tool and save your |
| 5616 | changes to create an updated version of the |
| 5617 | <filename>.config</filename> configuration file. |
| 5618 | </para> |
| 5619 | |
| 5620 | <para> |
| 5621 | Consider an example that configures the <filename>linux-yocto-3.14</filename> |
| 5622 | kernel. |
| 5623 | The OpenEmbedded build system recognizes this kernel as |
| 5624 | <filename>linux-yocto</filename>. |
| 5625 | Thus, the following commands from the shell in which you previously sourced the |
| 5626 | environment initialization script cleans the shared state cache and the |
| 5627 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> |
| 5628 | directory and then runs <filename>menuconfig</filename>: |
| 5629 | <literallayout class='monospaced'> |
| 5630 | $ bitbake linux-yocto -c menuconfig |
| 5631 | </literallayout> |
| 5632 | </para> |
| 5633 | |
| 5634 | <para> |
| 5635 | Once <filename>menuconfig</filename> launches, use the interface |
| 5636 | to navigate through the selections to find the configuration settings in |
| 5637 | which you are interested. |
| 5638 | For example, consider the <filename>CONFIG_SMP</filename> configuration setting. |
| 5639 | You can find it at <filename>Processor Type and Features</filename> under |
| 5640 | the configuration selection <filename>Symmetric Multi-processing Support</filename>. |
| 5641 | After highlighting the selection, use the arrow keys to select or deselect |
| 5642 | the setting. |
| 5643 | When you are finished with all your selections, exit out and save them. |
| 5644 | </para> |
| 5645 | |
| 5646 | <para> |
| 5647 | Saving the selections updates the <filename>.config</filename> configuration file. |
| 5648 | This is the file that the OpenEmbedded build system uses to configure the |
| 5649 | kernel during the build. |
| 5650 | You can find and examine this file in the Build Directory in |
| 5651 | <filename>tmp/work/</filename>. |
| 5652 | The actual <filename>.config</filename> is located in the area where the |
| 5653 | specific kernel is built. |
| 5654 | For example, if you were building a Linux Yocto kernel based on the |
| 5655 | Linux 3.14 kernel and you were building a QEMU image targeted for |
| 5656 | <filename>x86</filename> architecture, the |
| 5657 | <filename>.config</filename> file would be located here: |
| 5658 | <literallayout class='monospaced'> |
| 5659 | poky/build/tmp/work/qemux86-poky-linux/linux-yocto-3.14.11+git1+84f... |
| 5660 | ...656ed30-r1/linux-qemux86-standard-build |
| 5661 | </literallayout> |
| 5662 | <note> |
| 5663 | The previous example directory is artificially split and many of the characters |
| 5664 | in the actual filename are omitted in order to make it more readable. |
| 5665 | Also, depending on the kernel you are using, the exact pathname |
| 5666 | for <filename>linux-yocto-3.14...</filename> might differ. |
| 5667 | </note> |
| 5668 | </para> |
| 5669 | |
| 5670 | <para> |
| 5671 | Within the <filename>.config</filename> file, you can see the kernel settings. |
| 5672 | For example, the following entry shows that symmetric multi-processor support |
| 5673 | is not set: |
| 5674 | <literallayout class='monospaced'> |
| 5675 | # CONFIG_SMP is not set |
| 5676 | </literallayout> |
| 5677 | </para> |
| 5678 | |
| 5679 | <para> |
| 5680 | A good method to isolate changed configurations is to use a combination of the |
| 5681 | <filename>menuconfig</filename> tool and simple shell commands. |
| 5682 | Before changing configurations with <filename>menuconfig</filename>, copy the |
| 5683 | existing <filename>.config</filename> and rename it to something else, |
| 5684 | use <filename>menuconfig</filename> to make |
| 5685 | as many changes as you want and save them, then compare the renamed configuration |
| 5686 | file against the newly created file. |
| 5687 | You can use the resulting differences as your base to create configuration fragments |
| 5688 | to permanently save in your kernel layer. |
| 5689 | <note> |
| 5690 | Be sure to make a copy of the <filename>.config</filename> and don't just |
| 5691 | rename it. |
| 5692 | The build system needs an existing <filename>.config</filename> |
| 5693 | from which to work. |
| 5694 | </note> |
| 5695 | </para> |
| 5696 | </section> |
| 5697 | |
| 5698 | <section id='creating-a-defconfig-file'> |
| 5699 | <title>Creating a <filename>defconfig</filename> File</title> |
| 5700 | |
| 5701 | <para> |
| 5702 | A <filename>defconfig</filename> file is simply a |
| 5703 | <filename>.config</filename> renamed to "defconfig". |
| 5704 | You can use a <filename>defconfig</filename> file |
| 5705 | to retain a known set of kernel configurations from which the |
| 5706 | OpenEmbedded build system can draw to create the final |
| 5707 | <filename>.config</filename> file. |
| 5708 | <note> |
| 5709 | Out-of-the-box, the Yocto Project never ships a |
| 5710 | <filename>defconfig</filename> or |
| 5711 | <filename>.config</filename> file. |
| 5712 | The OpenEmbedded build system creates the final |
| 5713 | <filename>.config</filename> file used to configure the |
| 5714 | kernel. |
| 5715 | </note> |
| 5716 | </para> |
| 5717 | |
| 5718 | <para> |
| 5719 | To create a <filename>defconfig</filename>, start with a |
| 5720 | complete, working Linux kernel <filename>.config</filename> |
| 5721 | file. |
| 5722 | Copy that file to the appropriate |
| 5723 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 5724 | directory in your layer's |
| 5725 | <filename>recipes-kernel/linux</filename> directory, and rename |
| 5726 | the copied file to "defconfig". |
| 5727 | Then, add the following lines to the linux-yocto |
| 5728 | <filename>.bbappend</filename> file in your layer: |
| 5729 | <literallayout class='monospaced'> |
| 5730 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 5731 | SRC_URI += "file://defconfig" |
| 5732 | </literallayout> |
| 5733 | The |
| 5734 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 5735 | tells the build system how to search for the file, while the |
| 5736 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 5737 | extends the |
| 5738 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 5739 | variable (search directories) to include the |
| 5740 | <filename>${PN}</filename> directory you created to hold the |
| 5741 | configuration changes. |
| 5742 | <note> |
| 5743 | The build system applies the configurations from the |
| 5744 | <filename>defconfig</filename> file before applying any |
| 5745 | subsequent configuration fragments. |
| 5746 | The final kernel configuration is a combination of the |
| 5747 | configurations in the <filename>defconfig</filename> |
| 5748 | file and any configuration fragments you provide. |
| 5749 | You need to realize that if you have any configuration |
| 5750 | fragments, the build system applies these on top of and |
| 5751 | after applying the existing defconfig file configurations. |
| 5752 | </note> |
| 5753 | For more information on configuring the kernel, see the |
| 5754 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#changing-the-configuration'>Changing the Configuration</ulink>" |
| 5755 | and |
| 5756 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" |
| 5757 | sections, both in the Yocto Project Linux Kernel Development |
| 5758 | Manual. |
| 5759 | </para> |
| 5760 | </section> |
| 5761 | |
| 5762 | <section id='creating-config-fragments'> |
| 5763 | <title>Creating Configuration Fragments</title> |
| 5764 | |
| 5765 | <para> |
| 5766 | Configuration fragments are simply kernel options that appear in a file |
| 5767 | placed where the OpenEmbedded build system can find and apply them. |
| 5768 | Syntactically, the configuration statement is identical to what would appear |
| 5769 | in the <filename>.config</filename> file, which is in the |
| 5770 | <link linkend='build-directory'>Build Directory</link>: |
| 5771 | <literallayout class='monospaced'> |
| 5772 | tmp/work/<replaceable>arch</replaceable>-poky-linux/linux-yocto-<replaceable>release_specific_string</replaceable>/linux-<replaceable>arch</replaceable>-<replaceable>build_type</replaceable> |
| 5773 | </literallayout> |
| 5774 | </para> |
| 5775 | |
| 5776 | <para> |
| 5777 | It is simple to create a configuration fragment. |
| 5778 | For example, issuing the following from the shell creates a configuration fragment |
| 5779 | file named <filename>my_smp.cfg</filename> that enables multi-processor support |
| 5780 | within the kernel: |
| 5781 | <literallayout class='monospaced'> |
| 5782 | $ echo "CONFIG_SMP=y" >> my_smp.cfg |
| 5783 | </literallayout> |
| 5784 | <note> |
| 5785 | All configuration fragment files must use the |
| 5786 | <filename>.cfg</filename> extension in order for the |
| 5787 | OpenEmbedded build system to recognize them as a |
| 5788 | configuration fragment. |
| 5789 | </note> |
| 5790 | </para> |
| 5791 | |
| 5792 | <para> |
| 5793 | Where do you put your configuration fragment files? |
| 5794 | You can place these files in the same area pointed to by |
| 5795 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 5796 | The OpenEmbedded build system picks up the configuration and |
| 5797 | adds it to the kernel's configuration. |
| 5798 | For example, suppose you had a set of configuration options |
| 5799 | in a file called <filename>myconfig.cfg</filename>. |
| 5800 | If you put that file inside a directory named |
| 5801 | <filename>linux-yocto</filename> that resides in the same |
| 5802 | directory as the kernel's append file and then add a |
| 5803 | <filename>SRC_URI</filename> statement such as the following |
| 5804 | to the kernel's append file, those configuration options |
| 5805 | will be picked up and applied when the kernel is built. |
| 5806 | <literallayout class='monospaced'> |
| 5807 | SRC_URI += "file://myconfig.cfg" |
| 5808 | </literallayout> |
| 5809 | </para> |
| 5810 | |
| 5811 | <para> |
| 5812 | As mentioned earlier, you can group related configurations into multiple files and |
| 5813 | name them all in the <filename>SRC_URI</filename> statement as well. |
| 5814 | For example, you could group separate configurations specifically for Ethernet and graphics |
| 5815 | into their own files and add those by using a <filename>SRC_URI</filename> statement like the |
| 5816 | following in your append file: |
| 5817 | <literallayout class='monospaced'> |
| 5818 | SRC_URI += "file://myconfig.cfg \ |
| 5819 | file://eth.cfg \ |
| 5820 | file://gfx.cfg" |
| 5821 | </literallayout> |
| 5822 | </para> |
| 5823 | </section> |
| 5824 | |
| 5825 | <section id='fine-tuning-the-kernel-configuration-file'> |
| 5826 | <title>Fine-Tuning the Kernel Configuration File</title> |
| 5827 | |
| 5828 | <para> |
| 5829 | You can make sure the <filename>.config</filename> file is as lean or efficient as |
| 5830 | possible by reading the output of the kernel configuration fragment audit, |
| 5831 | noting any issues, making changes to correct the issues, and then repeating. |
| 5832 | </para> |
| 5833 | |
| 5834 | <para> |
| 5835 | As part of the kernel build process, the |
| 5836 | <filename>do_kernel_configcheck</filename> task runs. |
| 5837 | This task validates the kernel configuration by checking the final |
| 5838 | <filename>.config</filename> file against the input files. |
| 5839 | During the check, the task produces warning messages for the following |
| 5840 | issues: |
| 5841 | <itemizedlist> |
| 5842 | <listitem><para>Requested options that did not make the final |
| 5843 | <filename>.config</filename> file.</para></listitem> |
| 5844 | <listitem><para>Configuration items that appear twice in the same |
| 5845 | configuration fragment.</para></listitem> |
| 5846 | <listitem><para>Configuration items tagged as "required" that were overridden. |
| 5847 | </para></listitem> |
| 5848 | <listitem><para>A board overrides a non-board specific option.</para></listitem> |
| 5849 | <listitem><para>Listed options not valid for the kernel being processed. |
| 5850 | In other words, the option does not appear anywhere.</para></listitem> |
| 5851 | </itemizedlist> |
| 5852 | <note> |
| 5853 | The <filename>do_kernel_configcheck</filename> task can |
| 5854 | also optionally report if an option is overridden during |
| 5855 | processing. |
| 5856 | </note> |
| 5857 | </para> |
| 5858 | |
| 5859 | <para> |
| 5860 | For each output warning, a message points to the file |
| 5861 | that contains a list of the options and a pointer to the |
| 5862 | configuration fragment that defines them. |
| 5863 | Collectively, the files are the key to streamlining the |
| 5864 | configuration. |
| 5865 | </para> |
| 5866 | |
| 5867 | <para> |
| 5868 | To streamline the configuration, do the following: |
| 5869 | <orderedlist> |
| 5870 | <listitem><para>Start with a full configuration that you |
| 5871 | know works - it builds and boots successfully. |
| 5872 | This configuration file will be your baseline. |
| 5873 | </para></listitem> |
| 5874 | <listitem><para>Separately run the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5875 | <filename>do_kernel_configme</filename> and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5876 | <filename>do_kernel_configcheck</filename> tasks. |
| 5877 | </para></listitem> |
| 5878 | <listitem><para>Take the resulting list of files from the |
| 5879 | <filename>do_kernel_configcheck</filename> task |
| 5880 | warnings and do the following: |
| 5881 | <itemizedlist> |
| 5882 | <listitem><para> |
| 5883 | Drop values that are redefined in the fragment |
| 5884 | but do not change the final |
| 5885 | <filename>.config</filename> file. |
| 5886 | </para></listitem> |
| 5887 | <listitem><para> |
| 5888 | Analyze and potentially drop values from the |
| 5889 | <filename>.config</filename> file that override |
| 5890 | required configurations. |
| 5891 | </para></listitem> |
| 5892 | <listitem><para> |
| 5893 | Analyze and potentially remove non-board |
| 5894 | specific options. |
| 5895 | </para></listitem> |
| 5896 | <listitem><para> |
| 5897 | Remove repeated and invalid options. |
| 5898 | </para></listitem> |
| 5899 | </itemizedlist></para></listitem> |
| 5900 | <listitem><para> |
| 5901 | After you have worked through the output of the kernel |
| 5902 | configuration audit, you can re-run the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5903 | <filename>do_kernel_configme</filename> and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5904 | <filename>do_kernel_configcheck</filename> tasks to |
| 5905 | see the results of your changes. |
| 5906 | If you have more issues, you can deal with them as |
| 5907 | described in the previous step. |
| 5908 | </para></listitem> |
| 5909 | </orderedlist> |
| 5910 | </para> |
| 5911 | |
| 5912 | <para> |
| 5913 | Iteratively working through steps two through four eventually yields |
| 5914 | a minimal, streamlined configuration file. |
| 5915 | Once you have the best <filename>.config</filename>, you can build the Linux |
| 5916 | Yocto kernel. |
| 5917 | </para> |
| 5918 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5919 | |
| 5920 | <section id='determining-hardware-and-non-hardware-features-for-the-kernel-configuration-audit-phase'> |
| 5921 | <title>Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase</title> |
| 5922 | |
| 5923 | <para> |
| 5924 | This section describes part of the kernel configuration audit |
| 5925 | phase that most developers can ignore. |
| 5926 | During this part of the audit phase, the contents of the final |
| 5927 | <filename>.config</filename> file are compared against the |
| 5928 | fragments specified by the system. |
| 5929 | These fragments can be system fragments, distro fragments, |
| 5930 | or user specified configuration elements. |
| 5931 | Regardless of their origin, the OpenEmbedded build system |
| 5932 | warns the user if a specific option is not included in the |
| 5933 | final kernel configuration. |
| 5934 | </para> |
| 5935 | |
| 5936 | <para> |
| 5937 | In order to not overwhelm the user with configuration warnings, |
| 5938 | by default the system only reports on missing "hardware" |
| 5939 | options because a missing hardware option could mean a boot |
| 5940 | failure or that important hardware is not available. |
| 5941 | </para> |
| 5942 | |
| 5943 | <para> |
| 5944 | To determine whether or not a given option is "hardware" or |
| 5945 | "non-hardware", the kernel Metadata contains files that |
| 5946 | classify individual or groups of options as either hardware |
| 5947 | or non-hardware. |
| 5948 | To better show this, consider a situation where the |
| 5949 | Yocto Project kernel cache contains the following files: |
| 5950 | <literallayout class='monospaced'> |
| 5951 | kernel-cache/features/drm-psb/hardware.cfg |
| 5952 | kernel-cache/features/kgdb/hardware.cfg |
| 5953 | kernel-cache/ktypes/base/hardware.cfg |
| 5954 | kernel-cache/bsp/mti-malta32/hardware.cfg |
| 5955 | kernel-cache/bsp/fsl-mpc8315e-rdb/hardware.cfg |
| 5956 | kernel-cache/bsp/qemu-ppc32/hardware.cfg |
| 5957 | kernel-cache/bsp/qemuarma9/hardware.cfg |
| 5958 | kernel-cache/bsp/mti-malta64/hardware.cfg |
| 5959 | kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg |
| 5960 | kernel-cache/bsp/common-pc/hardware.cfg |
| 5961 | kernel-cache/bsp/common-pc-64/hardware.cfg |
| 5962 | kernel-cache/features/rfkill/non-hardware.cfg |
| 5963 | kernel-cache/ktypes/base/non-hardware.cfg |
| 5964 | kernel-cache/features/aufs/non-hardware.kcf |
| 5965 | kernel-cache/features/ocf/non-hardware.kcf |
| 5966 | kernel-cache/ktypes/base/non-hardware.kcf |
| 5967 | kernel-cache/ktypes/base/hardware.kcf |
| 5968 | kernel-cache/bsp/qemu-ppc32/hardware.kcf |
| 5969 | </literallayout> |
| 5970 | The following list provides explanations for the various |
| 5971 | files: |
| 5972 | <itemizedlist> |
| 5973 | <listitem><para><filename>hardware.kcf</filename>: |
| 5974 | Specifies a list of kernel Kconfig files that contain |
| 5975 | hardware options only. |
| 5976 | </para></listitem> |
| 5977 | <listitem><para><filename>non-hardware.kcf</filename>: |
| 5978 | Specifies a list of kernel Kconfig files that contain |
| 5979 | non-hardware options only. |
| 5980 | </para></listitem> |
| 5981 | <listitem><para><filename>hardware.cfg</filename>: |
| 5982 | Specifies a list of kernel |
| 5983 | <filename>CONFIG_</filename> options that are hardware, |
| 5984 | regardless of whether or not they are within a Kconfig |
| 5985 | file specified by a hardware or non-hardware |
| 5986 | Kconfig file (i.e. <filename>hardware.kcf</filename> or |
| 5987 | <filename>non-hardware.kcf</filename>). |
| 5988 | </para></listitem> |
| 5989 | <listitem><para><filename>non-hardware.cfg</filename>: |
| 5990 | Specifies a list of kernel |
| 5991 | <filename>CONFIG_</filename> options that are |
| 5992 | not hardware, regardless of whether or not they are |
| 5993 | within a Kconfig file specified by a hardware or |
| 5994 | non-hardware Kconfig file (i.e. |
| 5995 | <filename>hardware.kcf</filename> or |
| 5996 | <filename>non-hardware.kcf</filename>). |
| 5997 | </para></listitem> |
| 5998 | </itemizedlist> |
| 5999 | Here is a specific example using the |
| 6000 | <filename>kernel-cache/bsp/mti-malta32/hardware.cfg</filename>: |
| 6001 | <literallayout class='monospaced'> |
| 6002 | CONFIG_SERIAL_8250 |
| 6003 | CONFIG_SERIAL_8250_CONSOLE |
| 6004 | CONFIG_SERIAL_8250_NR_UARTS |
| 6005 | CONFIG_SERIAL_8250_PCI |
| 6006 | CONFIG_SERIAL_CORE |
| 6007 | CONFIG_SERIAL_CORE_CONSOLE |
| 6008 | CONFIG_VGA_ARB |
| 6009 | </literallayout> |
| 6010 | The kernel configuration audit automatically detects these |
| 6011 | files (hence the names must be exactly the ones discussed here), |
| 6012 | and uses them as inputs when generating warnings about the |
| 6013 | final <filename>.config</filename> file. |
| 6014 | </para> |
| 6015 | |
| 6016 | <para> |
| 6017 | A user-specified kernel Metadata repository, or recipe space |
| 6018 | feature, can use these same files to classify options that are |
| 6019 | found within its <filename>.cfg</filename> files as hardware |
| 6020 | or non-hardware, to prevent the OpenEmbedded build system from |
| 6021 | producing an error or warning when an option is not in the |
| 6022 | final <filename>.config</filename> file. |
| 6023 | </para> |
| 6024 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6025 | </section> |
| 6026 | |
| 6027 | <section id="patching-the-kernel"> |
| 6028 | <title>Patching the Kernel</title> |
| 6029 | |
| 6030 | <para> |
| 6031 | Patching the kernel involves changing or adding configurations to an existing kernel, |
| 6032 | changing or adding recipes to the kernel that are needed to support specific hardware features, |
| 6033 | or even altering the source code itself. |
| 6034 | <note> |
| 6035 | You can use the <filename>yocto-kernel</filename> script |
| 6036 | found in the <link linkend='source-directory'>Source Directory</link> |
| 6037 | under <filename>scripts</filename> to manage kernel patches and configuration. |
| 6038 | See the "<ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'>Managing kernel Patches and Config Items with yocto-kernel</ulink>" |
| 6039 | section in the Yocto Project Board Support Packages (BSP) Developer's Guide for |
| 6040 | more information.</note> |
| 6041 | </para> |
| 6042 | |
| 6043 | <para> |
| 6044 | This example creates a simple patch by adding some QEMU emulator console |
| 6045 | output at boot time through <filename>printk</filename> statements in the kernel's |
| 6046 | <filename>calibrate.c</filename> source code file. |
| 6047 | Applying the patch and booting the modified image causes the added |
| 6048 | messages to appear on the emulator's console. |
| 6049 | </para> |
| 6050 | |
| 6051 | <para> |
| 6052 | The example assumes a clean build exists for the <filename>qemux86</filename> |
| 6053 | machine in a |
| 6054 | <link linkend='source-directory'>Source Directory</link> |
| 6055 | named <filename>poky</filename>. |
| 6056 | Furthermore, the <link linkend='build-directory'>Build Directory</link> is |
| 6057 | <filename>build</filename> and is located in <filename>poky</filename> and |
| 6058 | the kernel is based on the Linux 3.4 kernel. |
| 6059 | </para> |
| 6060 | |
| 6061 | <para> |
| 6062 | Also, for more information on patching the kernel, see the |
| 6063 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#applying-patches'>Applying Patches</ulink>" |
| 6064 | section in the Yocto Project Linux Kernel Development Manual. |
| 6065 | </para> |
| 6066 | |
| 6067 | <section id='create-a-layer-for-your-changes'> |
| 6068 | <title>Create a Layer for your Changes</title> |
| 6069 | |
| 6070 | <para> |
| 6071 | The first step is to create a layer so you can isolate your |
| 6072 | changes. |
| 6073 | Rather than use the <filename>yocto-layer</filename> script |
| 6074 | to create the layer, this example steps through the process |
| 6075 | by hand. |
| 6076 | If you want information on the script that creates a general |
| 6077 | layer, see the |
| 6078 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 6079 | section. |
| 6080 | </para> |
| 6081 | |
| 6082 | <para> |
| 6083 | These two commands create a directory you can use for your |
| 6084 | layer: |
| 6085 | <literallayout class='monospaced'> |
| 6086 | $ cd ~/poky |
| 6087 | $ mkdir meta-mylayer |
| 6088 | </literallayout> |
| 6089 | Creating a directory that follows the Yocto Project layer naming |
| 6090 | conventions sets up the layer for your changes. |
| 6091 | The layer is where you place your configuration files, append |
| 6092 | files, and patch files. |
| 6093 | To learn more about creating a layer and filling it with the |
| 6094 | files you need, see the "<link linkend='understanding-and-creating-layers'>Understanding |
| 6095 | and Creating Layers</link>" section. |
| 6096 | </para> |
| 6097 | </section> |
| 6098 | |
| 6099 | <section id='finding-the-kernel-source-code'> |
| 6100 | <title>Finding the Kernel Source Code</title> |
| 6101 | |
| 6102 | <para> |
| 6103 | Each time you build a kernel image, the kernel source code is fetched |
| 6104 | and unpacked into the following directory: |
| 6105 | <literallayout class='monospaced'> |
| 6106 | ${S}/linux |
| 6107 | </literallayout> |
| 6108 | See the "<link linkend='finding-the-temporary-source-code'>Finding Temporary Source Code</link>" |
| 6109 | section and the |
| 6110 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> variable |
| 6111 | for more information about where source is kept during a build. |
| 6112 | </para> |
| 6113 | |
| 6114 | <para> |
| 6115 | For this example, we are going to patch the |
| 6116 | <filename>init/calibrate.c</filename> file |
| 6117 | by adding some simple console <filename>printk</filename> statements that we can |
| 6118 | see when we boot the image using QEMU. |
| 6119 | </para> |
| 6120 | </section> |
| 6121 | |
| 6122 | <section id='creating-the-patch'> |
| 6123 | <title>Creating the Patch</title> |
| 6124 | |
| 6125 | <para> |
| 6126 | Two methods exist by which you can create the patch: |
| 6127 | <link linkend='using-devtool-in-your-workflow'><filename>devtool</filename></link> and |
| 6128 | <link linkend='using-a-quilt-workflow'>Quilt</link>. |
| 6129 | For kernel patches, the Git workflow is more appropriate. |
| 6130 | This section assumes the Git workflow and shows the steps specific to |
| 6131 | this example. |
| 6132 | <orderedlist> |
| 6133 | <listitem><para><emphasis>Change the working directory</emphasis>: |
| 6134 | Change to where the kernel source code is before making |
| 6135 | your edits to the <filename>calibrate.c</filename> file: |
| 6136 | <literallayout class='monospaced'> |
| 6137 | $ cd ~/poky/build/tmp/work/qemux86-poky-linux/linux-yocto-${PV}-${PR}/linux |
| 6138 | </literallayout> |
| 6139 | Because you are working in an established Git repository, |
| 6140 | you must be in this directory in order to commit your changes |
| 6141 | and create the patch file. |
| 6142 | <note>The <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> and |
| 6143 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> variables |
| 6144 | represent the version and revision for the |
| 6145 | <filename>linux-yocto</filename> recipe. |
| 6146 | The <filename>PV</filename> variable includes the Git meta and machine |
| 6147 | hashes, which make the directory name longer than you might |
| 6148 | expect. |
| 6149 | </note></para></listitem> |
| 6150 | <listitem><para><emphasis>Edit the source file</emphasis>: |
| 6151 | Edit the <filename>init/calibrate.c</filename> file to have the |
| 6152 | following changes: |
| 6153 | <literallayout class='monospaced'> |
| 6154 | void calibrate_delay(void) |
| 6155 | { |
| 6156 | unsigned long lpj; |
| 6157 | static bool printed; |
| 6158 | int this_cpu = smp_processor_id(); |
| 6159 | |
| 6160 | printk("*************************************\n"); |
| 6161 | printk("* *\n"); |
| 6162 | printk("* HELLO YOCTO KERNEL *\n"); |
| 6163 | printk("* *\n"); |
| 6164 | printk("*************************************\n"); |
| 6165 | |
| 6166 | if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { |
| 6167 | . |
| 6168 | . |
| 6169 | . |
| 6170 | </literallayout></para></listitem> |
| 6171 | <listitem><para><emphasis>Stage and commit your changes</emphasis>: |
| 6172 | These Git commands display the modified file, stage it, and then |
| 6173 | commit the file: |
| 6174 | <literallayout class='monospaced'> |
| 6175 | $ git status |
| 6176 | $ git add init/calibrate.c |
| 6177 | $ git commit -m "calibrate: Add printk example" |
| 6178 | </literallayout></para></listitem> |
| 6179 | <listitem><para><emphasis>Generate the patch file</emphasis>: |
| 6180 | This Git command creates the a patch file named |
| 6181 | <filename>0001-calibrate-Add-printk-example.patch</filename> |
| 6182 | in the current directory. |
| 6183 | <literallayout class='monospaced'> |
| 6184 | $ git format-patch -1 |
| 6185 | </literallayout> |
| 6186 | </para></listitem> |
| 6187 | </orderedlist> |
| 6188 | </para> |
| 6189 | </section> |
| 6190 | |
| 6191 | <section id='set-up-your-layer-for-the-build'> |
| 6192 | <title>Set Up Your Layer for the Build</title> |
| 6193 | |
| 6194 | <para>These steps get your layer set up for the build: |
| 6195 | <orderedlist> |
| 6196 | <listitem><para><emphasis>Create additional structure</emphasis>: |
| 6197 | Create the additional layer structure: |
| 6198 | <literallayout class='monospaced'> |
| 6199 | $ cd ~/poky/meta-mylayer |
| 6200 | $ mkdir conf |
| 6201 | $ mkdir recipes-kernel |
| 6202 | $ mkdir recipes-kernel/linux |
| 6203 | $ mkdir recipes-kernel/linux/linux-yocto |
| 6204 | </literallayout> |
| 6205 | The <filename>conf</filename> directory holds your configuration files, while the |
| 6206 | <filename>recipes-kernel</filename> directory holds your append file and |
| 6207 | your patch file.</para></listitem> |
| 6208 | <listitem><para><emphasis>Create the layer configuration file</emphasis>: |
| 6209 | Move to the <filename>meta-mylayer/conf</filename> directory and create |
| 6210 | the <filename>layer.conf</filename> file as follows: |
| 6211 | <literallayout class='monospaced'> |
| 6212 | # We have a conf and classes directory, add to BBPATH |
| 6213 | BBPATH .= ":${LAYERDIR}" |
| 6214 | |
| 6215 | # We have recipes-* directories, add to BBFILES |
| 6216 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ |
| 6217 | ${LAYERDIR}/recipes-*/*/*.bbappend" |
| 6218 | |
| 6219 | BBFILE_COLLECTIONS += "mylayer" |
| 6220 | BBFILE_PATTERN_mylayer = "^${LAYERDIR}/" |
| 6221 | BBFILE_PRIORITY_mylayer = "5" |
| 6222 | </literallayout> |
| 6223 | Notice <filename>mylayer</filename> as part of the last three |
| 6224 | statements.</para></listitem> |
| 6225 | <listitem><para><emphasis>Create the kernel recipe append file</emphasis>: |
| 6226 | Move to the <filename>meta-mylayer/recipes-kernel/linux</filename> directory and create |
| 6227 | the <filename>linux-yocto_3.4.bbappend</filename> file as follows: |
| 6228 | <literallayout class='monospaced'> |
| 6229 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 6230 | |
| 6231 | SRC_URI += "file://0001-calibrate-Add-printk-example.patch" |
| 6232 | </literallayout> |
| 6233 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 6234 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 6235 | statements enable the OpenEmbedded build system to find the patch file. |
| 6236 | For more information on using append files, see the |
| 6237 | "<link linkend='using-bbappend-files'>Using .bbappend Files</link>" |
| 6238 | section. |
| 6239 | </para></listitem> |
| 6240 | <listitem><para><emphasis>Put the patch file in your layer</emphasis>: |
| 6241 | Move the <filename>0001-calibrate-Add-printk-example.patch</filename> file to |
| 6242 | the <filename>meta-mylayer/recipes-kernel/linux/linux-yocto</filename> |
| 6243 | directory.</para></listitem> |
| 6244 | </orderedlist> |
| 6245 | </para> |
| 6246 | </section> |
| 6247 | |
| 6248 | <section id='set-up-for-the-build'> |
| 6249 | <title>Set Up for the Build</title> |
| 6250 | |
| 6251 | <para> |
| 6252 | Do the following to make sure the build parameters are set up for the example. |
| 6253 | Once you set up these build parameters, they do not have to change unless you |
| 6254 | change the target architecture of the machine you are building: |
| 6255 | <itemizedlist> |
| 6256 | <listitem><para><emphasis>Build for the correct target architecture:</emphasis> Your |
| 6257 | selected <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 6258 | definition within the <filename>local.conf</filename> file in the |
| 6259 | <link linkend='build-directory'>Build Directory</link> |
| 6260 | specifies the target architecture used when building the Linux kernel. |
| 6261 | By default, <filename>MACHINE</filename> is set to |
| 6262 | <filename>qemux86</filename>, which specifies a 32-bit |
| 6263 | <trademark class='registered'>Intel</trademark> Architecture |
| 6264 | target machine suitable for the QEMU emulator.</para></listitem> |
| 6265 | <listitem><para><emphasis>Identify your <filename>meta-mylayer</filename> |
| 6266 | layer:</emphasis> The |
| 6267 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> |
| 6268 | variable in the |
| 6269 | <filename>bblayers.conf</filename> file found in the |
| 6270 | <filename>poky/build/conf</filename> directory needs to have the path to your local |
| 6271 | <filename>meta-mylayer</filename> layer. |
| 6272 | By default, the <filename>BBLAYERS</filename> variable contains paths to |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6273 | <filename>meta</filename>, <filename>meta-poky</filename>, and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6274 | <filename>meta-yocto-bsp</filename> in the |
| 6275 | <filename>poky</filename> Git repository. |
| 6276 | Add the path to your <filename>meta-mylayer</filename> location: |
| 6277 | <literallayout class='monospaced'> |
| 6278 | BBLAYERS ?= " \ |
| 6279 | $HOME/poky/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6280 | $HOME/poky/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6281 | $HOME/poky/meta-yocto-bsp \ |
| 6282 | $HOME/poky/meta-mylayer \ |
| 6283 | " |
| 6284 | </literallayout></para></listitem> |
| 6285 | </itemizedlist> |
| 6286 | </para> |
| 6287 | </section> |
| 6288 | |
| 6289 | <section id='build-the-modified-qemu-kernel-image'> |
| 6290 | <title>Build the Modified QEMU Kernel Image</title> |
| 6291 | |
| 6292 | <para> |
| 6293 | The following steps build your modified kernel image: |
| 6294 | <orderedlist> |
| 6295 | <listitem><para><emphasis>Be sure your build environment is initialized</emphasis>: |
| 6296 | Your environment should be set up since you previously sourced |
| 6297 | the |
| 6298 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> |
| 6299 | script. |
| 6300 | If it is not, source the script again from <filename>poky</filename>. |
| 6301 | <literallayout class='monospaced'> |
| 6302 | $ cd ~/poky |
| 6303 | $ source &OE_INIT_FILE; |
| 6304 | </literallayout> |
| 6305 | </para></listitem> |
| 6306 | <listitem><para><emphasis>Clean up</emphasis>: |
| 6307 | Be sure to clean the shared state out by using BitBake |
| 6308 | to run from within the Build Directory the |
| 6309 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink> |
| 6310 | task as follows: |
| 6311 | <literallayout class='monospaced'> |
| 6312 | $ bitbake -c cleansstate linux-yocto |
| 6313 | </literallayout></para> |
| 6314 | <para> |
| 6315 | <note> |
| 6316 | Never remove any files by hand from the |
| 6317 | <filename>tmp/deploy</filename> |
| 6318 | directory inside the |
| 6319 | <link linkend='build-directory'>Build Directory</link>. |
| 6320 | Always use the various BitBake clean tasks to |
| 6321 | clear out previous build artifacts. |
| 6322 | For information on the clean tasks, see the |
| 6323 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-clean'><filename>do_clean</filename></ulink>", |
| 6324 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>do_cleanall</filename></ulink>", |
| 6325 | and |
| 6326 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>do_cleansstate</filename></ulink>" |
| 6327 | sections all in the Yocto Project Reference |
| 6328 | Manual. |
| 6329 | </note> |
| 6330 | </para></listitem> |
| 6331 | <listitem><para><emphasis>Build the image</emphasis>: |
| 6332 | Next, build the kernel image using this command: |
| 6333 | <literallayout class='monospaced'> |
| 6334 | $ bitbake -k linux-yocto |
| 6335 | </literallayout></para></listitem> |
| 6336 | </orderedlist> |
| 6337 | </para> |
| 6338 | </section> |
| 6339 | |
| 6340 | <section id='boot-the-image-and-verify-your-changes'> |
| 6341 | <title>Boot the Image and Verify Your Changes</title> |
| 6342 | |
| 6343 | <para> |
| 6344 | These steps boot the image and allow you to see the changes |
| 6345 | <orderedlist> |
| 6346 | <listitem><para><emphasis>Boot the image</emphasis>: |
| 6347 | Boot the modified image in the QEMU emulator |
| 6348 | using this command: |
| 6349 | <literallayout class='monospaced'> |
| 6350 | $ runqemu qemux86 |
| 6351 | </literallayout></para></listitem> |
| 6352 | <listitem><para><emphasis>Verify the changes</emphasis>: |
| 6353 | Log into the machine using <filename>root</filename> with no password and then |
| 6354 | use the following shell command to scroll through the console's boot output. |
| 6355 | <literallayout class='monospaced'> |
| 6356 | # dmesg | less |
| 6357 | </literallayout> |
| 6358 | You should see the results of your <filename>printk</filename> statements |
| 6359 | as part of the output.</para></listitem> |
| 6360 | </orderedlist> |
| 6361 | </para> |
| 6362 | </section> |
| 6363 | </section> |
| 6364 | |
| 6365 | <section id='making-images-more-secure'> |
| 6366 | <title>Making Images More Secure</title> |
| 6367 | |
| 6368 | <para> |
| 6369 | Security is of increasing concern for embedded devices. |
| 6370 | Consider the issues and problems discussed in just this |
| 6371 | sampling of work found across the Internet: |
| 6372 | <itemizedlist> |
| 6373 | <listitem><para><emphasis> |
| 6374 | "<ulink url='https://www.schneier.com/blog/archives/2014/01/security_risks_9.html'>Security Risks of Embedded Systems</ulink>"</emphasis> |
| 6375 | by Bruce Schneier |
| 6376 | </para></listitem> |
| 6377 | <listitem><para><emphasis> |
| 6378 | "<ulink url='http://internetcensus2012.bitbucket.org/paper.html'>Internet Census 2012</ulink>"</emphasis> |
| 6379 | by Carna Botnet</para></listitem> |
| 6380 | <listitem><para><emphasis> |
| 6381 | "<ulink url='http://elinux.org/images/6/6f/Security-issues.pdf'>Security Issues for Embedded Devices</ulink>"</emphasis> |
| 6382 | by Jake Edge |
| 6383 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6384 | </itemizedlist> |
| 6385 | </para> |
| 6386 | |
| 6387 | <para> |
| 6388 | When securing your image is of concern, there are steps, tools, |
| 6389 | and variables that you can consider to help you reach the |
| 6390 | security goals you need for your particular device. |
| 6391 | Not all situations are identical when it comes to making an |
| 6392 | image secure. |
| 6393 | Consequently, this section provides some guidance and suggestions |
| 6394 | for consideration when you want to make your image more secure. |
| 6395 | <note> |
| 6396 | Because the security requirements and risks are |
| 6397 | different for every type of device, this section cannot |
| 6398 | provide a complete reference on securing your custom OS. |
| 6399 | It is strongly recommended that you also consult other sources |
| 6400 | of information on embedded Linux system hardening and on |
| 6401 | security. |
| 6402 | </note> |
| 6403 | </para> |
| 6404 | |
| 6405 | <section id='general-considerations'> |
| 6406 | <title>General Considerations</title> |
| 6407 | |
| 6408 | <para> |
| 6409 | General considerations exist that help you create more |
| 6410 | secure images. |
| 6411 | You should consider the following suggestions to help |
| 6412 | make your device more secure: |
| 6413 | <itemizedlist> |
| 6414 | <listitem><para> |
| 6415 | Scan additional code you are adding to the system |
| 6416 | (e.g. application code) by using static analysis |
| 6417 | tools. |
| 6418 | Look for buffer overflows and other potential |
| 6419 | security problems. |
| 6420 | </para></listitem> |
| 6421 | <listitem><para> |
| 6422 | Pay particular attention to the security for |
| 6423 | any web-based administration interface. |
| 6424 | </para> |
| 6425 | <para>Web interfaces typically need to perform |
| 6426 | administrative functions and tend to need to run with |
| 6427 | elevated privileges. |
| 6428 | Thus, the consequences resulting from the interface's |
| 6429 | security becoming compromised can be serious. |
| 6430 | Look for common web vulnerabilities such as |
| 6431 | cross-site-scripting (XSS), unvalidated inputs, |
| 6432 | and so forth.</para> |
| 6433 | <para>As with system passwords, the default credentials |
| 6434 | for accessing a web-based interface should not be the |
| 6435 | same across all devices. |
| 6436 | This is particularly true if the interface is enabled |
| 6437 | by default as it can be assumed that many end-users |
| 6438 | will not change the credentials. |
| 6439 | </para></listitem> |
| 6440 | <listitem><para> |
| 6441 | Ensure you can update the software on the device to |
| 6442 | mitigate vulnerabilities discovered in the future. |
| 6443 | This consideration especially applies when your |
| 6444 | device is network-enabled. |
| 6445 | </para></listitem> |
| 6446 | <listitem><para> |
| 6447 | Ensure you remove or disable debugging functionality |
| 6448 | before producing the final image. |
| 6449 | For information on how to do this, see the |
| 6450 | "<link linkend='considerations-specific-to-the-openembedded-build-system'>Considerations Specific to the OpenEmbedded Build System</link>" |
| 6451 | section. |
| 6452 | </para></listitem> |
| 6453 | <listitem><para> |
| 6454 | Ensure you have no network services listening that |
| 6455 | are not needed. |
| 6456 | </para></listitem> |
| 6457 | <listitem><para> |
| 6458 | Remove any software from the image that is not needed. |
| 6459 | </para></listitem> |
| 6460 | <listitem><para> |
| 6461 | Enable hardware support for secure boot functionality |
| 6462 | when your device supports this functionality. |
| 6463 | </para></listitem> |
| 6464 | </itemizedlist> |
| 6465 | </para> |
| 6466 | </section> |
| 6467 | |
| 6468 | <section id='security-flags'> |
| 6469 | <title>Security Flags</title> |
| 6470 | |
| 6471 | <para> |
| 6472 | The Yocto Project has security flags that you can enable that |
| 6473 | help make your build output more secure. |
| 6474 | The security flags are in the |
| 6475 | <filename>meta/conf/distro/include/security_flags.inc</filename> |
| 6476 | file in your |
| 6477 | <link linkend='source-directory'>Source Directory</link> |
| 6478 | (e.g. <filename>poky</filename>). |
| 6479 | <note> |
| 6480 | Depending on the recipe, certain security flags are enabled |
| 6481 | and disabled by default. |
| 6482 | </note> |
| 6483 | </para> |
| 6484 | |
| 6485 | <para> |
| 6486 | <!-- |
| 6487 | The GCC/LD flags in <filename>security_flags.inc</filename> |
| 6488 | enable more secure code generation. |
| 6489 | By including the <filename>security_flags.inc</filename> |
| 6490 | file, you enable flags to the compiler and linker that cause |
| 6491 | them to generate more secure code. |
| 6492 | <note> |
| 6493 | The GCC/LD flags are enabled by default in the |
| 6494 | <filename>poky-lsb</filename> distribution. |
| 6495 | </note> |
| 6496 | --> |
| 6497 | Use the following line in your |
| 6498 | <filename>local.conf</filename> file or in your custom |
| 6499 | distribution configuration file to enable the security |
| 6500 | compiler and linker flags for your build: |
| 6501 | <literallayout class='monospaced'> |
| 6502 | require conf/distro/include/security_flags.inc |
| 6503 | </literallayout> |
| 6504 | </para> |
| 6505 | </section> |
| 6506 | |
| 6507 | <section id='considerations-specific-to-the-openembedded-build-system'> |
| 6508 | <title>Considerations Specific to the OpenEmbedded Build System</title> |
| 6509 | |
| 6510 | <para> |
| 6511 | You can take some steps that are specific to the |
| 6512 | OpenEmbedded build system to make your images more secure: |
| 6513 | <itemizedlist> |
| 6514 | <listitem><para> |
| 6515 | Ensure "debug-tweaks" is not one of your selected |
| 6516 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>. |
| 6517 | When creating a new project, the default is to provide you |
| 6518 | with an initial <filename>local.conf</filename> file that |
| 6519 | enables this feature using the |
| 6520 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> variable with the line: |
| 6521 | <literallayout class='monospaced'> |
| 6522 | EXTRA_IMAGE_FEATURES = "debug-tweaks" |
| 6523 | </literallayout> |
| 6524 | To disable that feature, simply comment out that line in your |
| 6525 | <filename>local.conf</filename> file, or |
| 6526 | make sure <filename>IMAGE_FEATURES</filename> does not contain |
| 6527 | "debug-tweaks" before producing your final image. |
| 6528 | Among other things, leaving this in place sets the |
| 6529 | root password as blank, which makes logging in for |
| 6530 | debugging or inspection easy during |
| 6531 | development but also means anyone can easily log in |
| 6532 | during production. |
| 6533 | </para></listitem> |
| 6534 | <listitem><para> |
| 6535 | It is possible to set a root password for the image |
| 6536 | and also to set passwords for any extra users you might |
| 6537 | add (e.g. administrative or service type users). |
| 6538 | When you set up passwords for multiple images or |
| 6539 | users, you should not duplicate passwords. |
| 6540 | </para> |
| 6541 | <para> |
| 6542 | To set up passwords, use the |
| 6543 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers</filename></ulink> |
| 6544 | class, which is the preferred method. |
| 6545 | For an example on how to set up both root and user |
| 6546 | passwords, see the |
| 6547 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-extrausers'><filename>extrausers.bbclass</filename></ulink>" |
| 6548 | section. |
| 6549 | <note> |
| 6550 | When adding extra user accounts or setting a |
| 6551 | root password, be cautious about setting the |
| 6552 | same password on every device. |
| 6553 | If you do this, and the password you have set |
| 6554 | is exposed, then every device is now potentially |
| 6555 | compromised. |
| 6556 | If you need this access but want to ensure |
| 6557 | security, consider setting a different, |
| 6558 | random password for each device. |
| 6559 | Typically, you do this as a separate step after |
| 6560 | you deploy the image onto the device. |
| 6561 | </note> |
| 6562 | </para></listitem> |
| 6563 | <listitem><para> |
| 6564 | Consider enabling a Mandatory Access Control (MAC) |
| 6565 | framework such as SMACK or SELinux and tuning it |
| 6566 | appropriately for your device's usage. |
| 6567 | You can find more information in the |
| 6568 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/meta-selinux/'><filename>meta-selinux</filename></ulink> |
| 6569 | layer. |
| 6570 | </para></listitem> |
| 6571 | </itemizedlist> |
| 6572 | </para> |
| 6573 | |
| 6574 | <para> |
| 6575 | </para> |
| 6576 | </section> |
| 6577 | |
| 6578 | <section id='tools-for-hardening-your-image'> |
| 6579 | <title>Tools for Hardening Your Image</title> |
| 6580 | |
| 6581 | <para> |
| 6582 | The Yocto Project provides tools for making your image |
| 6583 | more secure. |
| 6584 | You can find these tools in the |
| 6585 | <filename>meta-security</filename> layer of the |
| 6586 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>. |
| 6587 | </para> |
| 6588 | </section> |
| 6589 | </section> |
| 6590 | |
| 6591 | <section id='creating-your-own-distribution'> |
| 6592 | <title>Creating Your Own Distribution</title> |
| 6593 | |
| 6594 | <para> |
| 6595 | When you build an image using the Yocto Project and |
| 6596 | do not alter any distribution |
| 6597 | <link linkend='metadata'>Metadata</link>, you are creating a |
| 6598 | Poky distribution. |
| 6599 | If you wish to gain more control over package alternative |
| 6600 | selections, compile-time options, and other low-level |
| 6601 | configurations, you can create your own distribution. |
| 6602 | </para> |
| 6603 | |
| 6604 | <para> |
| 6605 | To create your own distribution, the basic steps consist of |
| 6606 | creating your own distribution layer, creating your own |
| 6607 | distribution configuration file, and then adding any needed |
| 6608 | code and Metadata to the layer. |
| 6609 | The following steps provide some more detail: |
| 6610 | <itemizedlist> |
| 6611 | <listitem><para><emphasis>Create a layer for your new distro:</emphasis> |
| 6612 | Create your distribution layer so that you can keep your |
| 6613 | Metadata and code for the distribution separate. |
| 6614 | It is strongly recommended that you create and use your own |
| 6615 | layer for configuration and code. |
| 6616 | Using your own layer as compared to just placing |
| 6617 | configurations in a <filename>local.conf</filename> |
| 6618 | configuration file makes it easier to reproduce the same |
| 6619 | build configuration when using multiple build machines. |
| 6620 | See the |
| 6621 | "<link linkend='creating-a-general-layer-using-the-yocto-layer-script'>Creating a General Layer Using the yocto-layer Script</link>" |
| 6622 | section for information on how to quickly set up a layer. |
| 6623 | </para></listitem> |
| 6624 | <listitem><para><emphasis>Create the distribution configuration file:</emphasis> |
| 6625 | The distribution configuration file needs to be created in |
| 6626 | the <filename>conf/distro</filename> directory of your |
| 6627 | layer. |
| 6628 | You need to name it using your distribution name |
| 6629 | (e.g. <filename>mydistro.conf</filename>). |
| 6630 | <note> |
| 6631 | The |
| 6632 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6633 | variable in your |
| 6634 | <filename>local.conf</filename> file determines the |
| 6635 | name of your distribution. |
| 6636 | </note></para> |
| 6637 | <para>You can split out parts of your configuration file |
| 6638 | into include files and then "require" them from within |
| 6639 | your distribution configuration file. |
| 6640 | Be sure to place the include files in the |
| 6641 | <filename>conf/distro/include</filename> directory of |
| 6642 | your layer. |
| 6643 | A common example usage of include files would be to |
| 6644 | separate out the selection of desired version and revisions |
| 6645 | for individual recipes. |
| 6646 | </para> |
| 6647 | <para>Your configuration file needs to set the following |
| 6648 | required variables: |
| 6649 | <literallayout class='monospaced'> |
| 6650 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_NAME'><filename>DISTRO_NAME</filename></ulink> |
| 6651 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_VERSION'><filename>DISTRO_VERSION</filename></ulink> |
| 6652 | </literallayout> |
| 6653 | These following variables are optional and you typically |
| 6654 | set them from the distribution configuration file: |
| 6655 | <literallayout class='monospaced'> |
| 6656 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 6657 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RDEPENDS'><filename>DISTRO_EXTRA_RDEPENDS</filename></ulink> |
| 6658 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_EXTRA_RRECOMMENDS'><filename>DISTRO_EXTRA_RRECOMMENDS</filename></ulink> |
| 6659 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TCLIBC'><filename>TCLIBC</filename></ulink> |
| 6660 | </literallayout> |
| 6661 | <tip> |
| 6662 | If you want to base your distribution configuration file |
| 6663 | on the very basic configuration from OE-Core, you |
| 6664 | can use |
| 6665 | <filename>conf/distro/defaultsetup.conf</filename> as |
| 6666 | a reference and just include variables that differ |
| 6667 | as compared to <filename>defaultsetup.conf</filename>. |
| 6668 | Alternatively, you can create a distribution |
| 6669 | configuration file from scratch using the |
| 6670 | <filename>defaultsetup.conf</filename> file |
| 6671 | or configuration files from other distributions |
| 6672 | such as Poky or Angstrom as references. |
| 6673 | </tip></para></listitem> |
| 6674 | <listitem><para><emphasis>Provide miscellaneous variables:</emphasis> |
| 6675 | Be sure to define any other variables for which you want to |
| 6676 | create a default or enforce as part of the distribution |
| 6677 | configuration. |
| 6678 | You can include nearly any variable from the |
| 6679 | <filename>local.conf</filename> file. |
| 6680 | The variables you use are not limited to the list in the |
| 6681 | previous bulleted item.</para></listitem> |
| 6682 | <listitem><para><emphasis>Point to Your distribution configuration file:</emphasis> |
| 6683 | In your <filename>local.conf</filename> file in the |
| 6684 | <link linkend='build-directory'>Build Directory</link>, |
| 6685 | set your |
| 6686 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6687 | variable to point to your distribution's configuration file. |
| 6688 | For example, if your distribution's configuration file is |
| 6689 | named <filename>mydistro.conf</filename>, then you point |
| 6690 | to it as follows: |
| 6691 | <literallayout class='monospaced'> |
| 6692 | DISTRO = "mydistro" |
| 6693 | </literallayout></para></listitem> |
| 6694 | <listitem><para><emphasis>Add more to the layer if necessary:</emphasis> |
| 6695 | Use your layer to hold other information needed for the |
| 6696 | distribution: |
| 6697 | <itemizedlist> |
| 6698 | <listitem><para>Add recipes for installing |
| 6699 | distro-specific configuration files that are not |
| 6700 | already installed by another recipe. |
| 6701 | If you have distro-specific configuration files |
| 6702 | that are included by an existing recipe, you should |
| 6703 | add an append file (<filename>.bbappend</filename>) |
| 6704 | for those. |
| 6705 | For general information and recommendations |
| 6706 | on how to add recipes to your layer, see the |
| 6707 | "<link linkend='creating-your-own-layer'>Creating Your Own Layer</link>" |
| 6708 | and |
| 6709 | "<link linkend='best-practices-to-follow-when-creating-layers'>Best Practices to Follow When Creating Layers</link>" |
| 6710 | sections.</para></listitem> |
| 6711 | <listitem><para>Add any image recipes that are specific |
| 6712 | to your distribution.</para></listitem> |
| 6713 | <listitem><para>Add a <filename>psplash</filename> |
| 6714 | append file for a branded splash screen. |
| 6715 | For information on append files, see the |
| 6716 | "<link linkend='using-bbappend-files'>Using .bbappend Files</link>" |
| 6717 | section.</para></listitem> |
| 6718 | <listitem><para>Add any other append files to make |
| 6719 | custom changes that are specific to individual |
| 6720 | recipes.</para></listitem> |
| 6721 | </itemizedlist></para></listitem> |
| 6722 | </itemizedlist> |
| 6723 | </para> |
| 6724 | </section> |
| 6725 | |
| 6726 | <section id='creating-a-custom-template-configuration-directory'> |
| 6727 | <title>Creating a Custom Template Configuration Directory</title> |
| 6728 | |
| 6729 | <para> |
| 6730 | If you are producing your own customized version |
| 6731 | of the build system for use by other users, you might |
| 6732 | want to customize the message shown by the setup script or |
| 6733 | you might want to change the template configuration files (i.e. |
| 6734 | <filename>local.conf</filename> and |
| 6735 | <filename>bblayers.conf</filename>) that are created in |
| 6736 | a new build directory. |
| 6737 | </para> |
| 6738 | |
| 6739 | <para> |
| 6740 | The OpenEmbedded build system uses the environment variable |
| 6741 | <filename>TEMPLATECONF</filename> to locate the directory |
| 6742 | from which it gathers configuration information that ultimately |
| 6743 | ends up in the |
| 6744 | <link linkend='build-directory'>Build Directory's</link> |
| 6745 | <filename>conf</filename> directory. |
| 6746 | By default, <filename>TEMPLATECONF</filename> is set as |
| 6747 | follows in the <filename>poky</filename> repository: |
| 6748 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6749 | TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6750 | </literallayout> |
| 6751 | This is the directory used by the build system to find templates |
| 6752 | from which to build some key configuration files. |
| 6753 | If you look at this directory, you will see the |
| 6754 | <filename>bblayers.conf.sample</filename>, |
| 6755 | <filename>local.conf.sample</filename>, and |
| 6756 | <filename>conf-notes.txt</filename> files. |
| 6757 | The build system uses these files to form the respective |
| 6758 | <filename>bblayers.conf</filename> file, |
| 6759 | <filename>local.conf</filename> file, and display the list of |
| 6760 | BitBake targets when running the setup script. |
| 6761 | </para> |
| 6762 | |
| 6763 | <para> |
| 6764 | To override these default configuration files with |
| 6765 | configurations you want used within every new |
| 6766 | Build Directory, simply set the |
| 6767 | <filename>TEMPLATECONF</filename> variable to your directory. |
| 6768 | The <filename>TEMPLATECONF</filename> variable is set in the |
| 6769 | <filename>.templateconf</filename> file, which is in the |
| 6770 | top-level |
| 6771 | <link linkend='source-directory'>Source Directory</link> |
| 6772 | folder (e.g. <filename>poky</filename>). |
| 6773 | Edit the <filename>.templateconf</filename> so that it can locate |
| 6774 | your directory. |
| 6775 | </para> |
| 6776 | |
| 6777 | <para> |
| 6778 | Best practices dictate that you should keep your |
| 6779 | template configuration directory in your custom distribution layer. |
| 6780 | For example, suppose you have a layer named |
| 6781 | <filename>meta-mylayer</filename> located in your home directory |
| 6782 | and you want your template configuration directory named |
| 6783 | <filename>myconf</filename>. |
| 6784 | Changing the <filename>.templateconf</filename> as follows |
| 6785 | causes the OpenEmbedded build system to look in your directory |
| 6786 | and base its configuration files on the |
| 6787 | <filename>*.sample</filename> configuration files it finds. |
| 6788 | The final configuration files (i.e. |
| 6789 | <filename>local.conf</filename> and |
| 6790 | <filename>bblayers.conf</filename> ultimately still end up in |
| 6791 | your Build Directory, but they are based on your |
| 6792 | <filename>*.sample</filename> files. |
| 6793 | <literallayout class='monospaced'> |
| 6794 | TEMPLATECONF=${TEMPLATECONF:-meta-mylayer/myconf} |
| 6795 | </literallayout> |
| 6796 | </para> |
| 6797 | |
| 6798 | <para> |
| 6799 | Aside from the <filename>*.sample</filename> configuration files, |
| 6800 | the <filename>conf-notes.txt</filename> also resides in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6801 | default <filename>meta-poky/conf</filename> directory. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6802 | The scripts that set up the build environment |
| 6803 | (i.e. |
| 6804 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-core-script"><filename>&OE_INIT_FILE;</filename></ulink> |
| 6805 | and |
| 6806 | <ulink url="&YOCTO_DOCS_REF_URL;#structure-memres-core-script"><filename>oe-init-build-env-memres</filename></ulink>) |
| 6807 | use this file to display BitBake targets as part of the script |
| 6808 | output. |
| 6809 | Customizing this <filename>conf-notes.txt</filename> file is a |
| 6810 | good way to make sure your list of custom targets appears |
| 6811 | as part of the script's output. |
| 6812 | </para> |
| 6813 | |
| 6814 | <para> |
| 6815 | Here is the default list of targets displayed as a result of |
| 6816 | running either of the setup scripts: |
| 6817 | <literallayout class='monospaced'> |
| 6818 | You can now run 'bitbake <target>' |
| 6819 | |
| 6820 | Common targets are: |
| 6821 | core-image-minimal |
| 6822 | core-image-sato |
| 6823 | meta-toolchain |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6824 | meta-ide-support |
| 6825 | </literallayout> |
| 6826 | </para> |
| 6827 | |
| 6828 | <para> |
| 6829 | Changing the listed common targets is as easy as editing your |
| 6830 | version of <filename>conf-notes.txt</filename> in your |
| 6831 | custom template configuration directory and making sure you |
| 6832 | have <filename>TEMPLATECONF</filename> set to your directory. |
| 6833 | </para> |
| 6834 | </section> |
| 6835 | |
| 6836 | <section id='building-a-tiny-system'> |
| 6837 | <title>Building a Tiny System</title> |
| 6838 | |
| 6839 | <para> |
| 6840 | Very small distributions have some significant advantages such |
| 6841 | as requiring less on-die or in-package memory (cheaper), better |
| 6842 | performance through efficient cache usage, lower power requirements |
| 6843 | due to less memory, faster boot times, and reduced development |
| 6844 | overhead. |
| 6845 | Some real-world examples where a very small distribution gives |
| 6846 | you distinct advantages are digital cameras, medical devices, |
| 6847 | and small headless systems. |
| 6848 | </para> |
| 6849 | |
| 6850 | <para> |
| 6851 | This section presents information that shows you how you can |
| 6852 | trim your distribution to even smaller sizes than the |
| 6853 | <filename>poky-tiny</filename> distribution, which is around |
| 6854 | 5 Mbytes, that can be built out-of-the-box using the Yocto Project. |
| 6855 | </para> |
| 6856 | |
| 6857 | <section id='tiny-system-overview'> |
| 6858 | <title>Overview</title> |
| 6859 | |
| 6860 | <para> |
| 6861 | The following list presents the overall steps you need to |
| 6862 | consider and perform to create distributions with smaller |
| 6863 | root filesystems, achieve faster boot times, maintain your critical |
| 6864 | functionality, and avoid initial RAM disks: |
| 6865 | <itemizedlist> |
| 6866 | <listitem><para> |
| 6867 | <link linkend='goals-and-guiding-principles'>Determine your goals and guiding principles.</link> |
| 6868 | </para></listitem> |
| 6869 | <listitem><para> |
| 6870 | <link linkend='understand-what-gives-your-image-size'>Understand what contributes to your image size.</link> |
| 6871 | </para></listitem> |
| 6872 | <listitem><para> |
| 6873 | <link linkend='trim-the-root-filesystem'>Reduce the size of the root filesystem.</link> |
| 6874 | </para></listitem> |
| 6875 | <listitem><para> |
| 6876 | <link linkend='trim-the-kernel'>Reduce the size of the kernel.</link> |
| 6877 | </para></listitem> |
| 6878 | <listitem><para> |
| 6879 | <link linkend='remove-package-management-requirements'>Eliminate packaging requirements.</link> |
| 6880 | </para></listitem> |
| 6881 | <listitem><para> |
| 6882 | <link linkend='look-for-other-ways-to-minimize-size'>Look for other ways to minimize size.</link> |
| 6883 | </para></listitem> |
| 6884 | <listitem><para> |
| 6885 | <link linkend='iterate-on-the-process'>Iterate on the process.</link> |
| 6886 | </para></listitem> |
| 6887 | </itemizedlist> |
| 6888 | </para> |
| 6889 | </section> |
| 6890 | |
| 6891 | <section id='goals-and-guiding-principles'> |
| 6892 | <title>Goals and Guiding Principles</title> |
| 6893 | |
| 6894 | <para> |
| 6895 | Before you can reach your destination, you need to know |
| 6896 | where you are going. |
| 6897 | Here is an example list that you can use as a guide when |
| 6898 | creating very small distributions: |
| 6899 | <itemizedlist> |
| 6900 | <listitem><para>Determine how much space you need |
| 6901 | (e.g. a kernel that is 1 Mbyte or less and |
| 6902 | a root filesystem that is 3 Mbytes or less). |
| 6903 | </para></listitem> |
| 6904 | <listitem><para>Find the areas that are currently |
| 6905 | taking 90% of the space and concentrate on reducing |
| 6906 | those areas. |
| 6907 | </para></listitem> |
| 6908 | <listitem><para>Do not create any difficult "hacks" |
| 6909 | to achieve your goals.</para></listitem> |
| 6910 | <listitem><para>Leverage the device-specific |
| 6911 | options.</para></listitem> |
| 6912 | <listitem><para>Work in a separate layer so that you |
| 6913 | keep changes isolated. |
| 6914 | For information on how to create layers, see |
| 6915 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. |
| 6916 | </para></listitem> |
| 6917 | </itemizedlist> |
| 6918 | </para> |
| 6919 | </section> |
| 6920 | |
| 6921 | <section id='understand-what-gives-your-image-size'> |
| 6922 | <title>Understand What Contributes to Your Image Size</title> |
| 6923 | |
| 6924 | <para> |
| 6925 | It is easiest to have something to start with when creating |
| 6926 | your own distribution. |
| 6927 | You can use the Yocto Project out-of-the-box to create the |
| 6928 | <filename>poky-tiny</filename> distribution. |
| 6929 | Ultimately, you will want to make changes in your own |
| 6930 | distribution that are likely modeled after |
| 6931 | <filename>poky-tiny</filename>. |
| 6932 | <note> |
| 6933 | To use <filename>poky-tiny</filename> in your build, |
| 6934 | set the |
| 6935 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 6936 | variable in your |
| 6937 | <filename>local.conf</filename> file to "poky-tiny" |
| 6938 | as described in the |
| 6939 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" |
| 6940 | section. |
| 6941 | </note> |
| 6942 | </para> |
| 6943 | |
| 6944 | <para> |
| 6945 | Understanding some memory concepts will help you reduce the |
| 6946 | system size. |
| 6947 | Memory consists of static, dynamic, and temporary memory. |
| 6948 | Static memory is the TEXT (code), DATA (initialized data |
| 6949 | in the code), and BSS (uninitialized data) sections. |
| 6950 | Dynamic memory represents memory that is allocated at runtime: |
| 6951 | stacks, hash tables, and so forth. |
| 6952 | Temporary memory is recovered after the boot process. |
| 6953 | This memory consists of memory used for decompressing |
| 6954 | the kernel and for the <filename>__init__</filename> |
| 6955 | functions. |
| 6956 | </para> |
| 6957 | |
| 6958 | <para> |
| 6959 | To help you see where you currently are with kernel and root |
| 6960 | filesystem sizes, you can use two tools found in the |
| 6961 | <link linkend='source-directory'>Source Directory</link> in |
| 6962 | the <filename>scripts/tiny/</filename> directory: |
| 6963 | <itemizedlist> |
| 6964 | <listitem><para><filename>ksize.py</filename>: Reports |
| 6965 | component sizes for the kernel build objects. |
| 6966 | </para></listitem> |
| 6967 | <listitem><para><filename>dirsize.py</filename>: Reports |
| 6968 | component sizes for the root filesystem.</para></listitem> |
| 6969 | </itemizedlist> |
| 6970 | This next tool and command help you organize configuration |
| 6971 | fragments and view file dependencies in a human-readable form: |
| 6972 | <itemizedlist> |
| 6973 | <listitem><para><filename>merge_config.sh</filename>: |
| 6974 | Helps you manage configuration files and fragments |
| 6975 | within the kernel. |
| 6976 | With this tool, you can merge individual configuration |
| 6977 | fragments together. |
| 6978 | The tool allows you to make overrides and warns you |
| 6979 | of any missing configuration options. |
| 6980 | The tool is ideal for allowing you to iterate on |
| 6981 | configurations, create minimal configurations, and |
| 6982 | create configuration files for different machines |
| 6983 | without having to duplicate your process.</para> |
| 6984 | <para>The <filename>merge_config.sh</filename> script is |
| 6985 | part of the Linux Yocto kernel Git repositories |
| 6986 | (i.e. <filename>linux-yocto-3.14</filename>, |
| 6987 | <filename>linux-yocto-3.10</filename>, |
| 6988 | <filename>linux-yocto-3.8</filename>, and so forth) |
| 6989 | in the |
| 6990 | <filename>scripts/kconfig</filename> directory.</para> |
| 6991 | <para>For more information on configuration fragments, |
| 6992 | see the |
| 6993 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" |
| 6994 | section of the Yocto Project Linux Kernel Development |
| 6995 | Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
| 6996 | section, which is in this manual.</para></listitem> |
| 6997 | <listitem><para><filename>bitbake -u depexp -g <replaceable>bitbake_target</replaceable></filename>: |
| 6998 | Using the BitBake command with these options brings up |
| 6999 | a Dependency Explorer from which you can view file |
| 7000 | dependencies. |
| 7001 | Understanding these dependencies allows you to make |
| 7002 | informed decisions when cutting out various pieces of the |
| 7003 | kernel and root filesystem.</para></listitem> |
| 7004 | </itemizedlist> |
| 7005 | </para> |
| 7006 | </section> |
| 7007 | |
| 7008 | <section id='trim-the-root-filesystem'> |
| 7009 | <title>Trim the Root Filesystem</title> |
| 7010 | |
| 7011 | <para> |
| 7012 | The root filesystem is made up of packages for booting, |
| 7013 | libraries, and applications. |
| 7014 | To change things, you can configure how the packaging happens, |
| 7015 | which changes the way you build them. |
| 7016 | You can also modify the filesystem itself or select a different |
| 7017 | filesystem. |
| 7018 | </para> |
| 7019 | |
| 7020 | <para> |
| 7021 | First, find out what is hogging your root filesystem by running the |
| 7022 | <filename>dirsize.py</filename> script from your root directory: |
| 7023 | <literallayout class='monospaced'> |
| 7024 | $ cd <replaceable>root-directory-of-image</replaceable> |
| 7025 | $ dirsize.py 100000 > dirsize-100k.log |
| 7026 | $ cat dirsize-100k.log |
| 7027 | </literallayout> |
| 7028 | You can apply a filter to the script to ignore files under |
| 7029 | a certain size. |
| 7030 | The previous example filters out any files below 100 Kbytes. |
| 7031 | The sizes reported by the tool are uncompressed, and thus |
| 7032 | will be smaller by a relatively constant factor in a |
| 7033 | compressed root filesystem. |
| 7034 | When you examine your log file, you can focus on areas of the |
| 7035 | root filesystem that take up large amounts of memory. |
| 7036 | </para> |
| 7037 | |
| 7038 | <para> |
| 7039 | You need to be sure that what you eliminate does not cripple |
| 7040 | the functionality you need. |
| 7041 | One way to see how packages relate to each other is by using |
| 7042 | the Dependency Explorer UI with the BitBake command: |
| 7043 | <literallayout class='monospaced'> |
| 7044 | $ cd <replaceable>image-directory</replaceable> |
| 7045 | $ bitbake -u depexp -g <replaceable>image</replaceable> |
| 7046 | </literallayout> |
| 7047 | Use the interface to select potential packages you wish to |
| 7048 | eliminate and see their dependency relationships. |
| 7049 | </para> |
| 7050 | |
| 7051 | <para> |
| 7052 | When deciding how to reduce the size, get rid of packages that |
| 7053 | result in minimal impact on the feature set. |
| 7054 | For example, you might not need a VGA display. |
| 7055 | Or, you might be able to get by with <filename>devtmpfs</filename> |
| 7056 | and <filename>mdev</filename> instead of |
| 7057 | <filename>udev</filename>. |
| 7058 | </para> |
| 7059 | |
| 7060 | <para> |
| 7061 | Use your <filename>local.conf</filename> file to make changes. |
| 7062 | For example, to eliminate <filename>udev</filename> and |
| 7063 | <filename>glib</filename>, set the following in the |
| 7064 | local configuration file: |
| 7065 | <literallayout class='monospaced'> |
| 7066 | VIRTUAL-RUNTIME_dev_manager = "" |
| 7067 | </literallayout> |
| 7068 | </para> |
| 7069 | |
| 7070 | <para> |
| 7071 | Finally, you should consider exactly the type of root |
| 7072 | filesystem you need to meet your needs while also reducing |
| 7073 | its size. |
| 7074 | For example, consider <filename>cramfs</filename>, |
| 7075 | <filename>squashfs</filename>, <filename>ubifs</filename>, |
| 7076 | <filename>ext2</filename>, or an <filename>initramfs</filename> |
| 7077 | using <filename>initramfs</filename>. |
| 7078 | Be aware that <filename>ext3</filename> requires a 1 Mbyte |
| 7079 | journal. |
| 7080 | If you are okay with running read-only, you do not need this |
| 7081 | journal. |
| 7082 | </para> |
| 7083 | |
| 7084 | <note> |
| 7085 | After each round of elimination, you need to rebuild your |
| 7086 | system and then use the tools to see the effects of your |
| 7087 | reductions. |
| 7088 | </note> |
| 7089 | |
| 7090 | |
| 7091 | </section> |
| 7092 | |
| 7093 | <section id='trim-the-kernel'> |
| 7094 | <title>Trim the Kernel</title> |
| 7095 | |
| 7096 | <para> |
| 7097 | The kernel is built by including policies for hardware-independent |
| 7098 | aspects. |
| 7099 | What subsystems do you enable? |
| 7100 | For what architecture are you building? |
| 7101 | Which drivers do you build by default? |
| 7102 | <note>You can modify the kernel source if you want to help |
| 7103 | with boot time. |
| 7104 | </note> |
| 7105 | </para> |
| 7106 | |
| 7107 | <para> |
| 7108 | Run the <filename>ksize.py</filename> script from the top-level |
| 7109 | Linux build directory to get an idea of what is making up |
| 7110 | the kernel: |
| 7111 | <literallayout class='monospaced'> |
| 7112 | $ cd <replaceable>top-level-linux-build-directory</replaceable> |
| 7113 | $ ksize.py > ksize.log |
| 7114 | $ cat ksize.log |
| 7115 | </literallayout> |
| 7116 | When you examine the log, you will see how much space is |
| 7117 | taken up with the built-in <filename>.o</filename> files for |
| 7118 | drivers, networking, core kernel files, filesystem, sound, |
| 7119 | and so forth. |
| 7120 | The sizes reported by the tool are uncompressed, and thus |
| 7121 | will be smaller by a relatively constant factor in a compressed |
| 7122 | kernel image. |
| 7123 | Look to reduce the areas that are large and taking up around |
| 7124 | the "90% rule." |
| 7125 | </para> |
| 7126 | |
| 7127 | <para> |
| 7128 | To examine, or drill down, into any particular area, use the |
| 7129 | <filename>-d</filename> option with the script: |
| 7130 | <literallayout class='monospaced'> |
| 7131 | $ ksize.py -d > ksize.log |
| 7132 | </literallayout> |
| 7133 | Using this option breaks out the individual file information |
| 7134 | for each area of the kernel (e.g. drivers, networking, and |
| 7135 | so forth). |
| 7136 | </para> |
| 7137 | |
| 7138 | <para> |
| 7139 | Use your log file to see what you can eliminate from the kernel |
| 7140 | based on features you can let go. |
| 7141 | For example, if you are not going to need sound, you do not |
| 7142 | need any drivers that support sound. |
| 7143 | </para> |
| 7144 | |
| 7145 | <para> |
| 7146 | After figuring out what to eliminate, you need to reconfigure |
| 7147 | the kernel to reflect those changes during the next build. |
| 7148 | You could run <filename>menuconfig</filename> and make all your |
| 7149 | changes at once. |
| 7150 | However, that makes it difficult to see the effects of your |
| 7151 | individual eliminations and also makes it difficult to replicate |
| 7152 | the changes for perhaps another target device. |
| 7153 | A better method is to start with no configurations using |
| 7154 | <filename>allnoconfig</filename>, create configuration |
| 7155 | fragments for individual changes, and then manage the |
| 7156 | fragments into a single configuration file using |
| 7157 | <filename>merge_config.sh</filename>. |
| 7158 | The tool makes it easy for you to iterate using the |
| 7159 | configuration change and build cycle. |
| 7160 | </para> |
| 7161 | |
| 7162 | <para> |
| 7163 | Each time you make configuration changes, you need to rebuild |
| 7164 | the kernel and check to see what impact your changes had on |
| 7165 | the overall size. |
| 7166 | </para> |
| 7167 | </section> |
| 7168 | |
| 7169 | <section id='remove-package-management-requirements'> |
| 7170 | <title>Remove Package Management Requirements</title> |
| 7171 | |
| 7172 | <para> |
| 7173 | Packaging requirements add size to the image. |
| 7174 | One way to reduce the size of the image is to remove all the |
| 7175 | packaging requirements from the image. |
| 7176 | This reduction includes both removing the package manager |
| 7177 | and its unique dependencies as well as removing the package |
| 7178 | management data itself. |
| 7179 | </para> |
| 7180 | |
| 7181 | <para> |
| 7182 | To eliminate all the packaging requirements for an image, |
| 7183 | be sure that "package-management" is not part of your |
| 7184 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 7185 | statement for the image. |
| 7186 | When you remove this feature, you are removing the package |
| 7187 | manager as well as its dependencies from the root filesystem. |
| 7188 | </para> |
| 7189 | </section> |
| 7190 | |
| 7191 | <section id='look-for-other-ways-to-minimize-size'> |
| 7192 | <title>Look for Other Ways to Minimize Size</title> |
| 7193 | |
| 7194 | <para> |
| 7195 | Depending on your particular circumstances, other areas that you |
| 7196 | can trim likely exist. |
| 7197 | The key to finding these areas is through tools and methods |
| 7198 | described here combined with experimentation and iteration. |
| 7199 | Here are a couple of areas to experiment with: |
| 7200 | <itemizedlist> |
| 7201 | <listitem><para><filename>glibc</filename>: |
| 7202 | In general, follow this process: |
| 7203 | <orderedlist> |
| 7204 | <listitem><para>Remove <filename>glibc</filename> |
| 7205 | features from |
| 7206 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 7207 | that you think you do not need.</para></listitem> |
| 7208 | <listitem><para>Build your distribution. |
| 7209 | </para></listitem> |
| 7210 | <listitem><para>If the build fails due to missing |
| 7211 | symbols in a package, determine if you can |
| 7212 | reconfigure the package to not need those |
| 7213 | features. |
| 7214 | For example, change the configuration to not |
| 7215 | support wide character support as is done for |
| 7216 | <filename>ncurses</filename>. |
| 7217 | Or, if support for those characters is needed, |
| 7218 | determine what <filename>glibc</filename> |
| 7219 | features provide the support and restore the |
| 7220 | configuration. |
| 7221 | </para></listitem> |
| 7222 | <listitem><para>Rebuild and repeat the process. |
| 7223 | </para></listitem> |
| 7224 | </orderedlist></para></listitem> |
| 7225 | <listitem><para><filename>busybox</filename>: |
| 7226 | For BusyBox, use a process similar as described for |
| 7227 | <filename>glibc</filename>. |
| 7228 | A difference is you will need to boot the resulting |
| 7229 | system to see if you are able to do everything you |
| 7230 | expect from the running system. |
| 7231 | You need to be sure to integrate configuration fragments |
| 7232 | into Busybox because BusyBox handles its own core |
| 7233 | features and then allows you to add configuration |
| 7234 | fragments on top. |
| 7235 | </para></listitem> |
| 7236 | </itemizedlist> |
| 7237 | </para> |
| 7238 | </section> |
| 7239 | |
| 7240 | <section id='iterate-on-the-process'> |
| 7241 | <title>Iterate on the Process</title> |
| 7242 | |
| 7243 | <para> |
| 7244 | If you have not reached your goals on system size, you need |
| 7245 | to iterate on the process. |
| 7246 | The process is the same. |
| 7247 | Use the tools and see just what is taking up 90% of the root |
| 7248 | filesystem and the kernel. |
| 7249 | Decide what you can eliminate without limiting your device |
| 7250 | beyond what you need. |
| 7251 | </para> |
| 7252 | |
| 7253 | <para> |
| 7254 | Depending on your system, a good place to look might be |
| 7255 | Busybox, which provides a stripped down |
| 7256 | version of Unix tools in a single, executable file. |
| 7257 | You might be able to drop virtual terminal services or perhaps |
| 7258 | ipv6. |
| 7259 | </para> |
| 7260 | </section> |
| 7261 | </section> |
| 7262 | |
| 7263 | <section id='building-images-for-more-than-one-machine'> |
| 7264 | <title>Building Images for More than One Machine</title> |
| 7265 | |
| 7266 | <para> |
| 7267 | A common scenario developers face is creating images for several |
| 7268 | different machines that use the same software environment. |
| 7269 | In this situation, it is tempting to set the |
| 7270 | tunings and optimization flags for each build specifically for |
| 7271 | the targeted hardware (i.e. "maxing out" the tunings). |
| 7272 | Doing so can considerably add to build times and package feed |
| 7273 | maintenance collectively for the machines. |
| 7274 | For example, selecting tunes that are extremely specific to a |
| 7275 | CPU core used in a system might enable some micro optimizations |
| 7276 | in GCC for that particular system but would otherwise not gain |
| 7277 | you much of a performance difference across the other systems |
| 7278 | as compared to using a more general tuning across all the builds |
| 7279 | (e.g. setting |
| 7280 | <ulink url='var-DEFAULTTUNE'><filename>DEFAULTTUNE</filename></ulink> |
| 7281 | specifically for each machine's build). |
| 7282 | Rather than "max out" each build's tunings, you can take steps that |
| 7283 | cause the OpenEmbedded build system to reuse software across the |
| 7284 | various machines where it makes sense. |
| 7285 | </para> |
| 7286 | <para> |
| 7287 | If build speed and package feed maintenance are considerations, |
| 7288 | you should consider the points in this section that can help you |
| 7289 | optimize your tunings to best consider build times and package |
| 7290 | feed maintenance. |
| 7291 | <itemizedlist> |
| 7292 | <listitem><para><emphasis>Share the Build Directory:</emphasis> |
| 7293 | If at all possible, share the |
| 7294 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> |
| 7295 | across builds. |
| 7296 | The Yocto Project supports switching between different |
| 7297 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 7298 | values in the same <filename>TMPDIR</filename>. |
| 7299 | This practice is well supported and regularly used by |
| 7300 | developers when building for multiple machines. |
| 7301 | When you use the same <filename>TMPDIR</filename> for |
| 7302 | multiple machine builds, the OpenEmbedded build system can |
| 7303 | reuse the existing native and often cross-recipes for |
| 7304 | multiple machines. |
| 7305 | Thus, build time decreases. |
| 7306 | <note> |
| 7307 | If |
| 7308 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO'><filename>DISTRO</filename></ulink> |
| 7309 | settings change or fundamental configuration settings |
| 7310 | such as the filesystem layout, you need to work with |
| 7311 | a clean <filename>TMPDIR</filename>. |
| 7312 | Sharing <filename>TMPDIR</filename> under these |
| 7313 | circumstances might work but since it is not |
| 7314 | guaranteed, you should use a clean |
| 7315 | <filename>TMPDIR</filename>. |
| 7316 | </note> |
| 7317 | </para></listitem> |
| 7318 | <listitem><para><emphasis>Enable the Appropriate Package Architecture:</emphasis> |
| 7319 | By default, the OpenEmbedded build system enables three |
| 7320 | levels of package architectures: "all", "tune" or "package", |
| 7321 | and "machine". |
| 7322 | Any given recipe usually selects one of these package |
| 7323 | architectures (types) for its output. |
| 7324 | Depending for what a given recipe creates packages, making |
| 7325 | sure you enable the appropriate package architecture can |
| 7326 | directly impact the build time.</para> |
| 7327 | <para>A recipe that just generates scripts can enable |
| 7328 | "all" architecture because there are no binaries to build. |
| 7329 | To specifically enable "all" architecture, be sure your |
| 7330 | recipe inherits the |
| 7331 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-allarch'><filename>allarch</filename></ulink> |
| 7332 | class. |
| 7333 | This class is useful for "all" architectures because it |
| 7334 | configures many variables so packages can be used across |
| 7335 | multiple architectures.</para> |
| 7336 | <para>If your recipe needs to generate packages that are |
| 7337 | machine-specific or when one of the build or runtime |
| 7338 | dependencies is already machine-architecture dependent, |
| 7339 | which makes your recipe also machine-architecture dependent, |
| 7340 | make sure your recipe enables the "machine" package |
| 7341 | architecture through the |
| 7342 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ARCH'><filename>MACHINE_ARCH</filename></ulink> |
| 7343 | variable: |
| 7344 | <literallayout class='monospaced'> |
| 7345 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 7346 | </literallayout> |
| 7347 | When you do not specifically enable a package |
| 7348 | architecture through the |
| 7349 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>, |
| 7350 | The OpenEmbedded build system defaults to the |
| 7351 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TUNE_PKGARCH'><filename>TUNE_PKGARCH</filename></ulink> |
| 7352 | setting: |
| 7353 | <literallayout class='monospaced'> |
| 7354 | PACKAGE_ARCH = "${TUNE_PKGARCH}" |
| 7355 | </literallayout> |
| 7356 | </para></listitem> |
| 7357 | <listitem><para><emphasis>Choose a Generic Tuning File if Possible:</emphasis> |
| 7358 | Some tunes are more generic and can run on multiple targets |
| 7359 | (e.g. an <filename>armv5</filename> set of packages could |
| 7360 | run on <filename>armv6</filename> and |
| 7361 | <filename>armv7</filename> processors in most cases). |
| 7362 | Similarly, <filename>i486</filename> binaries could work |
| 7363 | on <filename>i586</filename> and higher processors. |
| 7364 | You should realize, however, that advances on newer |
| 7365 | processor versions would not be used.</para> |
| 7366 | <para>If you select the same tune for several different |
| 7367 | machines, the OpenEmbedded build system reuses software |
| 7368 | previously built, thus speeding up the overall build time. |
| 7369 | Realize that even though a new sysroot for each machine is |
| 7370 | generated, the software is not recompiled and only one |
| 7371 | package feed exists. |
| 7372 | </para></listitem> |
| 7373 | <listitem><para><emphasis>Manage Granular Level Packaging:</emphasis> |
| 7374 | Sometimes cases exist where injecting another level |
| 7375 | of package architecture beyond the three higher levels |
| 7376 | noted earlier can be useful. |
| 7377 | For example, consider the <filename>emgd</filename> |
| 7378 | graphics stack in the |
| 7379 | <filename>meta-intel</filename> layer. |
| 7380 | In this layer, a subset of software exists that is |
| 7381 | compiled against something different from the rest of the |
| 7382 | generic packages. |
| 7383 | You can examine the key code in the |
| 7384 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Source Repositories</ulink> |
| 7385 | "daisy" branch in |
| 7386 | <filename>classes/emgd-gl.bbclass</filename>. |
| 7387 | For a specific set of packages, the code redefines |
| 7388 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>. |
| 7389 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXTRA_ARCHS'><filename>PACKAGE_EXTRA_ARCHS</filename></ulink> |
| 7390 | is then appended with this extra tune name in |
| 7391 | <filename>meta-intel-emgd.inc</filename>. |
| 7392 | The result is that when searching for packages, the |
| 7393 | build system uses a four-level search and the packages |
| 7394 | in this new level are preferred as compared to the standard |
| 7395 | tune. |
| 7396 | The overall result is that the build system reuses most |
| 7397 | software from the common tune except for specific cases |
| 7398 | as needed. |
| 7399 | </para></listitem> |
| 7400 | <listitem><para><emphasis>Use Tools to Debug Issues:</emphasis> |
| 7401 | Sometimes you can run into situations where software is |
| 7402 | being rebuilt when you think it should not be. |
| 7403 | For example, the OpenEmbedded build system might not be |
| 7404 | using shared state between machines when you think it |
| 7405 | should be. |
| 7406 | These types of situations are usually due to references |
| 7407 | to machine-specific variables such as |
| 7408 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, |
| 7409 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SERIAL_CONSOLE'><filename>SERIAL_CONSOLE</filename></ulink>, |
| 7410 | <ulink url='&YOCTO_DOCS_REF_URL;#var-XSERVER'><filename>XSERVER</filename></ulink>, |
| 7411 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_FEATURES'><filename>MACHINE_FEATURES</filename></ulink>, |
| 7412 | and so forth in code that is supposed to only be |
| 7413 | tune-specific or when the recipe depends |
| 7414 | (<ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink>, |
| 7415 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>, |
| 7416 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>, |
| 7417 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RSUGGESTS'><filename>RSUGGESTS</filename></ulink>, |
| 7418 | and so forth) on some other recipe that already has |
| 7419 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> |
| 7420 | defined as "${MACHINE_ARCH}". |
| 7421 | <note> |
| 7422 | Patches to fix any issues identified are most welcome |
| 7423 | as these issues occasionally do occur. |
| 7424 | </note></para> |
| 7425 | <para>For such cases, you can use some tools to help you |
| 7426 | sort out the situation: |
| 7427 | <itemizedlist> |
| 7428 | <listitem><para><emphasis><filename>sstate-diff-machines.sh</filename>:</emphasis> |
| 7429 | You can find this tool in the |
| 7430 | <filename>scripts</filename> directory of the |
| 7431 | Source Repositories. |
| 7432 | See the comments in the script for information on |
| 7433 | how to use the tool. |
| 7434 | </para></listitem> |
| 7435 | <listitem><para><emphasis>BitBake's "-S printdiff" Option:</emphasis> |
| 7436 | Using this option causes BitBake to try to |
| 7437 | establish the closest signature match it can |
| 7438 | (e.g. in the shared state cache) and then run |
| 7439 | <filename>bitbake-diffsigs</filename> over the |
| 7440 | matches to determine the stamps and delta where |
| 7441 | these two stamp trees diverge. |
| 7442 | </para></listitem> |
| 7443 | </itemizedlist> |
| 7444 | </para></listitem> |
| 7445 | </itemizedlist> |
| 7446 | </para> |
| 7447 | </section> |
| 7448 | |
| 7449 | <section id='working-with-packages'> |
| 7450 | <title>Working with Packages</title> |
| 7451 | |
| 7452 | <para> |
| 7453 | This section describes a few tasks that involve packages: |
| 7454 | <itemizedlist> |
| 7455 | <listitem><para> |
| 7456 | <link linkend='excluding-packages-from-an-image'>Excluding packages from an image</link> |
| 7457 | </para></listitem> |
| 7458 | <listitem><para> |
| 7459 | <link linkend='incrementing-a-package-revision-number'>Incrementing a package revision number</link> |
| 7460 | </para></listitem> |
| 7461 | <listitem><para> |
| 7462 | <link linkend='handling-optional-module-packaging'>Handling optional module packaging</link> |
| 7463 | </para></listitem> |
| 7464 | <listitem><para> |
| 7465 | <link linkend='using-runtime-package-management'>Using Runtime Package Management</link> |
| 7466 | </para></listitem> |
| 7467 | <listitem><para> |
| 7468 | <link linkend='testing-packages-with-ptest'>Setting up and running package test (ptest)</link> |
| 7469 | </para></listitem> |
| 7470 | </itemizedlist> |
| 7471 | </para> |
| 7472 | |
| 7473 | <section id='excluding-packages-from-an-image'> |
| 7474 | <title>Excluding Packages from an Image</title> |
| 7475 | |
| 7476 | <para> |
| 7477 | You might find it necessary to prevent specific packages |
| 7478 | from being installed into an image. |
| 7479 | If so, you can use several variables to direct the build |
| 7480 | system to essentially ignore installing recommended packages |
| 7481 | or to not install a package at all. |
| 7482 | </para> |
| 7483 | |
| 7484 | <para> |
| 7485 | The following list introduces variables you can use to |
| 7486 | prevent packages from being installed into your image. |
| 7487 | Each of these variables only works with IPK and RPM |
| 7488 | package types. |
| 7489 | Support for Debian packages does not exist. |
| 7490 | Also, you can use these variables from your |
| 7491 | <filename>local.conf</filename> file or attach them to a |
| 7492 | specific image recipe by using a recipe name override. |
| 7493 | For more detail on the variables, see the descriptions in the |
| 7494 | Yocto Project Reference Manual's glossary chapter. |
| 7495 | <itemizedlist> |
| 7496 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-BAD_RECOMMENDATIONS'><filename>BAD_RECOMMENDATIONS</filename></ulink>: |
| 7497 | Use this variable to specify "recommended-only" |
| 7498 | packages that you do not want installed. |
| 7499 | </para></listitem> |
| 7500 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-NO_RECOMMENDATIONS'><filename>NO_RECOMMENDATIONS</filename></ulink>: |
| 7501 | Use this variable to prevent all "recommended-only" |
| 7502 | packages from being installed. |
| 7503 | </para></listitem> |
| 7504 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>: |
| 7505 | Use this variable to prevent specific packages from |
| 7506 | being installed regardless of whether they are |
| 7507 | "recommended-only" or not. |
| 7508 | You need to realize that the build process could |
| 7509 | fail with an error when you |
| 7510 | prevent the installation of a package whose presence |
| 7511 | is required by an installed package. |
| 7512 | </para></listitem> |
| 7513 | </itemizedlist> |
| 7514 | </para> |
| 7515 | </section> |
| 7516 | |
| 7517 | <section id='incrementing-a-package-revision-number'> |
| 7518 | <title>Incrementing a Package Revision Number</title> |
| 7519 | |
| 7520 | <para> |
| 7521 | If a committed change results in changing the package output, |
| 7522 | then the value of the |
| 7523 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7524 | variable needs to be increased (or "bumped"). |
| 7525 | Increasing <filename>PR</filename> occurs one of two ways: |
| 7526 | <itemizedlist> |
| 7527 | <listitem><para>Automatically using a Package Revision |
| 7528 | Service (PR Service).</para></listitem> |
| 7529 | <listitem><para>Manually incrementing the |
| 7530 | <filename>PR</filename> variable.</para></listitem> |
| 7531 | </itemizedlist> |
| 7532 | </para> |
| 7533 | |
| 7534 | <para> |
| 7535 | Given that one of the challenges any build system and its |
| 7536 | users face is how to maintain a package feed that is compatible |
| 7537 | with existing package manager applications such as |
| 7538 | RPM, APT, and OPKG, using an automated system is much |
| 7539 | preferred over a manual system. |
| 7540 | In either system, the main requirement is that version |
| 7541 | numbering increases in a linear fashion and that a number of |
| 7542 | version components exist that support that linear progression. |
| 7543 | </para> |
| 7544 | |
| 7545 | <para> |
| 7546 | The following two sections provide information on the PR Service |
| 7547 | and on manual <filename>PR</filename> bumping. |
| 7548 | </para> |
| 7549 | |
| 7550 | <section id='working-with-a-pr-service'> |
| 7551 | <title>Working With a PR Service</title> |
| 7552 | |
| 7553 | <para> |
| 7554 | As mentioned, attempting to maintain revision numbers in the |
| 7555 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> |
| 7556 | is error prone, inaccurate, and causes problems for people |
| 7557 | submitting recipes. |
| 7558 | Conversely, the PR Service automatically generates |
| 7559 | increasing numbers, particularly the revision field, |
| 7560 | which removes the human element. |
| 7561 | <note> |
| 7562 | For additional information on using a PR Service, you |
| 7563 | can see the |
| 7564 | <ulink url='&YOCTO_WIKI_URL;/wiki/PR_Service'>PR Service</ulink> |
| 7565 | wiki page. |
| 7566 | </note> |
| 7567 | </para> |
| 7568 | |
| 7569 | <para> |
| 7570 | The Yocto Project uses variables in order of |
| 7571 | decreasing priority to facilitate revision numbering (i.e. |
| 7572 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PE'><filename>PE</filename></ulink>, |
| 7573 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>, and |
| 7574 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7575 | for epoch, version, and revision, respectively). |
| 7576 | The values are highly dependent on the policies and |
| 7577 | procedures of a given distribution and package feed. |
| 7578 | </para> |
| 7579 | |
| 7580 | <para> |
| 7581 | Because the OpenEmbedded build system uses |
| 7582 | "<ulink url='&YOCTO_DOCS_REF_URL;#checksums'>signatures</ulink>", |
| 7583 | which are unique to a given build, the build system |
| 7584 | knows when to rebuild packages. |
| 7585 | All the inputs into a given task are represented by a |
| 7586 | signature, which can trigger a rebuild when different. |
| 7587 | Thus, the build system itself does not rely on the |
| 7588 | <filename>PR</filename> numbers to trigger a rebuild. |
| 7589 | The signatures, however, can be used to generate |
| 7590 | <filename>PR</filename> values. |
| 7591 | </para> |
| 7592 | |
| 7593 | <para> |
| 7594 | The PR Service works with both |
| 7595 | <filename>OEBasic</filename> and |
| 7596 | <filename>OEBasicHash</filename> generators. |
| 7597 | The value of <filename>PR</filename> bumps when the |
| 7598 | checksum changes and the different generator mechanisms |
| 7599 | change signatures under different circumstances. |
| 7600 | </para> |
| 7601 | |
| 7602 | <para> |
| 7603 | As implemented, the build system includes values from |
| 7604 | the PR Service into the <filename>PR</filename> field as |
| 7605 | an addition using the form "<filename>.x</filename>" so |
| 7606 | <filename>r0</filename> becomes <filename>r0.1</filename>, |
| 7607 | <filename>r0.2</filename> and so forth. |
| 7608 | This scheme allows existing <filename>PR</filename> values |
| 7609 | to be used for whatever reasons, which include manual |
| 7610 | <filename>PR</filename> bumps, should it be necessary. |
| 7611 | </para> |
| 7612 | |
| 7613 | <para> |
| 7614 | By default, the PR Service is not enabled or running. |
| 7615 | Thus, the packages generated are just "self consistent". |
| 7616 | The build system adds and removes packages and |
| 7617 | there are no guarantees about upgrade paths but images |
| 7618 | will be consistent and correct with the latest changes. |
| 7619 | </para> |
| 7620 | |
| 7621 | <para> |
| 7622 | The simplest form for a PR Service is for it to exist |
| 7623 | for a single host development system that builds the |
| 7624 | package feed (building system). |
| 7625 | For this scenario, you can enable a local PR Service by |
| 7626 | setting |
| 7627 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PRSERV_HOST'><filename>PRSERV_HOST</filename></ulink> |
| 7628 | in your <filename>local.conf</filename> file in the |
| 7629 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>: |
| 7630 | <literallayout class='monospaced'> |
| 7631 | PRSERV_HOST = "localhost:0" |
| 7632 | </literallayout> |
| 7633 | Once the service is started, packages will automatically |
| 7634 | get increasing <filename>PR</filename> values and |
| 7635 | BitBake will take care of starting and stopping the server. |
| 7636 | </para> |
| 7637 | |
| 7638 | <para> |
| 7639 | If you have a more complex setup where multiple host |
| 7640 | development systems work against a common, shared package |
| 7641 | feed, you have a single PR Service running and it is |
| 7642 | connected to each building system. |
| 7643 | For this scenario, you need to start the PR Service using |
| 7644 | the <filename>bitbake-prserv</filename> command: |
| 7645 | <literallayout class='monospaced'> |
| 7646 | bitbake-prserv --host <replaceable>ip</replaceable> --port <replaceable>port</replaceable> --start |
| 7647 | </literallayout> |
| 7648 | In addition to hand-starting the service, you need to |
| 7649 | update the <filename>local.conf</filename> file of each |
| 7650 | building system as described earlier so each system |
| 7651 | points to the server and port. |
| 7652 | </para> |
| 7653 | |
| 7654 | <para> |
| 7655 | It is also recommended you use build history, which adds |
| 7656 | some sanity checks to package versions, in conjunction with |
| 7657 | the server that is running the PR Service. |
| 7658 | To enable build history, add the following to each building |
| 7659 | system's <filename>local.conf</filename> file: |
| 7660 | <literallayout class='monospaced'> |
| 7661 | # It is recommended to activate "buildhistory" for testing the PR service |
| 7662 | INHERIT += "buildhistory" |
| 7663 | BUILDHISTORY_COMMIT = "1" |
| 7664 | </literallayout> |
| 7665 | For information on build history, see the |
| 7666 | "<ulink url='&YOCTO_DOCS_REF_URL;#maintaining-build-output-quality'>Maintaining Build Output Quality</ulink>" |
| 7667 | section in the Yocto Project Reference Manual. |
| 7668 | </para> |
| 7669 | |
| 7670 | <note> |
| 7671 | <para>The OpenEmbedded build system does not maintain |
| 7672 | <filename>PR</filename> information as part of the |
| 7673 | shared state (sstate) packages. |
| 7674 | If you maintain an sstate feed, its expected that either |
| 7675 | all your building systems that contribute to the sstate |
| 7676 | feed use a shared PR Service, or you do not run a PR |
| 7677 | Service on any of your building systems. |
| 7678 | Having some systems use a PR Service while others do |
| 7679 | not leads to obvious problems.</para> |
| 7680 | <para>For more information on shared state, see the |
| 7681 | "<ulink url='&YOCTO_DOCS_REF_URL;#shared-state-cache'>Shared State Cache</ulink>" |
| 7682 | section in the Yocto Project Reference Manual.</para> |
| 7683 | </note> |
| 7684 | </section> |
| 7685 | |
| 7686 | <section id='manually-bumping-pr'> |
| 7687 | <title>Manually Bumping PR</title> |
| 7688 | |
| 7689 | <para> |
| 7690 | The alternative to setting up a PR Service is to manually |
| 7691 | bump the |
| 7692 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 7693 | variable. |
| 7694 | </para> |
| 7695 | |
| 7696 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7697 | If a committed change results in changing the package |
| 7698 | output, then the value of the PR variable needs to be |
| 7699 | increased (or "bumped") as part of that commit. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7700 | For new recipes you should add the <filename>PR</filename> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7701 | variable and set its initial value equal to "r0", which is |
| 7702 | the default. |
| 7703 | Even though the default value is "r0", the practice of |
| 7704 | adding it to a new recipe makes it harder to forget to bump |
| 7705 | the variable when you make changes to the recipe in future. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7706 | </para> |
| 7707 | |
| 7708 | <para> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7709 | If you are sharing a common <filename>.inc</filename> file |
| 7710 | with multiple recipes, you can also use the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7711 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-INC_PR'>INC_PR</ulink></filename> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7712 | variable to ensure that the recipes sharing the |
| 7713 | <filename>.inc</filename> file are rebuilt when the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7714 | <filename>.inc</filename> file itself is changed. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7715 | The <filename>.inc</filename> file must set |
| 7716 | <filename>INC_PR</filename> (initially to "r0"), and all |
| 7717 | recipes referring to it should set <filename>PR</filename> |
| 7718 | to "${INC_PR}.0" initially, incrementing the last number |
| 7719 | when the recipe is changed. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7720 | If the <filename>.inc</filename> file is changed then its |
| 7721 | <filename>INC_PR</filename> should be incremented. |
| 7722 | </para> |
| 7723 | |
| 7724 | <para> |
| 7725 | When upgrading the version of a package, assuming the |
| 7726 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'>PV</ulink></filename> |
| 7727 | changes, the <filename>PR</filename> variable should be |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7728 | reset to "r0" (or "${INC_PR}.0" if you are using |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7729 | <filename>INC_PR</filename>). |
| 7730 | </para> |
| 7731 | |
| 7732 | <para> |
| 7733 | Usually, version increases occur only to packages. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7734 | However, if for some reason <filename>PV</filename> changes |
| 7735 | but does not increase, you can increase the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7736 | <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PE'>PE</ulink></filename> |
| 7737 | variable (Package Epoch). |
| 7738 | The <filename>PE</filename> variable defaults to "0". |
| 7739 | </para> |
| 7740 | |
| 7741 | <para> |
| 7742 | Version numbering strives to follow the |
| 7743 | <ulink url='http://www.debian.org/doc/debian-policy/ch-controlfields.html'> |
| 7744 | Debian Version Field Policy Guidelines</ulink>. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7745 | These guidelines define how versions are compared and what |
| 7746 | "increasing" a version means. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7747 | </para> |
| 7748 | </section> |
| 7749 | </section> |
| 7750 | |
| 7751 | <section id='handling-optional-module-packaging'> |
| 7752 | <title>Handling Optional Module Packaging</title> |
| 7753 | |
| 7754 | <para> |
| 7755 | Many pieces of software split functionality into optional |
| 7756 | modules (or plug-ins) and the plug-ins that are built |
| 7757 | might depend on configuration options. |
| 7758 | To avoid having to duplicate the logic that determines what |
| 7759 | modules are available in your recipe or to avoid having |
| 7760 | to package each module by hand, the OpenEmbedded build system |
| 7761 | provides functionality to handle module packaging dynamically. |
| 7762 | </para> |
| 7763 | |
| 7764 | <para> |
| 7765 | To handle optional module packaging, you need to do two things: |
| 7766 | <itemizedlist> |
| 7767 | <listitem><para>Ensure the module packaging is actually |
| 7768 | done.</para></listitem> |
| 7769 | <listitem><para>Ensure that any dependencies on optional |
| 7770 | modules from other recipes are satisfied by your recipe. |
| 7771 | </para></listitem> |
| 7772 | </itemizedlist> |
| 7773 | </para> |
| 7774 | |
| 7775 | <section id='making-sure-the-packaging-is-done'> |
| 7776 | <title>Making Sure the Packaging is Done</title> |
| 7777 | |
| 7778 | <para> |
| 7779 | To ensure the module packaging actually gets done, you use |
| 7780 | the <filename>do_split_packages</filename> function within |
| 7781 | the <filename>populate_packages</filename> Python function |
| 7782 | in your recipe. |
| 7783 | The <filename>do_split_packages</filename> function |
| 7784 | searches for a pattern of files or directories under a |
| 7785 | specified path and creates a package for each one it finds |
| 7786 | by appending to the |
| 7787 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 7788 | variable and setting the appropriate values for |
| 7789 | <filename>FILES_packagename</filename>, |
| 7790 | <filename>RDEPENDS_packagename</filename>, |
| 7791 | <filename>DESCRIPTION_packagename</filename>, and so forth. |
| 7792 | Here is an example from the <filename>lighttpd</filename> |
| 7793 | recipe: |
| 7794 | <literallayout class='monospaced'> |
| 7795 | python populate_packages_prepend () { |
| 7796 | lighttpd_libdir = d.expand('${libdir}') |
| 7797 | do_split_packages(d, lighttpd_libdir, '^mod_(.*)\.so$', |
| 7798 | 'lighttpd-module-%s', 'Lighttpd module for %s', |
| 7799 | extra_depends='') |
| 7800 | } |
| 7801 | </literallayout> |
| 7802 | The previous example specifies a number of things in the |
| 7803 | call to <filename>do_split_packages</filename>. |
| 7804 | <itemizedlist> |
| 7805 | <listitem><para>A directory within the files installed |
| 7806 | by your recipe through <filename>do_install</filename> |
| 7807 | in which to search.</para></listitem> |
| 7808 | <listitem><para>A regular expression used to match module |
| 7809 | files in that directory. |
| 7810 | In the example, note the parentheses () that mark |
| 7811 | the part of the expression from which the module |
| 7812 | name should be derived.</para></listitem> |
| 7813 | <listitem><para>A pattern to use for the package names. |
| 7814 | </para></listitem> |
| 7815 | <listitem><para>A description for each package. |
| 7816 | </para></listitem> |
| 7817 | <listitem><para>An empty string for |
| 7818 | <filename>extra_depends</filename>, which disables |
| 7819 | the default dependency on the main |
| 7820 | <filename>lighttpd</filename> package. |
| 7821 | Thus, if a file in <filename>${libdir}</filename> |
| 7822 | called <filename>mod_alias.so</filename> is found, |
| 7823 | a package called <filename>lighttpd-module-alias</filename> |
| 7824 | is created for it and the |
| 7825 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> |
| 7826 | is set to "Lighttpd module for alias".</para></listitem> |
| 7827 | </itemizedlist> |
| 7828 | </para> |
| 7829 | |
| 7830 | <para> |
| 7831 | Often, packaging modules is as simple as the previous |
| 7832 | example. |
| 7833 | However, more advanced options exist that you can use |
| 7834 | within <filename>do_split_packages</filename> to modify its |
| 7835 | behavior. |
| 7836 | And, if you need to, you can add more logic by specifying |
| 7837 | a hook function that is called for each package. |
| 7838 | It is also perfectly acceptable to call |
| 7839 | <filename>do_split_packages</filename> multiple times if |
| 7840 | you have more than one set of modules to package. |
| 7841 | </para> |
| 7842 | |
| 7843 | <para> |
| 7844 | For more examples that show how to use |
| 7845 | <filename>do_split_packages</filename>, see the |
| 7846 | <filename>connman.inc</filename> file in the |
| 7847 | <filename>meta/recipes-connectivity/connman/</filename> |
| 7848 | directory of the <filename>poky</filename> |
| 7849 | <link linkend='yocto-project-repositories'>source repository</link>. |
| 7850 | You can also find examples in |
| 7851 | <filename>meta/classes/kernel.bbclass</filename>. |
| 7852 | </para> |
| 7853 | |
| 7854 | <para> |
| 7855 | Following is a reference that shows |
| 7856 | <filename>do_split_packages</filename> mandatory and |
| 7857 | optional arguments: |
| 7858 | <literallayout class='monospaced'> |
| 7859 | Mandatory arguments |
| 7860 | |
| 7861 | root |
| 7862 | The path in which to search |
| 7863 | file_regex |
| 7864 | Regular expression to match searched files. |
| 7865 | Use parentheses () to mark the part of this |
| 7866 | expression that should be used to derive the |
| 7867 | module name (to be substituted where %s is |
| 7868 | used in other function arguments as noted below) |
| 7869 | output_pattern |
| 7870 | Pattern to use for the package names. Must |
| 7871 | include %s. |
| 7872 | description |
| 7873 | Description to set for each package. Must |
| 7874 | include %s. |
| 7875 | |
| 7876 | Optional arguments |
| 7877 | |
| 7878 | postinst |
| 7879 | Postinstall script to use for all packages |
| 7880 | (as a string) |
| 7881 | recursive |
| 7882 | True to perform a recursive search - default |
| 7883 | False |
| 7884 | hook |
| 7885 | A hook function to be called for every match. |
| 7886 | The function will be called with the following |
| 7887 | arguments (in the order listed): |
| 7888 | |
| 7889 | f |
| 7890 | Full path to the file/directory match |
| 7891 | pkg |
| 7892 | The package name |
| 7893 | file_regex |
| 7894 | As above |
| 7895 | output_pattern |
| 7896 | As above |
| 7897 | modulename |
| 7898 | The module name derived using file_regex |
| 7899 | |
| 7900 | extra_depends |
| 7901 | Extra runtime dependencies (RDEPENDS) to be |
| 7902 | set for all packages. The default value of None |
| 7903 | causes a dependency on the main package |
| 7904 | (${PN}) - if you do not want this, pass empty |
| 7905 | string '' for this parameter. |
| 7906 | aux_files_pattern |
| 7907 | Extra item(s) to be added to FILES for each |
| 7908 | package. Can be a single string item or a list |
| 7909 | of strings for multiple items. Must include %s. |
| 7910 | postrm |
| 7911 | postrm script to use for all packages (as a |
| 7912 | string) |
| 7913 | allow_dirs |
| 7914 | True to allow directories to be matched - |
| 7915 | default False |
| 7916 | prepend |
| 7917 | If True, prepend created packages to PACKAGES |
| 7918 | instead of the default False which appends them |
| 7919 | match_path |
| 7920 | match file_regex on the whole relative path to |
| 7921 | the root rather than just the file name |
| 7922 | aux_files_pattern_verbatim |
| 7923 | Extra item(s) to be added to FILES for each |
| 7924 | package, using the actual derived module name |
| 7925 | rather than converting it to something legal |
| 7926 | for a package name. Can be a single string item |
| 7927 | or a list of strings for multiple items. Must |
| 7928 | include %s. |
| 7929 | allow_links |
| 7930 | True to allow symlinks to be matched - default |
| 7931 | False |
| 7932 | summary |
| 7933 | Summary to set for each package. Must include %s; |
| 7934 | defaults to description if not set. |
| 7935 | </literallayout> |
| 7936 | </para> |
| 7937 | </section> |
| 7938 | |
| 7939 | <section id='satisfying-dependencies'> |
| 7940 | <title>Satisfying Dependencies</title> |
| 7941 | |
| 7942 | <para> |
| 7943 | The second part for handling optional module packaging |
| 7944 | is to ensure that any dependencies on optional modules |
| 7945 | from other recipes are satisfied by your recipe. |
| 7946 | You can be sure these dependencies are satisfied by |
| 7947 | using the |
| 7948 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES_DYNAMIC'><filename>PACKAGES_DYNAMIC</filename></ulink> variable. |
| 7949 | Here is an example that continues with the |
| 7950 | <filename>lighttpd</filename> recipe shown earlier: |
| 7951 | <literallayout class='monospaced'> |
| 7952 | PACKAGES_DYNAMIC = "lighttpd-module-.*" |
| 7953 | </literallayout> |
| 7954 | The name specified in the regular expression can of |
| 7955 | course be anything. |
| 7956 | In this example, it is <filename>lighttpd-module-</filename> |
| 7957 | and is specified as the prefix to ensure that any |
| 7958 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 7959 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> |
| 7960 | on a package name starting with the prefix are satisfied |
| 7961 | during build time. |
| 7962 | If you are using <filename>do_split_packages</filename> |
| 7963 | as described in the previous section, the value you put in |
| 7964 | <filename>PACKAGES_DYNAMIC</filename> should correspond to |
| 7965 | the name pattern specified in the call to |
| 7966 | <filename>do_split_packages</filename>. |
| 7967 | </para> |
| 7968 | </section> |
| 7969 | </section> |
| 7970 | |
| 7971 | <section id='using-runtime-package-management'> |
| 7972 | <title>Using Runtime Package Management</title> |
| 7973 | |
| 7974 | <para> |
| 7975 | During a build, BitBake always transforms a recipe into one or |
| 7976 | more packages. |
| 7977 | For example, BitBake takes the <filename>bash</filename> recipe |
| 7978 | and currently produces the <filename>bash-dbg</filename>, |
| 7979 | <filename>bash-staticdev</filename>, |
| 7980 | <filename>bash-dev</filename>, <filename>bash-doc</filename>, |
| 7981 | <filename>bash-locale</filename>, and |
| 7982 | <filename>bash</filename> packages. |
| 7983 | Not all generated packages are included in an image. |
| 7984 | </para> |
| 7985 | |
| 7986 | <para> |
| 7987 | In several situations, you might need to update, add, remove, |
| 7988 | or query the packages on a target device at runtime |
| 7989 | (i.e. without having to generate a new image). |
| 7990 | Examples of such situations include: |
| 7991 | <itemizedlist> |
| 7992 | <listitem><para> |
| 7993 | You want to provide in-the-field updates to deployed |
| 7994 | devices (e.g. security updates). |
| 7995 | </para></listitem> |
| 7996 | <listitem><para> |
| 7997 | You want to have a fast turn-around development cycle |
| 7998 | for one or more applications that run on your device. |
| 7999 | </para></listitem> |
| 8000 | <listitem><para> |
| 8001 | You want to temporarily install the "debug" packages |
| 8002 | of various applications on your device so that |
| 8003 | debugging can be greatly improved by allowing |
| 8004 | access to symbols and source debugging. |
| 8005 | </para></listitem> |
| 8006 | <listitem><para> |
| 8007 | You want to deploy a more minimal package selection of |
| 8008 | your device but allow in-the-field updates to add a |
| 8009 | larger selection for customization. |
| 8010 | </para></listitem> |
| 8011 | </itemizedlist> |
| 8012 | </para> |
| 8013 | |
| 8014 | <para> |
| 8015 | In all these situations, you have something similar to a more |
| 8016 | traditional Linux distribution in that in-field devices |
| 8017 | are able to receive pre-compiled packages from a server for |
| 8018 | installation or update. |
| 8019 | Being able to install these packages on a running, |
| 8020 | in-field device is what is termed "runtime package |
| 8021 | management". |
| 8022 | </para> |
| 8023 | |
| 8024 | <para> |
| 8025 | In order to use runtime package management, you |
| 8026 | need a host/server machine that serves up the pre-compiled |
| 8027 | packages plus the required metadata. |
| 8028 | You also need package manipulation tools on the target. |
| 8029 | The build machine is a likely candidate to act as the server. |
| 8030 | However, that machine does not necessarily have to be the |
| 8031 | package server. |
| 8032 | The build machine could push its artifacts to another machine |
| 8033 | that acts as the server (e.g. Internet-facing). |
| 8034 | </para> |
| 8035 | |
| 8036 | <para> |
| 8037 | A simple build that targets just one device produces |
| 8038 | more than one package database. |
| 8039 | In other words, the packages produced by a build are separated |
| 8040 | out into a couple of different package groupings based on |
| 8041 | criteria such as the target's CPU architecture, the target |
| 8042 | board, or the C library used on the target. |
| 8043 | For example, a build targeting the <filename>qemuarm</filename> |
| 8044 | device produces the following three package databases: |
| 8045 | <filename>all</filename>, <filename>armv5te</filename>, and |
| 8046 | <filename>qemuarm</filename>. |
| 8047 | If you wanted your <filename>qemuarm</filename> device to be |
| 8048 | aware of all the packages that were available to it, |
| 8049 | you would need to point it to each of these databases |
| 8050 | individually. |
| 8051 | In a similar way, a traditional Linux distribution usually is |
| 8052 | configured to be aware of a number of software repositories |
| 8053 | from which it retrieves packages. |
| 8054 | </para> |
| 8055 | |
| 8056 | <para> |
| 8057 | Using runtime package management is completely optional and |
| 8058 | not required for a successful build or deployment in any |
| 8059 | way. |
| 8060 | But if you want to make use of runtime package management, |
| 8061 | you need to do a couple things above and beyond the basics. |
| 8062 | The remainder of this section describes what you need to do. |
| 8063 | </para> |
| 8064 | |
| 8065 | <section id='runtime-package-management-build'> |
| 8066 | <title>Build Considerations</title> |
| 8067 | |
| 8068 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8069 | This section describes build considerations of which you |
| 8070 | need to be aware in order to provide support for runtime |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8071 | package management. |
| 8072 | </para> |
| 8073 | |
| 8074 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8075 | When BitBake generates packages, it needs to know |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8076 | what format or formats to use. |
| 8077 | In your configuration, you use the |
| 8078 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8079 | variable to specify the format: |
| 8080 | <orderedlist> |
| 8081 | <listitem><para> |
| 8082 | Open the <filename>local.conf</filename> file |
| 8083 | inside your |
| 8084 | <link linkend='build-directory'>Build Directory</link> |
| 8085 | (e.g. <filename>~/poky/build/conf/local.conf</filename>). |
| 8086 | </para></listitem> |
| 8087 | <listitem><para> |
| 8088 | Select the desired package format as follows: |
| 8089 | <literallayout class='monospaced'> |
| 8090 | PACKAGE_CLASSES ?= “package_<replaceable>packageformat</replaceable>” |
| 8091 | </literallayout> |
| 8092 | where <replaceable>packageformat</replaceable> |
| 8093 | can be "ipk", "rpm", and "deb", which are the |
| 8094 | supported package formats. |
| 8095 | <note> |
| 8096 | Because the Yocto Project supports three |
| 8097 | different package formats, you can set the |
| 8098 | variable with more than one argument. |
| 8099 | However, the OpenEmbedded build system only |
| 8100 | uses the first argument when creating an image |
| 8101 | or Software Development Kit (SDK). |
| 8102 | </note> |
| 8103 | </para></listitem> |
| 8104 | </orderedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8105 | </para> |
| 8106 | |
| 8107 | <para> |
| 8108 | If you would like your image to start off with a basic |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8109 | package database containing the packages in your current |
| 8110 | build as well as to have the relevant tools available on the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8111 | target for runtime package management, you can include |
| 8112 | "package-management" in the |
| 8113 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 8114 | variable. |
| 8115 | Including "package-management" in this |
| 8116 | configuration variable ensures that when the image |
| 8117 | is assembled for your target, the image includes |
| 8118 | the currently-known package databases as well as |
| 8119 | the target-specific tools required for runtime |
| 8120 | package management to be performed on the target. |
| 8121 | However, this is not strictly necessary. |
| 8122 | You could start your image off without any databases |
| 8123 | but only include the required on-target package |
| 8124 | tool(s). |
| 8125 | As an example, you could include "opkg" in your |
| 8126 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink> |
| 8127 | variable if you are using the IPK package format. |
| 8128 | You can then initialize your target's package database(s) |
| 8129 | later once your image is up and running. |
| 8130 | </para> |
| 8131 | |
| 8132 | <para> |
| 8133 | Whenever you perform any sort of build step that can |
| 8134 | potentially generate a package or modify an existing |
| 8135 | package, it is always a good idea to re-generate the |
| 8136 | package index with: |
| 8137 | <literallayout class='monospaced'> |
| 8138 | $ bitbake package-index |
| 8139 | </literallayout> |
| 8140 | Realize that it is not sufficient to simply do the |
| 8141 | following: |
| 8142 | <literallayout class='monospaced'> |
| 8143 | $ bitbake <replaceable>some-package</replaceable> package-index |
| 8144 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8145 | The reason for this restriction is because BitBake does not |
| 8146 | properly schedule the <filename>package-index</filename> |
| 8147 | target fully after any other target has completed. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8148 | Thus, be sure to run the package update step separately. |
| 8149 | </para> |
| 8150 | |
| 8151 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8152 | You can use the |
| 8153 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8154 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, |
| 8155 | and |
| 8156 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8157 | variables to pre-configure target images to use a package |
| 8158 | feed. |
| 8159 | If you do not define these variables, then manual steps |
| 8160 | as described in the subsequent sections are necessary to |
| 8161 | configure the target. |
| 8162 | You should set these variables before building the image |
| 8163 | in order to produce a correctly configured image. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8164 | </para> |
| 8165 | |
| 8166 | <para> |
| 8167 | When your build is complete, your packages reside in the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8168 | <filename>${TMPDIR}/deploy/<replaceable>packageformat</replaceable></filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8169 | directory. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8170 | For example, if |
| 8171 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink><filename>}</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8172 | is <filename>tmp</filename> and your selected package type |
| 8173 | is IPK, then your IPK packages are available in |
| 8174 | <filename>tmp/deploy/ipk</filename>. |
| 8175 | </para> |
| 8176 | </section> |
| 8177 | |
| 8178 | <section id='runtime-package-management-server'> |
| 8179 | <title>Host or Server Machine Setup</title> |
| 8180 | |
| 8181 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8182 | Although other protocols are possible, a server using HTTP |
| 8183 | typically serves packages. |
| 8184 | If you want to use HTTP, then set up and configure a |
| 8185 | web server such as Apache 2, lighttpd, or |
| 8186 | SimpleHTTPServer on the machine serving the packages. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8187 | </para> |
| 8188 | |
| 8189 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8190 | To keep things simple, this section describes how to set |
| 8191 | up a SimpleHTTPServer web server to share package feeds |
| 8192 | from the developer's machine. |
| 8193 | Although this server might not be the best for a production |
| 8194 | environment, the setup is simple and straight forward. |
| 8195 | Should you want to use a different server more suited for |
| 8196 | production (e.g. Apache 2, Lighttpd, or Nginx), take the |
| 8197 | appropriate steps to do so. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8198 | </para> |
| 8199 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8200 | <para> |
| 8201 | From within the build directory where you have built an |
| 8202 | image based on your packaging choice (i.e. the |
| 8203 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> |
| 8204 | setting), simply start the server. |
| 8205 | The following example assumes a build directory of |
| 8206 | <filename>~/poky/build/tmp/deploy/rpm</filename> and a |
| 8207 | <filename>PACKAGE_CLASSES</filename> setting of |
| 8208 | "package_rpm": |
| 8209 | <literallayout class='monospaced'> |
| 8210 | $ cd ~/poky/build/tmp/deploy/rpm |
| 8211 | $ python -m SimpleHTTPServer |
| 8212 | </literallayout> |
| 8213 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8214 | </section> |
| 8215 | |
| 8216 | <section id='runtime-package-management-target'> |
| 8217 | <title>Target Setup</title> |
| 8218 | |
| 8219 | <para> |
| 8220 | Setting up the target differs depending on the |
| 8221 | package management system. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8222 | This section provides information for RPM, IPK, and DEB. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8223 | </para> |
| 8224 | |
| 8225 | <section id='runtime-package-management-target-rpm'> |
| 8226 | <title>Using RPM</title> |
| 8227 | |
| 8228 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8229 | The <filename>smart</filename> application performs |
| 8230 | runtime package management of RPM packages. |
| 8231 | You must perform an initial setup for |
| 8232 | <filename>smart</filename> on the target machine |
| 8233 | if the |
| 8234 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8235 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8236 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8237 | variables have not been set or the target image was |
| 8238 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8239 | </para> |
| 8240 | |
| 8241 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8242 | As an example, assume the target is able to use the |
| 8243 | following package databases: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8244 | <filename>all</filename>, <filename>i586</filename>, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8245 | and <filename>qemux86</filename> from a server named |
| 8246 | <filename>my.server</filename>. |
| 8247 | You must inform <filename>smart</filename> of the |
| 8248 | availability of these databases by issuing the |
| 8249 | following commands on the target: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8250 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8251 | # smart channel --add i585 type=rpm-md baseurl=http://my.server/rpm/i586 |
| 8252 | # smart channel --add qemux86 type=rpm-md baseurl=http://my.server/rpm/qemux86 |
| 8253 | # smart channel --add all type=rpm-md baseurl=http://my.server/rpm/all |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8254 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8255 | From the target machine, fetch the repository: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8256 | <literallayout class='monospaced'> |
| 8257 | # smart update |
| 8258 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8259 | After everything is set up, <filename>smart</filename> |
| 8260 | is able to find, install, and upgrade packages from |
| 8261 | the specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8262 | </para> |
| 8263 | </section> |
| 8264 | |
| 8265 | <section id='runtime-package-management-target-ipk'> |
| 8266 | <title>Using IPK</title> |
| 8267 | |
| 8268 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8269 | The <filename>opkg</filename> application performs |
| 8270 | runtime package management of IPK packages. |
| 8271 | You must perform an initial setup for |
| 8272 | <filename>opkg</filename> on the target machine |
| 8273 | if the |
| 8274 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8275 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8276 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8277 | variables have not been set or the target image was |
| 8278 | built before the variables were set. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8279 | </para> |
| 8280 | |
| 8281 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8282 | The <filename>opkg</filename> application uses |
| 8283 | configuration files to find available package |
| 8284 | databases. |
| 8285 | Thus, you need to create a configuration file inside |
| 8286 | the <filename>/etc/opkg/</filename> direction, which |
| 8287 | informs <filename>opkg</filename> of any repository |
| 8288 | you want to use. |
| 8289 | </para> |
| 8290 | |
| 8291 | <para> |
| 8292 | As an example, suppose you are serving packages from a |
| 8293 | <filename>ipk/</filename> directory containing the |
| 8294 | <filename>i586</filename>, |
| 8295 | <filename>all</filename>, and |
| 8296 | <filename>qemux86</filename> databases through an |
| 8297 | HTTP server named <filename>my.server</filename>. |
| 8298 | On the target, create a configuration file |
| 8299 | (e.g. <filename>my_repo.conf</filename>) inside the |
| 8300 | <filename>/etc/opkg/</filename> directory containing |
| 8301 | the following: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8302 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8303 | src/gz all http://my.server/ipk/all |
| 8304 | src/gz i586 http://my.server/ipk/i586 |
| 8305 | src/gz qemux86 http://my.server/ipk/qemux86 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8306 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8307 | Next, instruct <filename>opkg</filename> to fetch |
| 8308 | the repository information: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8309 | <literallayout class='monospaced'> |
| 8310 | # opkg update |
| 8311 | </literallayout> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 8312 | The <filename>opkg</filename> application is now able |
| 8313 | to find, install, and upgrade packages from the |
| 8314 | specified repository. |
| 8315 | </para> |
| 8316 | </section> |
| 8317 | |
| 8318 | <section id='runtime-package-management-target-deb'> |
| 8319 | <title>Using DEB</title> |
| 8320 | |
| 8321 | <para> |
| 8322 | The <filename>apt</filename> application performs |
| 8323 | runtime package management of DEB packages. |
| 8324 | This application uses a source list file to find |
| 8325 | available package databases. |
| 8326 | You must perform an initial setup for |
| 8327 | <filename>apt</filename> on the target machine |
| 8328 | if the |
| 8329 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_ARCHS'><filename>PACKAGE_FEED_ARCHS</filename></ulink>, |
| 8330 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_BASE_PATHS'><filename>PACKAGE_FEED_BASE_PATHS</filename></ulink>, and |
| 8331 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_FEED_URIS'><filename>PACKAGE_FEED_URIS</filename></ulink> |
| 8332 | variables have not been set or the target image was |
| 8333 | built before the variables were set. |
| 8334 | </para> |
| 8335 | |
| 8336 | <para> |
| 8337 | To inform <filename>apt</filename> of the repository |
| 8338 | you want to use, you might create a list file (e.g. |
| 8339 | <filename>my_repo.list</filename>) inside the |
| 8340 | <filename>/etc/apt/sources.list.d/</filename> |
| 8341 | directory. |
| 8342 | As an example, suppose you are serving packages from a |
| 8343 | <filename>deb/</filename> directory containing the |
| 8344 | <filename>i586</filename>, |
| 8345 | <filename>all</filename>, and |
| 8346 | <filename>qemux86</filename> databases through an |
| 8347 | HTTP server named <filename>my.server</filename>. |
| 8348 | The list file should contain: |
| 8349 | <literallayout class='monospaced'> |
| 8350 | deb http://my.server/deb/all ./ |
| 8351 | deb http://my.server/deb/i586 ./ |
| 8352 | deb http://my.server/deb/qemux86 ./ |
| 8353 | </literallayout> |
| 8354 | Next, instruct the <filename>apt</filename> |
| 8355 | application to fetch the repository information: |
| 8356 | <literallayout class='monospaced'> |
| 8357 | # apt-get update |
| 8358 | </literallayout> |
| 8359 | After this step, <filename>apt</filename> is able |
| 8360 | to find, install, and upgrade packages from the |
| 8361 | specified repository. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8362 | </para> |
| 8363 | </section> |
| 8364 | </section> |
| 8365 | </section> |
| 8366 | |
| 8367 | <section id='testing-packages-with-ptest'> |
| 8368 | <title>Testing Packages With ptest</title> |
| 8369 | |
| 8370 | <para> |
| 8371 | A Package Test (ptest) runs tests against packages built |
| 8372 | by the OpenEmbedded build system on the target machine. |
| 8373 | A ptest contains at least two items: the actual test, and |
| 8374 | a shell script (<filename>run-ptest</filename>) that starts |
| 8375 | the test. |
| 8376 | The shell script that starts the test must not contain |
| 8377 | the actual test - the script only starts the test. |
| 8378 | On the other hand, the test can be anything from a simple |
| 8379 | shell script that runs a binary and checks the output to |
| 8380 | an elaborate system of test binaries and data files. |
| 8381 | </para> |
| 8382 | |
| 8383 | <para> |
| 8384 | The test generates output in the format used by |
| 8385 | Automake: |
| 8386 | <literallayout class='monospaced'> |
| 8387 | <replaceable>result</replaceable>: <replaceable>testname</replaceable> |
| 8388 | </literallayout> |
| 8389 | where the result can be <filename>PASS</filename>, |
| 8390 | <filename>FAIL</filename>, or <filename>SKIP</filename>, |
| 8391 | and the testname can be any identifying string. |
| 8392 | </para> |
| 8393 | |
| 8394 | <para> |
| 8395 | For a list of Yocto Project recipes that are already |
| 8396 | enabled with ptest, see the |
| 8397 | <ulink url='https://wiki.yoctoproject.org/wiki/Ptest'>Ptest</ulink> |
| 8398 | wiki page. |
| 8399 | <note> |
| 8400 | A recipe is "ptest-enabled" if it inherits the |
| 8401 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 8402 | class. |
| 8403 | </note> |
| 8404 | </para> |
| 8405 | |
| 8406 | <section id='adding-ptest-to-your-build'> |
| 8407 | <title>Adding ptest to Your Build</title> |
| 8408 | |
| 8409 | <para> |
| 8410 | To add package testing to your build, add the |
| 8411 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink> |
| 8412 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink> |
| 8413 | variables to your <filename>local.conf</filename> file, |
| 8414 | which is found in the |
| 8415 | <link linkend='build-directory'>Build Directory</link>: |
| 8416 | <literallayout class='monospaced'> |
| 8417 | DISTRO_FEATURES_append = " ptest" |
| 8418 | EXTRA_IMAGE_FEATURES += "ptest-pkgs" |
| 8419 | </literallayout> |
| 8420 | Once your build is complete, the ptest files are installed |
| 8421 | into the |
| 8422 | <filename>/usr/lib/<replaceable>package</replaceable>/ptest</filename> |
| 8423 | directory within the image, where |
| 8424 | <filename><replaceable>package</replaceable></filename> |
| 8425 | is the name of the package. |
| 8426 | </para> |
| 8427 | </section> |
| 8428 | |
| 8429 | <section id='running-ptest'> |
| 8430 | <title>Running ptest</title> |
| 8431 | |
| 8432 | <para> |
| 8433 | The <filename>ptest-runner</filename> package installs a |
| 8434 | shell script that loops through all installed ptest test |
| 8435 | suites and runs them in sequence. |
| 8436 | Consequently, you might want to add this package to |
| 8437 | your image. |
| 8438 | </para> |
| 8439 | </section> |
| 8440 | |
| 8441 | <section id='getting-your-package-ready'> |
| 8442 | <title>Getting Your Package Ready</title> |
| 8443 | |
| 8444 | <para> |
| 8445 | In order to enable a recipe to run installed ptests |
| 8446 | on target hardware, |
| 8447 | you need to prepare the recipes that build the packages |
| 8448 | you want to test. |
| 8449 | Here is what you have to do for each recipe: |
| 8450 | <itemizedlist> |
| 8451 | <listitem><para><emphasis>Be sure the recipe |
| 8452 | inherits the |
| 8453 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-ptest'><filename>ptest</filename></ulink> |
| 8454 | class:</emphasis> |
| 8455 | Include the following line in each recipe: |
| 8456 | <literallayout class='monospaced'> |
| 8457 | inherit ptest |
| 8458 | </literallayout> |
| 8459 | </para></listitem> |
| 8460 | <listitem><para><emphasis>Create <filename>run-ptest</filename>:</emphasis> |
| 8461 | This script starts your test. |
| 8462 | Locate the script where you will refer to it |
| 8463 | using |
| 8464 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 8465 | Here is an example that starts a test for |
| 8466 | <filename>dbus</filename>: |
| 8467 | <literallayout class='monospaced'> |
| 8468 | #!/bin/sh |
| 8469 | cd test |
| 8470 | make -k runtest-TESTS |
| 8471 | </literallayout> |
| 8472 | </para></listitem> |
| 8473 | <listitem><para><emphasis>Ensure dependencies are |
| 8474 | met:</emphasis> |
| 8475 | If the test adds build or runtime dependencies |
| 8476 | that normally do not exist for the package |
| 8477 | (such as requiring "make" to run the test suite), |
| 8478 | use the |
| 8479 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 8480 | and |
| 8481 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 8482 | variables in your recipe in order for the package |
| 8483 | to meet the dependencies. |
| 8484 | Here is an example where the package has a runtime |
| 8485 | dependency on "make": |
| 8486 | <literallayout class='monospaced'> |
| 8487 | RDEPENDS_${PN}-ptest += "make" |
| 8488 | </literallayout> |
| 8489 | </para></listitem> |
| 8490 | <listitem><para><emphasis>Add a function to build the |
| 8491 | test suite:</emphasis> |
| 8492 | Not many packages support cross-compilation of |
| 8493 | their test suites. |
| 8494 | Consequently, you usually need to add a |
| 8495 | cross-compilation function to the package. |
| 8496 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8497 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8498 | <para>Many packages based on Automake compile and |
| 8499 | run the test suite by using a single command |
| 8500 | such as <filename>make check</filename>. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8501 | However, the host <filename>make check</filename> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8502 | builds and runs on the same computer, while |
| 8503 | cross-compiling requires that the package is built |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8504 | on the host but executed for the target |
| 8505 | architecture (though often, as in the case for |
| 8506 | ptest, the execution occurs on the host). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8507 | The built version of Automake that ships with the |
| 8508 | Yocto Project includes a patch that separates |
| 8509 | building and execution. |
| 8510 | Consequently, packages that use the unaltered, |
| 8511 | patched version of <filename>make check</filename> |
| 8512 | automatically cross-compiles.</para> |
| 8513 | <para>Regardless, you still must add a |
| 8514 | <filename>do_compile_ptest</filename> function to |
| 8515 | build the test suite. |
| 8516 | Add a function similar to the following to your |
| 8517 | recipe: |
| 8518 | <literallayout class='monospaced'> |
| 8519 | do_compile_ptest() { |
| 8520 | oe_runmake buildtest-TESTS |
| 8521 | } |
| 8522 | </literallayout> |
| 8523 | </para></listitem> |
| 8524 | <listitem><para><emphasis>Ensure special configurations |
| 8525 | are set:</emphasis> |
| 8526 | If the package requires special configurations |
| 8527 | prior to compiling the test code, you must |
| 8528 | insert a <filename>do_configure_ptest</filename> |
| 8529 | function into the recipe. |
| 8530 | </para></listitem> |
| 8531 | <listitem><para><emphasis>Install the test |
| 8532 | suite:</emphasis> |
| 8533 | The <filename>ptest</filename> class |
| 8534 | automatically copies the file |
| 8535 | <filename>run-ptest</filename> to the target and |
| 8536 | then runs make <filename>install-ptest</filename> |
| 8537 | to run the tests. |
| 8538 | If this is not enough, you need to create a |
| 8539 | <filename>do_install_ptest</filename> function and |
| 8540 | make sure it gets called after the |
| 8541 | "make install-ptest" completes. |
| 8542 | </para></listitem> |
| 8543 | </itemizedlist> |
| 8544 | </para> |
| 8545 | </section> |
| 8546 | </section> |
| 8547 | </section> |
| 8548 | |
| 8549 | <section id='working-with-source-files'> |
| 8550 | <title>Working with Source Files</title> |
| 8551 | |
| 8552 | <para> |
| 8553 | The OpenEmbedded build system works with source files located |
| 8554 | through the |
| 8555 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 8556 | variable. |
| 8557 | When you build something using BitBake, a big part of the operation |
| 8558 | is locating and downloading all the source tarballs. |
| 8559 | For images, downloading all the source for various packages can |
| 8560 | take a significant amount of time. |
| 8561 | </para> |
| 8562 | |
| 8563 | <para> |
| 8564 | This section presents information for working with source |
| 8565 | files that can lead to more efficient use of resources and |
| 8566 | time. |
| 8567 | </para> |
| 8568 | |
| 8569 | <section id='setting-up-effective-mirrors'> |
| 8570 | <title>Setting up Effective Mirrors</title> |
| 8571 | |
| 8572 | <para> |
| 8573 | As mentioned, a good deal that goes into a Yocto Project |
| 8574 | build is simply downloading all of the source tarballs. |
| 8575 | Maybe you have been working with another build system |
| 8576 | (OpenEmbedded or Angstrom) for which you have built up a |
| 8577 | sizable directory of source tarballs. |
| 8578 | Or, perhaps someone else has such a directory for which you |
| 8579 | have read access. |
| 8580 | If so, you can save time by adding statements to your |
| 8581 | configuration file so that the build process checks local |
| 8582 | directories first for existing tarballs before checking the |
| 8583 | Internet. |
| 8584 | </para> |
| 8585 | |
| 8586 | <para> |
| 8587 | Here is an efficient way to set it up in your |
| 8588 | <filename>local.conf</filename> file: |
| 8589 | <literallayout class='monospaced'> |
| 8590 | SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/" |
| 8591 | INHERIT += "own-mirrors" |
| 8592 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 8593 | # BB_NO_NETWORK = "1" |
| 8594 | </literallayout> |
| 8595 | </para> |
| 8596 | |
| 8597 | <para> |
| 8598 | In the previous example, the |
| 8599 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> |
| 8600 | variable causes the OpenEmbedded build system to generate |
| 8601 | tarballs of the Git repositories and store them in the |
| 8602 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 8603 | directory. |
| 8604 | Due to performance reasons, generating and storing these |
| 8605 | tarballs is not the build system's default behavior. |
| 8606 | </para> |
| 8607 | |
| 8608 | <para> |
| 8609 | You can also use the |
| 8610 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink> |
| 8611 | variable. |
| 8612 | For an example, see the variable's glossary entry in the |
| 8613 | Yocto Project Reference Manual. |
| 8614 | </para> |
| 8615 | </section> |
| 8616 | |
| 8617 | <section id='getting-source-files-and-suppressing-the-build'> |
| 8618 | <title>Getting Source Files and Suppressing the Build</title> |
| 8619 | |
| 8620 | <para> |
| 8621 | Another technique you can use to ready yourself for a |
| 8622 | successive string of build operations, is to pre-fetch |
| 8623 | all the source files without actually starting a build. |
| 8624 | This technique lets you work through any download issues |
| 8625 | and ultimately gathers all the source files into your |
| 8626 | download directory |
| 8627 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-build-downloads'><filename>build/downloads</filename></ulink>, |
| 8628 | which is located with |
| 8629 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink>. |
| 8630 | </para> |
| 8631 | |
| 8632 | <para> |
| 8633 | Use the following BitBake command form to fetch all the |
| 8634 | necessary sources without starting the build: |
| 8635 | <literallayout class='monospaced'> |
| 8636 | $ bitbake -c fetchall <replaceable>target</replaceable> |
| 8637 | </literallayout> |
| 8638 | This variation of the BitBake command guarantees that you |
| 8639 | have all the sources for that BitBake target should you |
| 8640 | disconnect from the Internet and want to do the build |
| 8641 | later offline. |
| 8642 | </para> |
| 8643 | </section> |
| 8644 | </section> |
| 8645 | |
| 8646 | <section id="building-software-from-an-external-source"> |
| 8647 | <title>Building Software from an External Source</title> |
| 8648 | |
| 8649 | <para> |
| 8650 | By default, the OpenEmbedded build system uses the |
| 8651 | <link linkend='build-directory'>Build Directory</link> when |
| 8652 | building source code. |
| 8653 | The build process involves fetching the source files, unpacking |
| 8654 | them, and then patching them if necessary before the build takes |
| 8655 | place. |
| 8656 | </para> |
| 8657 | |
| 8658 | <para> |
| 8659 | Situations exist where you might want to build software from source |
| 8660 | files that are external to and thus outside of the |
| 8661 | OpenEmbedded build system. |
| 8662 | For example, suppose you have a project that includes a new BSP with |
| 8663 | a heavily customized kernel. |
| 8664 | And, you want to minimize exposing the build system to the |
| 8665 | development team so that they can focus on their project and |
| 8666 | maintain everyone's workflow as much as possible. |
| 8667 | In this case, you want a kernel source directory on the development |
| 8668 | machine where the development occurs. |
| 8669 | You want the recipe's |
| 8670 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 8671 | variable to point to the external directory and use it as is, not |
| 8672 | copy it. |
| 8673 | </para> |
| 8674 | |
| 8675 | <para> |
| 8676 | To build from software that comes from an external source, all you |
| 8677 | need to do is inherit the |
| 8678 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 8679 | class and then set the |
| 8680 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink> |
| 8681 | variable to point to your external source code. |
| 8682 | Here are the statements to put in your |
| 8683 | <filename>local.conf</filename> file: |
| 8684 | <literallayout class='monospaced'> |
| 8685 | INHERIT += "externalsrc" |
| 8686 | EXTERNALSRC_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 8687 | </literallayout> |
| 8688 | </para> |
| 8689 | |
| 8690 | <para> |
| 8691 | This next example shows how to accomplish the same thing by setting |
| 8692 | <filename>EXTERNALSRC</filename> in the recipe itself or in the |
| 8693 | recipe's append file: |
| 8694 | <literallayout class='monospaced'> |
| 8695 | EXTERNALSRC = "<replaceable>path</replaceable>" |
| 8696 | EXTERNALSRC_BUILD = "<replaceable>path</replaceable>" |
| 8697 | </literallayout> |
| 8698 | <note> |
| 8699 | In order for these settings to take effect, you must globally |
| 8700 | or locally inherit the |
| 8701 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> |
| 8702 | class. |
| 8703 | </note> |
| 8704 | </para> |
| 8705 | |
| 8706 | <para> |
| 8707 | By default, <filename>externalsrc.bbclass</filename> builds |
| 8708 | the source code in a directory separate from the external source |
| 8709 | directory as specified by |
| 8710 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC'><filename>EXTERNALSRC</filename></ulink>. |
| 8711 | If you need to have the source built in the same directory in |
| 8712 | which it resides, or some other nominated directory, you can set |
| 8713 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNALSRC_BUILD'><filename>EXTERNALSRC_BUILD</filename></ulink> |
| 8714 | to point to that directory: |
| 8715 | <literallayout class='monospaced'> |
| 8716 | EXTERNALSRC_BUILD_pn-<replaceable>myrecipe</replaceable> = "<replaceable>path-to-your-source-tree</replaceable>" |
| 8717 | </literallayout> |
| 8718 | </para> |
| 8719 | </section> |
| 8720 | |
| 8721 | <section id="selecting-an-initialization-manager"> |
| 8722 | <title>Selecting an Initialization Manager</title> |
| 8723 | |
| 8724 | <para> |
| 8725 | By default, the Yocto Project uses SysVinit as the initialization |
| 8726 | manager. |
| 8727 | However, support also exists for systemd, |
| 8728 | which is a full replacement for init with |
| 8729 | parallel starting of services, reduced shell overhead and other |
| 8730 | features that are used by many distributions. |
| 8731 | </para> |
| 8732 | |
| 8733 | <para> |
| 8734 | If you want to use SysVinit, you do |
| 8735 | not have to do anything. |
| 8736 | But, if you want to use systemd, you must |
| 8737 | take some steps as described in the following sections. |
| 8738 | </para> |
| 8739 | |
| 8740 | <section id='using-systemd-exclusively'> |
| 8741 | <title>Using systemd Exclusively</title> |
| 8742 | |
| 8743 | <para> |
| 8744 | Set the these variables in your distribution configuration |
| 8745 | file as follows: |
| 8746 | <literallayout class='monospaced'> |
| 8747 | DISTRO_FEATURES_append = " systemd" |
| 8748 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 8749 | </literallayout> |
| 8750 | You can also prevent the SysVinit |
| 8751 | distribution feature from |
| 8752 | being automatically enabled as follows: |
| 8753 | <literallayout class='monospaced'> |
| 8754 | DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit" |
| 8755 | </literallayout> |
| 8756 | Doing so removes any redundant SysVinit scripts. |
| 8757 | </para> |
| 8758 | |
| 8759 | <para> |
| 8760 | To remove initscripts from your image altogether, |
| 8761 | set this variable also: |
| 8762 | <literallayout class='monospaced'> |
| 8763 | VIRTUAL-RUNTIME_initscripts = "" |
| 8764 | </literallayout> |
| 8765 | </para> |
| 8766 | |
| 8767 | <para> |
| 8768 | For information on the backfill variable, see |
| 8769 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES_BACKFILL_CONSIDERED'><filename>DISTRO_FEATURES_BACKFILL_CONSIDERED</filename></ulink>. |
| 8770 | </para> |
| 8771 | </section> |
| 8772 | |
| 8773 | <section id='using-systemd-for-the-main-image-and-using-sysvinit-for-the-rescue-image'> |
| 8774 | <title>Using systemd for the Main Image and Using SysVinit for the Rescue Image</title> |
| 8775 | |
| 8776 | <para> |
| 8777 | Set these variables in your distribution configuration |
| 8778 | file as follows: |
| 8779 | <literallayout class='monospaced'> |
| 8780 | DISTRO_FEATURES_append = " systemd" |
| 8781 | VIRTUAL-RUNTIME_init_manager = "systemd" |
| 8782 | </literallayout> |
| 8783 | Doing so causes your main image to use the |
| 8784 | <filename>packagegroup-core-boot.bb</filename> recipe and |
| 8785 | systemd. |
| 8786 | The rescue/minimal image cannot use this package group. |
| 8787 | However, it can install SysVinit |
| 8788 | and the appropriate packages will have support for both |
| 8789 | systemd and SysVinit. |
| 8790 | </para> |
| 8791 | </section> |
| 8792 | </section> |
| 8793 | |
| 8794 | <section id="selecting-dev-manager"> |
| 8795 | <title>Selecting a Device Manager</title> |
| 8796 | |
| 8797 | <para> |
| 8798 | The Yocto Project provides multiple ways to manage the device |
| 8799 | manager (<filename>/dev</filename>): |
| 8800 | <itemizedlist> |
| 8801 | <listitem><para><emphasis>Persistent and Pre-Populated<filename>/dev</filename>:</emphasis> |
| 8802 | For this case, the <filename>/dev</filename> directory |
| 8803 | is persistent and the required device nodes are created |
| 8804 | during the build. |
| 8805 | </para></listitem> |
| 8806 | <listitem><para><emphasis>Use <filename>devtmpfs</filename> with a Device Manager:</emphasis> |
| 8807 | For this case, the <filename>/dev</filename> directory |
| 8808 | is provided by the kernel as an in-memory file system and |
| 8809 | is automatically populated by the kernel at runtime. |
| 8810 | Additional configuration of device nodes is done in user |
| 8811 | space by a device manager like |
| 8812 | <filename>udev</filename> or |
| 8813 | <filename>busybox-mdev</filename>. |
| 8814 | </para></listitem> |
| 8815 | </itemizedlist> |
| 8816 | </para> |
| 8817 | |
| 8818 | <section id="static-dev-management"> |
| 8819 | <title>Using Persistent and Pre-Populated<filename>/dev</filename></title> |
| 8820 | |
| 8821 | <para> |
| 8822 | To use the static method for device population, you need to |
| 8823 | set the |
| 8824 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 8825 | variable to "0" as follows: |
| 8826 | <literallayout class='monospaced'> |
| 8827 | USE_DEVFS = "0" |
| 8828 | </literallayout> |
| 8829 | </para> |
| 8830 | |
| 8831 | <para> |
| 8832 | The content of the resulting <filename>/dev</filename> |
| 8833 | directory is defined in a Device Table file. |
| 8834 | The |
| 8835 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_DEVICE_TABLES'><filename>IMAGE_DEVICE_TABLES</filename></ulink> |
| 8836 | variable defines the Device Table to use and should be set |
| 8837 | in the machine or distro configuration file. |
| 8838 | Alternatively, you can set this variable in your |
| 8839 | <filename>local.conf</filename> configuration file. |
| 8840 | </para> |
| 8841 | |
| 8842 | <para> |
| 8843 | If you do not define the |
| 8844 | <filename>IMAGE_DEVICE_TABLES</filename> variable, the default |
| 8845 | <filename>device_table-minimal.txt</filename> is used: |
| 8846 | <literallayout class='monospaced'> |
| 8847 | IMAGE_DEVICE_TABLES = "device_table-mymachine.txt" |
| 8848 | </literallayout> |
| 8849 | </para> |
| 8850 | |
| 8851 | <para> |
| 8852 | The population is handled by the <filename>makedevs</filename> |
| 8853 | utility during image creation: |
| 8854 | </para> |
| 8855 | </section> |
| 8856 | |
| 8857 | <section id="devtmpfs-dev-management"> |
| 8858 | <title>Using <filename>devtmpfs</filename> and a Device Manager</title> |
| 8859 | |
| 8860 | <para> |
| 8861 | To use the dynamic method for device population, you need to |
| 8862 | use (or be sure to set) the |
| 8863 | <ulink url='&YOCTO_DOCS_REF_URL;#var-USE_DEVFS'><filename>USE_DEVFS</filename></ulink> |
| 8864 | variable to "1", which is the default: |
| 8865 | <literallayout class='monospaced'> |
| 8866 | USE_DEVFS = "1" |
| 8867 | </literallayout> |
| 8868 | With this setting, the resulting <filename>/dev</filename> |
| 8869 | directory is populated by the kernel using |
| 8870 | <filename>devtmpfs</filename>. |
| 8871 | Make sure the corresponding kernel configuration variable |
| 8872 | <filename>CONFIG_DEVTMPFS</filename> is set when building |
| 8873 | you build a Linux kernel. |
| 8874 | </para> |
| 8875 | |
| 8876 | <para> |
| 8877 | All devices created by <filename>devtmpfs</filename> will be |
| 8878 | owned by <filename>root</filename> and have permissions |
| 8879 | <filename>0600</filename>. |
| 8880 | </para> |
| 8881 | |
| 8882 | <para> |
| 8883 | To have more control over the device nodes, you can use a |
| 8884 | device manager like <filename>udev</filename> or |
| 8885 | <filename>busybox-mdev</filename>. |
| 8886 | You choose the device manager by defining the |
| 8887 | <filename>VIRTUAL-RUNTIME_dev_manager</filename> variable |
| 8888 | in your machine or distro configuration file. |
| 8889 | Alternatively, you can set this variable in your |
| 8890 | <filename>local.conf</filename> configuration file: |
| 8891 | <literallayout class='monospaced'> |
| 8892 | VIRTUAL-RUNTIME_dev_manager = "udev" |
| 8893 | |
| 8894 | # Some alternative values |
| 8895 | # VIRTUAL-RUNTIME_dev_manager = "busybox-mdev" |
| 8896 | # VIRTUAL-RUNTIME_dev_manager = "systemd" |
| 8897 | </literallayout> |
| 8898 | </para> |
| 8899 | </section> |
| 8900 | </section> |
| 8901 | |
| 8902 | <section id="platdev-appdev-srcrev"> |
| 8903 | <title>Using an External SCM</title> |
| 8904 | |
| 8905 | <para> |
| 8906 | If you're working on a recipe that pulls from an external Source |
| 8907 | Code Manager (SCM), it is possible to have the OpenEmbedded build |
| 8908 | system notice new recipe changes added to the SCM and then build |
| 8909 | the resulting packages that depend on the new recipes by using |
| 8910 | the latest versions. |
| 8911 | This only works for SCMs from which it is possible to get a |
| 8912 | sensible revision number for changes. |
| 8913 | Currently, you can do this with Apache Subversion (SVN), Git, and |
| 8914 | Bazaar (BZR) repositories. |
| 8915 | </para> |
| 8916 | |
| 8917 | <para> |
| 8918 | To enable this behavior, the |
| 8919 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 8920 | of the recipe needs to reference |
| 8921 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>. |
| 8922 | Here is an example: |
| 8923 | <literallayout class='monospaced'> |
| 8924 | PV = "1.2.3+git${SRCPV}" |
| 8925 | </literallayout> |
| 8926 | Then, you can add the following to your |
| 8927 | <filename>local.conf</filename>: |
| 8928 | <literallayout class='monospaced'> |
| 8929 | SRCREV_pn-<replaceable>PN</replaceable> = "${AUTOREV}" |
| 8930 | </literallayout> |
| 8931 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> |
| 8932 | is the name of the recipe for which you want to enable automatic source |
| 8933 | revision updating. |
| 8934 | </para> |
| 8935 | |
| 8936 | <para> |
| 8937 | If you do not want to update your local configuration file, you can |
| 8938 | add the following directly to the recipe to finish enabling |
| 8939 | the feature: |
| 8940 | <literallayout class='monospaced'> |
| 8941 | SRCREV = "${AUTOREV}" |
| 8942 | </literallayout> |
| 8943 | </para> |
| 8944 | |
| 8945 | <para> |
| 8946 | The Yocto Project provides a distribution named |
| 8947 | <filename>poky-bleeding</filename>, whose configuration |
| 8948 | file contains the line: |
| 8949 | <literallayout class='monospaced'> |
| 8950 | require conf/distro/include/poky-floating-revisions.inc |
| 8951 | </literallayout> |
| 8952 | This line pulls in the listed include file that contains |
| 8953 | numerous lines of exactly that form: |
| 8954 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8955 | #SRCREV_pn-opkg-native ?= "${AUTOREV}" |
| 8956 | #SRCREV_pn-opkg-sdk ?= "${AUTOREV}" |
| 8957 | #SRCREV_pn-opkg ?= "${AUTOREV}" |
| 8958 | #SRCREV_pn-opkg-utils-native ?= "${AUTOREV}" |
| 8959 | #SRCREV_pn-opkg-utils ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8960 | SRCREV_pn-gconf-dbus ?= "${AUTOREV}" |
| 8961 | SRCREV_pn-matchbox-common ?= "${AUTOREV}" |
| 8962 | SRCREV_pn-matchbox-config-gtk ?= "${AUTOREV}" |
| 8963 | SRCREV_pn-matchbox-desktop ?= "${AUTOREV}" |
| 8964 | SRCREV_pn-matchbox-keyboard ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8965 | SRCREV_pn-matchbox-panel-2 ?= "${AUTOREV}" |
| 8966 | SRCREV_pn-matchbox-themes-extra ?= "${AUTOREV}" |
| 8967 | SRCREV_pn-matchbox-terminal ?= "${AUTOREV}" |
| 8968 | SRCREV_pn-matchbox-wm ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8969 | SRCREV_pn-settings-daemon ?= "${AUTOREV}" |
| 8970 | SRCREV_pn-screenshot ?= "${AUTOREV}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8971 | . |
| 8972 | . |
| 8973 | . |
| 8974 | </literallayout> |
| 8975 | These lines allow you to experiment with building a |
| 8976 | distribution that tracks the latest development source |
| 8977 | for numerous packages. |
| 8978 | <note><title>Caution</title> |
| 8979 | The <filename>poky-bleeding</filename> distribution |
| 8980 | is not tested on a regular basis. |
| 8981 | Keep this in mind if you use it. |
| 8982 | </note> |
| 8983 | </para> |
| 8984 | </section> |
| 8985 | |
| 8986 | <section id='creating-a-read-only-root-filesystem'> |
| 8987 | <title>Creating a Read-Only Root Filesystem</title> |
| 8988 | |
| 8989 | <para> |
| 8990 | Suppose, for security reasons, you need to disable |
| 8991 | your target device's root filesystem's write permissions |
| 8992 | (i.e. you need a read-only root filesystem). |
| 8993 | Or, perhaps you are running the device's operating system |
| 8994 | from a read-only storage device. |
| 8995 | For either case, you can customize your image for |
| 8996 | that behavior. |
| 8997 | </para> |
| 8998 | |
| 8999 | <note> |
| 9000 | Supporting a read-only root filesystem requires that the system and |
| 9001 | applications do not try to write to the root filesystem. |
| 9002 | You must configure all parts of the target system to write |
| 9003 | elsewhere, or to gracefully fail in the event of attempting to |
| 9004 | write to the root filesystem. |
| 9005 | </note> |
| 9006 | |
| 9007 | <section id='creating-the-root-filesystem'> |
| 9008 | <title>Creating the Root Filesystem</title> |
| 9009 | |
| 9010 | <para> |
| 9011 | To create the read-only root filesystem, simply add the |
| 9012 | "read-only-rootfs" feature to your image. |
| 9013 | Using either of the following statements in your |
| 9014 | image recipe or from within the |
| 9015 | <filename>local.conf</filename> file found in the |
| 9016 | <link linkend='build-directory'>Build Directory</link> |
| 9017 | causes the build system to create a read-only root filesystem: |
| 9018 | <literallayout class='monospaced'> |
| 9019 | IMAGE_FEATURES = "read-only-rootfs" |
| 9020 | </literallayout> |
| 9021 | or |
| 9022 | <literallayout class='monospaced'> |
| 9023 | EXTRA_IMAGE_FEATURES += "read-only-rootfs" |
| 9024 | </literallayout> |
| 9025 | </para> |
| 9026 | |
| 9027 | <para> |
| 9028 | For more information on how to use these variables, see the |
| 9029 | "<link linkend='usingpoky-extend-customimage-imagefeatures'>Customizing Images Using Custom <filename>IMAGE_FEATURES</filename> and <filename>EXTRA_IMAGE_FEATURES</filename></link>" |
| 9030 | section. |
| 9031 | For information on the variables, see |
| 9032 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 9033 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>. |
| 9034 | </para> |
| 9035 | </section> |
| 9036 | |
| 9037 | <section id='post-installation-scripts'> |
| 9038 | <title>Post-Installation Scripts</title> |
| 9039 | |
| 9040 | <para> |
| 9041 | It is very important that you make sure all |
| 9042 | post-Installation (<filename>pkg_postinst</filename>) scripts |
| 9043 | for packages that are installed into the image can be run |
| 9044 | at the time when the root filesystem is created during the |
| 9045 | build on the host system. |
| 9046 | These scripts cannot attempt to run during first-boot on the |
| 9047 | target device. |
| 9048 | With the "read-only-rootfs" feature enabled, |
| 9049 | the build system checks during root filesystem creation to make |
| 9050 | sure all post-installation scripts succeed. |
| 9051 | If any of these scripts still need to be run after the root |
| 9052 | filesystem is created, the build immediately fails. |
| 9053 | These build-time checks ensure that the build fails |
| 9054 | rather than the target device fails later during its |
| 9055 | initial boot operation. |
| 9056 | </para> |
| 9057 | |
| 9058 | <para> |
| 9059 | Most of the common post-installation scripts generated by the |
| 9060 | build system for the out-of-the-box Yocto Project are engineered |
| 9061 | so that they can run during root filesystem creation |
| 9062 | (e.g. post-installation scripts for caching fonts). |
| 9063 | However, if you create and add custom scripts, you need |
| 9064 | to be sure they can be run during this file system creation. |
| 9065 | </para> |
| 9066 | |
| 9067 | <para> |
| 9068 | Here are some common problems that prevent |
| 9069 | post-installation scripts from running during root filesystem |
| 9070 | creation: |
| 9071 | <itemizedlist> |
| 9072 | <listitem><para> |
| 9073 | <emphasis>Not using $D in front of absolute |
| 9074 | paths:</emphasis> |
| 9075 | The build system defines |
| 9076 | <filename>$</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> |
| 9077 | when the root filesystem is created. |
| 9078 | Furthermore, <filename>$D</filename> is blank when the |
| 9079 | script is run on the target device. |
| 9080 | This implies two purposes for <filename>$D</filename>: |
| 9081 | ensuring paths are valid in both the host and target |
| 9082 | environments, and checking to determine which |
| 9083 | environment is being used as a method for taking |
| 9084 | appropriate actions. |
| 9085 | </para></listitem> |
| 9086 | <listitem><para> |
| 9087 | <emphasis>Attempting to run processes that are |
| 9088 | specific to or dependent on the target |
| 9089 | architecture:</emphasis> |
| 9090 | You can work around these attempts by using native |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 9091 | tools, which run on the host system, |
| 9092 | to accomplish the same tasks, or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9093 | by alternatively running the processes under QEMU, |
| 9094 | which has the <filename>qemu_run_binary</filename> |
| 9095 | function. |
| 9096 | For more information, see the |
| 9097 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-qemu'><filename>qemu</filename></ulink> |
| 9098 | class.</para></listitem> |
| 9099 | </itemizedlist> |
| 9100 | </para> |
| 9101 | </section> |
| 9102 | |
| 9103 | <section id='areas-with-write-access'> |
| 9104 | <title>Areas With Write Access</title> |
| 9105 | |
| 9106 | <para> |
| 9107 | With the "read-only-rootfs" feature enabled, |
| 9108 | any attempt by the target to write to the root filesystem at |
| 9109 | runtime fails. |
| 9110 | Consequently, you must make sure that you configure processes |
| 9111 | and applications that attempt these types of writes do so |
| 9112 | to directories with write access (e.g. |
| 9113 | <filename>/tmp</filename> or <filename>/var/run</filename>). |
| 9114 | </para> |
| 9115 | </section> |
| 9116 | </section> |
| 9117 | |
| 9118 | <section id="performing-automated-runtime-testing"> |
| 9119 | <title>Performing Automated Runtime Testing</title> |
| 9120 | |
| 9121 | <para> |
| 9122 | The OpenEmbedded build system makes available a series of automated |
| 9123 | tests for images to verify runtime functionality. |
| 9124 | You can run these tests on either QEMU or actual target hardware. |
| 9125 | Tests are written in Python making use of the |
| 9126 | <filename>unittest</filename> module, and the majority of them |
| 9127 | run commands on the target system over SSH. |
| 9128 | This section describes how you set up the environment to use these |
| 9129 | tests, run available tests, and write and add your own tests. |
| 9130 | </para> |
| 9131 | |
| 9132 | <section id='enabling-tests'> |
| 9133 | <title>Enabling Tests</title> |
| 9134 | |
| 9135 | <para> |
| 9136 | Depending on whether you are planning to run tests using |
| 9137 | QEMU or on the hardware, you have to take |
| 9138 | different steps to enable the tests. |
| 9139 | See the following subsections for information on how to |
| 9140 | enable both types of tests. |
| 9141 | </para> |
| 9142 | |
| 9143 | <section id='qemu-image-enabling-tests'> |
| 9144 | <title>Enabling Runtime Tests on QEMU</title> |
| 9145 | |
| 9146 | <para> |
| 9147 | In order to run tests, you need to do the following: |
| 9148 | <itemizedlist> |
| 9149 | <listitem><para><emphasis>Set up to avoid interaction |
| 9150 | with <filename>sudo</filename> for networking:</emphasis> |
| 9151 | To accomplish this, you must do one of the |
| 9152 | following: |
| 9153 | <itemizedlist> |
| 9154 | <listitem><para>Add |
| 9155 | <filename>NOPASSWD</filename> for your user |
| 9156 | in <filename>/etc/sudoers</filename> either for |
| 9157 | all commands or just for |
| 9158 | <filename>runqemu-ifup</filename>. |
| 9159 | You must provide the full path as that can |
| 9160 | change if you are using multiple clones of the |
| 9161 | source repository. |
| 9162 | <note> |
| 9163 | On some distributions, you also need to |
| 9164 | comment out "Defaults requiretty" in |
| 9165 | <filename>/etc/sudoers</filename>. |
| 9166 | </note></para></listitem> |
| 9167 | <listitem><para>Manually configure a tap interface |
| 9168 | for your system.</para></listitem> |
| 9169 | <listitem><para>Run as root the script in |
| 9170 | <filename>scripts/runqemu-gen-tapdevs</filename>, |
| 9171 | which should generate a list of tap devices. |
| 9172 | This is the option typically chosen for |
| 9173 | Autobuilder-type environments. |
| 9174 | </para></listitem> |
| 9175 | </itemizedlist></para></listitem> |
| 9176 | <listitem><para><emphasis>Set the |
| 9177 | <filename>DISPLAY</filename> variable:</emphasis> |
| 9178 | You need to set this variable so that you have an X |
| 9179 | server available (e.g. start |
| 9180 | <filename>vncserver</filename> for a headless machine). |
| 9181 | </para></listitem> |
| 9182 | <listitem><para><emphasis>Be sure your host's firewall |
| 9183 | accepts incoming connections from |
| 9184 | 192.168.7.0/24:</emphasis> |
| 9185 | Some of the tests (in particular smart tests) start an |
| 9186 | HTTP server on a random high number port, which is |
| 9187 | used to serve files to the target. |
| 9188 | The smart module serves |
| 9189 | <filename>${DEPLOY_DIR}/rpm</filename> so it can run |
| 9190 | smart channel commands. That means your host's firewall |
| 9191 | must accept incoming connections from 192.168.7.0/24, |
| 9192 | which is the default IP range used for tap devices |
| 9193 | by <filename>runqemu</filename>.</para></listitem> |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 9194 | <listitem><para><emphasis>Be sure your host has the |
| 9195 | correct packages installed:</emphasis> |
| 9196 | Depending your host's distribution, you need |
| 9197 | to have the following packages installed: |
| 9198 | <itemizedlist> |
| 9199 | <listitem><para>Ubuntu and Debian: |
| 9200 | <filename>sysstat</filename> and |
| 9201 | <filename>iproute2</filename> |
| 9202 | </para></listitem> |
| 9203 | <listitem><para>OpenSUSE: |
| 9204 | <filename>sysstat</filename> and |
| 9205 | <filename>iproute2</filename> |
| 9206 | </para></listitem> |
| 9207 | <listitem><para>Fedora: |
| 9208 | <filename>sysstat</filename> and |
| 9209 | <filename>iproute</filename> |
| 9210 | </para></listitem> |
| 9211 | <listitem><para>CentOS: |
| 9212 | <filename>sysstat</filename> and |
| 9213 | <filename>iproute</filename> |
| 9214 | </para></listitem> |
| 9215 | </itemizedlist> |
| 9216 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9217 | </itemizedlist> |
| 9218 | </para> |
| 9219 | |
| 9220 | <para> |
| 9221 | Once you start running the tests, the following happens: |
| 9222 | <orderedlist> |
| 9223 | <listitem><para>A copy of the root filesystem is written |
| 9224 | to <filename>${WORKDIR}/testimage</filename>. |
| 9225 | </para></listitem> |
| 9226 | <listitem><para>The image is booted under QEMU using the |
| 9227 | standard <filename>runqemu</filename> script. |
| 9228 | </para></listitem> |
| 9229 | <listitem><para>A default timeout of 500 seconds occurs |
| 9230 | to allow for the boot process to reach the login prompt. |
| 9231 | You can change the timeout period by setting |
| 9232 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_QEMUBOOT_TIMEOUT'><filename>TEST_QEMUBOOT_TIMEOUT</filename></ulink> |
| 9233 | in the <filename>local.conf</filename> file. |
| 9234 | </para></listitem> |
| 9235 | <listitem><para>Once the boot process is reached and the |
| 9236 | login prompt appears, the tests run. |
| 9237 | The full boot log is written to |
| 9238 | <filename>${WORKDIR}/testimage/qemu_boot_log</filename>. |
| 9239 | </para></listitem> |
| 9240 | <listitem><para>Each test module loads in the order found |
| 9241 | in <filename>TEST_SUITES</filename>. |
| 9242 | You can find the full output of the commands run over |
| 9243 | SSH in |
| 9244 | <filename>${WORKDIR}/testimgage/ssh_target_log</filename>. |
| 9245 | </para></listitem> |
| 9246 | <listitem><para>If no failures occur, the task running the |
| 9247 | tests ends successfully. |
| 9248 | You can find the output from the |
| 9249 | <filename>unittest</filename> in the task log at |
| 9250 | <filename>${WORKDIR}/temp/log.do_testimage</filename>. |
| 9251 | </para></listitem> |
| 9252 | </orderedlist> |
| 9253 | </para> |
| 9254 | </section> |
| 9255 | |
| 9256 | <section id='hardware-image-enabling-tests'> |
| 9257 | <title>Enabling Runtime Tests on Hardware</title> |
| 9258 | |
| 9259 | <para> |
| 9260 | The OpenEmbedded build system can run tests on real |
| 9261 | hardware, and for certain devices it can also deploy |
| 9262 | the image to be tested onto the device beforehand. |
| 9263 | </para> |
| 9264 | |
| 9265 | <para> |
| 9266 | For automated deployment, a "master image" is installed |
| 9267 | onto the hardware once as part of setup. |
| 9268 | Then, each time tests are to be run, the following |
| 9269 | occurs: |
| 9270 | <orderedlist> |
| 9271 | <listitem><para>The master image is booted into and |
| 9272 | used to write the image to be tested to |
| 9273 | a second partition. |
| 9274 | </para></listitem> |
| 9275 | <listitem><para>The device is then rebooted using an |
| 9276 | external script that you need to provide. |
| 9277 | </para></listitem> |
| 9278 | <listitem><para>The device boots into the image to be |
| 9279 | tested. |
| 9280 | </para></listitem> |
| 9281 | </orderedlist> |
| 9282 | </para> |
| 9283 | |
| 9284 | <para> |
| 9285 | When running tests (independent of whether the image |
| 9286 | has been deployed automatically or not), the device is |
| 9287 | expected to be connected to a network on a |
| 9288 | pre-determined IP address. |
| 9289 | You can either use static IP addresses written into |
| 9290 | the image, or set the image to use DHCP and have your |
| 9291 | DHCP server on the test network assign a known IP address |
| 9292 | based on the MAC address of the device. |
| 9293 | </para> |
| 9294 | |
| 9295 | <para> |
| 9296 | In order to run tests on hardware, you need to set |
| 9297 | <filename>TEST_TARGET</filename> to an appropriate value. |
| 9298 | For QEMU, you do not have to change anything, the default |
| 9299 | value is "QemuTarget". |
| 9300 | For running tests on hardware, the following options exist: |
| 9301 | <itemizedlist> |
| 9302 | <listitem><para><emphasis>"SimpleRemoteTarget":</emphasis> |
| 9303 | Choose "SimpleRemoteTarget" if you are going to |
| 9304 | run tests on a target system that is already |
| 9305 | running the image to be tested and is available |
| 9306 | on the network. |
| 9307 | You can use "SimpleRemoteTarget" in conjunction |
| 9308 | with either real hardware or an image running |
| 9309 | within a separately started QEMU or any |
| 9310 | other virtual machine manager. |
| 9311 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9312 | <listitem><para><emphasis>"Systemd-bootTarget":</emphasis> |
| 9313 | Choose "Systemd-bootTarget" if your hardware is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9314 | an EFI-based machine with |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9315 | <filename>systemd-boot</filename> as bootloader and |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9316 | <filename>core-image-testmaster</filename> |
| 9317 | (or something similar) is installed. |
| 9318 | Also, your hardware under test must be in a |
| 9319 | DHCP-enabled network that gives it the same IP |
| 9320 | address for each reboot.</para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9321 | <para>If you choose "Systemd-bootTarget", there are |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9322 | additional requirements and considerations. |
| 9323 | See the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9324 | "<link linkend='selecting-systemd-boottarget'>Selecting Systemd-bootTarget</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9325 | section, which follows, for more information. |
| 9326 | </para></listitem> |
| 9327 | <listitem><para><emphasis>"BeagleBoneTarget":</emphasis> |
| 9328 | Choose "BeagleBoneTarget" if you are deploying |
| 9329 | images and running tests on the BeagleBone |
| 9330 | "Black" or original "White" hardware. |
| 9331 | For information on how to use these tests, see the |
| 9332 | comments at the top of the BeagleBoneTarget |
| 9333 | <filename>meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py</filename> |
| 9334 | file. |
| 9335 | </para></listitem> |
| 9336 | <listitem><para><emphasis>"EdgeRouterTarget":</emphasis> |
| 9337 | Choose "EdgeRouterTarget" is you are deploying |
| 9338 | images and running tests on the Ubiquiti Networks |
| 9339 | EdgeRouter Lite. |
| 9340 | For information on how to use these tests, see the |
| 9341 | comments at the top of the EdgeRouterTarget |
| 9342 | <filename>meta-yocto-bsp/lib/oeqa/controllers/edgeroutertarget.py</filename> |
| 9343 | file. |
| 9344 | </para></listitem> |
| 9345 | <listitem><para><emphasis>"GrubTarget":</emphasis> |
| 9346 | Choose the "supports deploying images and running |
| 9347 | tests on any generic PC that boots using GRUB. |
| 9348 | For information on how to use these tests, see the |
| 9349 | comments at the top of the GrubTarget |
| 9350 | <filename>meta-yocto-bsp/lib/oeqa/controllers/grubtarget.py</filename> |
| 9351 | file. |
| 9352 | </para></listitem> |
| 9353 | <listitem><para><emphasis>"<replaceable>your-target</replaceable>":</emphasis> |
| 9354 | Create your own custom target if you want to run |
| 9355 | tests when you are deploying images and running |
| 9356 | tests on a custom machine within your BSP layer. |
| 9357 | To do this, you need to add a Python unit that |
| 9358 | defines the target class under |
| 9359 | <filename>lib/oeqa/controllers/</filename> within |
| 9360 | your layer. |
| 9361 | You must also provide an empty |
| 9362 | <filename>__init__.py</filename>. |
| 9363 | For examples, see files in |
| 9364 | <filename>meta-yocto-bsp/lib/oeqa/controllers/</filename>. |
| 9365 | </para></listitem> |
| 9366 | </itemizedlist> |
| 9367 | </para> |
| 9368 | </section> |
| 9369 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9370 | <section id='selecting-systemd-boottarget'> |
| 9371 | <title>Selecting Systemd-bootTarget</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9372 | |
| 9373 | <para> |
| 9374 | If you did not set <filename>TEST_TARGET</filename> to |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9375 | "Systemd-bootTarget", then you do not need any information |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9376 | in this section. |
| 9377 | You can skip down to the |
| 9378 | "<link linkend='qemu-image-running-tests'>Running Tests</link>" |
| 9379 | section. |
| 9380 | </para> |
| 9381 | |
| 9382 | <para> |
| 9383 | If you did set <filename>TEST_TARGET</filename> to |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9384 | "Systemd-bootTarget", you also need to perform a one-time |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9385 | setup of your master image by doing the following: |
| 9386 | <orderedlist> |
| 9387 | <listitem><para><emphasis>Set <filename>EFI_PROVIDER</filename>:</emphasis> |
| 9388 | Be sure that <filename>EFI_PROVIDER</filename> |
| 9389 | is as follows: |
| 9390 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9391 | EFI_PROVIDER = "systemd-boot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9392 | </literallayout> |
| 9393 | </para></listitem> |
| 9394 | <listitem><para><emphasis>Build the master image:</emphasis> |
| 9395 | Build the <filename>core-image-testmaster</filename> |
| 9396 | image. |
| 9397 | The <filename>core-image-testmaster</filename> |
| 9398 | recipe is provided as an example for a |
| 9399 | "master" image and you can customize the image |
| 9400 | recipe as you would any other recipe. |
| 9401 | </para> |
| 9402 | <para>Here are the image recipe requirements: |
| 9403 | <itemizedlist> |
| 9404 | <listitem><para>Inherits |
| 9405 | <filename>core-image</filename> |
| 9406 | so that kernel modules are installed. |
| 9407 | </para></listitem> |
| 9408 | <listitem><para>Installs normal linux utilities |
| 9409 | not busybox ones (e.g. |
| 9410 | <filename>bash</filename>, |
| 9411 | <filename>coreutils</filename>, |
| 9412 | <filename>tar</filename>, |
| 9413 | <filename>gzip</filename>, and |
| 9414 | <filename>kmod</filename>). |
| 9415 | </para></listitem> |
| 9416 | <listitem><para>Uses a custom |
| 9417 | Initial RAM Disk (initramfs) image with a |
| 9418 | custom installer. |
| 9419 | A normal image that you can install usually |
| 9420 | creates a single rootfs partition. |
| 9421 | This image uses another installer that |
| 9422 | creates a specific partition layout. |
| 9423 | Not all Board Support Packages (BSPs) |
| 9424 | can use an installer. |
| 9425 | For such cases, you need to manually create |
| 9426 | the following partition layout on the |
| 9427 | target: |
| 9428 | <itemizedlist> |
| 9429 | <listitem><para>First partition mounted |
| 9430 | under <filename>/boot</filename>, |
| 9431 | labeled "boot". |
| 9432 | </para></listitem> |
| 9433 | <listitem><para>The main rootfs |
| 9434 | partition where this image gets |
| 9435 | installed, which is mounted under |
| 9436 | <filename>/</filename>. |
| 9437 | </para></listitem> |
| 9438 | <listitem><para>Another partition |
| 9439 | labeled "testrootfs" where test |
| 9440 | images get deployed. |
| 9441 | </para></listitem> |
| 9442 | </itemizedlist> |
| 9443 | </para></listitem> |
| 9444 | </itemizedlist> |
| 9445 | </para></listitem> |
| 9446 | <listitem><para><emphasis>Install image:</emphasis> |
| 9447 | Install the image that you just built on the target |
| 9448 | system. |
| 9449 | </para></listitem> |
| 9450 | </orderedlist> |
| 9451 | </para> |
| 9452 | |
| 9453 | <para> |
| 9454 | The final thing you need to do when setting |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9455 | <filename>TEST_TARGET</filename> to "Systemd-bootTarget" is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9456 | to set up the test image: |
| 9457 | <orderedlist> |
| 9458 | <listitem><para><emphasis>Set up your <filename>local.conf</filename> file:</emphasis> |
| 9459 | Make sure you have the following statements in |
| 9460 | your <filename>local.conf</filename> file: |
| 9461 | <literallayout class='monospaced'> |
| 9462 | IMAGE_FSTYPES += "tar.gz" |
| 9463 | INHERIT += "testimage" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9464 | TEST_TARGET = "Systemd-bootTarget" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9465 | TEST_TARGET_IP = "192.168.2.3" |
| 9466 | </literallayout> |
| 9467 | </para></listitem> |
| 9468 | <listitem><para><emphasis>Build your test image:</emphasis> |
| 9469 | Use BitBake to build the image: |
| 9470 | <literallayout class='monospaced'> |
| 9471 | $ bitbake core-image-sato |
| 9472 | </literallayout> |
| 9473 | </para></listitem> |
| 9474 | </orderedlist> |
| 9475 | </para> |
| 9476 | </section> |
| 9477 | |
| 9478 | <section id='power-control'> |
| 9479 | <title>Power Control</title> |
| 9480 | |
| 9481 | <para> |
| 9482 | For most hardware targets other than SimpleRemoteTarget, |
| 9483 | you can control power: |
| 9484 | <itemizedlist> |
| 9485 | <listitem><para> |
| 9486 | You can use |
| 9487 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 9488 | together with |
| 9489 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 9490 | as a command that runs on the host and does power |
| 9491 | cycling. |
| 9492 | The test code passes one argument to that command: |
| 9493 | off, on or cycle (off then on). |
| 9494 | Here is an example that could appear in your |
| 9495 | <filename>local.conf</filename> file: |
| 9496 | <literallayout class='monospaced'> |
| 9497 | TEST_POWERCONTROL_CMD = "powercontrol.exp test 10.11.12.1 nuc1" |
| 9498 | </literallayout> |
| 9499 | In this example, the expect script does the |
| 9500 | following: |
| 9501 | <literallayout class='monospaced'> |
| 9502 | ssh test@10.11.12.1 "pyctl nuc1 <replaceable>arg</replaceable>" |
| 9503 | </literallayout> |
| 9504 | It then runs a Python script that controls power |
| 9505 | for a label called <filename>nuc1</filename>. |
| 9506 | <note> |
| 9507 | You need to customize |
| 9508 | <filename>TEST_POWERCONTROL_CMD</filename> |
| 9509 | and |
| 9510 | <filename>TEST_POWERCONTROL_EXTRA_ARGS</filename> |
| 9511 | for your own setup. |
| 9512 | The one requirement is that it accepts |
| 9513 | "on", "off", and "cycle" as the last argument. |
| 9514 | </note> |
| 9515 | </para></listitem> |
| 9516 | <listitem><para> |
| 9517 | When no command is defined, it connects to the |
| 9518 | device over SSH and uses the classic reboot command |
| 9519 | to reboot the device. |
| 9520 | Classic reboot is fine as long as the machine |
| 9521 | actually reboots (i.e. the SSH test has not |
| 9522 | failed). |
| 9523 | It is useful for scenarios where you have a simple |
| 9524 | setup, typically with a single board, and where |
| 9525 | some manual interaction is okay from time to time. |
| 9526 | </para></listitem> |
| 9527 | </itemizedlist> |
| 9528 | If you have no hardware to automatically perform power |
| 9529 | control but still wish to experiment with automated |
| 9530 | hardware testing, you can use the dialog-power-control |
| 9531 | script that shows a dialog prompting you to perform the |
| 9532 | required power action. |
| 9533 | This script requires either KDialog or Zenity to be |
| 9534 | installed. |
| 9535 | To use this script, set the |
| 9536 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_POWERCONTROL_CMD'><filename>TEST_POWERCONTROL_CMD</filename></ulink> |
| 9537 | variable as follows: |
| 9538 | <literallayout class='monospaced'> |
| 9539 | TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control" |
| 9540 | </literallayout> |
| 9541 | </para> |
| 9542 | </section> |
| 9543 | |
| 9544 | <section id='serial-console-connection'> |
| 9545 | <title>Serial Console Connection</title> |
| 9546 | |
| 9547 | <para> |
| 9548 | For test target classes requiring a serial console |
| 9549 | to interact with the bootloader (e.g. BeagleBoneTarget, |
| 9550 | EdgeRouterTarget, and GrubTarget), you need to |
| 9551 | specify a command to use to connect to the serial console |
| 9552 | of the target machine by using the |
| 9553 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_CMD'><filename>TEST_SERIALCONTROL_CMD</filename></ulink> |
| 9554 | variable and optionally the |
| 9555 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SERIALCONTROL_EXTRA_ARGS'><filename>TEST_SERIALCONTROL_EXTRA_ARGS</filename></ulink> |
| 9556 | variable. |
| 9557 | </para> |
| 9558 | |
| 9559 | <para> |
| 9560 | These cases could be a serial terminal program if the |
| 9561 | machine is connected to a local serial port, or a |
| 9562 | <filename>telnet</filename> or |
| 9563 | <filename>ssh</filename> command connecting to a remote |
| 9564 | console server. |
| 9565 | Regardless of the case, the command simply needs to |
| 9566 | connect to the serial console and forward that connection |
| 9567 | to standard input and output as any normal terminal |
| 9568 | program does. |
| 9569 | For example, to use the picocom terminal program on |
| 9570 | serial device <filename>/dev/ttyUSB0</filename> |
| 9571 | at 115200bps, you would set the variable as follows: |
| 9572 | <literallayout class='monospaced'> |
| 9573 | TEST_SERIALCONTROL_CMD = "picocom /dev/ttyUSB0 -b 115200" |
| 9574 | </literallayout> |
| 9575 | For local devices where the serial port device disappears |
| 9576 | when the device reboots, an additional "serdevtry" wrapper |
| 9577 | script is provided. |
| 9578 | To use this wrapper, simply prefix the terminal command |
| 9579 | with |
| 9580 | <filename>${COREBASE}/scripts/contrib/serdevtry</filename>: |
| 9581 | <literallayout class='monospaced'> |
| 9582 | TEST_SERIALCONTROL_CMD = "${COREBASE}/scripts/contrib/serdevtry picocom -b |
| 9583 | 115200 /dev/ttyUSB0" |
| 9584 | </literallayout> |
| 9585 | </para> |
| 9586 | </section> |
| 9587 | </section> |
| 9588 | |
| 9589 | <section id="qemu-image-running-tests"> |
| 9590 | <title>Running Tests</title> |
| 9591 | |
| 9592 | <para> |
| 9593 | You can start the tests automatically or manually: |
| 9594 | <itemizedlist> |
| 9595 | <listitem><para><emphasis>Automatically running tests:</emphasis> |
| 9596 | To run the tests automatically after the |
| 9597 | OpenEmbedded build system successfully creates an image, |
| 9598 | first set the |
| 9599 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_IMAGE'><filename>TEST_IMAGE</filename></ulink> |
| 9600 | variable to "1" in your <filename>local.conf</filename> |
| 9601 | file in the |
| 9602 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>: |
| 9603 | <literallayout class='monospaced'> |
| 9604 | TEST_IMAGE = "1" |
| 9605 | </literallayout> |
| 9606 | Next, build your image. |
| 9607 | If the image successfully builds, the tests will be |
| 9608 | run: |
| 9609 | <literallayout class='monospaced'> |
| 9610 | bitbake core-image-sato |
| 9611 | </literallayout></para></listitem> |
| 9612 | <listitem><para><emphasis>Manually running tests:</emphasis> |
| 9613 | To manually run the tests, first globally inherit the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 9614 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9615 | class by editing your <filename>local.conf</filename> |
| 9616 | file: |
| 9617 | <literallayout class='monospaced'> |
| 9618 | INHERIT += "testimage" |
| 9619 | </literallayout> |
| 9620 | Next, use BitBake to run the tests: |
| 9621 | <literallayout class='monospaced'> |
| 9622 | bitbake -c testimage <replaceable>image</replaceable> |
| 9623 | </literallayout></para></listitem> |
| 9624 | </itemizedlist> |
| 9625 | </para> |
| 9626 | |
| 9627 | <para> |
| 9628 | All test files reside in |
| 9629 | <filename>meta/lib/oeqa/runtime</filename> in the |
| 9630 | <link linkend='source-directory'>Source Directory</link>. |
| 9631 | A test name maps directly to a Python module. |
| 9632 | Each test module may contain a number of individual tests. |
| 9633 | Tests are usually grouped together by the area |
| 9634 | tested (e.g tests for systemd reside in |
| 9635 | <filename>meta/lib/oeqa/runtime/systemd.py</filename>). |
| 9636 | </para> |
| 9637 | |
| 9638 | <para> |
| 9639 | You can add tests to any layer provided you place them in the |
| 9640 | proper area and you extend |
| 9641 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 9642 | in the <filename>local.conf</filename> file as normal. |
| 9643 | Be sure that tests reside in |
| 9644 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename>. |
| 9645 | <note> |
| 9646 | Be sure that module names do not collide with module names |
| 9647 | used in the default set of test modules in |
| 9648 | <filename>meta/lib/oeqa/runtime</filename>. |
| 9649 | </note> |
| 9650 | </para> |
| 9651 | |
| 9652 | <para> |
| 9653 | You can change the set of tests run by appending or overriding |
| 9654 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink> |
| 9655 | variable in <filename>local.conf</filename>. |
| 9656 | Each name in <filename>TEST_SUITES</filename> represents a |
| 9657 | required test for the image. |
| 9658 | Test modules named within <filename>TEST_SUITES</filename> |
| 9659 | cannot be skipped even if a test is not suitable for an image |
| 9660 | (e.g. running the RPM tests on an image without |
| 9661 | <filename>rpm</filename>). |
| 9662 | Appending "auto" to <filename>TEST_SUITES</filename> causes the |
| 9663 | build system to try to run all tests that are suitable for the |
| 9664 | image (i.e. each test module may elect to skip itself). |
| 9665 | </para> |
| 9666 | |
| 9667 | <para> |
| 9668 | The order you list tests in <filename>TEST_SUITES</filename> |
| 9669 | is important and influences test dependencies. |
| 9670 | Consequently, tests that depend on other tests should be added |
| 9671 | after the test on which they depend. |
| 9672 | For example, since the <filename>ssh</filename> test |
| 9673 | depends on the |
| 9674 | <filename>ping</filename> test, "ssh" needs to come after |
| 9675 | "ping" in the list. |
| 9676 | The test class provides no re-ordering or dependency handling. |
| 9677 | <note> |
| 9678 | Each module can have multiple classes with multiple test |
| 9679 | methods. |
| 9680 | And, Python <filename>unittest</filename> rules apply. |
| 9681 | </note> |
| 9682 | </para> |
| 9683 | |
| 9684 | <para> |
| 9685 | Here are some things to keep in mind when running tests: |
| 9686 | <itemizedlist> |
| 9687 | <listitem><para>The default tests for the image are defined |
| 9688 | as: |
| 9689 | <literallayout class='monospaced'> |
| 9690 | DEFAULT_TEST_SUITES_pn-<replaceable>image</replaceable> = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg" |
| 9691 | </literallayout></para></listitem> |
| 9692 | <listitem><para>Add your own test to the list of the |
| 9693 | by using the following: |
| 9694 | <literallayout class='monospaced'> |
| 9695 | TEST_SUITES_append = " mytest" |
| 9696 | </literallayout></para></listitem> |
| 9697 | <listitem><para>Run a specific list of tests as follows: |
| 9698 | <literallayout class='monospaced'> |
| 9699 | TEST_SUITES = "test1 test2 test3" |
| 9700 | </literallayout> |
| 9701 | Remember, order is important. |
| 9702 | Be sure to place a test that is dependent on another test |
| 9703 | later in the order.</para></listitem> |
| 9704 | </itemizedlist> |
| 9705 | </para> |
| 9706 | </section> |
| 9707 | |
| 9708 | <section id="exporting-tests"> |
| 9709 | <title>Exporting Tests</title> |
| 9710 | |
| 9711 | <para> |
| 9712 | You can export tests so that they can run independently of |
| 9713 | the build system. |
| 9714 | Exporting tests is required if you want to be able to hand |
| 9715 | the test execution off to a scheduler. |
| 9716 | You can only export tests that are defined in |
| 9717 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TEST_SUITES'><filename>TEST_SUITES</filename></ulink>. |
| 9718 | </para> |
| 9719 | |
| 9720 | <para> |
| 9721 | If your image is already built, make sure the following are set |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9722 | in your <filename>local.conf</filename> file: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9723 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9724 | INHERIT +="testexport" |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9725 | TEST_TARGET_IP = "<replaceable>IP-address-for-the-test-target</replaceable>" |
| 9726 | TEST_SERVER_IP = "<replaceable>IP-address-for-the-test-server</replaceable>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9727 | </literallayout> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9728 | You can then export the tests with the following BitBake |
| 9729 | command form: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9730 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9731 | $ bitbake <replaceable>image</replaceable> -c testexport |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9732 | </literallayout> |
| 9733 | Exporting the tests places them in the |
| 9734 | <link linkend='build-directory'>Build Directory</link> in |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9735 | <filename>tmp/testexport/</filename><replaceable>image</replaceable>, |
| 9736 | which is controlled by the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9737 | <filename>TEST_EXPORT_DIR</filename> variable. |
| 9738 | </para> |
| 9739 | |
| 9740 | <para> |
| 9741 | You can now run the tests outside of the build environment: |
| 9742 | <literallayout class='monospaced'> |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 9743 | $ cd tmp/testexport/<replaceable>image</replaceable> |
| 9744 | $ ./runexported.py testdata.json |
| 9745 | </literallayout> |
| 9746 | </para> |
| 9747 | |
| 9748 | <para> |
| 9749 | Here is a complete example that shows IP addresses and uses |
| 9750 | the <filename>core-image-sato</filename> image: |
| 9751 | <literallayout class='monospaced'> |
| 9752 | INHERIT +="testexport" |
| 9753 | TEST_TARGET_IP = "192.168.7.2" |
| 9754 | TEST_SERVER_IP = "192.168.7.1" |
| 9755 | </literallayout> |
| 9756 | Use BitBake to export the tests: |
| 9757 | <literallayout class='monospaced'> |
| 9758 | $ bitbake core-image-sato -c testexport |
| 9759 | </literallayout> |
| 9760 | Run the tests outside of the build environment using the |
| 9761 | following: |
| 9762 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9763 | $ cd tmp/testexport/core-image-sato |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9764 | $ ./runexported.py testdata.json |
| 9765 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9766 | </para> |
| 9767 | </section> |
| 9768 | |
| 9769 | <section id="qemu-image-writing-new-tests"> |
| 9770 | <title>Writing New Tests</title> |
| 9771 | |
| 9772 | <para> |
| 9773 | As mentioned previously, all new test files need to be in the |
| 9774 | proper place for the build system to find them. |
| 9775 | New tests for additional functionality outside of the core |
| 9776 | should be added to the layer that adds the functionality, in |
| 9777 | <filename><replaceable>layer</replaceable>/lib/oeqa/runtime</filename> |
| 9778 | (as long as |
| 9779 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> |
| 9780 | is extended in the layer's |
| 9781 | <filename>layer.conf</filename> file as normal). |
| 9782 | Just remember the following: |
| 9783 | <itemizedlist> |
| 9784 | <listitem><para>Filenames need to map directly to test |
| 9785 | (module) names. |
| 9786 | </para></listitem> |
| 9787 | <listitem><para>Do not use module names that |
| 9788 | collide with existing core tests. |
| 9789 | </para></listitem> |
| 9790 | <listitem><para>Minimally, an empty |
| 9791 | <filename>__init__.py</filename> file must exist |
| 9792 | in the runtime directory. |
| 9793 | </para></listitem> |
| 9794 | </itemizedlist> |
| 9795 | </para> |
| 9796 | |
| 9797 | <para> |
| 9798 | To create a new test, start by copying an existing module |
| 9799 | (e.g. <filename>syslog.py</filename> or |
| 9800 | <filename>gcc.py</filename> are good ones to use). |
| 9801 | Test modules can use code from |
| 9802 | <filename>meta/lib/oeqa/utils</filename>, which are helper |
| 9803 | classes. |
| 9804 | </para> |
| 9805 | |
| 9806 | <note> |
| 9807 | Structure shell commands such that you rely on them and they |
| 9808 | return a single code for success. |
| 9809 | Be aware that sometimes you will need to parse the output. |
| 9810 | See the <filename>df.py</filename> and |
| 9811 | <filename>date.py</filename> modules for examples. |
| 9812 | </note> |
| 9813 | |
| 9814 | <para> |
| 9815 | You will notice that all test classes inherit |
| 9816 | <filename>oeRuntimeTest</filename>, which is found in |
| 9817 | <filename>meta/lib/oetest.py</filename>. |
| 9818 | This base class offers some helper attributes, which are |
| 9819 | described in the following sections: |
| 9820 | </para> |
| 9821 | |
| 9822 | <section id='qemu-image-writing-tests-class-methods'> |
| 9823 | <title>Class Methods</title> |
| 9824 | |
| 9825 | <para> |
| 9826 | Class methods are as follows: |
| 9827 | <itemizedlist> |
| 9828 | <listitem><para><emphasis><filename>hasPackage(pkg)</filename>:</emphasis> |
| 9829 | Returns "True" if <filename>pkg</filename> is in the |
| 9830 | installed package list of the image, which is based |
| 9831 | on the manifest file that is generated during the |
| 9832 | <filename>do_rootfs</filename> task. |
| 9833 | </para></listitem> |
| 9834 | <listitem><para><emphasis><filename>hasFeature(feature)</filename>:</emphasis> |
| 9835 | Returns "True" if the feature is in |
| 9836 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink> |
| 9837 | or |
| 9838 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DISTRO_FEATURES'><filename>DISTRO_FEATURES</filename></ulink>. |
| 9839 | </para></listitem> |
| 9840 | </itemizedlist> |
| 9841 | </para> |
| 9842 | </section> |
| 9843 | |
| 9844 | <section id='qemu-image-writing-tests-class-attributes'> |
| 9845 | <title>Class Attributes</title> |
| 9846 | |
| 9847 | <para> |
| 9848 | Class attributes are as follows: |
| 9849 | <itemizedlist> |
| 9850 | <listitem><para><emphasis><filename>pscmd</filename>:</emphasis> |
| 9851 | Equals "ps -ef" if <filename>procps</filename> is |
| 9852 | installed in the image. |
| 9853 | Otherwise, <filename>pscmd</filename> equals |
| 9854 | "ps" (busybox). |
| 9855 | </para></listitem> |
| 9856 | <listitem><para><emphasis><filename>tc</filename>:</emphasis> |
| 9857 | The called test context, which gives access to the |
| 9858 | following attributes: |
| 9859 | <itemizedlist> |
| 9860 | <listitem><para><emphasis><filename>d</filename>:</emphasis> |
| 9861 | The BitBake datastore, which allows you to |
| 9862 | use stuff such as |
| 9863 | <filename>oeRuntimeTest.tc.d.getVar("VIRTUAL-RUNTIME_init_manager")</filename>. |
| 9864 | </para></listitem> |
| 9865 | <listitem><para><emphasis><filename>testslist</filename> and <filename>testsrequired</filename>:</emphasis> |
| 9866 | Used internally. |
| 9867 | The tests do not need these. |
| 9868 | </para></listitem> |
| 9869 | <listitem><para><emphasis><filename>filesdir</filename>:</emphasis> |
| 9870 | The absolute path to |
| 9871 | <filename>meta/lib/oeqa/runtime/files</filename>, |
| 9872 | which contains helper files for tests meant |
| 9873 | for copying on the target such as small |
| 9874 | files written in C for compilation. |
| 9875 | </para></listitem> |
| 9876 | <listitem><para><emphasis><filename>target</filename>:</emphasis> |
| 9877 | The target controller object used to deploy |
| 9878 | and start an image on a particular target |
| 9879 | (e.g. QemuTarget, SimpleRemote, and |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9880 | Systemd-bootTarget). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9881 | Tests usually use the following: |
| 9882 | <itemizedlist> |
| 9883 | <listitem><para><emphasis><filename>ip</filename>:</emphasis> |
| 9884 | The target's IP address. |
| 9885 | </para></listitem> |
| 9886 | <listitem><para><emphasis><filename>server_ip</filename>:</emphasis> |
| 9887 | The host's IP address, which is |
| 9888 | usually used by the "smart" test |
| 9889 | suite. |
| 9890 | </para></listitem> |
| 9891 | <listitem><para><emphasis><filename>run(cmd, timeout=None)</filename>:</emphasis> |
| 9892 | The single, most used method. |
| 9893 | This command is a wrapper for: |
| 9894 | <filename>ssh root@host "cmd"</filename>. |
| 9895 | The command returns a tuple: |
| 9896 | (status, output), which are what |
| 9897 | their names imply - the return code |
| 9898 | of "cmd" and whatever output |
| 9899 | it produces. |
| 9900 | The optional timeout argument |
| 9901 | represents the number of seconds the |
| 9902 | test should wait for "cmd" to |
| 9903 | return. |
| 9904 | If the argument is "None", the |
| 9905 | test uses the default instance's |
| 9906 | timeout period, which is 300 |
| 9907 | seconds. |
| 9908 | If the argument is "0", the test |
| 9909 | runs until the command returns. |
| 9910 | </para></listitem> |
| 9911 | <listitem><para><emphasis><filename>copy_to(localpath, remotepath)</filename>:</emphasis> |
| 9912 | <filename>scp localpath root@ip:remotepath</filename>. |
| 9913 | </para></listitem> |
| 9914 | <listitem><para><emphasis><filename>copy_from(remotepath, localpath)</filename>:</emphasis> |
| 9915 | <filename>scp root@host:remotepath localpath</filename>. |
| 9916 | </para></listitem> |
| 9917 | </itemizedlist></para></listitem> |
| 9918 | </itemizedlist></para></listitem> |
| 9919 | </itemizedlist> |
| 9920 | </para> |
| 9921 | </section> |
| 9922 | |
| 9923 | <section id='qemu-image-writing-tests-instance-attributes'> |
| 9924 | <title>Instance Attributes</title> |
| 9925 | |
| 9926 | <para> |
| 9927 | A single instance attribute exists, which is |
| 9928 | <filename>target</filename>. |
| 9929 | The <filename>target</filename> instance attribute is |
| 9930 | identical to the class attribute of the same name, which |
| 9931 | is described in the previous section. |
| 9932 | This attribute exists as both an instance and class |
| 9933 | attribute so tests can use |
| 9934 | <filename>self.target.run(cmd)</filename> in instance |
| 9935 | methods instead of |
| 9936 | <filename>oeRuntimeTest.tc.target.run(cmd)</filename>. |
| 9937 | </para> |
| 9938 | </section> |
| 9939 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 9940 | |
| 9941 | <section id='installing-packages-in-the-dut-without-the-package-manager'> |
| 9942 | <title>Installing Packages in the DUT Without the Package Manager</title> |
| 9943 | |
| 9944 | <para> |
| 9945 | When a test requires a package built by BitBake, it is possible |
| 9946 | to install that package. |
| 9947 | Installing the package does not require a package manager be |
| 9948 | installed in the device under test (DUT). |
| 9949 | It does, however, require an SSH connection and the target must |
| 9950 | be using the <filename>sshcontrol</filename> class. |
| 9951 | <note> |
| 9952 | This method uses <filename>scp</filename> to copy files |
| 9953 | from the host to the target, which causes permissions and |
| 9954 | special attributes to be lost. |
| 9955 | </note> |
| 9956 | </para> |
| 9957 | |
| 9958 | <para> |
| 9959 | A JSON file is used to define the packages needed by a test. |
| 9960 | This file must be in the same path as the file used to define |
| 9961 | the tests. |
| 9962 | Furthermore, the filename must map directly to the test |
| 9963 | module name with a <filename>.json</filename> extension. |
| 9964 | </para> |
| 9965 | |
| 9966 | <para> |
| 9967 | The JSON file must include an object with the test name as |
| 9968 | keys of an object or an array. |
| 9969 | This object (or array of objects) uses the following data: |
| 9970 | <itemizedlist> |
| 9971 | <listitem><para>"pkg" - A mandatory string that is the |
| 9972 | name of the package to be installed. |
| 9973 | </para></listitem> |
| 9974 | <listitem><para>"rm" - An optional boolean, which defaults |
| 9975 | to "false", that specifies to remove the package after |
| 9976 | the test. |
| 9977 | </para></listitem> |
| 9978 | <listitem><para>"extract" - An optional boolean, which |
| 9979 | defaults to "false", that specifies if the package must |
| 9980 | be extracted from the package format. |
| 9981 | When set to "true", the package is not automatically |
| 9982 | installed into the DUT. |
| 9983 | </para></listitem> |
| 9984 | </itemizedlist> |
| 9985 | </para> |
| 9986 | |
| 9987 | <para> |
| 9988 | Following is an example JSON file that handles test "foo" |
| 9989 | installing package "bar" and test "foobar" installing |
| 9990 | packages "foo" and "bar". |
| 9991 | Once the test is complete, the packages are removed from the |
| 9992 | DUT. |
| 9993 | <literallayout class='monospaced'> |
| 9994 | { |
| 9995 | "foo": { |
| 9996 | "pkg": "bar" |
| 9997 | }, |
| 9998 | "foobar": [ |
| 9999 | { |
| 10000 | "pkg": "foo", |
| 10001 | "rm": true |
| 10002 | }, |
| 10003 | { |
| 10004 | "pkg": "bar", |
| 10005 | "rm": true |
| 10006 | } |
| 10007 | ] |
| 10008 | } |
| 10009 | </literallayout> |
| 10010 | </para> |
| 10011 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10012 | </section> |
| 10013 | |
| 10014 | <section id="platdev-gdb-remotedebug"> |
| 10015 | <title>Debugging With the GNU Project Debugger (GDB) Remotely</title> |
| 10016 | |
| 10017 | <para> |
| 10018 | GDB allows you to examine running programs, which in turn helps you to understand and fix problems. |
| 10019 | It also allows you to perform post-mortem style analysis of program crashes. |
| 10020 | GDB is available as a package within the Yocto Project and is |
| 10021 | installed in SDK images by default. |
| 10022 | See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter |
| 10023 | in the Yocto Project Reference Manual for a description of these images. |
| 10024 | You can find information on GDB at <ulink url="http://sourceware.org/gdb/"/>. |
| 10025 | </para> |
| 10026 | |
| 10027 | <tip> |
| 10028 | For best results, install debug (<filename>-dbg</filename>) packages |
| 10029 | for the applications you are going to debug. |
| 10030 | Doing so makes extra debug symbols available that give you more |
| 10031 | meaningful output. |
| 10032 | </tip> |
| 10033 | |
| 10034 | <para> |
| 10035 | Sometimes, due to memory or disk space constraints, it is not possible |
| 10036 | to use GDB directly on the remote target to debug applications. |
| 10037 | These constraints arise because GDB needs to load the debugging information and the |
| 10038 | binaries of the process being debugged. |
| 10039 | Additionally, GDB needs to perform many computations to locate information such as function |
| 10040 | names, variable names and values, stack traces and so forth - even before starting the |
| 10041 | debugging process. |
| 10042 | These extra computations place more load on the target system and can alter the |
| 10043 | characteristics of the program being debugged. |
| 10044 | </para> |
| 10045 | |
| 10046 | <para> |
| 10047 | To help get past the previously mentioned constraints, you can use Gdbserver. |
| 10048 | Gdbserver runs on the remote target and does not load any debugging information |
| 10049 | from the debugged process. |
| 10050 | Instead, a GDB instance processes the debugging information that is run on a |
| 10051 | remote computer - the host GDB. |
| 10052 | The host GDB then sends control commands to Gdbserver to make it stop or start the debugged |
| 10053 | program, as well as read or write memory regions of that debugged program. |
| 10054 | All the debugging information loaded and processed as well |
| 10055 | as all the heavy debugging is done by the host GDB. |
| 10056 | Offloading these processes gives the Gdbserver running on the target a chance to remain |
| 10057 | small and fast. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10058 | </para> |
| 10059 | |
| 10060 | <para> |
| 10061 | Because the host GDB is responsible for loading the debugging information and |
| 10062 | for doing the necessary processing to make actual debugging happen, |
| 10063 | you have to make sure the host can access the unstripped binaries complete |
| 10064 | with their debugging information and also be sure the target is compiled with no optimizations. |
| 10065 | The host GDB must also have local access to all the libraries used by the |
| 10066 | debugged program. |
| 10067 | Because Gdbserver does not need any local debugging information, the binaries on |
| 10068 | the remote target can remain stripped. |
| 10069 | However, the binaries must also be compiled without optimization |
| 10070 | so they match the host's binaries. |
| 10071 | </para> |
| 10072 | |
| 10073 | <para> |
| 10074 | To remain consistent with GDB documentation and terminology, the binary being debugged |
| 10075 | on the remote target machine is referred to as the "inferior" binary. |
| 10076 | For documentation on GDB see the |
| 10077 | <ulink url="http://sourceware.org/gdb/documentation/">GDB site</ulink>. |
| 10078 | </para> |
| 10079 | |
| 10080 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10081 | The following steps show you how to debug using the GNU project |
| 10082 | debugger. |
| 10083 | <orderedlist> |
| 10084 | <listitem><para> |
| 10085 | <emphasis>Configure your build system to construct the |
| 10086 | companion debug filesystem:</emphasis></para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10087 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10088 | <para>In your <filename>local.conf</filename> file, set |
| 10089 | the following: |
| 10090 | <literallayout class='monospaced'> |
| 10091 | IMAGE_GEN_DEBUGFS = "1" |
| 10092 | IMAGE_FSTYPES_DEBUGFS = "tar.bz2" |
| 10093 | </literallayout> |
| 10094 | These options cause the OpenEmbedded build system |
| 10095 | to generate a special companion filesystem fragment, |
| 10096 | which contains the matching source and debug symbols to |
| 10097 | your deployable filesystem. |
| 10098 | The build system does this by looking at what is in the |
| 10099 | deployed filesystem, and pulling the corresponding |
| 10100 | <filename>-dbg</filename> packages.</para> |
| 10101 | |
| 10102 | <para>The companion debug filesystem is not a complete |
| 10103 | filesystem, but only contains the debug fragments. |
| 10104 | This filesystem must be combined with the full filesystem |
| 10105 | for debugging. |
| 10106 | Subsequent steps in this procedure show how to combine |
| 10107 | the partial filesystem with the full filesystem. |
| 10108 | </para></listitem> |
| 10109 | <listitem><para> |
| 10110 | <emphasis>Configure the system to include Gdbserver in |
| 10111 | the target filesystem:</emphasis></para> |
| 10112 | |
| 10113 | <para>Make the following addition in either your |
| 10114 | <filename>local.conf</filename> file or in an image |
| 10115 | recipe: |
| 10116 | <literallayout class='monospaced'> |
| 10117 | IMAGE_INSTALL_append = “ gdbserver" |
| 10118 | </literallayout> |
| 10119 | The change makes sure the <filename>gdbserver</filename> |
| 10120 | package is included. |
| 10121 | </para></listitem> |
| 10122 | <listitem><para> |
| 10123 | <emphasis>Build the environment:</emphasis></para> |
| 10124 | |
| 10125 | <para>Use the following command to construct the image and |
| 10126 | the companion Debug Filesystem: |
| 10127 | <literallayout class='monospaced'> |
| 10128 | $ bitbake <replaceable>image</replaceable> |
| 10129 | </literallayout> |
| 10130 | Build the cross GDB component and make it available |
| 10131 | for debugging. |
| 10132 | Build the SDK that matches the image. |
| 10133 | Building the SDK is best for a production build |
| 10134 | that can be used later for debugging, especially |
| 10135 | during long term maintenance: |
| 10136 | <literallayout class='monospaced'> |
| 10137 | $ bitbake -c populate_sdk <replaceable>image</replaceable> |
| 10138 | </literallayout></para> |
| 10139 | |
| 10140 | <para>Alternatively, you can build the minimal |
| 10141 | toolchain components that match the target. |
| 10142 | Doing so creates a smaller than typical SDK and only |
| 10143 | contains a minimal set of components with which to |
| 10144 | build simple test applications, as well as run the |
| 10145 | debugger: |
| 10146 | <literallayout class='monospaced'> |
| 10147 | $ bitbake meta-toolchain |
| 10148 | </literallayout></para> |
| 10149 | |
| 10150 | <para>A final method is to build Gdb itself within |
| 10151 | the build system: |
| 10152 | <literallayout class='monospaced'> |
| 10153 | $ bitbake gdb-cross-<replaceable>architecture</replaceable> |
| 10154 | </literallayout> |
| 10155 | Doing so produces a temporary copy of |
| 10156 | <filename>cross-gdb</filename> you can use for |
| 10157 | debugging during development. |
| 10158 | While this is the quickest approach, the two previous |
| 10159 | methods in this step are better when considering |
| 10160 | long-term maintenance strategies. |
| 10161 | <note> |
| 10162 | If you run |
| 10163 | <filename>bitbake gdb-cross</filename>, the |
| 10164 | OpenEmbedded build system suggests the actual |
| 10165 | image (e.g. <filename>gdb-cross-i586</filename>). |
| 10166 | The suggestion is usually the actual name you want |
| 10167 | to use. |
| 10168 | </note> |
| 10169 | </para></listitem> |
| 10170 | <listitem><para> |
| 10171 | <emphasis>Set up the</emphasis> <filename>debugfs</filename></para> |
| 10172 | |
| 10173 | <para>Run the following commands to set up the |
| 10174 | <filename>debugfs</filename>: |
| 10175 | <literallayout class='monospaced'> |
| 10176 | $ mkdir debugfs |
| 10177 | $ cd debugfs |
| 10178 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>.rootfs.tar.bz2 |
| 10179 | $ tar xvfj <replaceable>build-dir</replaceable>/tmp-glibc/deploy/images/<replaceable>machine</replaceable>/<replaceable>image</replaceable>-dbg.rootfs.tar.bz2 |
| 10180 | </literallayout> |
| 10181 | </para></listitem> |
| 10182 | <listitem><para> |
| 10183 | <emphasis>Set up GDB</emphasis></para> |
| 10184 | |
| 10185 | <para>Install the SDK (if you built one) and then |
| 10186 | source the correct environment file. |
| 10187 | Sourcing the environment file puts the SDK in your |
| 10188 | <filename>PATH</filename> environment variable.</para> |
| 10189 | |
| 10190 | <para>If you are using the build system, Gdb is |
| 10191 | located in |
| 10192 | <replaceable>build-dir</replaceable>/tmp/sysroots/<replaceable>host</replaceable>/usr/bin/<replaceable>architecture</replaceable>/<replaceable>architecture</replaceable>-gdb |
| 10193 | </para></listitem> |
| 10194 | <listitem><para> |
| 10195 | <emphasis>Boot the target:</emphasis></para> |
| 10196 | |
| 10197 | <para>For information on how to run QEMU, see the |
| 10198 | <ulink url='http://wiki.qemu.org/Documentation/GettingStartedDevelopers'>QEMU Documentation</ulink>. |
| 10199 | <note> |
| 10200 | Be sure to verify that your host can access the |
| 10201 | target via TCP. |
| 10202 | </note> |
| 10203 | </para></listitem> |
| 10204 | <listitem><para> |
| 10205 | <emphasis>Debug a program:</emphasis></para> |
| 10206 | |
| 10207 | <para>Debugging a program involves running Gdbserver |
| 10208 | on the target and then running Gdb on the host. |
| 10209 | The example in this step debugs |
| 10210 | <filename>gzip</filename>: |
| 10211 | <literallayout class='monospaced'> |
| 10212 | root@qemux86:~# gdbserver localhost:1234 /bin/gzip —help |
| 10213 | </literallayout> |
| 10214 | For additional Gdbserver options, see the |
| 10215 | <ulink url='https://www.gnu.org/software/gdb/documentation/'>Gdb Server Documentation</ulink>. |
| 10216 | </para> |
| 10217 | |
| 10218 | <para>After running Gdbserver on the target, you need |
| 10219 | to run Gdb on the host and configure it and connect to |
| 10220 | the target. |
| 10221 | Use these commands: |
| 10222 | <literallayout class='monospaced'> |
| 10223 | $ cd <replaceable>directory-holding-the-debugfs-directory</replaceable> |
| 10224 | $ <replaceable>arch</replaceable>-gdb |
| 10225 | |
| 10226 | (gdb) set sysroot debugfs |
| 10227 | (gdb) set substitute-path /usr/src/debug debugfs/usr/src/debug |
| 10228 | (gdb) target remote <replaceable>IP-of-target</replaceable>:1234 |
| 10229 | </literallayout> |
| 10230 | At this point, everything should automatically load |
| 10231 | (i.e. matching binaries, symbols and headers). |
| 10232 | <note> |
| 10233 | The Gdb <filename>set</filename> commands in the |
| 10234 | previous example can be placed into the users |
| 10235 | <filename>~/.gdbinit</filename> file. |
| 10236 | Upon starting, Gdb automatically runs whatever |
| 10237 | commands are in that file. |
| 10238 | </note> |
| 10239 | </para></listitem> |
| 10240 | <listitem><para> |
| 10241 | <emphasis>Deploying without a full image |
| 10242 | rebuild:</emphasis></para> |
| 10243 | |
| 10244 | <para>In many cases, during development you want a |
| 10245 | quick method to deploy a new binary to the target and |
| 10246 | debug it, without waiting for a full image build. |
| 10247 | </para> |
| 10248 | |
| 10249 | <para>One approach to solving this situation is to |
| 10250 | just build the component you want to debug. |
| 10251 | Once you have built the component, copy the |
| 10252 | executable directly to both the target and the |
| 10253 | host <filename>debugfs</filename>.</para> |
| 10254 | |
| 10255 | <para>If the binary is processed through the debug |
| 10256 | splitting in OpenEmbedded, you should also |
| 10257 | copy the debug items (i.e. <filename>.debug</filename> |
| 10258 | contents and corresponding |
| 10259 | <filename>/usr/src/debug</filename> files) |
| 10260 | from the work directory. |
| 10261 | Here is an example: |
| 10262 | <literallayout class='monospaced'> |
| 10263 | $ bitbake bash |
| 10264 | $ bitbake -c devshell bash |
| 10265 | $ cd .. |
| 10266 | $ scp packages-split/bash/bin/bash <replaceable>target</replaceable>:/bin/bash |
| 10267 | $ cp -a packages-split/bash-dbg/* <replaceable>path</replaceable>/debugfs |
| 10268 | </literallayout> |
| 10269 | </para></listitem> |
| 10270 | </orderedlist> |
| 10271 | </para> |
| 10272 | </section> |
| 10273 | |
| 10274 | <!-- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10275 | <section id='platdev-gdb-remotedebug-setup'> |
| 10276 | <title>Set Up the Cross-Development Debugging Environment</title> |
| 10277 | |
| 10278 | <para> |
| 10279 | Before you can initiate a remote debugging session, you need |
| 10280 | to be sure you have set up the cross-development environment, |
| 10281 | toolchain, and sysroot. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10282 | The <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-intro'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10283 | describes this process. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10284 | </para> |
| 10285 | </section> |
| 10286 | |
| 10287 | <section id="platdev-gdb-remotedebug-launch-gdbserver"> |
| 10288 | <title>Launch Gdbserver on the Target</title> |
| 10289 | |
| 10290 | <para> |
| 10291 | Make sure Gdbserver is installed on the target. |
| 10292 | If it is not, install the package |
| 10293 | <filename>gdbserver</filename>, which needs the |
| 10294 | <filename>libthread-db1</filename> package. |
| 10295 | </para> |
| 10296 | |
| 10297 | <para> |
| 10298 | Here is an example, that when entered from the host, |
| 10299 | connects to the target and launches Gdbserver in order to |
| 10300 | "debug" a binary named <filename>helloworld</filename>: |
| 10301 | <literallayout class='monospaced'> |
| 10302 | $ gdbserver localhost:2345 /usr/bin/helloworld |
| 10303 | </literallayout> |
| 10304 | Gdbserver should now be listening on port 2345 for debugging |
| 10305 | commands coming from a remote GDB process that is running on |
| 10306 | the host computer. |
| 10307 | Communication between Gdbserver and the host GDB are done |
| 10308 | using TCP. |
| 10309 | To use other communication protocols, please refer to the |
| 10310 | <ulink url='http://www.gnu.org/software/gdb/'>Gdbserver documentation</ulink>. |
| 10311 | </para> |
| 10312 | </section> |
| 10313 | |
| 10314 | <section id="platdev-gdb-remotedebug-launch-gdb"> |
| 10315 | <title>Launch GDB on the Host Computer</title> |
| 10316 | |
| 10317 | <para> |
| 10318 | Running GDB on the host computer takes a number of stages, which |
| 10319 | this section describes. |
| 10320 | </para> |
| 10321 | |
| 10322 | <section id="platdev-gdb-remotedebug-launch-gdb-buildcross"> |
| 10323 | <title>Build the Cross-GDB Package</title> |
| 10324 | <para> |
| 10325 | A suitable GDB cross-binary is required that runs on your |
| 10326 | host computer but also knows about the the ABI of the |
| 10327 | remote target. |
| 10328 | You can get this binary from the |
| 10329 | <link linkend='cross-development-toolchain'>Cross-Development Toolchain</link>. |
| 10330 | Here is an example where the toolchain has been installed |
| 10331 | in the default directory |
| 10332 | <filename>/opt/poky/&DISTRO;</filename>: |
| 10333 | <literallayout class='monospaced'> |
| 10334 | /opt/poky/&DISTRO;/sysroots/i686-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb |
| 10335 | </literallayout> |
| 10336 | where <filename>arm</filename> is the target architecture |
| 10337 | and <filename>linux-gnueabi</filename> is the target ABI. |
| 10338 | </para> |
| 10339 | |
| 10340 | <para> |
| 10341 | Alternatively, you can use BitBake to build the |
| 10342 | <filename>gdb-cross</filename> binary. |
| 10343 | Here is an example: |
| 10344 | <literallayout class='monospaced'> |
| 10345 | $ bitbake gdb-cross |
| 10346 | </literallayout> |
| 10347 | Once the binary is built, you can find it here: |
| 10348 | <literallayout class='monospaced'> |
| 10349 | tmp/sysroots/<replaceable>host-arch</replaceable>/usr/bin/<replaceable>target-platform</replaceable>/<replaceable>target-abi</replaceable>-gdb |
| 10350 | </literallayout> |
| 10351 | </para> |
| 10352 | </section> |
| 10353 | |
| 10354 | <section id='create-the-gdb-initialization-file'> |
| 10355 | <title>Create the GDB Initialization File and Point to Your Root Filesystem</title> |
| 10356 | |
| 10357 | <para> |
| 10358 | Aside from the GDB cross-binary, you also need a GDB |
| 10359 | initialization file in the same top directory in which |
| 10360 | your binary resides. |
| 10361 | When you start GDB on your host development system, GDB |
| 10362 | finds this initialization file and executes all the |
| 10363 | commands within. |
| 10364 | For information on the <filename>.gdbinit</filename>, see |
| 10365 | "<ulink url='http://sourceware.org/gdb/onlinedocs/gdb/'>Debugging with GDB</ulink>", |
| 10366 | which is maintained by |
| 10367 | <ulink url='http://www.sourceware.org'>sourceware.org</ulink>. |
| 10368 | </para> |
| 10369 | |
| 10370 | <para> |
| 10371 | You need to add a statement in the |
| 10372 | <filename>~/.gdbinit</filename> file that points to your |
| 10373 | root filesystem. |
| 10374 | Here is an example that points to the root filesystem for |
| 10375 | an ARM-based target device: |
| 10376 | <literallayout class='monospaced'> |
| 10377 | set sysroot ~/sysroot_arm |
| 10378 | </literallayout> |
| 10379 | </para> |
| 10380 | </section> |
| 10381 | |
| 10382 | <section id="platdev-gdb-remotedebug-launch-gdb-launchhost"> |
| 10383 | <title>Launch the Host GDB</title> |
| 10384 | |
| 10385 | <para> |
| 10386 | Before launching the host GDB, you need to be sure |
| 10387 | you have sourced the cross-debugging environment script, |
| 10388 | which if you installed the root filesystem in the default |
| 10389 | location is at <filename>/opt/poky/&DISTRO;</filename> |
| 10390 | and begins with the string "environment-setup". |
| 10391 | For more information, see the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10392 | <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's |
| 10393 | Guide</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10394 | </para> |
| 10395 | |
| 10396 | <para> |
| 10397 | Finally, switch to the directory where the binary resides |
| 10398 | and run the <filename>cross-gdb</filename> binary. |
| 10399 | Provide the binary file you are going to debug. |
| 10400 | For example, the following command continues with the |
| 10401 | example used in the previous section by loading |
| 10402 | the <filename>helloworld</filename> binary as well as the |
| 10403 | debugging information: |
| 10404 | <literallayout class='monospaced'> |
| 10405 | $ arm-poky-linux-gnuabi-gdb helloworld |
| 10406 | </literallayout> |
| 10407 | The commands in your <filename>.gdbinit</filename> execute |
| 10408 | and the GDB prompt appears. |
| 10409 | </para> |
| 10410 | </section> |
| 10411 | </section> |
| 10412 | |
| 10413 | <section id='platdev-gdb-connect-to-the-remote-gdb-server'> |
| 10414 | <title>Connect to the Remote GDB Server</title> |
| 10415 | |
| 10416 | <para> |
| 10417 | From the target, you need to connect to the remote GDB |
| 10418 | server that is running on the host. |
| 10419 | You need to specify the remote host and port. |
| 10420 | Here is the command continuing with the example: |
| 10421 | <literallayout class='monospaced'> |
| 10422 | target remote 192.168.7.2:2345 |
| 10423 | </literallayout> |
| 10424 | </para> |
| 10425 | </section> |
| 10426 | |
| 10427 | <section id="platdev-gdb-remotedebug-launch-gdb-using"> |
| 10428 | <title>Use the Debugger</title> |
| 10429 | |
| 10430 | <para> |
| 10431 | You can now proceed with debugging as normal - as if you were debugging |
| 10432 | on the local machine. |
| 10433 | For example, to instruct GDB to break in the "main" function and then |
| 10434 | continue with execution of the inferior binary use the following commands |
| 10435 | from within GDB: |
| 10436 | <literallayout class='monospaced'> |
| 10437 | (gdb) break main |
| 10438 | (gdb) continue |
| 10439 | </literallayout> |
| 10440 | </para> |
| 10441 | |
| 10442 | <para> |
| 10443 | For more information about using GDB, see the project's online documentation at |
| 10444 | <ulink url="http://sourceware.org/gdb/download/onlinedocs/"/>. |
| 10445 | </para> |
| 10446 | </section> |
| 10447 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10448 | --> |
| 10449 | |
| 10450 | <section id='debugging-with-the-gnu-project-debugger-gdb-on-the-target'> |
| 10451 | <title>Debugging with the GNU Project Debugger (GDB) on the Target</title> |
| 10452 | |
| 10453 | <para> |
| 10454 | The previous section addressed using GDB remotely for debugging |
| 10455 | purposes, which is the most usual case due to the inherent |
| 10456 | hardware limitations on many embedded devices. |
| 10457 | However, debugging in the target hardware itself is also possible |
| 10458 | with more powerful devices. |
| 10459 | This section describes what you need to do in order to support |
| 10460 | using GDB to debug on the target hardware. |
| 10461 | </para> |
| 10462 | |
| 10463 | <para> |
| 10464 | To support this kind of debugging, you need do the following: |
| 10465 | <itemizedlist> |
| 10466 | <listitem><para> |
| 10467 | Ensure that GDB is on the target. |
| 10468 | You can do this by adding "gdb" to |
| 10469 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>: |
| 10470 | <literallayout class='monospaced'> |
| 10471 | IMAGE_INSTALL_append = " gdb" |
| 10472 | </literallayout> |
| 10473 | Alternatively, you can add "tools-debug" to |
| 10474 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>: |
| 10475 | <literallayout class='monospaced'> |
| 10476 | IMAGE_FEATURES_append = " tools-debug" |
| 10477 | </literallayout> |
| 10478 | </para></listitem> |
| 10479 | <listitem><para> |
| 10480 | Ensure that debug symbols are present. |
| 10481 | You can make sure these symbols are present by installing |
| 10482 | <filename>-dbg</filename>: |
| 10483 | <literallayout class='monospaced'> |
| 10484 | IMAGE_INSTALL_append = " <replaceable>packagename</replaceable>-dbg" |
| 10485 | </literallayout> |
| 10486 | Alternatively, you can do the following to include all the |
| 10487 | debug symbols: |
| 10488 | <literallayout class='monospaced'> |
| 10489 | IMAGE_FEATURES_append = " dbg-pkgs" |
| 10490 | </literallayout> |
| 10491 | </para></listitem> |
| 10492 | </itemizedlist> |
| 10493 | <note> |
| 10494 | To improve the debug information accuracy, you can reduce the |
| 10495 | level of optimization used by the compiler. |
| 10496 | For example, when adding the following line to your |
| 10497 | <filename>local.conf</filename> file, you will reduce |
| 10498 | optimization from |
| 10499 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FULL_OPTIMIZATION'><filename>FULL_OPTIMIZATION</filename></ulink> |
| 10500 | of "-O2" to |
| 10501 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEBUG_OPTIMIZATION'><filename>DEBUG_OPTIMIZATION</filename></ulink> |
| 10502 | of "-O -fno-omit-frame-pointer": |
| 10503 | <literallayout class='monospaced'> |
| 10504 | DEBUG_BUILD = "1" |
| 10505 | </literallayout> |
| 10506 | Consider that this will reduce the application's performance |
| 10507 | and is recommended only for debugging purposes. |
| 10508 | </note> |
| 10509 | </para> |
| 10510 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10511 | |
| 10512 | <section id='debugging-parallel-make-races'> |
| 10513 | <title>Debugging Parallel Make Races</title> |
| 10514 | |
| 10515 | <para> |
| 10516 | A parallel <filename>make</filename> race occurs when the build |
| 10517 | consists of several parts that are run simultaneously and |
| 10518 | a situation occurs when the output or result of one |
| 10519 | part is not ready for use with a different part of the build that |
| 10520 | depends on that output. |
| 10521 | Parallel make races are annoying and can sometimes be difficult |
| 10522 | to reproduce and fix. |
| 10523 | However, some simple tips and tricks exist that can help |
| 10524 | you debug and fix them. |
| 10525 | This section presents a real-world example of an error encountered |
| 10526 | on the Yocto Project autobuilder and the process used to fix it. |
| 10527 | <note> |
| 10528 | If you cannot properly fix a <filename>make</filename> race |
| 10529 | condition, you can work around it by clearing either the |
| 10530 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 10531 | or |
| 10532 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKEINST'><filename>PARALLEL_MAKEINST</filename></ulink> |
| 10533 | variables. |
| 10534 | </note> |
| 10535 | </para> |
| 10536 | |
| 10537 | <section id='the-failure'> |
| 10538 | <title>The Failure</title> |
| 10539 | |
| 10540 | <para> |
| 10541 | For this example, assume that you are building an image that |
| 10542 | depends on the "neard" package. |
| 10543 | And, during the build, BitBake runs into problems and |
| 10544 | creates the following output. |
| 10545 | <note> |
| 10546 | This example log file has longer lines artificially |
| 10547 | broken to make the listing easier to read. |
| 10548 | </note> |
| 10549 | If you examine the output or the log file, you see the |
| 10550 | failure during <filename>make</filename>: |
| 10551 | <literallayout class='monospaced'> |
| 10552 | | DEBUG: SITE files ['endian-little', 'bit-32', 'ix86-common', 'common-linux', 'common-glibc', 'i586-linux', 'common'] |
| 10553 | | DEBUG: Executing shell function do_compile |
| 10554 | | NOTE: make -j 16 |
| 10555 | | make --no-print-directory all-am |
| 10556 | | /bin/mkdir -p include/near |
| 10557 | | /bin/mkdir -p include/near |
| 10558 | | /bin/mkdir -p include/near |
| 10559 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10560 | 0.14-r0/neard-0.14/include/types.h include/near/types.h |
| 10561 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10562 | 0.14-r0/neard-0.14/include/log.h include/near/log.h |
| 10563 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10564 | 0.14-r0/neard-0.14/include/plugin.h include/near/plugin.h |
| 10565 | | /bin/mkdir -p include/near |
| 10566 | | /bin/mkdir -p include/near |
| 10567 | | /bin/mkdir -p include/near |
| 10568 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10569 | 0.14-r0/neard-0.14/include/tag.h include/near/tag.h |
| 10570 | | /bin/mkdir -p include/near |
| 10571 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10572 | 0.14-r0/neard-0.14/include/adapter.h include/near/adapter.h |
| 10573 | | /bin/mkdir -p include/near |
| 10574 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10575 | 0.14-r0/neard-0.14/include/ndef.h include/near/ndef.h |
| 10576 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10577 | 0.14-r0/neard-0.14/include/tlv.h include/near/tlv.h |
| 10578 | | /bin/mkdir -p include/near |
| 10579 | | /bin/mkdir -p include/near |
| 10580 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10581 | 0.14-r0/neard-0.14/include/setting.h include/near/setting.h |
| 10582 | | /bin/mkdir -p include/near |
| 10583 | | /bin/mkdir -p include/near |
| 10584 | | /bin/mkdir -p include/near |
| 10585 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10586 | 0.14-r0/neard-0.14/include/device.h include/near/device.h |
| 10587 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10588 | 0.14-r0/neard-0.14/include/nfc_copy.h include/near/nfc_copy.h |
| 10589 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10590 | 0.14-r0/neard-0.14/include/snep.h include/near/snep.h |
| 10591 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10592 | 0.14-r0/neard-0.14/include/version.h include/near/version.h |
| 10593 | | ln -s /home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/work/i586-poky-linux/neard/ |
| 10594 | 0.14-r0/neard-0.14/include/dbus.h include/near/dbus.h |
| 10595 | | ./src/genbuiltin nfctype1 nfctype2 nfctype3 nfctype4 p2p > src/builtin.h |
| 10596 | | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/ |
| 10597 | build/build/tmp/sysroots/qemux86 -DHAVE_CONFIG_H -I. -I./include -I./src -I./gdbus -I/home/pokybuild/ |
| 10598 | yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/glib-2.0 |
| 10599 | -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/ |
| 10600 | lib/glib-2.0/include -I/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-x86/build/build/ |
| 10601 | tmp/sysroots/qemux86/usr/include/dbus-1.0 -I/home/pokybuild/yocto-autobuilder/yocto-slave/ |
| 10602 | nightly-x86/build/build/tmp/sysroots/qemux86/usr/lib/dbus-1.0/include -I/home/pokybuild/yocto-autobuilder/ |
| 10603 | yocto-slave/nightly-x86/build/build/tmp/sysroots/qemux86/usr/include/libnl3 |
| 10604 | -DNEAR_PLUGIN_BUILTIN -DPLUGINDIR=\""/usr/lib/near/plugins"\" |
| 10605 | -DCONFIGDIR=\""/etc/neard\"" -O2 -pipe -g -feliminate-unused-debug-types -c |
| 10606 | -o tools/snep-send.o tools/snep-send.c |
| 10607 | | In file included from tools/snep-send.c:16:0: |
| 10608 | | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 10609 | | #include <near/dbus.h> |
| 10610 | | ^ |
| 10611 | | compilation terminated. |
| 10612 | | make[1]: *** [tools/snep-send.o] Error 1 |
| 10613 | | make[1]: *** Waiting for unfinished jobs.... |
| 10614 | | make: *** [all] Error 2 |
| 10615 | | ERROR: oe_runmake failed |
| 10616 | </literallayout> |
| 10617 | </para> |
| 10618 | </section> |
| 10619 | |
| 10620 | <section id='reproducing-the-error'> |
| 10621 | <title>Reproducing the Error</title> |
| 10622 | |
| 10623 | <para> |
| 10624 | Because race conditions are intermittent, they do not |
| 10625 | manifest themselves every time you do the build. |
| 10626 | In fact, most times the build will complete without problems |
| 10627 | even though the potential race condition exists. |
| 10628 | Thus, once the error surfaces, you need a way to reproduce it. |
| 10629 | </para> |
| 10630 | |
| 10631 | <para> |
| 10632 | In this example, compiling the "neard" package is causing the |
| 10633 | problem. |
| 10634 | So the first thing to do is build "neard" locally. |
| 10635 | Before you start the build, set the |
| 10636 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink> |
| 10637 | variable in your <filename>local.conf</filename> file to |
| 10638 | a high number (e.g. "-j 20"). |
| 10639 | Using a high value for <filename>PARALLEL_MAKE</filename> |
| 10640 | increases the chances of the race condition showing up: |
| 10641 | <literallayout class='monospaced'> |
| 10642 | $ bitbake neard |
| 10643 | </literallayout> |
| 10644 | </para> |
| 10645 | |
| 10646 | <para> |
| 10647 | Once the local build for "neard" completes, start a |
| 10648 | <filename>devshell</filename> build: |
| 10649 | <literallayout class='monospaced'> |
| 10650 | $ bitbake neard -c devshell |
| 10651 | </literallayout> |
| 10652 | For information on how to use a |
| 10653 | <filename>devshell</filename>, see the |
| 10654 | "<link linkend='platdev-appdev-devshell'>Using a Development Shell</link>" |
| 10655 | section. |
| 10656 | </para> |
| 10657 | |
| 10658 | <para> |
| 10659 | In the <filename>devshell</filename>, do the following: |
| 10660 | <literallayout class='monospaced'> |
| 10661 | $ make clean |
| 10662 | $ make tools/snep-send.o |
| 10663 | </literallayout> |
| 10664 | The <filename>devshell</filename> commands cause the failure |
| 10665 | to clearly be visible. |
| 10666 | In this case, a missing dependency exists for the "neard" |
| 10667 | Makefile target. |
| 10668 | Here is some abbreviated, sample output with the |
| 10669 | missing dependency clearly visible at the end: |
| 10670 | <literallayout class='monospaced'> |
| 10671 | i586-poky-linux-gcc -m32 -march=i586 --sysroot=/home/scott-lenovo/...... |
| 10672 | . |
| 10673 | . |
| 10674 | . |
| 10675 | tools/snep-send.c |
| 10676 | In file included from tools/snep-send.c:16:0: |
| 10677 | tools/../src/near.h:41:23: fatal error: near/dbus.h: No such file or directory |
| 10678 | #include <near/dbus.h> |
| 10679 | ^ |
| 10680 | compilation terminated. |
| 10681 | make: *** [tools/snep-send.o] Error 1 |
| 10682 | $ |
| 10683 | </literallayout> |
| 10684 | </para> |
| 10685 | </section> |
| 10686 | |
| 10687 | <section id='creating-a-patch-for-the-fix'> |
| 10688 | <title>Creating a Patch for the Fix</title> |
| 10689 | |
| 10690 | <para> |
| 10691 | Because there is a missing dependency for the Makefile |
| 10692 | target, you need to patch the |
| 10693 | <filename>Makefile.am</filename> file, which is generated |
| 10694 | from <filename>Makefile.in</filename>. |
| 10695 | You can use Quilt to create the patch: |
| 10696 | <literallayout class='monospaced'> |
| 10697 | $ quilt new parallelmake.patch |
| 10698 | Patch patches/parallelmake.patch is now on top |
| 10699 | $ quilt add Makefile.am |
| 10700 | File Makefile.am added to patch patches/parallelmake.patch |
| 10701 | </literallayout> |
| 10702 | For more information on using Quilt, see the |
| 10703 | "<link linkend='using-a-quilt-workflow'>Using Quilt in Your Workflow</link>" |
| 10704 | section. |
| 10705 | </para> |
| 10706 | |
| 10707 | <para> |
| 10708 | At this point you need to make the edits to |
| 10709 | <filename>Makefile.am</filename> to add the missing |
| 10710 | dependency. |
| 10711 | For our example, you have to add the following line |
| 10712 | to the file: |
| 10713 | <literallayout class='monospaced'> |
| 10714 | tools/snep-send.$(OBJEXT): include/near/dbus.h |
| 10715 | </literallayout> |
| 10716 | </para> |
| 10717 | |
| 10718 | <para> |
| 10719 | Once you have edited the file, use the |
| 10720 | <filename>refresh</filename> command to create the patch: |
| 10721 | <literallayout class='monospaced'> |
| 10722 | $ quilt refresh |
| 10723 | Refreshed patch patches/parallelmake.patch |
| 10724 | </literallayout> |
| 10725 | Once the patch file exists, you need to add it back to the |
| 10726 | originating recipe folder. |
| 10727 | Here is an example assuming a top-level |
| 10728 | <link linkend='source-directory'>Source Directory</link> |
| 10729 | named <filename>poky</filename>: |
| 10730 | <literallayout class='monospaced'> |
| 10731 | $ cp patches/parallelmake.patch poky/meta/recipes-connectivity/neard/neard |
| 10732 | </literallayout> |
| 10733 | The final thing you need to do to implement the fix in the |
| 10734 | build is to update the "neard" recipe (i.e. |
| 10735 | <filename>neard-0.14.bb</filename>) so that the |
| 10736 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 10737 | statement includes the patch file. |
| 10738 | The recipe file is in the folder above the patch. |
| 10739 | Here is what the edited <filename>SRC_URI</filename> |
| 10740 | statement would look like: |
| 10741 | <literallayout class='monospaced'> |
| 10742 | SRC_URI = "${KERNELORG_MIRROR}/linux/network/nfc/${BPN}-${PV}.tar.xz \ |
| 10743 | file://neard.in \ |
| 10744 | file://neard.service.in \ |
| 10745 | file://parallelmake.patch \ |
| 10746 | " |
| 10747 | </literallayout> |
| 10748 | </para> |
| 10749 | |
| 10750 | <para> |
| 10751 | With the patch complete and moved to the correct folder and |
| 10752 | the <filename>SRC_URI</filename> statement updated, you can |
| 10753 | exit the <filename>devshell</filename>: |
| 10754 | <literallayout class='monospaced'> |
| 10755 | $ exit |
| 10756 | </literallayout> |
| 10757 | </para> |
| 10758 | </section> |
| 10759 | |
| 10760 | <section id='testing-the-build'> |
| 10761 | <title>Testing the Build</title> |
| 10762 | |
| 10763 | <para> |
| 10764 | With everything in place, you can get back to trying the |
| 10765 | build again locally: |
| 10766 | <literallayout class='monospaced'> |
| 10767 | $ bitbake neard |
| 10768 | </literallayout> |
| 10769 | This build should succeed. |
| 10770 | </para> |
| 10771 | |
| 10772 | <para> |
| 10773 | Now you can open up a <filename>devshell</filename> again |
| 10774 | and repeat the clean and make operations as follows: |
| 10775 | <literallayout class='monospaced'> |
| 10776 | $ bitbake neard -c devshell |
| 10777 | $ make clean |
| 10778 | $ make tools/snep-send.o |
| 10779 | </literallayout> |
| 10780 | The build should work without issue. |
| 10781 | </para> |
| 10782 | |
| 10783 | <para> |
| 10784 | As with all solved problems, if they originated upstream, you |
| 10785 | need to submit the fix for the recipe in OE-Core and upstream |
| 10786 | so that the problem is taken care of at its source. |
| 10787 | See the |
| 10788 | "<link linkend='how-to-submit-a-change'>How to Submit a Change</link>" |
| 10789 | section for more information. |
| 10790 | </para> |
| 10791 | </section> |
| 10792 | </section> |
| 10793 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10794 | <section id='maintaining-open-source-license-compliance-during-your-products-lifecycle'> |
| 10795 | <title>Maintaining Open Source License Compliance During Your Product's Lifecycle</title> |
| 10796 | |
| 10797 | <para> |
| 10798 | One of the concerns for a development organization using open source |
| 10799 | software is how to maintain compliance with various open source |
| 10800 | licensing during the lifecycle of the product. |
| 10801 | While this section does not provide legal advice or |
| 10802 | comprehensively cover all scenarios, it does |
| 10803 | present methods that you can use to |
| 10804 | assist you in meeting the compliance requirements during a software |
| 10805 | release. |
| 10806 | </para> |
| 10807 | |
| 10808 | <para> |
| 10809 | With hundreds of different open source licenses that the Yocto |
| 10810 | Project tracks, it is difficult to know the requirements of each |
| 10811 | and every license. |
| 10812 | However, the requirements of the major FLOSS licenses can begin |
| 10813 | to be covered by |
| 10814 | assuming that three main areas of concern exist: |
| 10815 | <itemizedlist> |
| 10816 | <listitem><para>Source code must be provided.</para></listitem> |
| 10817 | <listitem><para>License text for the software must be |
| 10818 | provided.</para></listitem> |
| 10819 | <listitem><para>Compilation scripts and modifications to the |
| 10820 | source code must be provided. |
| 10821 | </para></listitem> |
| 10822 | </itemizedlist> |
| 10823 | There are other requirements beyond the scope of these |
| 10824 | three and the methods described in this section |
| 10825 | (e.g. the mechanism through which source code is distributed). |
| 10826 | </para> |
| 10827 | |
| 10828 | <para> |
| 10829 | As different organizations have different methods of complying with |
| 10830 | open source licensing, this section is not meant to imply that |
| 10831 | there is only one single way to meet your compliance obligations, |
| 10832 | but rather to describe one method of achieving compliance. |
| 10833 | The remainder of this section describes methods supported to meet the |
| 10834 | previously mentioned three requirements. |
| 10835 | Once you take steps to meet these requirements, |
| 10836 | and prior to releasing images, sources, and the build system, |
| 10837 | you should audit all artifacts to ensure completeness. |
| 10838 | <note> |
| 10839 | The Yocto Project generates a license manifest during |
| 10840 | image creation that is located |
| 10841 | in <filename>${DEPLOY_DIR}/licenses/<replaceable>image_name-datestamp</replaceable></filename> |
| 10842 | to assist with any audits. |
| 10843 | </note> |
| 10844 | </para> |
| 10845 | |
| 10846 | <section id='providing-the-source-code'> |
| 10847 | <title>Providing the Source Code</title> |
| 10848 | |
| 10849 | <para> |
| 10850 | Compliance activities should begin before you generate the |
| 10851 | final image. |
| 10852 | The first thing you should look at is the requirement that |
| 10853 | tops the list for most compliance groups - providing |
| 10854 | the source. |
| 10855 | The Yocto Project has a few ways of meeting this |
| 10856 | requirement. |
| 10857 | </para> |
| 10858 | |
| 10859 | <para> |
| 10860 | One of the easiest ways to meet this requirement is |
| 10861 | to provide the entire |
| 10862 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> |
| 10863 | used by the build. |
| 10864 | This method, however, has a few issues. |
| 10865 | The most obvious is the size of the directory since it includes |
| 10866 | all sources used in the build and not just the source used in |
| 10867 | the released image. |
| 10868 | It will include toolchain source, and other artifacts, which |
| 10869 | you would not generally release. |
| 10870 | However, the more serious issue for most companies is accidental |
| 10871 | release of proprietary software. |
| 10872 | The Yocto Project provides an |
| 10873 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-archiver'><filename>archiver</filename></ulink> |
| 10874 | class to help avoid some of these concerns. |
| 10875 | </para> |
| 10876 | |
| 10877 | <para> |
| 10878 | Before you employ <filename>DL_DIR</filename> or the |
| 10879 | archiver class, you need to decide how you choose to |
| 10880 | provide source. |
| 10881 | The source archiver class can generate tarballs and SRPMs |
| 10882 | and can create them with various levels of compliance in mind. |
| 10883 | </para> |
| 10884 | |
| 10885 | <para> |
| 10886 | One way of doing this (but certainly not the only way) is to |
| 10887 | release just the source as a tarball. |
| 10888 | You can do this by adding the following to the |
| 10889 | <filename>local.conf</filename> file found in the |
| 10890 | <link linkend='build-directory'>Build Directory</link>: |
| 10891 | <literallayout class='monospaced'> |
| 10892 | INHERIT += "archiver" |
| 10893 | ARCHIVER_MODE[src] = "original" |
| 10894 | </literallayout> |
| 10895 | During the creation of your image, the source from all |
| 10896 | recipes that deploy packages to the image is placed within |
| 10897 | subdirectories of |
| 10898 | <filename>DEPLOY_DIR/sources</filename> based on the |
| 10899 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 10900 | for each recipe. |
| 10901 | Releasing the entire directory enables you to comply with |
| 10902 | requirements concerning providing the unmodified source. |
| 10903 | It is important to note that the size of the directory can |
| 10904 | get large. |
| 10905 | </para> |
| 10906 | |
| 10907 | <para> |
| 10908 | A way to help mitigate the size issue is to only release |
| 10909 | tarballs for licenses that require the release of |
| 10910 | source. |
| 10911 | Let us assume you are only concerned with GPL code as |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10912 | identified by running the following script: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10913 | <literallayout class='monospaced'> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10914 | # Script to archive a subset of packages matching specific license(s) |
| 10915 | # Source and license files are copied into sub folders of package folder |
| 10916 | # Must be run from build folder |
| 10917 | #!/bin/bash |
| 10918 | src_release_dir="source-release" |
| 10919 | mkdir -p $src_release_dir |
| 10920 | for a in tmp/deploy/sources/*; do |
| 10921 | for d in $a/*; do |
| 10922 | # Get package name from path |
| 10923 | p=`basename $d` |
| 10924 | p=${p%-*} |
| 10925 | p=${p%-*} |
| 10926 | # Only archive GPL packages (update *GPL* regex for your license check) |
| 10927 | numfiles=`ls tmp/deploy/licenses/$p/*GPL* 2> /dev/null | wc -l` |
| 10928 | if [ $numfiles -gt 1 ]; then |
| 10929 | echo Archiving $p |
| 10930 | mkdir -p $src_release_dir/$p/source |
| 10931 | cp $d/* $src_release_dir/$p/source 2> /dev/null |
| 10932 | mkdir -p $src_release_dir/$p/license |
| 10933 | cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null |
| 10934 | fi |
| 10935 | done |
| 10936 | done </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10937 | At this point, you could create a tarball from the |
| 10938 | <filename>gpl_source_release</filename> directory and |
| 10939 | provide that to the end user. |
| 10940 | This method would be a step toward achieving compliance |
| 10941 | with section 3a of GPLv2 and with section 6 of GPLv3. |
| 10942 | </para> |
| 10943 | </section> |
| 10944 | |
| 10945 | <section id='providing-license-text'> |
| 10946 | <title>Providing License Text</title> |
| 10947 | |
| 10948 | <para> |
| 10949 | One requirement that is often overlooked is inclusion |
| 10950 | of license text. |
| 10951 | This requirement also needs to be dealt with prior to |
| 10952 | generating the final image. |
| 10953 | Some licenses require the license text to accompany |
| 10954 | the binary. |
| 10955 | You can achieve this by adding the following to your |
| 10956 | <filename>local.conf</filename> file: |
| 10957 | <literallayout class='monospaced'> |
| 10958 | COPY_LIC_MANIFEST = "1" |
| 10959 | COPY_LIC_DIRS = "1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10960 | LICENSE_CREATE_PACKAGE = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10961 | </literallayout> |
| 10962 | Adding these statements to the configuration file ensures |
| 10963 | that the licenses collected during package generation |
| 10964 | are included on your image. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10965 | <note> |
| 10966 | <para>Setting all three variables to "1" results in the |
| 10967 | image having two copies of the same license file. |
| 10968 | One copy resides in |
| 10969 | <filename>/usr/share/common-licenses</filename> and |
| 10970 | the other resides in |
| 10971 | <filename>/usr/share/license</filename>.</para> |
| 10972 | |
| 10973 | <para>The reason for this behavior is because |
| 10974 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_DIRS'><filename>COPY_LIC_DIRS</filename></ulink> |
| 10975 | and |
| 10976 | <ulink url='&YOCTO_DOCS_REF_URL;#var-COPY_LIC_MANIFEST'><filename>COPY_LIC_MANIFEST</filename></ulink> |
| 10977 | add a copy of the license when the image is built but do not |
| 10978 | offer a path for adding licenses for newly installed packages |
| 10979 | to an image. |
| 10980 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE_CREATE_PACKAGE'><filename>LICENSE_CREATE_PACKAGE</filename></ulink> |
| 10981 | adds a separate package and an upgrade path for adding |
| 10982 | licenses to an image.</para> |
| 10983 | </note> |
| 10984 | </para> |
| 10985 | |
| 10986 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10987 | As the source archiver has already archived the original |
| 10988 | unmodified source that contains the license files, |
| 10989 | you would have already met the requirements for inclusion |
| 10990 | of the license information with source as defined by the GPL |
| 10991 | and other open source licenses. |
| 10992 | </para> |
| 10993 | </section> |
| 10994 | |
| 10995 | <section id='providing-compilation-scripts-and-source-code-modifications'> |
| 10996 | <title>Providing Compilation Scripts and Source Code Modifications</title> |
| 10997 | |
| 10998 | <para> |
| 10999 | At this point, we have addressed all we need to address |
| 11000 | prior to generating the image. |
| 11001 | The next two requirements are addressed during the final |
| 11002 | packaging of the release. |
| 11003 | </para> |
| 11004 | |
| 11005 | <para> |
| 11006 | By releasing the version of the OpenEmbedded build system |
| 11007 | and the layers used during the build, you will be providing both |
| 11008 | compilation scripts and the source code modifications in one |
| 11009 | step. |
| 11010 | </para> |
| 11011 | |
| 11012 | <para> |
| 11013 | If the deployment team has a |
| 11014 | <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP layer</ulink> |
| 11015 | and a distro layer, and those those layers are used to patch, |
| 11016 | compile, package, or modify (in any way) any open source |
| 11017 | software included in your released images, you |
| 11018 | might be required to to release those layers under section 3 of |
| 11019 | GPLv2 or section 1 of GPLv3. |
| 11020 | One way of doing that is with a clean |
| 11021 | checkout of the version of the Yocto Project and layers used |
| 11022 | during your build. |
| 11023 | Here is an example: |
| 11024 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11025 | # We built using the &DISTRO_NAME_NO_CAP; branch of the poky repo |
| 11026 | $ git clone -b &DISTRO_NAME_NO_CAP; git://git.yoctoproject.org/poky |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11027 | $ cd poky |
| 11028 | # We built using the release_branch for our layers |
| 11029 | $ git clone -b release_branch git://git.mycompany.com/meta-my-bsp-layer |
| 11030 | $ git clone -b release_branch git://git.mycompany.com/meta-my-software-layer |
| 11031 | # clean up the .git repos |
| 11032 | $ find . -name ".git" -type d -exec rm -rf {} \; |
| 11033 | </literallayout> |
| 11034 | One thing a development organization might want to consider |
| 11035 | for end-user convenience is to modify |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11036 | <filename>meta-poky/conf/bblayers.conf.sample</filename> to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11037 | ensure that when the end user utilizes the released build |
| 11038 | system to build an image, the development organization's |
| 11039 | layers are included in the <filename>bblayers.conf</filename> |
| 11040 | file automatically: |
| 11041 | <literallayout class='monospaced'> |
| 11042 | # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf |
| 11043 | # changes incompatibly |
| 11044 | LCONF_VERSION = "6" |
| 11045 | |
| 11046 | BBPATH = "${TOPDIR}" |
| 11047 | BBFILES ?= "" |
| 11048 | |
| 11049 | BBLAYERS ?= " \ |
| 11050 | ##OEROOT##/meta \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 11051 | ##OEROOT##/meta-poky \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11052 | ##OEROOT##/meta-yocto-bsp \ |
| 11053 | ##OEROOT##/meta-mylayer \ |
| 11054 | " |
| 11055 | </literallayout> |
| 11056 | Creating and providing an archive of the |
| 11057 | <link linkend='metadata'>Metadata</link> layers |
| 11058 | (recipes, configuration files, and so forth) |
| 11059 | enables you to meet your |
| 11060 | requirements to include the scripts to control compilation |
| 11061 | as well as any modifications to the original source. |
| 11062 | </para> |
| 11063 | </section> |
| 11064 | </section> |
| 11065 | |
| 11066 | <section id='using-the-error-reporting-tool'> |
| 11067 | <title>Using the Error Reporting Tool</title> |
| 11068 | |
| 11069 | <para> |
| 11070 | The error reporting tool allows you to |
| 11071 | submit errors encountered during builds to a central database. |
| 11072 | Outside of the build environment, you can use a web interface to |
| 11073 | browse errors, view statistics, and query for errors. |
| 11074 | The tool works using a client-server system where the client |
| 11075 | portion is integrated with the installed Yocto Project |
| 11076 | <link linkend='source-directory'>Source Directory</link> |
| 11077 | (e.g. <filename>poky</filename>). |
| 11078 | The server receives the information collected and saves it in a |
| 11079 | database. |
| 11080 | </para> |
| 11081 | |
| 11082 | <para> |
| 11083 | A live instance of the error reporting server exists at |
| 11084 | <ulink url='http://errors.yoctoproject.org'></ulink>. |
| 11085 | This server exists so that when you want to get help with |
| 11086 | build failures, you can submit all of the information on the |
| 11087 | failure easily and then point to the URL in your bug report |
| 11088 | or send an email to the mailing list. |
| 11089 | <note> |
| 11090 | If you send error reports to this server, the reports become |
| 11091 | publicly visible. |
| 11092 | </note> |
| 11093 | </para> |
| 11094 | |
| 11095 | <section id='enabling-and-using-the-tool'> |
| 11096 | <title>Enabling and Using the Tool</title> |
| 11097 | |
| 11098 | <para> |
| 11099 | By default, the error reporting tool is disabled. |
| 11100 | You can enable it by inheriting the |
| 11101 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-report-error'><filename>report-error</filename></ulink> |
| 11102 | class by adding the following statement to the end of |
| 11103 | your <filename>local.conf</filename> file in your |
| 11104 | <link linkend='build-directory'>Build Directory</link>. |
| 11105 | <literallayout class='monospaced'> |
| 11106 | INHERIT += "report-error" |
| 11107 | </literallayout> |
| 11108 | </para> |
| 11109 | |
| 11110 | <para> |
| 11111 | By default, the error reporting feature stores information in |
| 11112 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LOG_DIR'><filename>LOG_DIR</filename></ulink><filename>}/error-report</filename>. |
| 11113 | However, you can specify a directory to use by adding the following |
| 11114 | to your <filename>local.conf</filename> file: |
| 11115 | <literallayout class='monospaced'> |
| 11116 | ERR_REPORT_DIR = "path" |
| 11117 | </literallayout> |
| 11118 | Enabling error reporting causes the build process to collect |
| 11119 | the errors and store them in a file as previously described. |
| 11120 | When the build system encounters an error, it includes a |
| 11121 | command as part of the console output. |
| 11122 | You can run the command to send the error file to the server. |
| 11123 | For example, the following command sends the errors to an |
| 11124 | upstream server: |
| 11125 | <literallayout class='monospaced'> |
| 11126 | $ send-error-report /home/brandusa/project/poky/build/tmp/log/error-report/error_report_201403141617.txt |
| 11127 | </literallayout> |
| 11128 | In the previous example, the errors are sent to a public |
| 11129 | database available at |
| 11130 | <ulink url='http://errors.yoctoproject.org'></ulink>, which is |
| 11131 | used by the entire community. |
| 11132 | If you specify a particular server, you can send the errors |
| 11133 | to a different database. |
| 11134 | Use the following command for more information on available |
| 11135 | options: |
| 11136 | <literallayout class='monospaced'> |
| 11137 | $ send-error-report --help |
| 11138 | </literallayout> |
| 11139 | </para> |
| 11140 | |
| 11141 | <para> |
| 11142 | When sending the error file, you are prompted to review the |
| 11143 | data being sent as well as to provide a name and optional |
| 11144 | email address. |
| 11145 | Once you satisfy these prompts, the command returns a link |
| 11146 | from the server that corresponds to your entry in the database. |
| 11147 | For example, here is a typical link: |
| 11148 | <literallayout class='monospaced'> |
| 11149 | http://errors.yoctoproject.org/Errors/Details/9522/ |
| 11150 | </literallayout> |
| 11151 | Following the link takes you to a web interface where you can |
| 11152 | browse, query the errors, and view statistics. |
| 11153 | </para> |
| 11154 | </section> |
| 11155 | |
| 11156 | <section id='disabling-the-tool'> |
| 11157 | <title>Disabling the Tool</title> |
| 11158 | |
| 11159 | <para> |
| 11160 | To disable the error reporting feature, simply remove or comment |
| 11161 | out the following statement from the end of your |
| 11162 | <filename>local.conf</filename> file in your |
| 11163 | <link linkend='build-directory'>Build Directory</link>. |
| 11164 | <literallayout class='monospaced'> |
| 11165 | INHERIT += "report-error" |
| 11166 | </literallayout> |
| 11167 | </para> |
| 11168 | </section> |
| 11169 | |
| 11170 | <section id='setting-up-your-own-error-reporting-server'> |
| 11171 | <title>Setting Up Your Own Error Reporting Server</title> |
| 11172 | |
| 11173 | <para> |
| 11174 | If you want to set up your own error reporting server, you |
| 11175 | can obtain the code from the Git repository at |
| 11176 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi/error-report-web/'></ulink>. |
| 11177 | Instructions on how to set it up are in the README document. |
| 11178 | </para> |
| 11179 | </section> |
| 11180 | </section> |
| 11181 | </chapter> |
| 11182 | |
| 11183 | <!-- |
| 11184 | vim: expandtab tw=80 ts=4 |
| 11185 | --> |