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='kernel-dev-common'> |
| 6 | |
| 7 | <title>Common Tasks</title> |
| 8 | |
| 9 | <para> |
| 10 | This chapter presents several common tasks you perform when you |
| 11 | work with the Yocto Project Linux kernel. |
| 12 | These tasks include preparing a layer, modifying an existing recipe, |
| 13 | iterative development, working with your own sources, and incorporating |
| 14 | out-of-tree modules. |
| 15 | <note> |
| 16 | The examples presented in this chapter work with the Yocto Project |
| 17 | 1.2.2 Release and forward. |
| 18 | </note> |
| 19 | </para> |
| 20 | |
| 21 | <section id='creating-and-preparing-a-layer'> |
| 22 | <title>Creating and Preparing a Layer</title> |
| 23 | |
| 24 | <para> |
| 25 | If you are going to be modifying kernel recipes, it is recommended |
| 26 | that you create and prepare your own layer in which to do your |
| 27 | work. |
| 28 | Your layer contains its own |
| 29 | <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink> |
| 30 | append files |
| 31 | (<filename>.bbappend</filename>) and provides a convenient |
| 32 | mechanism to create your own recipe files |
| 33 | (<filename>.bb</filename>). |
| 34 | For details on how to create and work with layers, see the following |
| 35 | sections in the Yocto Project Development Manual: |
| 36 | <itemizedlist> |
| 37 | <listitem><para>"<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" for |
| 38 | general information on layers and how to create layers.</para></listitem> |
| 39 | <listitem><para>"<ulink url='&YOCTO_DOCS_DEV_URL;#set-up-your-layer-for-the-build'>Set Up Your Layer for the Build</ulink>" for |
| 40 | specific instructions on setting up a layer for kernel |
| 41 | development.</para></listitem> |
| 42 | </itemizedlist> |
| 43 | </para> |
| 44 | </section> |
| 45 | |
| 46 | <section id='modifying-an-existing-recipe'> |
| 47 | <title>Modifying an Existing Recipe</title> |
| 48 | |
| 49 | <para> |
| 50 | In many cases, you can customize an existing linux-yocto recipe to |
| 51 | meet the needs of your project. |
| 52 | Each release of the Yocto Project provides a few Linux |
| 53 | kernel recipes from which you can choose. |
| 54 | These are located in the |
| 55 | <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink> |
| 56 | in <filename>meta/recipes-kernel/linux</filename>. |
| 57 | </para> |
| 58 | |
| 59 | <para> |
| 60 | Modifying an existing recipe can consist of the following: |
| 61 | <itemizedlist> |
| 62 | <listitem><para>Creating the append file</para></listitem> |
| 63 | <listitem><para>Applying patches</para></listitem> |
| 64 | <listitem><para>Changing the configuration</para></listitem> |
| 65 | </itemizedlist> |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | Before modifying an existing recipe, be sure that you have created |
| 70 | a minimal, custom layer from which you can work. |
| 71 | See the "<link linkend='creating-and-preparing-a-layer'>Creating and Preparing a Layer</link>" |
| 72 | section for some general resources. |
| 73 | You can also see the |
| 74 | "<ulink url='&YOCTO_DOCS_DEV_URL;#set-up-your-layer-for-the-build'>Set Up Your Layer for the Build</ulink>" section |
| 75 | of the Yocto Project Development Manual for a detailed |
| 76 | example. |
| 77 | </para> |
| 78 | |
| 79 | <section id='creating-the-append-file'> |
| 80 | <title>Creating the Append File</title> |
| 81 | |
| 82 | <para> |
| 83 | You create this file in your custom layer. |
| 84 | You also name it accordingly based on the linux-yocto recipe |
| 85 | you are using. |
| 86 | For example, if you are modifying the |
| 87 | <filename>meta/recipes-kernel/linux/linux-yocto_3.19.bb</filename> |
| 88 | recipe, the append file will typically be located as follows |
| 89 | within your custom layer: |
| 90 | <literallayout class='monospaced'> |
| 91 | <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto_3.19.bbappend |
| 92 | </literallayout> |
| 93 | The append file should initially extend the |
| 94 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 95 | search path by prepending the directory that contains your |
| 96 | files to the |
| 97 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 98 | variable as follows: |
| 99 | <literallayout class='monospaced'> |
| 100 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 101 | </literallayout> |
| 102 | The path <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> |
| 103 | expands to "linux-yocto" in the current directory for this |
| 104 | example. |
| 105 | If you add any new files that modify the kernel recipe and you |
| 106 | have extended <filename>FILESPATH</filename> as |
| 107 | described above, you must place the files in your layer in the |
| 108 | following area: |
| 109 | <literallayout class='monospaced'> |
| 110 | <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto/ |
| 111 | </literallayout> |
| 112 | <note>If you are working on a new machine Board Support Package |
| 113 | (BSP), be sure to refer to the |
| 114 | <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>. |
| 115 | </note> |
| 116 | </para> |
| 117 | </section> |
| 118 | |
| 119 | <section id='applying-patches'> |
| 120 | <title>Applying Patches</title> |
| 121 | |
| 122 | <para> |
| 123 | If you have a single patch or a small series of patches |
| 124 | that you want to apply to the Linux kernel source, you |
| 125 | can do so just as you would with any other recipe. |
| 126 | You first copy the patches to the path added to |
| 127 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 128 | in your <filename>.bbappend</filename> file as described in |
| 129 | the previous section, and then reference them in |
| 130 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 131 | statements. |
| 132 | </para> |
| 133 | |
| 134 | <para> |
| 135 | For example, you can apply a three-patch series by adding the |
| 136 | following lines to your linux-yocto |
| 137 | <filename>.bbappend</filename> file in your layer: |
| 138 | <literallayout class='monospaced'> |
| 139 | SRC_URI += "file://0001-first-change.patch" |
| 140 | SRC_URI += "file://0002-second-change.patch" |
| 141 | SRC_URI += "file://0003-third-change.patch" |
| 142 | </literallayout> |
| 143 | The next time you run BitBake to build the Linux kernel, |
| 144 | BitBake detects the change in the recipe and fetches and |
| 145 | applies the patches before building the kernel. |
| 146 | </para> |
| 147 | |
| 148 | <para> |
| 149 | For a detailed example showing how to patch the kernel, see the |
| 150 | "<ulink url='&YOCTO_DOCS_DEV_URL;#patching-the-kernel'>Patching the Kernel</ulink>" |
| 151 | section in the Yocto Project Development Manual. |
| 152 | </para> |
| 153 | </section> |
| 154 | |
| 155 | <section id='changing-the-configuration'> |
| 156 | <title>Changing the Configuration</title> |
| 157 | |
| 158 | <para> |
| 159 | You can make wholesale or incremental changes to the final |
| 160 | <filename>.config</filename> file used for the eventual |
| 161 | Linux kernel configuration by including a |
| 162 | <filename>defconfig</filename> file and by specifying |
| 163 | configuration fragments in the |
| 164 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 165 | to be applied to that file. |
| 166 | </para> |
| 167 | |
| 168 | <para> |
| 169 | If you have a complete, working Linux kernel |
| 170 | <filename>.config</filename> |
| 171 | file you want to use for the configuration, as before, copy |
| 172 | that file to the appropriate <filename>${PN}</filename> |
| 173 | directory in your layer's |
| 174 | <filename>recipes-kernel/linux</filename> directory, |
| 175 | and rename the copied file to "defconfig". |
| 176 | Then, add the following lines to the linux-yocto |
| 177 | <filename>.bbappend</filename> file in your layer: |
| 178 | <literallayout class='monospaced'> |
| 179 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 180 | SRC_URI += "file://defconfig" |
| 181 | </literallayout> |
| 182 | The <filename>SRC_URI</filename> tells the build system how to |
| 183 | search for the file, while the |
| 184 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 185 | extends the |
| 186 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> |
| 187 | variable (search directories) to include the |
| 188 | <filename>${PN}</filename> directory you created to hold the |
| 189 | configuration changes. |
| 190 | </para> |
| 191 | |
| 192 | <note> |
| 193 | The build system applies the configurations from the |
| 194 | <filename>defconfig</filename> file before applying any |
| 195 | subsequent configuration fragments. |
| 196 | The final kernel configuration is a combination of the |
| 197 | configurations in the <filename>defconfig</filename> file and |
| 198 | any configuration fragments you provide. |
| 199 | You need to realize that if you have any configuration |
| 200 | fragments, the build system applies these on top of and |
| 201 | after applying the existing <filename>defconfig</filename> |
| 202 | file configurations. |
| 203 | </note> |
| 204 | |
| 205 | <para> |
| 206 | Generally speaking, the preferred approach is to determine the |
| 207 | incremental change you want to make and add that as a |
| 208 | configuration fragment. |
| 209 | For example, if you want to add support for a basic serial |
| 210 | console, create a file named <filename>8250.cfg</filename> in |
| 211 | the <filename>${PN}</filename> directory with the following |
| 212 | content (without indentation): |
| 213 | <literallayout class='monospaced'> |
| 214 | CONFIG_SERIAL_8250=y |
| 215 | CONFIG_SERIAL_8250_CONSOLE=y |
| 216 | CONFIG_SERIAL_8250_PCI=y |
| 217 | CONFIG_SERIAL_8250_NR_UARTS=4 |
| 218 | CONFIG_SERIAL_8250_RUNTIME_UARTS=4 |
| 219 | CONFIG_SERIAL_CORE=y |
| 220 | CONFIG_SERIAL_CORE_CONSOLE=y |
| 221 | </literallayout> |
| 222 | Next, include this configuration fragment and extend the |
| 223 | <filename>FILESPATH</filename> variable in your |
| 224 | <filename>.bbappend</filename> file: |
| 225 | <literallayout class='monospaced'> |
| 226 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 227 | SRC_URI += "file://8250.cfg" |
| 228 | </literallayout> |
| 229 | The next time you run BitBake to build the Linux kernel, BitBake |
| 230 | detects the change in the recipe and fetches and applies the |
| 231 | new configuration before building the kernel. |
| 232 | </para> |
| 233 | |
| 234 | <para> |
| 235 | For a detailed example showing how to configure the kernel, |
| 236 | see the |
| 237 | "<ulink url='&YOCTO_DOCS_DEV_URL;#configuring-the-kernel'>Configuring the Kernel</ulink>" |
| 238 | section in the Yocto Project Development Manual. |
| 239 | </para> |
| 240 | </section> |
| 241 | |
| 242 | <section id='using-an-in-tree-defconfig-file'> |
| 243 | <title>Using an "In-Tree" <filename>defconfig</filename> File</title> |
| 244 | |
| 245 | <para> |
| 246 | It might be desirable to have kernel configuration fragment |
| 247 | support through a <filename>defconfig</filename> file that |
| 248 | is pulled from the kernel source tree for the configured |
| 249 | machine. |
| 250 | By default, the OpenEmbedded build system looks for |
| 251 | <filename>defconfig</filename> files in the layer used for |
| 252 | Metadata, which is "out-of-tree", and then configures them |
| 253 | using the following: |
| 254 | <literallayout class='monospaced'> |
| 255 | SRC_URI += "file://defconfig" |
| 256 | </literallayout> |
| 257 | If you do not want to maintain copies of |
| 258 | <filename>defconfig</filename> files in your layer but would |
| 259 | rather allow users to use the default configuration from the |
| 260 | kernel tree and still be able to add configuration fragments |
| 261 | to the |
| 262 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 263 | through, for example, append files, you can direct the |
| 264 | OpenEmbedded build system to use a |
| 265 | <filename>defconfig</filename> file that is "in-tree". |
| 266 | </para> |
| 267 | |
| 268 | <para> |
| 269 | To specify an "in-tree" <filename>defconfig</filename> file, |
| 270 | edit the recipe that builds your kernel so that it has the |
| 271 | following command form: |
| 272 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 273 | KBUILD_DEFCONFIG_KMACHINE ?= <replaceable>defconfig_file</replaceable> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 274 | </literallayout> |
| 275 | You need to append the variable with |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 276 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink> |
| 277 | and then supply the path to your "in-tree" |
| 278 | <filename>defconfig</filename> file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 279 | </para> |
| 280 | |
| 281 | <para> |
| 282 | Aside from modifying your kernel recipe and providing your own |
| 283 | <filename>defconfig</filename> file, you need to be sure no |
| 284 | files or statements set <filename>SRC_URI</filename> to use a |
| 285 | <filename>defconfig</filename> other than your "in-tree" |
| 286 | file (e.g. a kernel's <filename>linux-</filename><replaceable>machine</replaceable><filename>.inc</filename> |
| 287 | file). |
| 288 | In other words, if the build system detects a statement |
| 289 | that identifies an "out-of-tree" |
| 290 | <filename>defconfig</filename> file, that statement |
| 291 | will override your |
| 292 | <filename>KBUILD_DEFCONFIG</filename> variable. |
| 293 | </para> |
| 294 | |
| 295 | <para> |
| 296 | See the |
| 297 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBUILD_DEFCONFIG'><filename>KBUILD_DEFCONFIG</filename></ulink> |
| 298 | variable description for more information. |
| 299 | </para> |
| 300 | </section> |
| 301 | </section> |
| 302 | |
| 303 | <section id='using-an-iterative-development-process'> |
| 304 | <title>Using an Iterative Development Process</title> |
| 305 | |
| 306 | <para> |
| 307 | If you do not have existing patches or configuration files, |
| 308 | you can iteratively generate them from within the BitBake build |
| 309 | environment as described within this section. |
| 310 | During an iterative workflow, running a previously completed BitBake |
| 311 | task causes BitBake to invalidate the tasks that follow the |
| 312 | completed task in the build sequence. |
| 313 | Invalidated tasks rebuild the next time you run the build using |
| 314 | BitBake. |
| 315 | </para> |
| 316 | |
| 317 | <para> |
| 318 | As you read this section, be sure to substitute the name |
| 319 | of your Linux kernel recipe for the term |
| 320 | "linux-yocto". |
| 321 | </para> |
| 322 | |
| 323 | <section id='tip-dirty-string'> |
| 324 | <title>"-dirty" String</title> |
| 325 | |
| 326 | <!-- |
| 327 | <para> |
| 328 | <emphasis>AR - Darren Hart:</emphasis> This section |
| 329 | originated from the old Yocto Project Kernel Architecture |
| 330 | and Use Manual. |
| 331 | It was decided we need to put it in this section here. |
| 332 | Darren needs to figure out where we want it and what part |
| 333 | of it we want (all, revision???) |
| 334 | </para> |
| 335 | --> |
| 336 | |
| 337 | <para> |
| 338 | If kernel images are being built with "-dirty" on the |
| 339 | end of the version string, this simply means that |
| 340 | modifications in the source directory have not been committed. |
| 341 | <literallayout class='monospaced'> |
| 342 | $ git status |
| 343 | </literallayout> |
| 344 | </para> |
| 345 | |
| 346 | <para> |
| 347 | You can use the above Git command to report modified, |
| 348 | removed, or added files. |
| 349 | You should commit those changes to the tree regardless of |
| 350 | whether they will be saved, exported, or used. |
| 351 | Once you commit the changes, you need to rebuild the kernel. |
| 352 | </para> |
| 353 | |
| 354 | <para> |
| 355 | To force a pickup and commit of all such pending changes, |
| 356 | enter the following: |
| 357 | <literallayout class='monospaced'> |
| 358 | $ git add . |
| 359 | $ git commit -s -a -m "getting rid of -dirty" |
| 360 | </literallayout> |
| 361 | </para> |
| 362 | |
| 363 | <para> |
| 364 | Next, rebuild the kernel. |
| 365 | </para> |
| 366 | </section> |
| 367 | |
| 368 | <section id='generating-configuration-files'> |
| 369 | <title>Generating Configuration Files</title> |
| 370 | |
| 371 | <para> |
| 372 | You can manipulate the <filename>.config</filename> file |
| 373 | used to build a linux-yocto recipe with the |
| 374 | <filename>menuconfig</filename> command as follows: |
| 375 | <literallayout class='monospaced'> |
| 376 | $ bitbake linux-yocto -c menuconfig |
| 377 | </literallayout> |
| 378 | This command starts the Linux kernel configuration tool, |
| 379 | which allows you to prepare a new |
| 380 | <filename>.config</filename> file for the build. |
| 381 | When you exit the tool, be sure to save your changes |
| 382 | at the prompt. |
| 383 | </para> |
| 384 | |
| 385 | <para> |
| 386 | The resulting <filename>.config</filename> file is |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 387 | located in the build directory, |
| 388 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}</filename>, |
| 389 | which expands to |
| 390 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename><filename>/linux-</filename><filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink><filename>}-build</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 391 | You can use the entire <filename>.config</filename> file as the |
| 392 | <filename>defconfig</filename> file as described in the |
| 393 | "<link linkend='changing-the-configuration'>Changing the Configuration</link>" section. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 394 | For more information on the <filename>.config</filename> file, |
| 395 | see the |
| 396 | "<ulink url='&YOCTO_DOCS_DEV_URL;#using-menuconfig'>Using <filename>menuconfig</filename></ulink>" |
| 397 | section in the Yocto Project Development Manual. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 398 | <note> |
| 399 | You can determine what a variable expands to by looking |
| 400 | at the output of the <filename>bitbake -e</filename> |
| 401 | command: |
| 402 | <literallayout class='monospaced'> |
| 403 | $ bitbake -e virtual/kernel |
| 404 | </literallayout> |
| 405 | Search the output for the variable in which you are |
| 406 | interested to see exactly how it is expanded and used. |
| 407 | </note> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 408 | </para> |
| 409 | |
| 410 | <para> |
| 411 | A better method is to create a configuration fragment using the |
| 412 | differences between two configuration files: one previously |
| 413 | created and saved, and one freshly created using the |
| 414 | <filename>menuconfig</filename> tool. |
| 415 | </para> |
| 416 | |
| 417 | <para> |
| 418 | To create a configuration fragment using this method, follow |
| 419 | these steps: |
| 420 | <orderedlist> |
| 421 | <listitem><para>Complete a build at least through the kernel |
| 422 | configuration task as follows: |
| 423 | <literallayout class='monospaced'> |
| 424 | $ bitbake linux-yocto -c kernel_configme -f |
| 425 | </literallayout> |
| 426 | This step ensures that you will be creating a |
| 427 | <filename>.config</filename> file from a known state. |
| 428 | Because situations exist where your build state might |
| 429 | become unknown, it is best to run the previous |
| 430 | command prior to starting up |
| 431 | <filename>menuconfig</filename>. |
| 432 | </para></listitem> |
| 433 | <listitem><para>Run the <filename>menuconfig</filename> |
| 434 | command: |
| 435 | <literallayout class='monospaced'> |
| 436 | $ bitbake linux-yocto -c menuconfig |
| 437 | </literallayout></para></listitem> |
| 438 | <listitem><para>Run the <filename>diffconfig</filename> |
| 439 | command to prepare a configuration fragment. |
| 440 | The resulting file <filename>fragment.cfg</filename> |
| 441 | will be placed in the |
| 442 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> directory: |
| 443 | <literallayout class='monospaced'> |
| 444 | $ bitbake linux-yocto -c diffconfig |
| 445 | </literallayout></para></listitem> |
| 446 | </orderedlist> |
| 447 | </para> |
| 448 | |
| 449 | <para> |
| 450 | The <filename>diffconfig</filename> command creates a file that is a |
| 451 | list of Linux kernel <filename>CONFIG_</filename> assignments. |
| 452 | See the "<link linkend='changing-the-configuration'>Changing the Configuration</link>" |
| 453 | section for information on how to use the output as a |
| 454 | configuration fragment. |
| 455 | <note> |
| 456 | You can also use this method to create configuration |
| 457 | fragments for a BSP. |
| 458 | See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>" |
| 459 | section for more information. |
| 460 | </note> |
| 461 | </para> |
| 462 | |
| 463 | <para> |
| 464 | The kernel tools also provide configuration validation. |
| 465 | You can use these tools to produce warnings for when a |
| 466 | requested configuration does not appear in the final |
| 467 | <filename>.config</filename> file or when you override a |
| 468 | policy configuration in a hardware configuration fragment. |
| 469 | Here is an example with some sample output of the command |
| 470 | that runs these tools: |
| 471 | <literallayout class='monospaced'> |
| 472 | $ bitbake linux-yocto -c kernel_configcheck -f |
| 473 | |
| 474 | ... |
| 475 | |
| 476 | NOTE: validating kernel configuration |
| 477 | This BSP sets 3 invalid/obsolete kernel options. |
| 478 | These config options are not offered anywhere within this kernel. |
| 479 | The full list can be found in your kernel src dir at: |
| 480 | meta/cfg/standard/mybsp/invalid.cfg |
| 481 | |
| 482 | This BSP sets 21 kernel options that are possibly non-hardware related. |
| 483 | The full list can be found in your kernel src dir at: |
| 484 | meta/cfg/standard/mybsp/specified_non_hdw.cfg |
| 485 | |
| 486 | WARNING: There were 2 hardware options requested that do not |
| 487 | have a corresponding value present in the final ".config" file. |
| 488 | This probably means you are not getting the config you wanted. |
| 489 | The full list can be found in your kernel src dir at: |
| 490 | meta/cfg/standard/mybsp/mismatch.cfg |
| 491 | </literallayout> |
| 492 | </para> |
| 493 | |
| 494 | <para> |
| 495 | The output describes the various problems that you can |
| 496 | encounter along with where to find the offending configuration |
| 497 | items. |
| 498 | You can use the information in the logs to adjust your |
| 499 | configuration files and then repeat the |
| 500 | <filename>kernel_configme</filename> and |
| 501 | <filename>kernel_configcheck</filename> commands until |
| 502 | they produce no warnings. |
| 503 | </para> |
| 504 | |
| 505 | <para> |
| 506 | For more information on how to use the |
| 507 | <filename>menuconfig</filename> tool, see the |
| 508 | "<ulink url='&YOCTO_DOCS_DEV_URL;#using-menuconfig'>Using <filename>menuconfig</filename></ulink>" |
| 509 | section in the Yocto Project Development Manual. |
| 510 | </para> |
| 511 | </section> |
| 512 | |
| 513 | <section id='modifying-source-code'> |
| 514 | <title>Modifying Source Code</title> |
| 515 | |
| 516 | <para> |
| 517 | You can experiment with source code changes and create a |
| 518 | simple patch without leaving the BitBake environment. |
| 519 | To get started, be sure to complete a build at |
| 520 | least through the kernel configuration task: |
| 521 | <literallayout class='monospaced'> |
| 522 | $ bitbake linux-yocto -c kernel_configme -f |
| 523 | </literallayout> |
| 524 | Taking this step ensures you have the sources prepared |
| 525 | and the configuration completed. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 526 | You can find the sources in the build directory within the |
| 527 | <filename>source/</filename> directory, which is a symlink |
| 528 | (i.e. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink><filename>}/source</filename>). |
| 529 | The <filename>source/</filename> directory expands to |
| 530 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename><filename>/linux-</filename><filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink><filename>}-${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink><filename>}-build/source</filename>. |
| 531 | The directory pointed to by the |
| 532 | <filename>source/</filename> symlink is also known as |
| 533 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink><filename>}</filename>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 534 | </para> |
| 535 | |
| 536 | <para> |
| 537 | You can edit the sources as you would any other Linux source |
| 538 | tree. |
| 539 | However, keep in mind that you will lose changes if you |
| 540 | trigger the |
| 541 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> |
| 542 | task for the recipe. |
| 543 | You can avoid triggering this task by not using BitBake to |
| 544 | run the |
| 545 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleanall'><filename>cleanall</filename></ulink>, |
| 546 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-cleansstate'><filename>cleansstate</filename></ulink>, |
| 547 | or forced |
| 548 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>fetch</filename></ulink> |
| 549 | commands. |
| 550 | Also, do not modify the recipe itself while working |
| 551 | with temporary changes or BitBake might run the |
| 552 | <filename>fetch</filename> command depending on the |
| 553 | changes to the recipe. |
| 554 | </para> |
| 555 | |
| 556 | <para> |
| 557 | To test your temporary changes, instruct BitBake to run the |
| 558 | <filename>compile</filename> again. |
| 559 | The <filename>-f</filename> option forces the command to run |
| 560 | even though BitBake might think it has already done so: |
| 561 | <literallayout class='monospaced'> |
| 562 | $ bitbake linux-yocto -c compile -f |
| 563 | </literallayout> |
| 564 | If the compile fails, you can update the sources and repeat |
| 565 | the <filename>compile</filename>. |
| 566 | Once compilation is successful, you can inspect and test |
| 567 | the resulting build (i.e. kernel, modules, and so forth) from |
| 568 | the following build directory: |
| 569 | <literallayout class='monospaced'> |
| 570 | ${WORKDIR}/linux-${PACKAGE_ARCH}-${LINUX_KERNEL_TYPE}-build |
| 571 | </literallayout> |
| 572 | Alternatively, you can run the <filename>deploy</filename> |
| 573 | command to place the kernel image in the |
| 574 | <filename>tmp/deploy/images</filename> directory: |
| 575 | <literallayout class='monospaced'> |
| 576 | $ bitbake linux-yocto -c deploy |
| 577 | </literallayout> |
| 578 | And, of course, you can perform the remaining installation and |
| 579 | packaging steps by issuing: |
| 580 | <literallayout class='monospaced'> |
| 581 | $ bitbake linux-yocto |
| 582 | </literallayout> |
| 583 | </para> |
| 584 | |
| 585 | <para> |
| 586 | For rapid iterative development, the edit-compile-repeat loop |
| 587 | described in this section is preferable to rebuilding the |
| 588 | entire recipe because the installation and packaging tasks |
| 589 | are very time consuming. |
| 590 | </para> |
| 591 | |
| 592 | <para> |
| 593 | Once you are satisfied with your source code modifications, |
| 594 | you can make them permanent by generating patches and |
| 595 | applying them to the |
| 596 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 597 | statement as described in the |
| 598 | "<link linkend='applying-patches'>Applying Patches</link>" |
| 599 | section. |
| 600 | If you are not familiar with generating patches, refer to the |
| 601 | "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-the-patch'>Creating the Patch</ulink>" |
| 602 | section in the Yocto Project Development Manual. |
| 603 | </para> |
| 604 | </section> |
| 605 | </section> |
| 606 | |
| 607 | <section id='working-with-your-own-sources'> |
| 608 | <title>Working With Your Own Sources</title> |
| 609 | |
| 610 | <para> |
| 611 | If you cannot work with one of the Linux kernel |
| 612 | versions supported by existing linux-yocto recipes, you can |
| 613 | still make use of the Yocto Project Linux kernel tooling by |
| 614 | working with your own sources. |
| 615 | When you use your own sources, you will not be able to |
| 616 | leverage the existing kernel |
| 617 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> and |
| 618 | stabilization work of the linux-yocto sources. |
| 619 | However, you will be able to manage your own Metadata in the same |
| 620 | format as the linux-yocto sources. |
| 621 | Maintaining format compatibility facilitates converging with |
| 622 | linux-yocto on a future, mutually-supported kernel version. |
| 623 | </para> |
| 624 | |
| 625 | <para> |
| 626 | To help you use your own sources, the Yocto Project provides a |
| 627 | linux-yocto custom recipe |
| 628 | (<filename>linux-yocto-custom.bb</filename>) that uses |
| 629 | <filename>kernel.org</filename> sources |
| 630 | and the Yocto Project Linux kernel tools for managing |
| 631 | kernel Metadata. |
| 632 | You can find this recipe in the |
| 633 | <filename>poky</filename> Git repository of the |
| 634 | Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink> |
| 635 | at: |
| 636 | <literallayout class="monospaced"> |
| 637 | poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb |
| 638 | </literallayout> |
| 639 | </para> |
| 640 | |
| 641 | <para> |
| 642 | Here are some basic steps you can use to work with your own sources: |
| 643 | <orderedlist> |
| 644 | <listitem><para>Copy the <filename>linux-yocto-custom.bb</filename> |
| 645 | recipe to your layer and give it a meaningful name. |
| 646 | The name should include the version of the Linux kernel you |
| 647 | are using (e.g. |
| 648 | <filename>linux-yocto-myproject_3.19.bb</filename>, |
| 649 | where "3.19" is the base version of the Linux kernel |
| 650 | with which you would be working).</para></listitem> |
| 651 | <listitem><para>In the same directory inside your layer, |
| 652 | create a matching directory |
| 653 | to store your patches and configuration files (e.g. |
| 654 | <filename>linux-yocto-myproject</filename>). |
| 655 | </para></listitem> |
| 656 | <listitem><para>Make sure you have either a |
| 657 | <filename>defconfig</filename> file or configuration |
| 658 | fragment files. |
| 659 | When you use the <filename>linux-yocto-custom.bb</filename> |
| 660 | recipe, you must specify a configuration. |
| 661 | If you do not have a <filename>defconfig</filename> file, |
| 662 | you can run the following: |
| 663 | <literallayout class='monospaced'> |
| 664 | $ make defconfig |
| 665 | </literallayout> |
| 666 | After running the command, copy the resulting |
| 667 | <filename>.config</filename> to the |
| 668 | <filename>files</filename> directory as "defconfig" and |
| 669 | then add it to the |
| 670 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 671 | variable in the recipe.</para> |
| 672 | <para>Running the <filename>make defconfig</filename> |
| 673 | command results in the default configuration for your |
| 674 | architecture as defined by your kernel. |
| 675 | However, no guarantee exists that this configuration is |
| 676 | valid for your use case, or that your board will even boot. |
| 677 | This is particularly true for non-x86 architectures. |
| 678 | To use non-x86 <filename>defconfig</filename> files, you |
| 679 | need to be more specific and find one that matches your |
| 680 | board (i.e. for arm, you look in |
| 681 | <filename>arch/arm/configs</filename> and use the one that |
| 682 | is the best starting point for your board). |
| 683 | </para></listitem> |
| 684 | <listitem><para>Edit the following variables in your recipe |
| 685 | as appropriate for your project: |
| 686 | <itemizedlist> |
| 687 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>: |
| 688 | The <filename>SRC_URI</filename> should specify |
| 689 | a Git repository that uses one of the supported Git |
| 690 | fetcher protocols (i.e. <filename>file</filename>, |
| 691 | <filename>git</filename>, <filename>http</filename>, |
| 692 | and so forth). |
| 693 | The <filename>SRC_URI</filename> variable should |
| 694 | also specify either a <filename>defconfig</filename> |
| 695 | file or some configuration fragment files. |
| 696 | The skeleton recipe provides an example |
| 697 | <filename>SRC_URI</filename> as a syntax reference. |
| 698 | </para></listitem> |
| 699 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION'><filename>LINUX_VERSION</filename></ulink>: |
| 700 | The Linux kernel version you are using (e.g. |
| 701 | "3.19").</para></listitem> |
| 702 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION_EXTENSION'><filename>LINUX_VERSION_EXTENSION</filename></ulink>: |
| 703 | The Linux kernel <filename>CONFIG_LOCALVERSION</filename> |
| 704 | that is compiled into the resulting kernel and visible |
| 705 | through the <filename>uname</filename> command. |
| 706 | </para></listitem> |
| 707 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>: |
| 708 | The commit ID from which you want to build. |
| 709 | </para></listitem> |
| 710 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>: |
| 711 | Treat this variable the same as you would in any other |
| 712 | recipe. |
| 713 | Increment the variable to indicate to the OpenEmbedded |
| 714 | build system that the recipe has changed. |
| 715 | </para></listitem> |
| 716 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>: |
| 717 | The default <filename>PV</filename> assignment is |
| 718 | typically adequate. |
| 719 | It combines the <filename>LINUX_VERSION</filename> |
| 720 | with the Source Control Manager (SCM) revision |
| 721 | as derived from the |
| 722 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink> |
| 723 | variable. |
| 724 | The combined results are a string with |
| 725 | the following form: |
| 726 | <literallayout class='monospaced'> |
| 727 | 3.19.11+git1+68a635bf8dfb64b02263c1ac80c948647cc76d5f_1+218bd8d2022b9852c60d32f0d770931e3cf343e2 |
| 728 | </literallayout> |
| 729 | While lengthy, the extra verbosity in <filename>PV</filename> |
| 730 | helps ensure you are using the exact |
| 731 | sources from which you intend to build. |
| 732 | </para></listitem> |
| 733 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'><filename>COMPATIBLE_MACHINE</filename></ulink>: |
| 734 | A list of the machines supported by your new recipe. |
| 735 | This variable in the example recipe is set |
| 736 | by default to a regular expression that matches |
| 737 | only the empty string, "(^$)". |
| 738 | This default setting triggers an explicit build |
| 739 | failure. |
| 740 | You must change it to match a list of the machines |
| 741 | that your new recipe supports. |
| 742 | For example, to support the <filename>qemux86</filename> |
| 743 | and <filename>qemux86-64</filename> machines, use |
| 744 | the following form: |
| 745 | <literallayout class='monospaced'> |
| 746 | COMPATIBLE_MACHINE = "qemux86|qemux86-64" |
| 747 | </literallayout></para></listitem> |
| 748 | </itemizedlist></para></listitem> |
| 749 | <listitem><para>Provide further customizations to your recipe |
| 750 | as needed just as you would customize an existing |
| 751 | linux-yocto recipe. |
| 752 | See the "<link linkend='modifying-an-existing-recipe'>Modifying |
| 753 | an Existing Recipe</link>" section for information. |
| 754 | </para></listitem> |
| 755 | </orderedlist> |
| 756 | </para> |
| 757 | </section> |
| 758 | |
| 759 | <section id='working-with-out-of-tree-modules'> |
| 760 | <title>Working with Out-of-Tree Modules</title> |
| 761 | |
| 762 | <para> |
| 763 | This section describes steps to build out-of-tree modules on |
| 764 | your target and describes how to incorporate out-of-tree modules |
| 765 | in the build. |
| 766 | </para> |
| 767 | |
| 768 | <section id='building-out-of-tree-modules-on-the-target'> |
| 769 | <title>Building Out-of-Tree Modules on the Target</title> |
| 770 | |
| 771 | <para> |
| 772 | While the traditional Yocto Project development model would be |
| 773 | to include kernel modules as part of the normal build |
| 774 | process, you might find it useful to build modules on the |
| 775 | target. |
| 776 | This could be the case if your target system is capable |
| 777 | and powerful enough to handle the necessary compilation. |
| 778 | Before deciding to build on your target, however, you should |
| 779 | consider the benefits of using a proper cross-development |
| 780 | environment from your build host. |
| 781 | </para> |
| 782 | |
| 783 | <para> |
| 784 | If you want to be able to build out-of-tree modules on |
| 785 | the target, there are some steps you need to take |
| 786 | on the target that is running your SDK image. |
| 787 | Briefly, the <filename>kernel-dev</filename> package |
| 788 | is installed by default on all |
| 789 | <filename>*.sdk</filename> images and the |
| 790 | <filename>kernel-devsrc</filename> package is installed |
| 791 | on many of the <filename>*.sdk</filename> images. |
| 792 | However, you need to create some scripts prior to |
| 793 | attempting to build the out-of-tree modules on the target |
| 794 | that is running that image. |
| 795 | </para> |
| 796 | |
| 797 | <para> |
| 798 | Prior to attempting to build the out-of-tree modules, |
| 799 | you need to be on the target as root and you need to |
| 800 | change to the <filename>/usr/src/kernel</filename> directory. |
| 801 | Next, <filename>make</filename> the scripts: |
| 802 | <literallayout class='monospaced'> |
| 803 | # cd /usr/src/kernel |
| 804 | # make scripts |
| 805 | </literallayout> |
| 806 | Because all SDK image recipes include |
| 807 | <filename>dev-pkgs</filename>, the |
| 808 | <filename>kernel-dev</filename> packages will be installed |
| 809 | as part of the SDK image and the |
| 810 | <filename>kernel-devsrc</filename> packages will be installed |
| 811 | as part of applicable SDK images. |
| 812 | The SDK uses the scripts when building out-of-tree |
| 813 | modules. |
| 814 | Once you have switched to that directory and created the |
| 815 | scripts, you should be able to build your out-of-tree modules |
| 816 | on the target. |
| 817 | </para> |
| 818 | </section> |
| 819 | |
| 820 | <section id='incorporating-out-of-tree-modules'> |
| 821 | <title>Incorporating Out-of-Tree Modules</title> |
| 822 | |
| 823 | <para> |
| 824 | While it is always preferable to work with sources integrated |
| 825 | into the Linux kernel sources, if you need an external kernel |
| 826 | module, the <filename>hello-mod.bb</filename> recipe is |
| 827 | available as a template from which you can create your |
| 828 | own out-of-tree Linux kernel module recipe. |
| 829 | </para> |
| 830 | |
| 831 | <para> |
| 832 | This template recipe is located in the |
| 833 | <filename>poky</filename> Git repository of the |
| 834 | Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink> |
| 835 | at: |
| 836 | <literallayout class="monospaced"> |
| 837 | poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb |
| 838 | </literallayout> |
| 839 | </para> |
| 840 | |
| 841 | <para> |
| 842 | To get started, copy this recipe to your layer and give it a |
| 843 | meaningful name (e.g. <filename>mymodule_1.0.bb</filename>). |
| 844 | In the same directory, create a new directory named |
| 845 | <filename>files</filename> where you can store any source files, |
| 846 | patches, or other files necessary for building |
| 847 | the module that do not come with the sources. |
| 848 | Finally, update the recipe as needed for the module. |
| 849 | Typically, you will need to set the following variables: |
| 850 | <itemizedlist> |
| 851 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> |
| 852 | </para></listitem> |
| 853 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE*</filename></ulink> |
| 854 | </para></listitem> |
| 855 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 856 | </para></listitem> |
| 857 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> |
| 858 | </para></listitem> |
| 859 | </itemizedlist> |
| 860 | </para> |
| 861 | |
| 862 | <para> |
| 863 | Depending on the build system used by the module sources, |
| 864 | you might need to make some adjustments. |
| 865 | For example, a typical module <filename>Makefile</filename> |
| 866 | looks much like the one provided with the |
| 867 | <filename>hello-mod</filename> template: |
| 868 | <literallayout class='monospaced'> |
| 869 | obj-m := hello.o |
| 870 | |
| 871 | SRC := $(shell pwd) |
| 872 | |
| 873 | all: |
| 874 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) |
| 875 | |
| 876 | modules_install: |
| 877 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install |
| 878 | ... |
| 879 | </literallayout> |
| 880 | </para> |
| 881 | |
| 882 | <para> |
| 883 | The important point to note here is the |
| 884 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_SRC'><filename>KERNEL_SRC</filename></ulink> |
| 885 | variable. |
| 886 | The |
| 887 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-module'><filename>module</filename></ulink> |
| 888 | class sets this variable and the |
| 889 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_PATH'><filename>KERNEL_PATH</filename></ulink> |
| 890 | variable to |
| 891 | <filename>${<ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>}</filename> |
| 892 | with the necessary Linux kernel build information to build |
| 893 | modules. |
| 894 | If your module <filename>Makefile</filename> uses a different |
| 895 | variable, you might want to override the |
| 896 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile()</filename></ulink> |
| 897 | step, or create a patch to |
| 898 | the <filename>Makefile</filename> to work with the more typical |
| 899 | <filename>KERNEL_SRC</filename> or |
| 900 | <filename>KERNEL_PATH</filename> variables. |
| 901 | </para> |
| 902 | |
| 903 | <para> |
| 904 | After you have prepared your recipe, you will likely want to |
| 905 | include the module in your images. |
| 906 | To do this, see the documentation for the following variables in |
| 907 | the Yocto Project Reference Manual and set one of them |
| 908 | appropriately for your machine configuration file: |
| 909 | <itemizedlist> |
| 910 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RDEPENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RDEPENDS</filename></ulink> |
| 911 | </para></listitem> |
| 912 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink> |
| 913 | </para></listitem> |
| 914 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RDEPENDS'><filename>MACHINE_EXTRA_RDEPENDS</filename></ulink> |
| 915 | </para></listitem> |
| 916 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RRECOMMENDS'><filename>MACHINE_EXTRA_RRECOMMENDS</filename></ulink> |
| 917 | </para></listitem> |
| 918 | </itemizedlist> |
| 919 | </para> |
| 920 | |
| 921 | <para> |
| 922 | Modules are often not required for boot and can be excluded from |
| 923 | certain build configurations. |
| 924 | The following allows for the most flexibility: |
| 925 | <literallayout class='monospaced'> |
| 926 | MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" |
| 927 | </literallayout> |
| 928 | The value is derived by appending the module filename without |
| 929 | the <filename>.ko</filename> extension to the string |
| 930 | "kernel-module-". |
| 931 | </para> |
| 932 | |
| 933 | <para> |
| 934 | Because the variable is |
| 935 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> |
| 936 | and not a |
| 937 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> |
| 938 | variable, the build will not fail if this module is not |
| 939 | available to include in the image. |
| 940 | </para> |
| 941 | </section> |
| 942 | </section> |
| 943 | |
| 944 | |
| 945 | <section id='inspecting-changes-and-commits'> |
| 946 | <title>Inspecting Changes and Commits</title> |
| 947 | |
| 948 | <para> |
| 949 | A common question when working with a kernel is: |
| 950 | "What changes have been applied to this tree?" |
| 951 | Rather than using "grep" across directories to see what has |
| 952 | changed, you can use Git to inspect or search the kernel tree. |
| 953 | Using Git is an efficient way to see what has changed in the tree. |
| 954 | </para> |
| 955 | |
| 956 | <section id='what-changed-in-a-kernel'> |
| 957 | <title>What Changed in a Kernel?</title> |
| 958 | |
| 959 | <para> |
| 960 | Following are a few examples that show how to use Git |
| 961 | commands to examine changes. |
| 962 | These examples are by no means the only way to see changes. |
| 963 | <note> |
| 964 | In the following examples, unless you provide a commit |
| 965 | range, <filename>kernel.org</filename> history is blended |
| 966 | with Yocto Project kernel changes. |
| 967 | You can form ranges by using branch names from the |
| 968 | kernel tree as the upper and lower commit markers with |
| 969 | the Git commands. |
| 970 | You can see the branch names through the web interface |
| 971 | to the Yocto Project source repositories at |
| 972 | <ulink url='http://git.yoctoproject.org/cgit.cgi'></ulink>. |
| 973 | </note> |
| 974 | To see a full range of the changes, use the |
| 975 | <filename>git whatchanged</filename> command and specify a |
| 976 | commit range for the branch |
| 977 | (<replaceable>commit</replaceable><filename>..</filename><replaceable>commit</replaceable>). |
| 978 | </para> |
| 979 | |
| 980 | <para> |
| 981 | Here is an example that looks at what has changed in the |
| 982 | <filename>emenlow</filename> branch of the |
| 983 | <filename>linux-yocto-3.19</filename> kernel. |
| 984 | The lower commit range is the commit associated with the |
| 985 | <filename>standard/base</filename> branch, while |
| 986 | the upper commit range is the commit associated with the |
| 987 | <filename>standard/emenlow</filename> branch. |
| 988 | <literallayout class='monospaced'> |
| 989 | $ git whatchanged origin/standard/base..origin/standard/emenlow |
| 990 | </literallayout> |
| 991 | </para> |
| 992 | |
| 993 | <para> |
| 994 | To see short, one line summaries of changes use the |
| 995 | <filename>git log</filename> command: |
| 996 | <literallayout class='monospaced'> |
| 997 | $ git log --oneline origin/standard/base..origin/standard/emenlow |
| 998 | </literallayout> |
| 999 | </para> |
| 1000 | |
| 1001 | <para> |
| 1002 | Use this command to see code differences for the changes: |
| 1003 | <literallayout class='monospaced'> |
| 1004 | $ git diff origin/standard/base..origin/standard/emenlow |
| 1005 | </literallayout> |
| 1006 | </para> |
| 1007 | |
| 1008 | <para> |
| 1009 | Use this command to see the commit log messages and the |
| 1010 | text differences: |
| 1011 | <literallayout class='monospaced'> |
| 1012 | $ git show origin/standard/base..origin/standard/emenlow |
| 1013 | </literallayout> |
| 1014 | </para> |
| 1015 | |
| 1016 | <para> |
| 1017 | Use this command to create individual patches for |
| 1018 | each change. |
| 1019 | Here is an example that that creates patch files for each |
| 1020 | commit and places them in your <filename>Documents</filename> |
| 1021 | directory: |
| 1022 | <literallayout class='monospaced'> |
| 1023 | $ git format-patch -o $HOME/Documents origin/standard/base..origin/standard/emenlow |
| 1024 | </literallayout> |
| 1025 | </para> |
| 1026 | </section> |
| 1027 | |
| 1028 | <section id='showing-a-particular-feature-or-branch-change'> |
| 1029 | <title>Showing a Particular Feature or Branch Change</title> |
| 1030 | |
| 1031 | <para> |
| 1032 | Tags in the Yocto Project kernel tree divide changes for |
| 1033 | significant features or branches. |
| 1034 | The <filename>git show</filename> <replaceable>tag</replaceable> |
| 1035 | command shows changes based on a tag. |
| 1036 | Here is an example that shows <filename>systemtap</filename> |
| 1037 | changes: |
| 1038 | <literallayout class='monospaced'> |
| 1039 | $ git show systemtap |
| 1040 | </literallayout> |
| 1041 | You can use the |
| 1042 | <filename>git branch --contains</filename> <replaceable>tag</replaceable> |
| 1043 | command to show the branches that contain a particular feature. |
| 1044 | This command shows the branches that contain the |
| 1045 | <filename>systemtap</filename> feature: |
| 1046 | <literallayout class='monospaced'> |
| 1047 | $ git branch --contains systemtap |
| 1048 | </literallayout> |
| 1049 | </para> |
| 1050 | </section> |
| 1051 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1052 | |
| 1053 | <section id='adding-recipe-space-kernel-features'> |
| 1054 | <title>Adding Recipe-Space Kernel Features</title> |
| 1055 | |
| 1056 | <para> |
| 1057 | You can add kernel features in the |
| 1058 | <link linkend='recipe-space-metadata'>recipe-space</link> by |
| 1059 | using the |
| 1060 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink> |
| 1061 | variable and by specifying the feature's <filename>.scc</filename> |
| 1062 | file path in the |
| 1063 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1064 | statement. |
| 1065 | When you add features using this method, the OpenEmbedded build |
| 1066 | system checks to be sure the features are present. |
| 1067 | If the features are not present, the build stops. |
| 1068 | Kernel features are the last elements processed for configuring |
| 1069 | and patching the kernel. |
| 1070 | Therefore, adding features in this manner is a way |
| 1071 | to enforce specific features are present and enabled |
| 1072 | without needing to do a full audit of any other layer's additions |
| 1073 | to the <filename>SRC_URI</filename> statement. |
| 1074 | </para> |
| 1075 | |
| 1076 | <para> |
| 1077 | You add a kernel feature by providing the feature as part of the |
| 1078 | <filename>KERNEL_FEATURES</filename> variable and by providing the |
| 1079 | path to the feature's <filename>.scc</filename> file, which is |
| 1080 | relative to the root of the kernel Metadata. |
| 1081 | The OpenEmbedded build system searches all forms of kernel |
| 1082 | Metadata on the <filename>SRC_URI</filename> statement regardless |
| 1083 | of whether the Metadata is in the "kernel-cache", system kernel |
| 1084 | Metadata, or a recipe-space Metadata. |
| 1085 | See the |
| 1086 | "<link linkend='kernel-metadata-location'>Kernel Metadata Location</link>" |
| 1087 | section for additional information. |
| 1088 | </para> |
| 1089 | |
| 1090 | <para> |
| 1091 | When you specify the feature's <filename>.scc</filename> file |
| 1092 | on the <filename>SRC_URI</filename> statement, the OpenEmbedded |
| 1093 | build system adds the directory of that |
| 1094 | <filename>.scc</filename> file along with all its subdirectories |
| 1095 | to the kernel feature search path. |
| 1096 | Because subdirectories are searched, you can reference a single |
| 1097 | <filename>.scc</filename> file in the |
| 1098 | <filename>SRC_URI</filename> statement to reference multiple kernel |
| 1099 | features. |
| 1100 | </para> |
| 1101 | |
| 1102 | <para> |
| 1103 | Consider the following example that adds the "test.scc" feature |
| 1104 | to the build. |
| 1105 | <orderedlist> |
| 1106 | <listitem><para> |
| 1107 | Create a <filename>.scc</filename> file and locate it |
| 1108 | just as you would any other patch file, |
| 1109 | <filename>.cfg</filename> file, or fetcher item |
| 1110 | you specify in the <filename>SRC_URI</filename> |
| 1111 | statement. |
| 1112 | <note><title>Notes</title> |
| 1113 | <itemizedlist> |
| 1114 | <listitem><para> |
| 1115 | You must add the directory of the |
| 1116 | <filename>.scc</filename> file to the fetcher's |
| 1117 | search path in the same manner as you would |
| 1118 | add a <filename>.patch</filename> file. |
| 1119 | </para></listitem> |
| 1120 | <listitem><para> |
| 1121 | You can create additional |
| 1122 | <filename>.scc</filename> files beneath the |
| 1123 | directory that contains the file you are |
| 1124 | adding. |
| 1125 | All subdirectories are searched during the |
| 1126 | build as potential feature directories. |
| 1127 | </para></listitem> |
| 1128 | </itemizedlist> |
| 1129 | </note> |
| 1130 | Continuing with the example, suppose the "test.scc" |
| 1131 | feature you are adding has a |
| 1132 | <filename>test.scc</filename> file in the following |
| 1133 | directory: |
| 1134 | <literallayout class='monospaced'> |
| 1135 | <replaceable>my_recipe</replaceable> |
| 1136 | | |
| 1137 | +-linux-yocto |
| 1138 | | |
| 1139 | +-test.cfg |
| 1140 | +-test.scc |
| 1141 | </literallayout> |
| 1142 | In this example, the <filename>linux-yocto</filename> |
| 1143 | directory has both the feature |
| 1144 | <filename>test.scc</filename> file and a similarly |
| 1145 | named configuration fragment file |
| 1146 | <filename>test.cfg</filename>. |
| 1147 | </para></listitem> |
| 1148 | <listitem><para> |
| 1149 | Add the <filename>.scc</filename> file to the |
| 1150 | recipe's <filename>SRC_URI</filename> statement: |
| 1151 | <literallayout class='monospaced'> |
| 1152 | SRC_URI_append = " file://test.scc" |
| 1153 | </literallayout> |
| 1154 | The leading space before the path is important as the |
| 1155 | path is appended to the existing path. |
| 1156 | </para></listitem> |
| 1157 | <listitem><para> |
| 1158 | Specify the feature as a kernel feature: |
| 1159 | <literallayout class='monospaced'> |
| 1160 | KERNEL_FEATURES_append = " test.scc" |
| 1161 | </literallayout> |
| 1162 | The OpenEmbedded build system processes the kernel feature |
| 1163 | when it builds the kernel. |
| 1164 | <note> |
| 1165 | If other features are contained below "test.scc", |
| 1166 | then their directories are relative to the directory |
| 1167 | containing the <filename>test.scc</filename> file. |
| 1168 | </note> |
| 1169 | </para></listitem> |
| 1170 | </orderedlist> |
| 1171 | </para> |
| 1172 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1173 | </chapter> |
| 1174 | <!-- |
| 1175 | vim: expandtab tw=80 ts=4 |
| 1176 | --> |