| 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'> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | <title>Common Tasks</title> | 
 | 7 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 |     <para> | 
 | 9 |         This chapter presents several common tasks you perform when you | 
 | 10 |         work with the Yocto Project Linux kernel. | 
 | 11 |         These tasks include preparing your host development system for | 
 | 12 |         kernel development, preparing a layer, modifying an existing recipe, | 
 | 13 |         patching the kernel, configuring the kernel, iterative development, | 
 | 14 |         working with your own sources, and incorporating out-of-tree modules. | 
 | 15 |         <note> | 
 | 16 |             The examples presented in this chapter work with the Yocto Project | 
 | 17 |             2.4 Release and forward. | 
 | 18 |         </note> | 
 | 19 |     </para> | 
 | 20 |  | 
 | 21 |     <section id='preparing-the-build-host-to-work-on-the-kernel'> | 
 | 22 |         <title>Preparing the Build Host to Work on the Kernel</title> | 
 | 23 |  | 
 | 24 |         <para> | 
 | 25 |             Before you can do any kernel development, you need to be | 
 | 26 |             sure your build host is set up to use the Yocto Project. | 
 | 27 |             For information on how to get set up, see the | 
 | 28 |             "<ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-the-development-host-to-use-the-yocto-project'>Setting Up to Use the Yocto Project</ulink>" | 
 | 29 |             section in the Yocto Project Development Tasks Manual. | 
 | 30 |             Part of preparing the system is creating a local Git | 
 | 31 |             repository of the | 
 | 32 |             <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | 
 | 33 |             (<filename>poky</filename>) on your system. | 
 | 34 |             Follow the steps in the | 
 | 35 |             "<ulink url='&YOCTO_DOCS_DEV_URL;#cloning-the-poky-repository'>Cloning the <filename>poky</filename> Repository</ulink>" | 
 | 36 |             section in the Yocto Project Development Tasks Manual to set up your | 
 | 37 |             Source Directory. | 
 | 38 |             <note> | 
 | 39 |                 Be sure you check out the appropriate development branch or | 
 | 40 |                 you create your local branch by checking out a specific tag | 
 | 41 |                 to get the desired version of Yocto Project. | 
 | 42 |                 See the | 
 | 43 |                 "<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking Out by Branch in Poky</ulink>" | 
 | 44 |                 and | 
 | 45 |                 "<ulink url='&YOCTO_DOCS_DEV_URL;#checkout-out-by-tag-in-poky'>Checking Out by Tag in Poky</ulink>" | 
 | 46 |                 sections in the Yocto Project Development Tasks Manual for more | 
 | 47 |                 information. | 
 | 48 |             </note> | 
 | 49 |         </para> | 
 | 50 |  | 
 | 51 |         <para> | 
 | 52 |             Kernel development is best accomplished using | 
 | 53 |             <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename></ulink> | 
 | 54 |             and not through traditional kernel workflow methods. | 
 | 55 |             The remainder of this section provides information for both | 
 | 56 |             scenarios. | 
 | 57 |         </para> | 
 | 58 |  | 
 | 59 |         <section id='getting-ready-to-develop-using-devtool'> | 
 | 60 |             <title>Getting Ready to Develop Using <filename>devtool</filename></title> | 
 | 61 |  | 
 | 62 |             <para> | 
 | 63 |                 Follow these steps to prepare to update the kernel image using | 
 | 64 |                 <filename>devtool</filename>. | 
 | 65 |                 Completing this procedure leaves you with a clean kernel image | 
 | 66 |                 and ready to make modifications as described in the | 
 | 67 |                 "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" | 
 | 68 |                 section: | 
 | 69 |                 <orderedlist> | 
 | 70 |                     <listitem><para> | 
 | 71 |                         <emphasis>Initialize the BitBake Environment:</emphasis> | 
 | 72 |                         Before building an extensible SDK, you need to | 
 | 73 |                         initialize the BitBake build environment by sourcing the | 
 | 74 |                         build environment script | 
 | 75 |                         (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>): | 
 | 76 |                         <literallayout class='monospaced'> | 
 | 77 |      $ cd ~/poky | 
 | 78 |      $ source oe-init-build-env | 
 | 79 |                         </literallayout> | 
 | 80 |                         <note> | 
 | 81 |                             The previous commands assume the | 
 | 82 |                             <ulink url='&YOCTO_DOCS_REF_URL;#source-repositories'>Source Repositories</ulink> | 
 | 83 |                             (i.e. <filename>poky</filename>) have been cloned | 
 | 84 |                             using Git and the local repository is named | 
 | 85 |                             "poky". | 
 | 86 |                         </note> | 
 | 87 |                         </para></listitem> | 
 | 88 |                     <listitem><para> | 
 | 89 |                         <emphasis>Prepare Your <filename>local.conf</filename> File:</emphasis> | 
 | 90 |                         By default, the | 
 | 91 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> | 
 | 92 |                         variable is set to "qemux86", which is fine if you are | 
 | 93 |                         building for the QEMU emulator in 32-bit mode. | 
 | 94 |                         However, if you are not, you need to set the | 
 | 95 |                         <filename>MACHINE</filename> variable appropriately in | 
 | 96 |                         your <filename>conf/local.conf</filename> file found in | 
 | 97 |                         the | 
 | 98 |                         <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | 
 | 99 |                         (i.e. <filename>~/poky/build</filename> in this | 
 | 100 |                         example).</para> | 
 | 101 |  | 
 | 102 |                         <para>Also, since you are preparing to work on the | 
 | 103 |                         kernel image, you need to set the | 
 | 104 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink> | 
 | 105 |                         variable to include kernel modules.</para> | 
 | 106 |  | 
 | 107 |                         <para>This example uses the default "qemux86" for the | 
 | 108 |                         <filename>MACHINE</filename> variable but needs to | 
 | 109 |                         add the "kernel-modules": | 
 | 110 |                         <literallayout class='monospaced'> | 
 | 111 |      MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" | 
 | 112 |                         </literallayout> | 
 | 113 |                         </para></listitem> | 
 | 114 |                     <listitem><para> | 
 | 115 |                         <emphasis>Create a Layer for Patches:</emphasis> | 
 | 116 |                         You need to create a layer to hold patches created | 
 | 117 |                         for the kernel image. | 
 | 118 |                         You can use the | 
 | 119 |                         <filename>bitbake-layers create-layer</filename> | 
 | 120 |                         command as follows: | 
 | 121 |                         <literallayout class='monospaced'> | 
 | 122 |      $ cd ~/poky/build | 
 | 123 |      $ bitbake-layers create-layer ../../meta-mylayer | 
 | 124 |      NOTE: Starting bitbake server... | 
 | 125 |      Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer' | 
 | 126 |      $ | 
 | 127 |                         </literallayout> | 
 | 128 |                         <note> | 
 | 129 |                             For background information on working with | 
 | 130 |                             common and BSP layers, see the | 
 | 131 |                             "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" | 
 | 132 |                             section in the Yocto Project Development Tasks | 
 | 133 |                             Manual and the | 
 | 134 |                             "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" | 
 | 135 |                             section in the Yocto Project Board Support (BSP) | 
 | 136 |                             Developer's Guide, respectively. | 
 | 137 |                             For information on how to use the | 
 | 138 |                             <filename>bitbake-layers create-layer</filename> | 
 | 139 |                             command, see the | 
 | 140 |                             "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>" | 
 | 141 |                             section in the Yocto Project Development Tasks | 
 | 142 |                             Manual. | 
 | 143 |                         </note> | 
 | 144 |                         </para></listitem> | 
 | 145 |                     <listitem><para> | 
 | 146 |                         <emphasis>Inform the BitBake Build Environment About | 
 | 147 |                         Your Layer:</emphasis> | 
 | 148 |                         As directed when you created your layer, you need to | 
 | 149 |                         add the layer to the | 
 | 150 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> | 
 | 151 |                         variable in the <filename>bblayers.conf</filename> file | 
 | 152 |                         as follows: | 
 | 153 |                         <literallayout class='monospaced'> | 
 | 154 |      $ cd ~/poky/build | 
 | 155 |      $ bitbake-layers add-layer ../../meta-mylayer | 
 | 156 |      NOTE: Starting bitbake server... | 
 | 157 |      $ | 
 | 158 |                         </literallayout> | 
 | 159 |                         </para></listitem> | 
 | 160 |                     <listitem><para> | 
 | 161 |                         <emphasis>Build the Extensible SDK:</emphasis> | 
 | 162 |                         Use BitBake to build the extensible SDK specifically | 
 | 163 |                         for use with images to be run using QEMU: | 
 | 164 |                         <literallayout class='monospaced'> | 
 | 165 |      $ cd ~/poky/build | 
 | 166 |      $ bitbake core-image-minimal -c populate_sdk_ext | 
 | 167 |                         </literallayout> | 
 | 168 |                         Once the build finishes, you can find the SDK installer | 
 | 169 |                         file (i.e. <filename>*.sh</filename> file) in the | 
 | 170 |                         following directory: | 
 | 171 |                         <literallayout class='monospaced'> | 
 | 172 |      ~/poky/build/tmp/deploy/sdk | 
 | 173 |                         </literallayout> | 
 | 174 |                         For this example, the installer file is named | 
 | 175 |                         <filename>poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh</filename> | 
 | 176 |                         </para></listitem> | 
 | 177 |                     <listitem><para> | 
 | 178 |                         <emphasis>Install the Extensible SDK:</emphasis> | 
 | 179 |                         Use the following command to install the SDK. | 
 | 180 |                         For this example, install the SDK in the default | 
 | 181 |                         <filename>~/poky_sdk</filename> directory: | 
 | 182 |                         <literallayout class='monospaced'> | 
 | 183 |      $ cd ~/poky/build/tmp/deploy/sdk | 
 | 184 |      $ ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh | 
 | 185 |      Poky (Yocto Project Reference Distro) Extensible SDK installer version &DISTRO; | 
 | 186 |      ============================================================================ | 
 | 187 |      Enter target directory for SDK (default: ~/poky_sdk): | 
 | 188 |      You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed[Y/n]? Y | 
 | 189 |      Extracting SDK......................................done | 
 | 190 |      Setting it up... | 
 | 191 |      Extracting buildtools... | 
 | 192 |      Preparing build system... | 
 | 193 |      Parsing recipes: 100% |#################################################################| Time: 0:00:52 | 
 | 194 |      Initializing tasks: 100% |############## ###############################################| Time: 0:00:04 | 
 | 195 |      Checking sstate mirror object availability: 100% |######################################| Time: 0:00:00 | 
 | 196 |      Parsing recipes: 100% |#################################################################| Time: 0:00:33 | 
 | 197 |      Initializing tasks: 100% |##############################################################| Time: 0:00:00 | 
 | 198 |      done | 
 | 199 |      SDK has been successfully set up and is ready to be used. | 
 | 200 |      Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. | 
 | 201 |       $ . /home/scottrif/poky_sdk/environment-setup-i586-poky-linux | 
 | 202 |                         </literallayout> | 
 | 203 |                         </para></listitem> | 
 | 204 |                     <listitem><para id='setting-up-the-esdk-terminal'> | 
 | 205 |                         <emphasis>Set Up a New Terminal to Work With the | 
 | 206 |                         Extensible SDK:</emphasis> | 
 | 207 |                         You must set up a new terminal to work with the SDK. | 
 | 208 |                         You cannot use the same BitBake shell used to build the | 
 | 209 |                         installer.</para> | 
 | 210 |  | 
 | 211 |                         <para>After opening a new shell, run the SDK environment | 
 | 212 |                         setup script as directed by the output from installing | 
 | 213 |                         the SDK: | 
 | 214 |                         <literallayout class='monospaced'> | 
 | 215 |      $ source ~/poky_sdk/environment-setup-i586-poky-linux | 
 | 216 |      "SDK environment now set up; additionally you may now run devtool to perform development tasks. | 
 | 217 |      Run devtool --help for further details. | 
 | 218 |                         </literallayout> | 
 | 219 |                         <note> | 
 | 220 |                             If you get a warning about attempting to use the | 
 | 221 |                             extensible SDK in an environment set up to run | 
 | 222 |                             BitBake, you did not use a new shell. | 
 | 223 |                         </note> | 
 | 224 |                         </para></listitem> | 
 | 225 |                     <listitem><para> | 
 | 226 |                         <emphasis>Build the Clean Image:</emphasis> | 
 | 227 |                         The final step in preparing to work on the kernel is to | 
 | 228 |                         build an initial image using | 
 | 229 |                         <filename>devtool</filename> in the new terminal you | 
 | 230 |                         just set up and initialized for SDK work: | 
 | 231 |                         <literallayout class='monospaced'> | 
 | 232 |      $ devtool build-image | 
 | 233 |      Parsing recipes: 100% |##########################################| Time: 0:00:05 | 
 | 234 |      Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors. | 
 | 235 |      WARNING: No packages to add, building image core-image-minimal unmodified | 
 | 236 |      Loading cache: 100% |############################################| Time: 0:00:00 | 
 | 237 |      Loaded 1299 entries from dependency cache. | 
 | 238 |      NOTE: Resolving any missing task queue dependencies | 
 | 239 |      Initializing tasks: 100% |#######################################| Time: 0:00:07 | 
 | 240 |      Checking sstate mirror object availability: 100% |###############| Time: 0:00:00 | 
 | 241 |      NOTE: Executing SetScene Tasks | 
 | 242 |      NOTE: Executing RunQueue Tasks | 
 | 243 |      NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded. | 
 | 244 |      NOTE: Successfully built core-image-minimal. You can find output files in /home/scottrif/poky_sdk/tmp/deploy/images/qemux86 | 
 | 245 |                         </literallayout> | 
 | 246 |                         If you were building for actual hardware and not for | 
 | 247 |                         emulation, you could flash the image to a USB stick | 
 | 248 |                         on <filename>/dev/sdd</filename> and boot your device. | 
 | 249 |                         For an example that uses a Minnowboard, see the | 
 | 250 |                         <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/KernelDevelopmentWithEsdk'>TipsAndTricks/KernelDevelopmentWithEsdk</ulink> | 
 | 251 |                         Wiki page. | 
 | 252 |                         </para></listitem> | 
 | 253 |                 </orderedlist> | 
 | 254 |             </para> | 
 | 255 |  | 
 | 256 |             <para> | 
 | 257 |                 At this point you have set up to start making modifications to | 
 | 258 |                 the kernel by using the extensible SDK. | 
 | 259 |                 For a continued example, see the | 
 | 260 |                 "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" | 
 | 261 |                 section. | 
 | 262 |             </para> | 
 | 263 |         </section> | 
 | 264 |  | 
 | 265 |         <section id='getting-ready-for-traditional-kernel-development'> | 
 | 266 |             <title>Getting Ready for Traditional Kernel Development</title> | 
 | 267 |  | 
 | 268 |             <para> | 
 | 269 |                 Getting ready for traditional kernel development using the Yocto | 
 | 270 |                 Project involves many of the same steps as described in the | 
 | 271 |                 previous section. | 
 | 272 |                 However, you need to establish a local copy of the kernel source | 
 | 273 |                 since you will be editing these files. | 
 | 274 |             </para> | 
 | 275 |  | 
 | 276 |             <para> | 
 | 277 |                 Follow these steps to prepare to update the kernel image using | 
 | 278 |                 traditional kernel development flow with the Yocto Project. | 
 | 279 |                 Completing this procedure leaves you ready to make modifications | 
 | 280 |                 to the kernel source as described in the | 
 | 281 |                 "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>" | 
 | 282 |                 section: | 
 | 283 |                 <orderedlist> | 
 | 284 |                     <listitem><para> | 
 | 285 |                         <emphasis>Initialize the BitBake Environment:</emphasis> | 
 | 286 |                         Before you can do anything using BitBake, you need to | 
 | 287 |                         initialize the BitBake build environment by sourcing the | 
 | 288 |                         build environment script | 
 | 289 |                         (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>). | 
 | 290 |                         Also, for this example, be sure that the local branch | 
 | 291 |                         you have checked out for <filename>poky</filename> is | 
 | 292 |                         the Yocto Project &DISTRO_NAME; branch. | 
 | 293 |                         If you need to checkout out the &DISTRO_NAME; branch, | 
 | 294 |                         see the | 
 | 295 |                         "<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking out by Branch in Poky</ulink>" | 
 | 296 |                         section in the Yocto Project Development Tasks Manual. | 
 | 297 |                         <literallayout class='monospaced'> | 
 | 298 |      $ cd ~/poky | 
 | 299 |      $ git branch | 
 | 300 |      master | 
 | 301 |      * &DISTRO_NAME; | 
 | 302 |      $ source oe-init-build-env | 
 | 303 |                         </literallayout> | 
 | 304 |                         <note> | 
 | 305 |                             The previous commands assume the | 
 | 306 |                             <ulink url='&YOCTO_DOCS_REF_URL;#source-repositories'>Source Repositories</ulink> | 
 | 307 |                             (i.e. <filename>poky</filename>) have been cloned | 
 | 308 |                             using Git and the local repository is named | 
 | 309 |                             "poky". | 
 | 310 |                         </note> | 
 | 311 |                         </para></listitem> | 
 | 312 |                     <listitem><para> | 
 | 313 |                         <emphasis>Prepare Your <filename>local.conf</filename> | 
 | 314 |                         File:</emphasis> | 
 | 315 |                         By default, the | 
 | 316 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> | 
 | 317 |                         variable is set to "qemux86", which is fine if you are | 
 | 318 |                         building for the QEMU emulator in 32-bit mode. | 
 | 319 |                         However, if you are not, you need to set the | 
 | 320 |                         <filename>MACHINE</filename> variable appropriately in | 
 | 321 |                         your <filename>conf/local.conf</filename> file found | 
 | 322 |                         in the | 
 | 323 |                         <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | 
 | 324 |                         (i.e. <filename>~/poky/build</filename> in this | 
 | 325 |                         example).</para> | 
 | 326 |  | 
 | 327 |                         <para>Also, since you are preparing to work on the | 
 | 328 |                         kernel image, you need to set the | 
 | 329 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink> | 
 | 330 |                         variable to include kernel modules.</para> | 
 | 331 |  | 
 | 332 |                         <para>This example uses the default "qemux86" for the | 
 | 333 |                         <filename>MACHINE</filename> variable but needs to | 
 | 334 |                         add the "kernel-modules": | 
 | 335 |                         <literallayout class='monospaced'> | 
 | 336 |      MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" | 
 | 337 |                         </literallayout> | 
 | 338 |                         </para></listitem> | 
 | 339 |                     <listitem><para> | 
 | 340 |                         <emphasis>Create a Layer for Patches:</emphasis> | 
 | 341 |                         You need to create a layer to hold patches created | 
 | 342 |                         for the kernel image. | 
 | 343 |                         You can use the | 
 | 344 |                         <filename>bitbake-layers create-layer</filename> | 
 | 345 |                         command as follows: | 
 | 346 |                         <literallayout class='monospaced'> | 
 | 347 |      $ cd ~/poky/build | 
 | 348 |      $ bitbake-layers create-layer ../../meta-mylayer | 
 | 349 |      NOTE: Starting bitbake server... | 
 | 350 |      Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer' | 
 | 351 |                         </literallayout> | 
 | 352 |                         <note> | 
 | 353 |                             For background information on working with | 
 | 354 |                             common and BSP layers, see the | 
 | 355 |                             "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" | 
 | 356 |                             section in the Yocto Project Development Tasks | 
 | 357 |                             Manual and the | 
 | 358 |                             "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>" | 
 | 359 |                             section in the Yocto Project Board Support (BSP) | 
 | 360 |                             Developer's Guide, respectively. | 
 | 361 |                             For information on how to use the | 
 | 362 |                             <filename>bitbake-layers create-layer</filename> | 
 | 363 |                             command, see the | 
 | 364 |                             "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>" | 
 | 365 |                             section in the Yocto Project Development Tasks | 
 | 366 |                             Manual. | 
 | 367 |                         </note> | 
 | 368 |                         </para></listitem> | 
 | 369 |                     <listitem><para> | 
 | 370 |                         <emphasis>Inform the BitBake Build Environment About | 
 | 371 |                         Your Layer:</emphasis> | 
 | 372 |                         As directed when you created your layer, you need to add | 
 | 373 |                         the layer to the | 
 | 374 |                         <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink> | 
 | 375 |                         variable in the <filename>bblayers.conf</filename> file | 
 | 376 |                         as follows: | 
 | 377 |                         <literallayout class='monospaced'> | 
 | 378 |      $ cd ~/poky/build | 
 | 379 |      $ bitbake-layers add-layer ../../meta-mylayer | 
 | 380 |      NOTE: Starting bitbake server ... | 
 | 381 |      $ | 
 | 382 |                         </literallayout> | 
 | 383 |                         </para></listitem> | 
 | 384 |                     <listitem><para> | 
 | 385 |                         <emphasis>Create a Local Copy of the Kernel Git | 
 | 386 |                         Repository:</emphasis> | 
 | 387 |                         You can find Git repositories of supported Yocto Project | 
 | 388 |                         kernels organized under "Yocto Linux Kernel" in the | 
 | 389 |                         Yocto Project Source Repositories at | 
 | 390 |                         <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>. | 
 | 391 |                         </para> | 
 | 392 |  | 
 | 393 |                         <para> | 
 | 394 |                         For simplicity, it is recommended that you create your | 
 | 395 |                         copy of the kernel Git repository outside of the | 
 | 396 |                         <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>, | 
 | 397 |                         which is usually named <filename>poky</filename>. | 
 | 398 |                         Also, be sure you are in the | 
 | 399 |                         <filename>standard/base</filename> branch. | 
 | 400 |                         </para> | 
 | 401 |  | 
 | 402 |                         <para> | 
 | 403 |                         The following commands show how to create a local copy | 
 | 404 |                         of the <filename>linux-yocto-4.12</filename> kernel and | 
 | 405 |                         be in the <filename>standard/base</filename> branch. | 
 | 406 |                         <note> | 
 | 407 |                             The <filename>linux-yocto-4.12</filename> kernel | 
 | 408 |                             can be used with the Yocto Project 2.4 release | 
 | 409 |                             and forward. | 
 | 410 |                             You cannot use the | 
 | 411 |                             <filename>linux-yocto-4.12</filename> kernel with | 
 | 412 |                             releases prior to Yocto Project 2.4: | 
 | 413 |                         </note> | 
 | 414 |                         <literallayout class='monospaced'> | 
 | 415 |      $ cd ~ | 
 | 416 |      $ git clone git://git.yoctoproject.org/linux-yocto-4.12 --branch standard/base | 
 | 417 |      Cloning into 'linux-yocto-4.12'... | 
 | 418 |      remote: Counting objects: 6097195, done. | 
 | 419 |      remote: Compressing objects: 100% (901026/901026), done. | 
 | 420 |      remote: Total 6097195 (delta 5152604), reused 6096847 (delta 5152256) | 
 | 421 |      Receiving objects: 100% (6097195/6097195), 1.24 GiB | 7.81 MiB/s, done. | 
 | 422 |      Resolving deltas: 100% (5152604/5152604), done. | 
 | 423 |      Checking connectivity... done. | 
 | 424 |      Checking out files: 100% (59846/59846), done. | 
 | 425 |                         </literallayout> | 
 | 426 |                         </para></listitem> | 
 | 427 |                     <listitem><para> | 
 | 428 |                         <emphasis>Create a Local Copy of the Kernel Cache Git | 
 | 429 |                         Repository:</emphasis> | 
 | 430 |                         For simplicity, it is recommended that you create your | 
 | 431 |                         copy of the kernel cache Git repository outside of the | 
 | 432 |                         <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>, | 
 | 433 |                         which is usually named <filename>poky</filename>. | 
 | 434 |                         Also, for this example, be sure you are in the | 
 | 435 |                         <filename>yocto-4.12</filename> branch. | 
 | 436 |                         </para> | 
 | 437 |  | 
 | 438 |                         <para> | 
 | 439 |                         The following commands show how to create a local copy | 
 | 440 |                         of the <filename>yocto-kernel-cache</filename> and | 
 | 441 |                         be in the <filename>yocto-4.12</filename> branch: | 
 | 442 |                         <literallayout class='monospaced'> | 
 | 443 |      $ cd ~ | 
 | 444 |      $ git clone git://git.yoctoproject.org/yocto-kernel-cache --branch yocto-4.12 | 
 | 445 |      Cloning into 'yocto-kernel-cache'... | 
 | 446 |      remote: Counting objects: 22639, done. | 
 | 447 |      remote: Compressing objects: 100% (9761/9761), done. | 
 | 448 |      remote: Total 22639 (delta 12400), reused 22586 (delta 12347) | 
 | 449 |      Receiving objects: 100% (22639/22639), 22.34 MiB | 6.27 MiB/s, done. | 
 | 450 |      Resolving deltas: 100% (12400/12400), done. | 
 | 451 |      Checking connectivity... done. | 
 | 452 |                         </literallayout> | 
 | 453 |                         </para></listitem> | 
 | 454 |                 </orderedlist> | 
 | 455 |             </para> | 
 | 456 |  | 
 | 457 |             <para> | 
 | 458 |                 At this point, you are ready to start making modifications to | 
 | 459 |                 the kernel using traditional kernel development steps. | 
 | 460 |                 For a continued example, see the | 
 | 461 |                 "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>" | 
 | 462 |                 section. | 
 | 463 |             </para> | 
 | 464 |         </section> | 
 | 465 |     </section> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 466 |  | 
 | 467 |     <section id='creating-and-preparing-a-layer'> | 
 | 468 |         <title>Creating and Preparing a Layer</title> | 
 | 469 |  | 
 | 470 |         <para> | 
 | 471 |             If you are going to be modifying kernel recipes, it is recommended | 
 | 472 |             that you create and prepare your own layer in which to do your | 
 | 473 |             work. | 
 | 474 |             Your layer contains its own | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 475 |             <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> | 
 | 476 |             append files (<filename>.bbappend</filename>) and provides a | 
 | 477 |             convenient mechanism to create your own recipe files | 
 | 478 |             (<filename>.bb</filename>) as well as store and use kernel | 
 | 479 |             patch files. | 
 | 480 |             For background information on working with layers, see the | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 481 |             "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 482 |             section in the Yocto Project Development Tasks Manual. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 483 |             <note><title>Tip</title> | 
 | 484 |                 The Yocto Project comes with many tools that simplify | 
 | 485 |                 tasks you need to perform. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 486 |                 One such tool is the | 
 | 487 |                 <filename>bitbake-layers create-layer</filename> | 
 | 488 |                 command, which simplifies creating a new layer. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 489 |                 See the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 490 |                 "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>" | 
 | 491 |                 section in the Yocto Project Development Tasks Manual for | 
 | 492 |                 information on how to use this script. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 493 |             </note> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 494 |         </para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 495 |  | 
 | 496 |         <para> | 
 | 497 |             To better understand the layer you create for kernel development, | 
 | 498 |             the following section describes how to create a layer | 
 | 499 |             without the aid of tools. | 
 | 500 |             These steps assume creation of a layer named | 
 | 501 |             <filename>mylayer</filename> in your home directory: | 
 | 502 |             <orderedlist> | 
 | 503 |                 <listitem><para> | 
 | 504 |                     <emphasis>Create Structure</emphasis>: | 
 | 505 |                     Create the layer's structure: | 
 | 506 |                     <literallayout class='monospaced'> | 
 | 507 |      $ cd $HOME | 
 | 508 |      $ mkdir meta-mylayer | 
 | 509 |      $ mkdir meta-mylayer/conf | 
 | 510 |      $ mkdir meta-mylayer/recipes-kernel | 
 | 511 |      $ mkdir meta-mylayer/recipes-kernel/linux | 
 | 512 |      $ mkdir meta-mylayer/recipes-kernel/linux/linux-yocto | 
 | 513 |                     </literallayout> | 
 | 514 |                     The <filename>conf</filename> directory holds your | 
 | 515 |                     configuration files, while the | 
 | 516 |                     <filename>recipes-kernel</filename> directory holds your | 
 | 517 |                     append file and eventual patch files. | 
 | 518 |                     </para></listitem> | 
 | 519 |                 <listitem><para> | 
 | 520 |                     <emphasis>Create the Layer Configuration File</emphasis>: | 
 | 521 |                     Move to the <filename>meta-mylayer/conf</filename> | 
 | 522 |                     directory and create the <filename>layer.conf</filename> | 
 | 523 |                     file as follows: | 
 | 524 |                     <literallayout class='monospaced'> | 
 | 525 |      # We have a conf and classes directory, add to BBPATH | 
 | 526 |      BBPATH .= ":${LAYERDIR}" | 
 | 527 |  | 
 | 528 |      # We have recipes-* directories, add to BBFILES | 
 | 529 |      BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ | 
 | 530 |                  ${LAYERDIR}/recipes-*/*/*.bbappend" | 
 | 531 |  | 
 | 532 |      BBFILE_COLLECTIONS += "mylayer" | 
 | 533 |      BBFILE_PATTERN_mylayer = "^${LAYERDIR}/" | 
 | 534 |      BBFILE_PRIORITY_mylayer = "5" | 
 | 535 |                     </literallayout> | 
 | 536 |                     Notice <filename>mylayer</filename> as part of the last | 
 | 537 |                     three statements. | 
 | 538 |                     </para></listitem> | 
 | 539 |                 <listitem><para> | 
 | 540 |                     <emphasis>Create the Kernel Recipe Append File</emphasis>: | 
 | 541 |                     Move to the | 
 | 542 |                     <filename>meta-mylayer/recipes-kernel/linux</filename> | 
 | 543 |                     directory and create the kernel's append file. | 
 | 544 |                     This example uses the | 
 | 545 |                     <filename>linux-yocto-4.12</filename> kernel. | 
 | 546 |                     Thus, the name of the append file is | 
 | 547 |                     <filename>linux-yocto_4.12.bbappend</filename>: | 
 | 548 |                     <literallayout class='monospaced'> | 
 | 549 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 550 |  | 
 | 551 |      SRC_URI_append += "file://<replaceable>patch-file-one</replaceable>" | 
 | 552 |      SRC_URI_append += "file://<replaceable>patch-file-two</replaceable>" | 
 | 553 |      SRC_URI_append += "file://<replaceable>patch-file-three</replaceable>" | 
 | 554 |                     </literallayout> | 
 | 555 |                     The | 
 | 556 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 557 |                     and | 
 | 558 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 559 |                     statements enable the OpenEmbedded build system to find | 
 | 560 |                     patch files. | 
 | 561 |                     For more information on using append files, see the | 
 | 562 |                     "<ulink url='&YOCTO_DOCS_DEV_URL;#using-bbappend-files'>Using .bbappend Files in Your Layer</ulink>" | 
 | 563 |                     section in the Yocto Project Development Tasks Manual. | 
 | 564 |                     </para></listitem> | 
 | 565 |             </orderedlist> | 
 | 566 |         </para> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 567 |     </section> | 
 | 568 |  | 
 | 569 |     <section id='modifying-an-existing-recipe'> | 
 | 570 |         <title>Modifying an Existing Recipe</title> | 
 | 571 |  | 
 | 572 |         <para> | 
 | 573 |             In many cases, you can customize an existing linux-yocto recipe to | 
 | 574 |             meet the needs of your project. | 
 | 575 |             Each release of the Yocto Project provides a few Linux | 
 | 576 |             kernel recipes from which you can choose. | 
 | 577 |             These are located in the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 578 |             <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 579 |             in <filename>meta/recipes-kernel/linux</filename>. | 
 | 580 |         </para> | 
 | 581 |  | 
 | 582 |         <para> | 
 | 583 |             Modifying an existing recipe can consist of the following: | 
 | 584 |             <itemizedlist> | 
 | 585 |                 <listitem><para>Creating the append file</para></listitem> | 
 | 586 |                 <listitem><para>Applying patches</para></listitem> | 
 | 587 |                 <listitem><para>Changing the configuration</para></listitem> | 
 | 588 |             </itemizedlist> | 
 | 589 |         </para> | 
 | 590 |  | 
 | 591 |         <para> | 
 | 592 |             Before modifying an existing recipe, be sure that you have created | 
 | 593 |             a minimal, custom layer from which you can work. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 594 |             See the | 
 | 595 |             "<link linkend='creating-and-preparing-a-layer'>Creating and Preparing a Layer</link>" | 
 | 596 |             section for information. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 597 |         </para> | 
 | 598 |  | 
 | 599 |         <section id='creating-the-append-file'> | 
 | 600 |             <title>Creating the Append File</title> | 
 | 601 |  | 
 | 602 |             <para> | 
 | 603 |                 You create this file in your custom layer. | 
 | 604 |                 You also name it accordingly based on the linux-yocto recipe | 
 | 605 |                 you are using. | 
 | 606 |                 For example, if you are modifying the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 607 |                 <filename>meta/recipes-kernel/linux/linux-yocto_4.12.bb</filename> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 608 |                 recipe, the append file will typically be located as follows | 
 | 609 |                 within your custom layer: | 
 | 610 |                 <literallayout class='monospaced'> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 611 |      <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto_4.12.bbappend | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 612 |                 </literallayout> | 
 | 613 |                 The append file should initially extend the | 
 | 614 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> | 
 | 615 |                 search path by prepending the directory that contains your | 
 | 616 |                 files to the | 
 | 617 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 618 |                 variable as follows: | 
 | 619 |                 <literallayout class='monospaced'> | 
 | 620 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 621 |                 </literallayout> | 
 | 622 |                 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> | 
 | 623 |                 expands to "linux-yocto" in the current directory for this | 
 | 624 |                 example. | 
 | 625 |                 If you add any new files that modify the kernel recipe and you | 
 | 626 |                 have extended <filename>FILESPATH</filename> as | 
 | 627 |                 described above, you must place the files in your layer in the | 
 | 628 |                 following area: | 
 | 629 |                 <literallayout class='monospaced'> | 
 | 630 |      <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto/ | 
 | 631 |                 </literallayout> | 
 | 632 |                 <note>If you are working on a new machine Board Support Package | 
 | 633 |                     (BSP), be sure to refer to the | 
 | 634 |                     <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>. | 
 | 635 |                 </note> | 
 | 636 |             </para> | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 637 |  | 
 | 638 |             <para> | 
 | 639 |                 As an example, consider the following append file | 
 | 640 |                 used by the BSPs in <filename>meta-yocto-bsp</filename>: | 
 | 641 |                 <literallayout class='monospaced'> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 642 |      meta-yocto-bsp/recipes-kernel/linux/linux-yocto_4.12.bbappend | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 643 |                 </literallayout> | 
 | 644 |                 The following listing shows the file. | 
 | 645 |                 Be aware that the actual commit ID strings in this | 
 | 646 |                 example listing might be different than the actual strings | 
 | 647 |                 in the file from the <filename>meta-yocto-bsp</filename> | 
 | 648 |                 layer upstream. | 
 | 649 |                 <literallayout class='monospaced'> | 
 | 650 |      KBRANCH_genericx86  = "standard/base" | 
 | 651 |      KBRANCH_genericx86-64  = "standard/base" | 
 | 652 |  | 
 | 653 |      KMACHINE_genericx86 ?= "common-pc" | 
 | 654 |      KMACHINE_genericx86-64 ?= "common-pc-64" | 
 | 655 |      KBRANCH_edgerouter = "standard/edgerouter" | 
 | 656 |      KBRANCH_beaglebone = "standard/beaglebone" | 
 | 657 |      KBRANCH_mpc8315e-rdb = "standard/fsl-mpc8315e-rdb" | 
 | 658 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 659 |      SRCREV_machine_genericx86    ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19" | 
 | 660 |      SRCREV_machine_genericx86-64 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19" | 
 | 661 |      SRCREV_machine_edgerouter ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d" | 
 | 662 |      SRCREV_machine_beaglebone ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d" | 
 | 663 |      SRCREV_machine_mpc8315e-rdb ?= "2d1d010240846d7bff15d1fcc0cb6eb8a22fc78a" | 
 | 664 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 665 |  | 
 | 666 |      COMPATIBLE_MACHINE_genericx86 = "genericx86" | 
 | 667 |      COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64" | 
 | 668 |      COMPATIBLE_MACHINE_edgerouter = "edgerouter" | 
 | 669 |      COMPATIBLE_MACHINE_beaglebone = "beaglebone" | 
 | 670 |      COMPATIBLE_MACHINE_mpc8315e-rdb = "mpc8315e-rdb" | 
 | 671 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 672 |      LINUX_VERSION_genericx86 = "4.12.7" | 
 | 673 |      LINUX_VERSION_genericx86-64 = "4.12.7" | 
 | 674 |      LINUX_VERSION_edgerouter = "4.12.10" | 
 | 675 |      LINUX_VERSION_beaglebone = "4.12.10" | 
 | 676 |      LINUX_VERSION_mpc8315e-rdb = "4.12.10" | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 677 |                 </literallayout> | 
 | 678 |                 This append file contains statements used to support | 
 | 679 |                 several BSPs that ship with the Yocto Project. | 
 | 680 |                 The file defines machines using the | 
 | 681 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'><filename>COMPATIBLE_MACHINE</filename></ulink> | 
 | 682 |                 variable and uses the | 
 | 683 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink> | 
 | 684 |                 variable to ensure the machine name used by the OpenEmbedded | 
 | 685 |                 build system maps to the machine name used by the Linux Yocto | 
 | 686 |                 kernel. | 
 | 687 |                 The file also uses the optional | 
 | 688 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> | 
 | 689 |                 variable to ensure the build process uses the | 
 | 690 |                 appropriate kernel branch. | 
 | 691 |             </para> | 
 | 692 |  | 
 | 693 |             <para> | 
 | 694 |                 Although this particular example does not use it, the | 
 | 695 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink> | 
 | 696 |                 variable could be used to enable features specific to | 
 | 697 |                 the kernel. | 
 | 698 |                 The append file points to specific commits in the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 699 |                 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 700 |                 Git repository and the <filename>meta</filename> Git repository | 
 | 701 |                 branches to identify the exact kernel needed to build the | 
 | 702 |                 BSP. | 
 | 703 |             </para> | 
 | 704 |  | 
 | 705 |             <para> | 
 | 706 |                 One thing missing in this particular BSP, which you will | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 707 |                 typically need when developing a BSP, is the kernel | 
 | 708 |                 configuration file (<filename>.config</filename>) for your BSP. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 709 |                 When developing a BSP, you probably have a kernel configuration | 
 | 710 |                 file or a set of kernel configuration files that, when taken | 
 | 711 |                 together, define the kernel configuration for your BSP. | 
 | 712 |                 You can accomplish this definition by putting the configurations | 
 | 713 |                 in a file or a set of files inside a directory located at the | 
 | 714 |                 same level as your kernel's append file and having the same | 
 | 715 |                 name as the kernel's main recipe file. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 716 |                 With all these conditions met, simply reference those files in | 
 | 717 |                 the | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 718 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 719 |                 statement in the append file. | 
 | 720 |             </para> | 
 | 721 |  | 
 | 722 |             <para> | 
 | 723 |                 For example, suppose you had some configuration options | 
 | 724 |                 in a file called <filename>network_configs.cfg</filename>. | 
 | 725 |                 You can place that file inside a directory named | 
 | 726 |                 <filename>linux-yocto</filename> and then add | 
 | 727 |                 a <filename>SRC_URI</filename> statement such as the | 
 | 728 |                 following to the append file. | 
 | 729 |                 When the OpenEmbedded build system builds the kernel, the | 
 | 730 |                 configuration options are picked up and applied. | 
 | 731 |                 <literallayout class='monospaced'> | 
 | 732 |      SRC_URI += "file://network_configs.cfg" | 
 | 733 |                 </literallayout> | 
 | 734 |             </para> | 
 | 735 |  | 
 | 736 |             <para> | 
 | 737 |                 To group related configurations into multiple files, you | 
 | 738 |                 perform a similar procedure. | 
 | 739 |                 Here is an example that groups separate configurations | 
 | 740 |                 specifically for Ethernet and graphics into their own | 
 | 741 |                 files and adds the configurations by using a | 
 | 742 |                 <filename>SRC_URI</filename> statement like the following | 
 | 743 |                 in your append file: | 
 | 744 |                 <literallayout class='monospaced'> | 
 | 745 |      SRC_URI += "file://myconfig.cfg \ | 
 | 746 |                  file://eth.cfg \ | 
 | 747 |                  file://gfx.cfg" | 
 | 748 |                 </literallayout> | 
 | 749 |             </para> | 
 | 750 |  | 
 | 751 |             <para> | 
 | 752 |                 Another variable you can use in your kernel recipe append | 
 | 753 |                 file is the | 
 | 754 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 755 |                 variable. | 
 | 756 |                 When you use this statement, you are extending the locations | 
 | 757 |                 used by the OpenEmbedded system to look for files and | 
 | 758 |                 patches as the recipe is processed. | 
 | 759 |             </para> | 
 | 760 |  | 
 | 761 |             <note> | 
 | 762 |                 <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 763 |                     Other methods exist to accomplish grouping and defining | 
 | 764 |                     configuration options. | 
 | 765 |                     For example, if you are working with a local clone of the | 
 | 766 |                     kernel repository, you could checkout the kernel's | 
 | 767 |                     <filename>meta</filename> branch, make your changes, and | 
 | 768 |                     then push the changes to the local bare clone of the | 
 | 769 |                     kernel. | 
 | 770 |                     The result is that you directly add configuration options | 
 | 771 |                     to the <filename>meta</filename> branch for your BSP. | 
 | 772 |                     The configuration options will likely end up in that | 
 | 773 |                     location anyway if the BSP gets added to the Yocto Project. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 774 |                 </para> | 
 | 775 |  | 
 | 776 |                 <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 777 |                     In general, however, the Yocto Project maintainers take | 
 | 778 |                     care of moving the <filename>SRC_URI</filename>-specified | 
 | 779 |                     configuration options to the kernel's | 
 | 780 |                     <filename>meta</filename> branch. | 
 | 781 |                     Not only is it easier for BSP developers to not have to | 
 | 782 |                     worry about putting those configurations in the branch, | 
 | 783 |                     but having the maintainers do it allows them to apply | 
 | 784 |                     'global' knowledge about the kinds of common configuration | 
 | 785 |                     options multiple BSPs in the tree are typically using. | 
 | 786 |                     This allows for promotion of common configurations into | 
 | 787 |                     common features. | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 788 |                 </para> | 
 | 789 |             </note> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 790 |         </section> | 
 | 791 |  | 
 | 792 |         <section id='applying-patches'> | 
 | 793 |             <title>Applying Patches</title> | 
 | 794 |  | 
 | 795 |             <para> | 
 | 796 |                 If you have a single patch or a small series of patches | 
 | 797 |                 that you want to apply to the Linux kernel source, you | 
 | 798 |                 can do so just as you would with any other recipe. | 
 | 799 |                 You first copy the patches to the path added to | 
 | 800 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 801 |                 in your <filename>.bbappend</filename> file as described in | 
 | 802 |                 the previous section, and then reference them in | 
 | 803 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 804 |                 statements. | 
 | 805 |             </para> | 
 | 806 |  | 
 | 807 |             <para> | 
 | 808 |                 For example, you can apply a three-patch series by adding the | 
 | 809 |                 following lines to your linux-yocto | 
 | 810 |                 <filename>.bbappend</filename> file in your layer: | 
 | 811 |                 <literallayout class='monospaced'> | 
 | 812 |      SRC_URI += "file://0001-first-change.patch" | 
 | 813 |      SRC_URI += "file://0002-second-change.patch" | 
 | 814 |      SRC_URI += "file://0003-third-change.patch" | 
 | 815 |                 </literallayout> | 
 | 816 |                 The next time you run BitBake to build the Linux kernel, | 
 | 817 |                 BitBake detects the change in the recipe and fetches and | 
 | 818 |                 applies the patches before building the kernel. | 
 | 819 |             </para> | 
 | 820 |  | 
 | 821 |             <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 822 |                 For a detailed example showing how to patch the kernel using | 
 | 823 |                 <filename>devtool</filename>, see the | 
 | 824 |                 "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" | 
 | 825 |                 and | 
 | 826 |                 "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>" | 
 | 827 |                 sections. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 828 |             </para> | 
 | 829 |         </section> | 
 | 830 |  | 
 | 831 |         <section id='changing-the-configuration'> | 
 | 832 |             <title>Changing the Configuration</title> | 
 | 833 |  | 
 | 834 |             <para> | 
 | 835 |                 You can make wholesale or incremental changes to the final | 
 | 836 |                 <filename>.config</filename> file used for the eventual | 
 | 837 |                 Linux kernel configuration by including a | 
 | 838 |                 <filename>defconfig</filename> file and by specifying | 
 | 839 |                 configuration fragments in the | 
 | 840 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 841 |                 to be applied to that file. | 
 | 842 |             </para> | 
 | 843 |  | 
 | 844 |             <para> | 
 | 845 |                 If you have a complete, working Linux kernel | 
 | 846 |                 <filename>.config</filename> | 
 | 847 |                 file you want to use for the configuration, as before, copy | 
 | 848 |                 that file to the appropriate <filename>${PN}</filename> | 
 | 849 |                 directory in your layer's | 
 | 850 |                 <filename>recipes-kernel/linux</filename> directory, | 
 | 851 |                 and rename the copied file to "defconfig". | 
 | 852 |                 Then, add the following lines to the linux-yocto | 
 | 853 |                 <filename>.bbappend</filename> file in your layer: | 
 | 854 |                 <literallayout class='monospaced'> | 
 | 855 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 856 |      SRC_URI += "file://defconfig" | 
 | 857 |                 </literallayout> | 
 | 858 |                 The <filename>SRC_URI</filename> tells the build system how to | 
 | 859 |                 search for the file, while the | 
 | 860 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 861 |                 extends the | 
 | 862 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> | 
 | 863 |                 variable (search directories) to include the | 
 | 864 |                 <filename>${PN}</filename> directory you created to hold the | 
 | 865 |                 configuration changes. | 
 | 866 |             </para> | 
 | 867 |  | 
 | 868 |             <note> | 
 | 869 |                 The build system applies the configurations from the | 
 | 870 |                 <filename>defconfig</filename> file before applying any | 
 | 871 |                 subsequent configuration fragments. | 
 | 872 |                 The final kernel configuration is a combination of the | 
 | 873 |                 configurations in the <filename>defconfig</filename> file and | 
 | 874 |                 any configuration fragments you provide. | 
 | 875 |                 You need to realize that if you have any configuration | 
 | 876 |                 fragments, the build system applies these on top of and | 
 | 877 |                 after applying the existing <filename>defconfig</filename> | 
 | 878 |                 file configurations. | 
 | 879 |             </note> | 
 | 880 |  | 
 | 881 |             <para> | 
 | 882 |                 Generally speaking, the preferred approach is to determine the | 
 | 883 |                 incremental change you want to make and add that as a | 
 | 884 |                 configuration fragment. | 
 | 885 |                 For example, if you want to add support for a basic serial | 
 | 886 |                 console, create a file named <filename>8250.cfg</filename> in | 
 | 887 |                 the <filename>${PN}</filename> directory with the following | 
 | 888 |                 content (without indentation): | 
 | 889 |                 <literallayout class='monospaced'> | 
 | 890 |      CONFIG_SERIAL_8250=y | 
 | 891 |      CONFIG_SERIAL_8250_CONSOLE=y | 
 | 892 |      CONFIG_SERIAL_8250_PCI=y | 
 | 893 |      CONFIG_SERIAL_8250_NR_UARTS=4 | 
 | 894 |      CONFIG_SERIAL_8250_RUNTIME_UARTS=4 | 
 | 895 |      CONFIG_SERIAL_CORE=y | 
 | 896 |      CONFIG_SERIAL_CORE_CONSOLE=y | 
 | 897 |                 </literallayout> | 
 | 898 |                 Next, include this configuration fragment and extend the | 
 | 899 |                 <filename>FILESPATH</filename> variable in your | 
 | 900 |                 <filename>.bbappend</filename> file: | 
 | 901 |                 <literallayout class='monospaced'> | 
 | 902 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 903 |      SRC_URI += "file://8250.cfg" | 
 | 904 |                 </literallayout> | 
 | 905 |                 The next time you run BitBake to build the Linux kernel, BitBake | 
 | 906 |                 detects the change in the recipe and fetches and applies the | 
 | 907 |                 new configuration before building the kernel. | 
 | 908 |             </para> | 
 | 909 |  | 
 | 910 |             <para> | 
 | 911 |                 For a detailed example showing how to configure the kernel, | 
 | 912 |                 see the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 913 |                 "<link linkend='configuring-the-kernel'>Configuring the Kernel</link>" | 
 | 914 |                 section. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 915 |             </para> | 
 | 916 |         </section> | 
 | 917 |  | 
 | 918 |         <section id='using-an-in-tree-defconfig-file'> | 
 | 919 |             <title>Using an "In-Tree"  <filename>defconfig</filename> File</title> | 
 | 920 |  | 
 | 921 |             <para> | 
 | 922 |                 It might be desirable to have kernel configuration fragment | 
 | 923 |                 support through a <filename>defconfig</filename> file that | 
 | 924 |                 is pulled from the kernel source tree for the configured | 
 | 925 |                 machine. | 
 | 926 |                 By default, the OpenEmbedded build system looks for | 
 | 927 |                 <filename>defconfig</filename> files in the layer used for | 
 | 928 |                 Metadata, which is "out-of-tree", and then configures them | 
 | 929 |                 using the following: | 
 | 930 |                 <literallayout class='monospaced'> | 
 | 931 |      SRC_URI += "file://defconfig" | 
 | 932 |                 </literallayout> | 
 | 933 |                 If you do not want to maintain copies of | 
 | 934 |                 <filename>defconfig</filename> files in your layer but would | 
 | 935 |                 rather allow users to use the default configuration from the | 
 | 936 |                 kernel tree and still be able to add configuration fragments | 
 | 937 |                 to the | 
 | 938 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 939 |                 through, for example, append files, you can direct the | 
 | 940 |                 OpenEmbedded build system to use a | 
 | 941 |                 <filename>defconfig</filename> file that is "in-tree". | 
 | 942 |             </para> | 
 | 943 |  | 
 | 944 |             <para> | 
 | 945 |                 To specify an "in-tree" <filename>defconfig</filename> file, | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 946 |                 use the following statement form: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 947 |                 <literallayout class='monospaced'> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 948 |      KBUILD_DEFCONFIG_<replaceable>KMACHINE</replaceable> ?= <replaceable>defconfig_file</replaceable> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 949 |                 </literallayout> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 950 |                 Here is an example that appends the | 
 | 951 |                 <filename>KBUILD_DEFCONFIG</filename> variable with | 
 | 952 |                 "common-pc" and provides the path to the "in-tree" | 
 | 953 |                 <filename>defconfig</filename> file: | 
 | 954 |                 <literallayout class='monospaced'> | 
 | 955 |      KBUILD_DEFCONFIG_common-pc ?= "/home/scottrif/configfiles/my_defconfig_file" | 
 | 956 |                 </literallayout> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 957 |             </para> | 
 | 958 |  | 
 | 959 |             <para> | 
 | 960 |                 Aside from modifying your kernel recipe and providing your own | 
 | 961 |                 <filename>defconfig</filename> file, you need to be sure no | 
 | 962 |                 files or statements set <filename>SRC_URI</filename> to use a | 
 | 963 |                 <filename>defconfig</filename> other than your "in-tree" | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 964 |                 file (e.g. a kernel's | 
 | 965 |                 <filename>linux-</filename><replaceable>machine</replaceable><filename>.inc</filename> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 966 |                 file). | 
 | 967 |                 In other words, if the build system detects a statement | 
 | 968 |                 that identifies an "out-of-tree" | 
 | 969 |                 <filename>defconfig</filename> file, that statement | 
 | 970 |                 will override your | 
 | 971 |                 <filename>KBUILD_DEFCONFIG</filename> variable. | 
 | 972 |             </para> | 
 | 973 |  | 
 | 974 |             <para> | 
 | 975 |                 See the | 
 | 976 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KBUILD_DEFCONFIG'><filename>KBUILD_DEFCONFIG</filename></ulink> | 
 | 977 |                 variable description for more information. | 
 | 978 |             </para> | 
 | 979 |         </section> | 
 | 980 |     </section> | 
 | 981 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 982 |     <section id="using-devtool-to-patch-the-kernel"> | 
 | 983 |         <title>Using <filename>devtool</filename> to Patch the Kernel</title> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 984 |  | 
 | 985 |         <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 986 |             The steps in this procedure show you how you can patch the | 
 | 987 |             kernel using the extensible SDK and <filename>devtool</filename>. | 
 | 988 |             <note> | 
 | 989 |                 Before attempting this procedure, be sure you have performed | 
 | 990 |                 the steps to get ready for updating the kernel as described | 
 | 991 |                 in the | 
 | 992 |                 "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>" | 
 | 993 |                 section. | 
 | 994 |             </note> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 995 |         </para> | 
 | 996 |  | 
 | 997 |         <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 998 |             Patching the kernel involves changing or adding configurations | 
 | 999 |             to an existing kernel, changing or adding recipes to the kernel | 
 | 1000 |             that are needed to support specific hardware features, or even | 
 | 1001 |             altering the source code itself. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1002 |         </para> | 
 | 1003 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1004 |         <para> | 
 | 1005 |             This example creates a simple patch by adding some QEMU emulator | 
 | 1006 |             console output at boot time through <filename>printk</filename> | 
 | 1007 |             statements in the kernel's <filename>calibrate.c</filename> source | 
 | 1008 |             code file. | 
 | 1009 |             Applying the patch and booting the modified image causes the added | 
 | 1010 |             messages to appear on the emulator's console. | 
 | 1011 |             The example is a continuation of the setup procedure found in | 
 | 1012 |             the | 
 | 1013 |             "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>" | 
 | 1014 |             Section. | 
 | 1015 |             <orderedlist> | 
 | 1016 |                 <listitem><para> | 
 | 1017 |                     <emphasis>Check Out the Kernel Source Files:</emphasis> | 
 | 1018 |                     First you must use <filename>devtool</filename> to checkout | 
 | 1019 |                     the kernel source code in its workspace. | 
 | 1020 |                     Be sure you are in the terminal set up to do work | 
 | 1021 |                     with the extensible SDK. | 
 | 1022 |                     <note> | 
 | 1023 |                         See this | 
 | 1024 |                         <link linkend='setting-up-the-esdk-terminal'>step</link> | 
 | 1025 |                         in the | 
 | 1026 |                         "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>" | 
 | 1027 |                         section for more information. | 
 | 1028 |                     </note> | 
 | 1029 |                     Use the following <filename>devtool</filename> command | 
 | 1030 |                     to check out the code: | 
 | 1031 |                     <literallayout class='monospaced'> | 
 | 1032 |      $ devtool modify linux-yocto | 
 | 1033 |                     </literallayout> | 
 | 1034 |                     <note> | 
 | 1035 |                         During the checkout operation, a bug exists that could | 
 | 1036 |                         cause errors such as the following to appear: | 
 | 1037 |                         <literallayout class='monospaced'> | 
 | 1038 |      ERROR: Taskhash mismatch 2c793438c2d9f8c3681fd5f7bc819efa versus | 
 | 1039 |             be3a89ce7c47178880ba7bf6293d7404 for | 
 | 1040 |             /path/to/esdk/layers/poky/meta/recipes-kernel/linux/linux-yocto_4.10.bb.do_unpack | 
 | 1041 |                         </literallayout> | 
 | 1042 |                         You can safely ignore these messages. | 
 | 1043 |                         The source code is correctly checked out. | 
 | 1044 |                     </note> | 
 | 1045 |                     </para></listitem> | 
 | 1046 |                 <listitem><para> | 
 | 1047 |                     <emphasis>Edit the Source Files</emphasis> | 
 | 1048 |                     Follow these steps to make some simple changes to the source | 
 | 1049 |                     files: | 
 | 1050 |                     <orderedlist> | 
 | 1051 |                         <listitem><para> | 
 | 1052 |                             <emphasis>Change the working directory</emphasis>: | 
 | 1053 |                             In the previous step, the output noted where you can find | 
 | 1054 |                             the source files (e.g. | 
 | 1055 |                             <filename>~/poky_sdk/workspace/sources/linux-yocto</filename>). | 
 | 1056 |                             Change to where the kernel source code is before making | 
 | 1057 |                             your edits to the <filename>calibrate.c</filename> file: | 
 | 1058 |                             <literallayout class='monospaced'> | 
 | 1059 |      $ cd ~/poky_sdk/workspace/sources/linux-yocto | 
 | 1060 |                             </literallayout> | 
 | 1061 |                             </para></listitem> | 
 | 1062 |                         <listitem><para> | 
 | 1063 |                             <emphasis>Edit the source file</emphasis>: | 
 | 1064 |                             Edit the <filename>init/calibrate.c</filename> file to have | 
 | 1065 |                             the following changes: | 
 | 1066 |                             <literallayout class='monospaced'> | 
 | 1067 |      void calibrate_delay(void) | 
 | 1068 |      { | 
 | 1069 |          unsigned long lpj; | 
 | 1070 |          static bool printed; | 
 | 1071 |          int this_cpu = smp_processor_id(); | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1072 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1073 |          printk("*************************************\n"); | 
 | 1074 |          printk("*                                   *\n"); | 
 | 1075 |          printk("*        HELLO YOCTO KERNEL         *\n"); | 
 | 1076 |          printk("*                                   *\n"); | 
 | 1077 |          printk("*************************************\n"); | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1078 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1079 |      	if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { | 
 | 1080 |                . | 
 | 1081 |                . | 
 | 1082 |                . | 
 | 1083 |                             </literallayout> | 
 | 1084 |                             </para></listitem> | 
 | 1085 |                     </orderedlist> | 
 | 1086 |                     </para></listitem> | 
 | 1087 |                 <listitem><para> | 
 | 1088 |                     <emphasis>Build the Updated Kernel Source:</emphasis> | 
 | 1089 |                     To build the updated kernel source, use | 
 | 1090 |                     <filename>devtool</filename>: | 
 | 1091 |                     <literallayout class='monospaced'> | 
 | 1092 |      $ devtool build linux-yocto | 
 | 1093 |                     </literallayout> | 
 | 1094 |                     </para></listitem> | 
 | 1095 |                 <listitem><para> | 
 | 1096 |                     <emphasis>Create the Image With the New Kernel:</emphasis> | 
 | 1097 |                     Use the <filename>devtool build-image</filename> command | 
 | 1098 |                     to create a new image that has the new kernel. | 
 | 1099 |                     <note> | 
 | 1100 |                         If the image you originally created resulted in a Wic | 
 | 1101 |                         file, you can use an alternate method to create the new | 
 | 1102 |                         image with the updated kernel. | 
 | 1103 |                         For an example, see the steps in the | 
 | 1104 |                         <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/KernelDevelopmentWithEsdk'>TipsAndTricks/KernelDevelopmentWithEsdk</ulink> | 
 | 1105 |                         Wiki Page. | 
 | 1106 |                     </note> | 
 | 1107 |                     <literallayout class='monospaced'> | 
 | 1108 |      $ cd ~ | 
 | 1109 |      $ devtool build-image core-image-minimal | 
 | 1110 |                     </literallayout> | 
 | 1111 |                     </para></listitem> | 
 | 1112 |                 <listitem><para> | 
 | 1113 |                     <emphasis>Test the New Image:</emphasis> | 
 | 1114 |                     For this example, you can run the new image using QEMU | 
 | 1115 |                     to verify your changes: | 
 | 1116 |                     <orderedlist> | 
 | 1117 |                         <listitem><para> | 
 | 1118 |                             <emphasis>Boot the image</emphasis>: | 
 | 1119 |                             Boot the modified image in the QEMU emulator | 
 | 1120 |                             using this command: | 
 | 1121 |                             <literallayout class='monospaced'> | 
 | 1122 |      $ runqemu qemux86 | 
 | 1123 |                             </literallayout> | 
 | 1124 |                             </para></listitem> | 
 | 1125 |                         <listitem><para> | 
 | 1126 |                             <emphasis>Verify the changes</emphasis>: | 
 | 1127 |                             Log into the machine using <filename>root</filename> | 
 | 1128 |                             with no password and then use the following shell | 
 | 1129 |                             command to scroll through the console's boot output. | 
 | 1130 |                             <literallayout class='monospaced'> | 
 | 1131 |      # dmesg | less | 
 | 1132 |                             </literallayout> | 
 | 1133 |                             You should see the results of your | 
 | 1134 |                             <filename>printk</filename> statements | 
 | 1135 |                             as part of the output when you scroll down the | 
 | 1136 |                             console window. | 
 | 1137 |                             </para></listitem> | 
 | 1138 |                     </orderedlist> | 
 | 1139 |                     </para></listitem> | 
 | 1140 |                 <listitem><para> | 
 | 1141 |                     <emphasis>Stage and commit your changes</emphasis>: | 
 | 1142 |                     Within your eSDK terminal, change your working directory to | 
 | 1143 |                     where you modified the <filename>calibrate.c</filename> | 
 | 1144 |                     file and use these Git commands to stage and commit your | 
 | 1145 |                     changes: | 
 | 1146 |                     <literallayout class='monospaced'> | 
 | 1147 |      $ cd ~/poky_sdk/workspace/sources/linux-yocto | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1148 |      $ git status | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1149 |      $ git add init/calibrate.c | 
 | 1150 |      $ git commit -m "calibrate: Add printk example" | 
 | 1151 |                     </literallayout> | 
 | 1152 |                     </para></listitem> | 
 | 1153 |                 <listitem><para> | 
 | 1154 |                     <emphasis>Export the Patches and Create an Append File:</emphasis> | 
 | 1155 |                     To export your commits as patches and create a | 
 | 1156 |                     <filename>.bbappend</filename> file, use the following | 
 | 1157 |                     command in the terminal used to work with the extensible | 
 | 1158 |                     SDK. | 
 | 1159 |                     This example uses the previously established layer named | 
 | 1160 |                     <filename>meta-mylayer</filename>. | 
 | 1161 |                     <note> | 
 | 1162 |                         See Step 3 of the | 
 | 1163 |                         "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using devtool</link>" | 
 | 1164 |                         section for information on setting up this layer. | 
 | 1165 |                     </note> | 
 | 1166 |                     <literallayout class='monospaced'> | 
 | 1167 |      $ devtool finish linux-yocto ~/meta-mylayer | 
 | 1168 |                     </literallayout> | 
 | 1169 |                     Once the command finishes, the patches and the | 
 | 1170 |                     <filename>.bbappend</filename> file are located in the | 
 | 1171 |                     <filename>~/meta-mylayer/recipes-kernel/linux</filename> | 
 | 1172 |                     directory. | 
 | 1173 |                     </para></listitem> | 
 | 1174 |                 <listitem><para> | 
 | 1175 |                     <emphasis>Build the Image With Your Modified Kernel:</emphasis> | 
 | 1176 |                     You can now build an image that includes your kernel | 
 | 1177 |                     patches. | 
 | 1178 |                     Execute the following command from your | 
 | 1179 |                     <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | 
 | 1180 |                     in the terminal set up to run BitBake: | 
 | 1181 |                     <literallayout class='monospaced'> | 
 | 1182 |      $ cd ~/poky/build | 
 | 1183 |      $ bitbake core-image-minimal | 
 | 1184 |                     </literallayout> | 
 | 1185 |                     </para></listitem> | 
 | 1186 |             </orderedlist> | 
 | 1187 |         </para> | 
 | 1188 |     </section> | 
 | 1189 |  | 
 | 1190 |     <section id="using-traditional-kernel-development-to-patch-the-kernel"> | 
 | 1191 |         <title>Using Traditional Kernel Development to Patch the Kernel</title> | 
 | 1192 |  | 
 | 1193 |         <para> | 
 | 1194 |             The steps in this procedure show you how you can patch the | 
 | 1195 |             kernel using traditional kernel development (i.e. not using | 
 | 1196 |             <filename>devtool</filename> and the extensible SDK as | 
 | 1197 |             described in the | 
 | 1198 |             "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" | 
 | 1199 |             section). | 
 | 1200 |             <note> | 
 | 1201 |                 Before attempting this procedure, be sure you have performed | 
 | 1202 |                 the steps to get ready for updating the kernel as described | 
 | 1203 |                 in the | 
 | 1204 |                 "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>" | 
 | 1205 |                 section. | 
 | 1206 |             </note> | 
 | 1207 |         </para> | 
 | 1208 |  | 
 | 1209 |         <para> | 
 | 1210 |             Patching the kernel involves changing or adding configurations | 
 | 1211 |             to an existing kernel, changing or adding recipes to the kernel | 
 | 1212 |             that are needed to support specific hardware features, or even | 
 | 1213 |             altering the source code itself. | 
 | 1214 |         </para> | 
 | 1215 |  | 
 | 1216 |         <para> | 
 | 1217 |             The example in this section creates a simple patch by adding some | 
 | 1218 |             QEMU emulator console output at boot time through | 
 | 1219 |             <filename>printk</filename> statements in the kernel's | 
 | 1220 |             <filename>calibrate.c</filename> source code file. | 
 | 1221 |             Applying the patch and booting the modified image causes the added | 
 | 1222 |             messages to appear on the emulator's console. | 
 | 1223 |             The example is a continuation of the setup procedure found in | 
 | 1224 |             the | 
 | 1225 |             "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>" | 
 | 1226 |             Section. | 
 | 1227 |         </para> | 
 | 1228 |  | 
 | 1229 |         <para> | 
 | 1230 |             Although this example uses Git and shell commands to generate the | 
 | 1231 |             patch, you could use the <filename>yocto-kernel</filename> script | 
 | 1232 |             found in the <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | 
 | 1233 |             under <filename>scripts</filename> to add and manage kernel | 
 | 1234 |             patches and configuration. | 
 | 1235 |             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>" | 
 | 1236 |             section in the Yocto Project Board Support Packages (BSP) | 
 | 1237 |             Developer's Guide for more information on the | 
 | 1238 |             <filename>yocto-kernel</filename> script. | 
 | 1239 |             <orderedlist> | 
 | 1240 |                 <listitem><para> | 
 | 1241 |                     <emphasis>Edit the Source Files</emphasis> | 
 | 1242 |                     Prior to this step, you should have used Git to create a | 
 | 1243 |                     local copy of the repository for your kernel. | 
 | 1244 |                     Assuming you created the repository as directed in the | 
 | 1245 |                     "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>" | 
 | 1246 |                     section, use the following commands to edit the | 
 | 1247 |                     <filename>calibrate.c</filename> file: | 
 | 1248 |                     <orderedlist> | 
 | 1249 |                         <listitem><para> | 
 | 1250 |                             <emphasis>Change the working directory</emphasis>: | 
 | 1251 |                             You need to locate the source files in the | 
 | 1252 |                             local copy of the kernel Git repository: | 
 | 1253 |                             Change to where the kernel source code is before making | 
 | 1254 |                             your edits to the <filename>calibrate.c</filename> file: | 
 | 1255 |                             <literallayout class='monospaced'> | 
 | 1256 |      $ cd ~/linux-yocto-4.12/init | 
 | 1257 |                             </literallayout> | 
 | 1258 |                             </para></listitem> | 
 | 1259 |                         <listitem><para> | 
 | 1260 |                             <emphasis>Edit the source file</emphasis>: | 
 | 1261 |                             Edit the <filename>calibrate.c</filename> file to have | 
 | 1262 |                             the following changes: | 
 | 1263 |                             <literallayout class='monospaced'> | 
 | 1264 |      void calibrate_delay(void) | 
 | 1265 |      { | 
 | 1266 |          unsigned long lpj; | 
 | 1267 |          static bool printed; | 
 | 1268 |          int this_cpu = smp_processor_id(); | 
 | 1269 |  | 
 | 1270 |          printk("*************************************\n"); | 
 | 1271 |          printk("*                                   *\n"); | 
 | 1272 |          printk("*        HELLO YOCTO KERNEL         *\n"); | 
 | 1273 |          printk("*                                   *\n"); | 
 | 1274 |          printk("*************************************\n"); | 
 | 1275 |  | 
 | 1276 |      	if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { | 
 | 1277 |                . | 
 | 1278 |                . | 
 | 1279 |                . | 
 | 1280 |                             </literallayout> | 
 | 1281 |                             </para></listitem> | 
 | 1282 |                     </orderedlist> | 
 | 1283 |                     </para></listitem> | 
 | 1284 |                 <listitem><para> | 
 | 1285 |                     <emphasis>Stage and Commit Your Changes:</emphasis> | 
 | 1286 |                     Use standard Git commands to stage and commit the changes | 
 | 1287 |                     you just made: | 
 | 1288 |                     <literallayout class='monospaced'> | 
 | 1289 |      $ git add calibrate.c | 
 | 1290 |      $ git commit -m "calibrate.c - Added some printk statements" | 
 | 1291 |                     </literallayout> | 
 | 1292 |                     If you do not stage and commit your changes, the OpenEmbedded | 
 | 1293 |                     Build System will not pick up the changes. | 
 | 1294 |                     </para></listitem> | 
 | 1295 |                 <listitem><para> | 
 | 1296 |                     <emphasis>Update Your <filename>local.conf</filename> File | 
 | 1297 |                     to Point to Your Source Files:</emphasis> | 
 | 1298 |                     In addition to your <filename>local.conf</filename> file | 
 | 1299 |                     specifying to use "kernel-modules" and the "qemux86" | 
 | 1300 |                     machine, it must also point to the updated kernel source | 
 | 1301 |                     files. | 
 | 1302 |                     Add | 
 | 1303 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 1304 |                     and | 
 | 1305 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> | 
 | 1306 |                     statements similar to the following to your | 
 | 1307 |                     <filename>local.conf</filename>: | 
 | 1308 |                     <literallayout class='monospaced'> | 
 | 1309 |      $ cd ~/poky/build/conf | 
 | 1310 |                     </literallayout> | 
 | 1311 |                     Add the following to the <filename>local.conf</filename>: | 
 | 1312 |                     <literallayout class='monospaced'> | 
 | 1313 |      SRC_URI_pn-linux-yocto = "git:///<replaceable>path-to</replaceable>/linux-yocto-4.12;protocol=file;name=machine;branch=standard/base; \ | 
 | 1314 |                                git:///<replaceable>path-to</replaceable>/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}" | 
 | 1315 |      SRCREV_meta_qemux86 = "${AUTOREV}" | 
 | 1316 |      SRCREV_machine_qemux86 = "${AUTOREV}" | 
 | 1317 |                     </literallayout> | 
 | 1318 |                     <note> | 
 | 1319 |                         Be sure to replace | 
 | 1320 |                         <replaceable>path-to</replaceable> with the pathname | 
 | 1321 |                         to your local Git repositories. | 
 | 1322 |                         Also, you must be sure to specify the correct branch | 
 | 1323 |                         and machine types. | 
 | 1324 |                         For this example, the branch is | 
 | 1325 |                         <filename>standard/base</filename> and the machine is | 
 | 1326 |                         "qemux86". | 
 | 1327 |                     </note> | 
 | 1328 |                     </para></listitem> | 
 | 1329 |                 <listitem><para> | 
 | 1330 |                     <emphasis>Build the Image:</emphasis> | 
 | 1331 |                     With the source modified, your changes staged and | 
 | 1332 |                     committed, and the <filename>local.conf</filename> file | 
 | 1333 |                     pointing to the kernel files, you can now use BitBake to | 
 | 1334 |                     build the image: | 
 | 1335 |                     <literallayout class='monospaced'> | 
 | 1336 |      $ cd ~/poky/build | 
 | 1337 |      $ bitbake core-image-minimal | 
 | 1338 |                     </literallayout> | 
 | 1339 |                     </para></listitem> | 
 | 1340 |                 <listitem><para> | 
 | 1341 |                     <emphasis>Boot the image</emphasis>: | 
 | 1342 |                     Boot the modified image in the QEMU emulator | 
 | 1343 |                     using this command. | 
 | 1344 |                     When prompted to login to the QEMU console, use "root" | 
 | 1345 |                     with no password: | 
 | 1346 |                     <literallayout class='monospaced'> | 
 | 1347 |      $ cd ~/poky/build | 
 | 1348 |      $ runqemu qemux86 | 
 | 1349 |                     </literallayout> | 
 | 1350 |                     </para></listitem> | 
 | 1351 |                 <listitem><para> | 
 | 1352 |                     <emphasis>Look for Your Changes:</emphasis> | 
 | 1353 |                     As QEMU booted, you might have seen your changes rapidly | 
 | 1354 |                     scroll by. | 
 | 1355 |                     If not, use these commands to see your changes: | 
 | 1356 |                     <literallayout class='monospaced'> | 
 | 1357 |      # dmesg | less | 
 | 1358 |                     </literallayout> | 
 | 1359 |                     You should see the results of your | 
 | 1360 |                     <filename>printk</filename> statements | 
 | 1361 |                     as part of the output when you scroll down the | 
 | 1362 |                     console window. | 
 | 1363 |                     </para></listitem> | 
 | 1364 |                 <listitem><para> | 
 | 1365 |                     <emphasis>Generate the Patch File:</emphasis> | 
 | 1366 |                     Once you are sure that your patch works correctly, you | 
 | 1367 |                     can generate a <filename>*.patch</filename> file in the | 
 | 1368 |                     kernel source repository: | 
 | 1369 |                     <literallayout class='monospaced'> | 
 | 1370 |      $ cd ~/linux-yocto-4.12/init | 
 | 1371 |      $ git format-patch -1 | 
 | 1372 |      0001-calibrate.c-Added-some-printk-statements.patch | 
 | 1373 |                     </literallayout> | 
 | 1374 |                     </para></listitem> | 
 | 1375 |                 <listitem><para> | 
 | 1376 |                     <emphasis>Move the Patch File to Your Layer:</emphasis> | 
 | 1377 |                     In order for subsequent builds to pick up patches, you | 
 | 1378 |                     need to move the patch file you created in the previous | 
 | 1379 |                     step to your layer <filename>meta-mylayer</filename>. | 
 | 1380 |                     For this example, the layer created earlier is located | 
 | 1381 |                     in your home directory as <filename>meta-mylayer</filename>. | 
 | 1382 |                     When the layer was created using the | 
 | 1383 |                     <filename>yocto-create</filename> script, no additional | 
 | 1384 |                     hierarchy was created to support patches. | 
 | 1385 |                     Before moving the patch file, you need to add additional | 
 | 1386 |                     structure to your layer using the following commands: | 
 | 1387 |                     <literallayout class='monospaced'> | 
 | 1388 |      $ cd ~/meta-mylayer | 
 | 1389 |      $ mkdir recipes-kernel | 
 | 1390 |      $ mkdir recipes-kernel/linux | 
 | 1391 |      $ mkdir recipes-kernel/linux/linux-yocto | 
 | 1392 |                     </literallayout> | 
 | 1393 |                     Once you have created this hierarchy in your layer, you can | 
 | 1394 |                     move the patch file using the following command: | 
 | 1395 |                     <literallayout class='monospaced'> | 
 | 1396 |      $ mv ~/linux-yocto-4.12/init/0001-calibrate.c-Added-some-printk-statements.patch ~/meta-mylayer/recipes-kernel/linux/linux-yocto | 
 | 1397 |                     </literallayout> | 
 | 1398 |                     </para></listitem> | 
 | 1399 |                 <listitem><para> | 
 | 1400 |                     <emphasis>Create the Append File:</emphasis> | 
 | 1401 |                     Finally, you need to create the | 
 | 1402 |                     <filename>linux-yocto_4.12.bbappend</filename> file and | 
 | 1403 |                     insert statements that allow the OpenEmbedded build | 
 | 1404 |                     system to find the patch. | 
 | 1405 |                     The append file needs to be in your layer's | 
 | 1406 |                     <filename>recipes-kernel/linux</filename> | 
 | 1407 |                     directory and it must be named | 
 | 1408 |                     <filename>linux-yocto_4.12.bbappend</filename> and have | 
 | 1409 |                     the following contents: | 
 | 1410 |                     <literallayout class='monospaced'> | 
 | 1411 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 1412 |  | 
 | 1413 |      SRC_URI_append = " file://0001-calibrate.c-Added-some-printk-statements.patch" | 
 | 1414 |                     </literallayout> | 
 | 1415 |                     The | 
 | 1416 |                     <ulink url='&YOCTO_DOCS_REF_URL;var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 1417 |                     and | 
 | 1418 |                     <ulink url='&YOCTO_DOCS_REF_URL;var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 1419 |                     statements enable the OpenEmbedded build system to find | 
 | 1420 |                     the patch file.</para> | 
 | 1421 |  | 
 | 1422 |                     <para>For more information on append files and patches, | 
 | 1423 |                     see the | 
 | 1424 |                     "<link linkend='creating-the-append-file'>Creating the Append File</link>" | 
 | 1425 |                     and | 
 | 1426 |                     "<link linkend='applying-patches'>Applying Patches</link>" | 
 | 1427 |                     sections. | 
 | 1428 |                     You can also see the | 
 | 1429 |                     "<ulink url='&YOCTO_DOCS_DEV_URL;#using-bbappend-files'>Using .bbappend Files in Your Layer"</ulink>" | 
 | 1430 |                     section in the Yocto Project Development Tasks Manual. | 
 | 1431 |                     <note> | 
 | 1432 |                         To build <filename>core-image-minimal</filename> | 
 | 1433 |                         again and see the effects of your patch, you can | 
 | 1434 |                         essentially eliminate the temporary source files | 
 | 1435 |                         saved in <filename>poky/build/tmp/work/...</filename> | 
 | 1436 |                         and residual effects of the build by entering the | 
 | 1437 |                         following sequence of commands: | 
 | 1438 |                         <literallayout class='monospaced'> | 
 | 1439 |      $ cd ~/poky/build | 
 | 1440 |      $ bitbake -c cleanall yocto-linux | 
 | 1441 |      $ bitbake core-image-minimal -c cleanall | 
 | 1442 |      $ bitbake core-image-minimal | 
 | 1443 |      $ runqemu qemux86 | 
 | 1444 |                         </literallayout> | 
 | 1445 |                     </note> | 
 | 1446 |                     </para></listitem> | 
 | 1447 |             </orderedlist> | 
 | 1448 |         </para> | 
 | 1449 |     </section> | 
 | 1450 |  | 
 | 1451 |     <section id='configuring-the-kernel'> | 
 | 1452 |         <title>Configuring the Kernel</title> | 
 | 1453 |  | 
 | 1454 |         <para> | 
 | 1455 |             Configuring the Yocto Project kernel consists of making sure the | 
 | 1456 |             <filename>.config</filename> file has all the right information | 
 | 1457 |             in it for the image you are building. | 
 | 1458 |             You can use the <filename>menuconfig</filename> tool and | 
 | 1459 |             configuration fragments to make sure your | 
 | 1460 |             <filename>.config</filename> file is just how you need it. | 
 | 1461 |             You can also save known configurations in a | 
 | 1462 |             <filename>defconfig</filename> file that the build system can use | 
 | 1463 |             for kernel configuration. | 
 | 1464 |         </para> | 
 | 1465 |  | 
 | 1466 |         <para> | 
 | 1467 |             This section describes how to use <filename>menuconfig</filename>, | 
 | 1468 |             create and use configuration fragments, and how to interactively | 
 | 1469 |             modify your <filename>.config</filename> file to create the | 
 | 1470 |             leanest kernel configuration file possible. | 
 | 1471 |         </para> | 
 | 1472 |  | 
 | 1473 |         <para> | 
 | 1474 |             For more information on kernel configuration, see the | 
 | 1475 |             "<link linkend='changing-the-configuration'>Changing the Configuration</link>" | 
 | 1476 |             section. | 
 | 1477 |         </para> | 
 | 1478 |  | 
 | 1479 |         <section id='using-menuconfig'> | 
 | 1480 |             <title>Using  <filename>menuconfig</filename></title> | 
 | 1481 |  | 
 | 1482 |             <para> | 
 | 1483 |                 The easiest way to define kernel configurations is to set | 
 | 1484 |                 them through the <filename>menuconfig</filename> tool. | 
 | 1485 |                 This tool provides an interactive method with which | 
 | 1486 |                 to set kernel configurations. | 
 | 1487 |                 For general information on <filename>menuconfig</filename>, see | 
 | 1488 |                 <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1489 |             </para> | 
 | 1490 |  | 
 | 1491 |             <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1492 |                 To use the <filename>menuconfig</filename> tool in the Yocto | 
 | 1493 |                 Project development environment, you must launch it using | 
 | 1494 |                 BitBake. | 
 | 1495 |                 Thus, the environment must be set up using the | 
 | 1496 |                 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink> | 
 | 1497 |                 script found in the | 
 | 1498 |                 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. | 
 | 1499 |                 You must also be sure of the state of your build's | 
 | 1500 |                 configuration in the | 
 | 1501 |                 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. | 
 | 1502 |                 The following commands initialize the BitBake environment, | 
 | 1503 |                 run the | 
 | 1504 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configme'><filename>do_kernel_configme</filename></ulink> | 
 | 1505 |                 task, and launch <filename>menuconfig</filename>. | 
 | 1506 |                 These commands assume the Source Directory's top-level folder | 
 | 1507 |                 is <filename>~/poky</filename>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1508 |                 <literallayout class='monospaced'> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1509 |      $ cd poky | 
 | 1510 |      $ source oe-init-build-env | 
 | 1511 |      $ bitbake linux-yocto -c kernel_configme -f | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1512 |      $ bitbake linux-yocto -c menuconfig | 
 | 1513 |                 </literallayout> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1514 |                 Once <filename>menuconfig</filename> comes up, its standard | 
 | 1515 |                 interface allows you to interactively examine and configure | 
 | 1516 |                 all the kernel configuration parameters. | 
 | 1517 |                 After making your changes, simply exit the tool and save your | 
 | 1518 |                 changes to create an updated version of the | 
 | 1519 |                 <filename>.config</filename> configuration file. | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1520 |                 <note> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1521 |                     You can use the entire <filename>.config</filename> file | 
 | 1522 |                     as the <filename>defconfig</filename> file. | 
 | 1523 |                     For information on <filename>defconfig</filename> files, | 
 | 1524 |                     see the | 
 | 1525 |                     "<link linkend='changing-the-configuration'>Changing the Configuration</link>", | 
 | 1526 |                     "<link linkend='using-an-in-tree-defconfig-file'>Using an In-Tree <filename>defconfig</filename> File</link>, | 
 | 1527 |                     and | 
 | 1528 |                     "<link linkend='creating-a-defconfig-file'>Creating a <filename>defconfig</filename> File</link>" | 
 | 1529 |                     sections. | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1530 |                 </note> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1531 |             </para> | 
 | 1532 |  | 
 | 1533 |             <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1534 |                 Consider an example that configures the "CONFIG_SMP" setting | 
 | 1535 |                 for the <filename>linux-yocto-4.12</filename> kernel. | 
 | 1536 |                 <note> | 
 | 1537 |                     The OpenEmbedded build system recognizes this kernel as | 
 | 1538 |                     <filename>linux-yocto</filename> through Metadata (e.g. | 
 | 1539 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_VERSION'><filename>PREFERRED_VERSION</filename></ulink><filename>_linux-yocto ?= "12.4%"</filename>). | 
 | 1540 |                 </note> | 
 | 1541 |                 Once <filename>menuconfig</filename> launches, use the | 
 | 1542 |                 interface to navigate through the selections to find the | 
 | 1543 |                 configuration settings in which you are interested. | 
 | 1544 |                 For this example, you deselect "CONFIG_SMP" by clearing the | 
 | 1545 |                 "Symmetric Multi-Processing Support" option. | 
 | 1546 |                 Using the interface, you can find the option under | 
 | 1547 |                 "Processor Type and Features". | 
 | 1548 |                 To deselect "CONFIG_SMP", use the arrow keys to | 
 | 1549 |                 highlight "Symmetric Multi-Processing Support" and enter "N" | 
 | 1550 |                 to clear the asterisk. | 
 | 1551 |                 When you are finished, exit out and save the change. | 
 | 1552 |             </para> | 
 | 1553 |  | 
 | 1554 |             <para> | 
 | 1555 |                 Saving the selections updates the <filename>.config</filename> | 
 | 1556 |                 configuration file. | 
 | 1557 |                 This is the file that the OpenEmbedded build system uses to | 
 | 1558 |                 configure the kernel during the build. | 
 | 1559 |                 You can find and examine this file in the Build Directory in | 
 | 1560 |                 <filename>tmp/work/</filename>. | 
 | 1561 |                 The actual <filename>.config</filename> is located in the | 
 | 1562 |                 area where the specific kernel is built. | 
 | 1563 |                 For example, if you were building a Linux Yocto kernel based | 
 | 1564 |                 on the <filename>linux-yocto-4.12</filename> kernel and you | 
 | 1565 |                 were building a QEMU image targeted for | 
 | 1566 |                 <filename>x86</filename> architecture, the | 
 | 1567 |                 <filename>.config</filename> file would be: | 
 | 1568 |                 <literallayout class='monospaced'> | 
 | 1569 |      poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18... | 
 | 1570 |      ...967-r0/linux-qemux86-standard-build/.config | 
 | 1571 |                 </literallayout> | 
 | 1572 |                 <note> | 
 | 1573 |                     The previous example directory is artificially split and | 
 | 1574 |                     many of the characters in the actual filename are omitted | 
 | 1575 |                     in order to make it more readable. | 
 | 1576 |                     Also, depending on the kernel you are using, the exact | 
 | 1577 |                     pathname might differ. | 
 | 1578 |                 </note> | 
 | 1579 |             </para> | 
 | 1580 |  | 
 | 1581 |             <para> | 
 | 1582 |                 Within the <filename>.config</filename> file, you can see the | 
 | 1583 |                 kernel settings. | 
 | 1584 |                 For example, the following entry shows that symmetric | 
 | 1585 |                 multi-processor support is not set: | 
 | 1586 |                 <literallayout class='monospaced'> | 
 | 1587 |      # CONFIG_SMP is not set | 
 | 1588 |                 </literallayout> | 
 | 1589 |             </para> | 
 | 1590 |  | 
 | 1591 |             <para> | 
 | 1592 |                 A good method to isolate changed configurations is to use a | 
 | 1593 |                 combination of the <filename>menuconfig</filename> tool and | 
 | 1594 |                 simple shell commands. | 
 | 1595 |                 Before changing configurations with | 
 | 1596 |                 <filename>menuconfig</filename>, copy the existing | 
 | 1597 |                 <filename>.config</filename> and rename it to something else, | 
 | 1598 |                 use <filename>menuconfig</filename> to make as many changes as | 
 | 1599 |                 you want and save them, then compare the renamed configuration | 
 | 1600 |                 file against the newly created file. | 
 | 1601 |                 You can use the resulting differences as your base to create | 
 | 1602 |                 configuration fragments to permanently save in your kernel | 
 | 1603 |                 layer. | 
 | 1604 |                 <note> | 
 | 1605 |                     Be sure to make a copy of the <filename>.config</filename> | 
 | 1606 |                     file and do not just rename it. | 
 | 1607 |                     The build system needs an existing | 
 | 1608 |                     <filename>.config</filename> file from which to work. | 
 | 1609 |                 </note> | 
 | 1610 |             </para> | 
 | 1611 |         </section> | 
 | 1612 |  | 
 | 1613 |         <section id='creating-a-defconfig-file'> | 
 | 1614 |             <title>Creating a  <filename>defconfig</filename> File</title> | 
 | 1615 |  | 
 | 1616 |             <para> | 
 | 1617 |                 A <filename>defconfig</filename> file is simply a | 
 | 1618 |                 <filename>.config</filename> renamed to "defconfig". | 
 | 1619 |                 You can use a <filename>defconfig</filename> file | 
 | 1620 |                 to retain a known set of kernel configurations from which the | 
 | 1621 |                 OpenEmbedded build system can draw to create the final | 
 | 1622 |                 <filename>.config</filename> file. | 
 | 1623 |                 <note> | 
 | 1624 |                     Out-of-the-box, the Yocto Project never ships a | 
 | 1625 |                     <filename>defconfig</filename> or | 
 | 1626 |                     <filename>.config</filename> file. | 
 | 1627 |                     The OpenEmbedded build system creates the final | 
 | 1628 |                     <filename>.config</filename> file used to configure the | 
 | 1629 |                     kernel. | 
 | 1630 |                 </note> | 
 | 1631 |             </para> | 
 | 1632 |  | 
 | 1633 |             <para> | 
 | 1634 |                 To create a <filename>defconfig</filename>, start with a | 
 | 1635 |                 complete, working Linux kernel <filename>.config</filename> | 
 | 1636 |                 file. | 
 | 1637 |                 Copy that file to the appropriate | 
 | 1638 |                 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> | 
 | 1639 |                 directory in your layer's | 
 | 1640 |                 <filename>recipes-kernel/linux</filename> directory, and rename | 
 | 1641 |                 the copied file to "defconfig" (e.g. | 
 | 1642 |                 <filename>~/meta-mylayer/recipes-kernel/linux/linux-yocto/defconfig</filename>). | 
 | 1643 |                 Then, add the following lines to the linux-yocto | 
 | 1644 |                 <filename>.bbappend</filename> file in your layer: | 
 | 1645 |                 <literallayout class='monospaced'> | 
 | 1646 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 1647 |      SRC_URI += "file://defconfig" | 
 | 1648 |                 </literallayout> | 
 | 1649 |                 The | 
 | 1650 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 1651 |                 tells the build system how to search for the file, while the | 
 | 1652 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> | 
 | 1653 |                 extends the | 
 | 1654 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink> | 
 | 1655 |                 variable (search directories) to include the | 
 | 1656 |                 <filename>${PN}</filename> directory you created to hold the | 
 | 1657 |                 configuration changes. | 
 | 1658 |                 <note> | 
 | 1659 |                     The build system applies the configurations from the | 
 | 1660 |                     <filename>defconfig</filename> file before applying any | 
 | 1661 |                     subsequent configuration fragments. | 
 | 1662 |                     The final kernel configuration is a combination of the | 
 | 1663 |                     configurations in the <filename>defconfig</filename> | 
 | 1664 |                     file and any configuration fragments you provide. | 
 | 1665 |                     You need to realize that if you have any configuration | 
 | 1666 |                     fragments, the build system applies these on top of and | 
 | 1667 |                     after applying the existing defconfig file configurations. | 
 | 1668 |                 </note> | 
 | 1669 |                 For more information on configuring the kernel, see the | 
 | 1670 |                 "<link link='changing-the-configuration'>Changing the Configuration</link>" | 
 | 1671 |                 section. | 
 | 1672 |             </para> | 
 | 1673 |         </section> | 
 | 1674 |  | 
 | 1675 |         <section id='creating-config-fragments'> | 
 | 1676 |             <title>Creating Configuration Fragments</title> | 
 | 1677 |  | 
 | 1678 |             <para> | 
 | 1679 |                 Configuration fragments are simply kernel options that | 
 | 1680 |                 appear in a file placed where the OpenEmbedded build system | 
 | 1681 |                 can find and apply them. | 
 | 1682 |                 The build system applies configuration fragments after | 
 | 1683 |                 applying configurations from a <filename>defconfig</filename> | 
 | 1684 |                 file. | 
 | 1685 |                 Thus, the final kernel configuration is a combination of the | 
 | 1686 |                 configurations in the <filename>defconfig</filename> | 
 | 1687 |                 file and then any configuration fragments you provide. | 
 | 1688 |                 The build system applies fragments on top of and | 
 | 1689 |                 after applying the existing defconfig file configurations. | 
 | 1690 |             </para> | 
 | 1691 |  | 
 | 1692 |             <para> | 
 | 1693 |                 Syntactically, the configuration statement is identical to | 
 | 1694 |                 what would appear in the <filename>.config</filename> file, | 
 | 1695 |                 which is in the | 
 | 1696 |                 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. | 
 | 1697 |                 <note> | 
 | 1698 |                     For more information about where the | 
 | 1699 |                     <filename>.config</filename> file is located, see the | 
 | 1700 |                     example in the | 
 | 1701 |                     "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>" | 
 | 1702 |                     section. | 
 | 1703 |                 </note> | 
 | 1704 |             </para> | 
 | 1705 |  | 
 | 1706 |             <para> | 
 | 1707 |                 It is simple to create a configuration fragment. | 
 | 1708 |                 One method is to use shell commands. | 
 | 1709 |                 For example, issuing the following from the shell creates a | 
 | 1710 |                 configuration fragment file named | 
 | 1711 |                 <filename>my_smp.cfg</filename> that enables multi-processor | 
 | 1712 |                 support within the kernel: | 
 | 1713 |                 <literallayout class='monospaced'> | 
 | 1714 |      $ echo "CONFIG_SMP=y" >> my_smp.cfg | 
 | 1715 |                 </literallayout> | 
 | 1716 |                 <note> | 
 | 1717 |                     All configuration fragment files must use the | 
 | 1718 |                     <filename>.cfg</filename> extension in order for the | 
 | 1719 |                     OpenEmbedded build system to recognize them as a | 
 | 1720 |                     configuration fragment. | 
 | 1721 |                 </note> | 
 | 1722 |             </para> | 
 | 1723 |  | 
 | 1724 |             <para> | 
 | 1725 |                 Another method is to create a configuration fragment using the | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1726 |                 differences between two configuration files: one previously | 
 | 1727 |                 created and saved, and one freshly created using the | 
 | 1728 |                 <filename>menuconfig</filename> tool. | 
 | 1729 |             </para> | 
 | 1730 |  | 
 | 1731 |             <para> | 
 | 1732 |                 To create a configuration fragment using this method, follow | 
 | 1733 |                 these steps: | 
 | 1734 |                 <orderedlist> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1735 |                     <listitem><para> | 
 | 1736 |                         <emphasis>Complete a Build Through Kernel Configuration:</emphasis> | 
 | 1737 |                         Complete a build at least through the kernel | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1738 |                         configuration task as follows: | 
 | 1739 |                         <literallayout class='monospaced'> | 
 | 1740 |      $ bitbake linux-yocto -c kernel_configme -f | 
 | 1741 |                         </literallayout> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1742 |                         This step ensures that you create a | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1743 |                         <filename>.config</filename> file from a known state. | 
 | 1744 |                         Because situations exist where your build state might | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1745 |                         become unknown, it is best to run this task prior | 
 | 1746 |                         to starting <filename>menuconfig</filename>. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1747 |                         </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1748 |                     <listitem><para> | 
 | 1749 |                         <emphasis>Launch <filename>menuconfig</filename>:</emphasis> | 
 | 1750 |                         Run the <filename>menuconfig</filename> command: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1751 |                         <literallayout class='monospaced'> | 
 | 1752 |      $ bitbake linux-yocto -c menuconfig | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1753 |                         </literallayout> | 
 | 1754 |                         </para></listitem> | 
 | 1755 |                     <listitem><para> | 
 | 1756 |                         <emphasis>Create the Configuration Fragment:</emphasis> | 
 | 1757 |                         Run the <filename>diffconfig</filename> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1758 |                         command to prepare a configuration fragment. | 
 | 1759 |                         The resulting file <filename>fragment.cfg</filename> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1760 |                         is placed in the | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1761 |                         <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> directory: | 
 | 1762 |                         <literallayout class='monospaced'> | 
 | 1763 |      $ bitbake linux-yocto -c diffconfig | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1764 |                         </literallayout> | 
 | 1765 |                         </para></listitem> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1766 |                 </orderedlist> | 
 | 1767 |             </para> | 
 | 1768 |  | 
 | 1769 |             <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1770 |                 The <filename>diffconfig</filename> command creates a file | 
 | 1771 |                 that is a list of Linux kernel <filename>CONFIG_</filename> | 
 | 1772 |                 assignments. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1773 |                 See the "<link linkend='changing-the-configuration'>Changing the Configuration</link>" | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1774 |                 section for additional information on how to use the output | 
 | 1775 |                 as a configuration fragment. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1776 |                 <note> | 
 | 1777 |                     You can also use this method to create configuration | 
 | 1778 |                     fragments for a BSP. | 
 | 1779 |                     See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>" | 
 | 1780 |                     section for more information. | 
 | 1781 |                 </note> | 
 | 1782 |             </para> | 
 | 1783 |  | 
 | 1784 |             <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1785 |                 Where do you put your configuration fragment files? | 
 | 1786 |                 You can place these files in an area pointed to by | 
 | 1787 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 1788 |                 as directed by your <filename>bblayers.conf</filename> file, | 
 | 1789 |                 which is located in your layer. | 
 | 1790 |                 The OpenEmbedded build system picks up the configuration and | 
 | 1791 |                 adds it to the kernel's configuration. | 
 | 1792 |                 For example, suppose you had a set of configuration options | 
 | 1793 |                 in a file called <filename>myconfig.cfg</filename>. | 
 | 1794 |                 If you put that file inside a directory named | 
 | 1795 |                 <filename>linux-yocto</filename> that resides in the same | 
 | 1796 |                 directory as the kernel's append file within your layer | 
 | 1797 |                 and then add the following statements to the kernel's append | 
 | 1798 |                 file, those configuration options will be picked up and applied | 
 | 1799 |                 when the kernel is built: | 
 | 1800 |                 <literallayout class='monospaced'> | 
 | 1801 |      FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | 
 | 1802 |      SRC_URI += "file://myconfig.cfg" | 
 | 1803 |                 </literallayout> | 
 | 1804 |             </para> | 
 | 1805 |  | 
 | 1806 |             <para> | 
 | 1807 |                 As mentioned earlier, you can group related configurations | 
 | 1808 |                 into multiple files and name them all in the | 
 | 1809 |                 <filename>SRC_URI</filename> statement as well. | 
 | 1810 |                 For example, you could group separate configurations | 
 | 1811 |                 specifically for Ethernet and graphics into their own files | 
 | 1812 |                 and add those by using a <filename>SRC_URI</filename> statement | 
 | 1813 |                 like the following in your append file: | 
 | 1814 |                 <literallayout class='monospaced'> | 
 | 1815 |      SRC_URI += "file://myconfig.cfg \ | 
 | 1816 |             file://eth.cfg \ | 
 | 1817 |             file://gfx.cfg" | 
 | 1818 |                 </literallayout> | 
 | 1819 |             </para> | 
 | 1820 |         </section> | 
 | 1821 |  | 
 | 1822 |         <section id='validating-configuration'> | 
 | 1823 |             <title>Validating Configuration</title> | 
 | 1824 |  | 
 | 1825 |             <para> | 
 | 1826 |                 You can use the | 
 | 1827 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configcheck'><filename>do_kernel_configcheck</filename></ulink> | 
 | 1828 |                 task to provide configuration validation: | 
 | 1829 |                 <literallayout class='monospaced'> | 
 | 1830 |      $ bitbake linux-yocto -c kernel_configcheck -f | 
 | 1831 |                 </literallayout> | 
 | 1832 |                 Running this task produces warnings for when a | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1833 |                 requested configuration does not appear in the final | 
 | 1834 |                 <filename>.config</filename> file or when you override a | 
 | 1835 |                 policy configuration in a hardware configuration fragment. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1836 |             </para> | 
 | 1837 |  | 
 | 1838 |             <para> | 
 | 1839 |                 In order to run this task, you must have an existing | 
 | 1840 |                 <filename>.config</filename> file. | 
 | 1841 |                 See the | 
 | 1842 |                 "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>" | 
 | 1843 |                 section for information on how to create a configuration file. | 
 | 1844 |             </para> | 
 | 1845 |  | 
 | 1846 |             <para> | 
 | 1847 |                 Following is sample output from the | 
 | 1848 |                 <filename>do_kernel_configcheck</filename> task: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1849 |                 <literallayout class='monospaced'> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1850 |      Loading cache: 100% |########################################################| Time: 0:00:00 | 
 | 1851 |      Loaded 1275 entries from dependency cache. | 
 | 1852 |      NOTE: Resolving any missing task queue dependencies | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1853 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1854 |      Build Configuration: | 
 | 1855 |          . | 
 | 1856 |          . | 
 | 1857 |          . | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1858 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1859 |      NOTE: Executing SetScene Tasks | 
 | 1860 |      NOTE: Executing RunQueue Tasks | 
 | 1861 |      WARNING: linux-yocto-4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0 do_kernel_configcheck: | 
 | 1862 |          [kernel config]: specified values did not make it into the kernel's final configuration: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1863 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1864 |      ---------- CONFIG_X86_TSC ----------------- | 
 | 1865 |      Config: CONFIG_X86_TSC | 
 | 1866 |      From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc-cpu.cfg | 
 | 1867 |      Requested value:  CONFIG_X86_TSC=y | 
 | 1868 |      Actual value: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1869 |  | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1870 |  | 
 | 1871 |      ---------- CONFIG_X86_BIGSMP ----------------- | 
 | 1872 |      Config: CONFIG_X86_BIGSMP | 
 | 1873 |      From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | 
 | 1874 |            /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | 
 | 1875 |      Requested value:  # CONFIG_X86_BIGSMP is not set | 
 | 1876 |      Actual value: | 
 | 1877 |  | 
 | 1878 |  | 
 | 1879 |      ---------- CONFIG_NR_CPUS ----------------- | 
 | 1880 |      Config: CONFIG_NR_CPUS | 
 | 1881 |      From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | 
 | 1882 |            /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc.cfg | 
 | 1883 |            /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | 
 | 1884 |      Requested value:  CONFIG_NR_CPUS=8 | 
 | 1885 |      Actual value:     CONFIG_NR_CPUS=1 | 
 | 1886 |  | 
 | 1887 |  | 
 | 1888 |      ---------- CONFIG_SCHED_SMT ----------------- | 
 | 1889 |      Config: CONFIG_SCHED_SMT | 
 | 1890 |      From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | 
 | 1891 |            /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | 
 | 1892 |      Requested value:  CONFIG_SCHED_SMT=y | 
 | 1893 |      Actual value: | 
 | 1894 |  | 
 | 1895 |  | 
 | 1896 |  | 
 | 1897 |      NOTE: Tasks Summary: Attempted 288 tasks of which 285 didn't need to be rerun and all succeeded. | 
 | 1898 |  | 
 | 1899 |      Summary: There were 3 WARNING messages shown. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1900 |                 </literallayout> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1901 |                 <note> | 
 | 1902 |                     The previous output example has artificial line breaks | 
 | 1903 |                     to make it more readable. | 
 | 1904 |                 </note> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1905 |             </para> | 
 | 1906 |  | 
 | 1907 |             <para> | 
 | 1908 |                 The output describes the various problems that you can | 
 | 1909 |                 encounter along with where to find the offending configuration | 
 | 1910 |                 items. | 
 | 1911 |                 You can use the information in the logs to adjust your | 
 | 1912 |                 configuration files and then repeat the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1913 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configme'><filename>do_kernel_configme</filename></ulink> | 
 | 1914 |                 and | 
 | 1915 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configcheck'><filename>do_kernel_configcheck</filename></ulink> | 
 | 1916 |                 tasks until they produce no warnings. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1917 |             </para> | 
 | 1918 |  | 
 | 1919 |             <para> | 
 | 1920 |                 For more information on how to use the | 
 | 1921 |                 <filename>menuconfig</filename> tool, see the | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1922 |                 "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1923 |                 section. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1924 |             </para> | 
 | 1925 |         </section> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1926 |  | 
 | 1927 |         <section id='fine-tuning-the-kernel-configuration-file'> | 
 | 1928 |             <title>Fine-Tuning the Kernel Configuration File</title> | 
 | 1929 |  | 
 | 1930 |             <para> | 
 | 1931 |                 You can make sure the <filename>.config</filename> file is as | 
 | 1932 |                 lean or efficient as possible by reading the output of the | 
 | 1933 |                 kernel configuration fragment audit, noting any issues, making | 
 | 1934 |                 changes to correct the issues, and then repeating. | 
 | 1935 |             </para> | 
 | 1936 |  | 
 | 1937 |             <para> | 
 | 1938 |                 As part of the kernel build process, the | 
 | 1939 |                 <filename>do_kernel_configcheck</filename> task runs. | 
 | 1940 |                 This task validates the kernel configuration by checking the | 
 | 1941 |                 final <filename>.config</filename> file against the input | 
 | 1942 |                 files. | 
 | 1943 |                 During the check, the task produces warning messages for the | 
 | 1944 |                 following issues: | 
 | 1945 |                 <itemizedlist> | 
 | 1946 |                     <listitem><para> | 
 | 1947 |                         Requested options that did not make the final | 
 | 1948 |                         <filename>.config</filename> file. | 
 | 1949 |                         </para></listitem> | 
 | 1950 |                     <listitem><para> | 
 | 1951 |                         Configuration items that appear twice in the same | 
 | 1952 |                         configuration fragment. | 
 | 1953 |                         </para></listitem> | 
 | 1954 |                     <listitem><para> | 
 | 1955 |                         Configuration items tagged as "required" that were | 
 | 1956 |                         overridden. | 
 | 1957 |                         </para></listitem> | 
 | 1958 |                     <listitem><para> | 
 | 1959 |                         A board overrides a non-board specific option. | 
 | 1960 |                         </para></listitem> | 
 | 1961 |                     <listitem><para> | 
 | 1962 |                         Listed options not valid for the kernel being | 
 | 1963 |                         processed. | 
 | 1964 |                         In other words, the option does not appear anywhere. | 
 | 1965 |                         </para></listitem> | 
 | 1966 |                 </itemizedlist> | 
 | 1967 |                 <note> | 
 | 1968 |                     The <filename>do_kernel_configcheck</filename> task can | 
 | 1969 |                     also optionally report if an option is overridden during | 
 | 1970 |                     processing. | 
 | 1971 |                 </note> | 
 | 1972 |             </para> | 
 | 1973 |  | 
 | 1974 |             <para> | 
 | 1975 |                 For each output warning, a message points to the file | 
 | 1976 |                 that contains a list of the options and a pointer to the | 
 | 1977 |                 configuration fragment that defines them. | 
 | 1978 |                 Collectively, the files are the key to streamlining the | 
 | 1979 |                 configuration. | 
 | 1980 |             </para> | 
 | 1981 |  | 
 | 1982 |             <para> | 
 | 1983 |                 To streamline the configuration, do the following: | 
 | 1984 |                 <orderedlist> | 
 | 1985 |                     <listitem><para> | 
 | 1986 |                         <emphasis>Use a Working Configuration:</emphasis> | 
 | 1987 |                         Start with a full configuration that you | 
 | 1988 |                         know works. | 
 | 1989 |                         Be sure the configuration builds and boots | 
 | 1990 |                         successfully. | 
 | 1991 |                         Use this configuration file as your baseline. | 
 | 1992 |                         </para></listitem> | 
 | 1993 |                     <listitem><para> | 
 | 1994 |                         <emphasis>Run Configure and Check Tasks:</emphasis> | 
 | 1995 |                         Separately run the | 
 | 1996 |                         <filename>do_kernel_configme</filename> and | 
 | 1997 |                         <filename>do_kernel_configcheck</filename> tasks: | 
 | 1998 |                         <literallayout class='monospaced'> | 
 | 1999 |      $ bitbake linux-yocto -c kernel_configme -f | 
 | 2000 |      $ bitbake linux-yocto -c kernel_configcheck -f | 
 | 2001 |                         </literallayout> | 
 | 2002 |                         </para></listitem> | 
 | 2003 |                     <listitem><para> | 
 | 2004 |                         <emphasis>Process the Results:</emphasis> | 
 | 2005 |                         Take the resulting list of files from the | 
 | 2006 |                         <filename>do_kernel_configcheck</filename> task | 
 | 2007 |                         warnings and do the following: | 
 | 2008 |                         <itemizedlist> | 
 | 2009 |                             <listitem><para> | 
 | 2010 |                                 Drop values that are redefined in the fragment | 
 | 2011 |                                 but do not change the final | 
 | 2012 |                                 <filename>.config</filename> file. | 
 | 2013 |                                 </para></listitem> | 
 | 2014 |                             <listitem><para> | 
 | 2015 |                                 Analyze and potentially drop values from the | 
 | 2016 |                                 <filename>.config</filename> file that override | 
 | 2017 |                                 required configurations. | 
 | 2018 |                                 </para></listitem> | 
 | 2019 |                             <listitem><para> | 
 | 2020 |                                 Analyze and potentially remove non-board | 
 | 2021 |                                 specific options. | 
 | 2022 |                                 </para></listitem> | 
 | 2023 |                             <listitem><para> | 
 | 2024 |                                 Remove repeated and invalid options. | 
 | 2025 |                                 </para></listitem> | 
 | 2026 |                         </itemizedlist> | 
 | 2027 |                         </para></listitem> | 
 | 2028 |                     <listitem><para> | 
 | 2029 |                         <emphasis>Re-Run Configure and Check Tasks:</emphasis> | 
 | 2030 |                         After you have worked through the output of the kernel | 
 | 2031 |                         configuration audit, you can re-run the | 
 | 2032 |                         <filename>do_kernel_configme</filename> and | 
 | 2033 |                         <filename>do_kernel_configcheck</filename> tasks to | 
 | 2034 |                         see the results of your changes. | 
 | 2035 |                         If you have more issues, you can deal with them as | 
 | 2036 |                         described in the previous step. | 
 | 2037 |                         </para></listitem> | 
 | 2038 |                 </orderedlist> | 
 | 2039 |             </para> | 
 | 2040 |  | 
 | 2041 |             <para> | 
 | 2042 |                 Iteratively working through steps two through four eventually | 
 | 2043 |                 yields a minimal, streamlined configuration file. | 
 | 2044 |                 Once you have the best <filename>.config</filename>, you can | 
 | 2045 |                 build the Linux Yocto kernel. | 
 | 2046 |             </para> | 
 | 2047 |         </section> | 
 | 2048 |     </section> | 
 | 2049 |  | 
 | 2050 |     <section id='expanding-variables'> | 
 | 2051 |         <title>Expanding Variables</title> | 
 | 2052 |  | 
 | 2053 |         <para> | 
 | 2054 |             Sometimes it is helpful to determine what a variable expands | 
 | 2055 |             to during a build. | 
 | 2056 |             You can do examine the values of variables by examining the | 
 | 2057 |             output of the <filename>bitbake -e</filename> command. | 
 | 2058 |             The output is long and is more easily managed in a text file, | 
 | 2059 |             which allows for easy searches: | 
 | 2060 |             <literallayout class='monospaced'> | 
 | 2061 |      $ bitbake -e virtual/kernel > <replaceable>some_text_file</replaceable> | 
 | 2062 |             </literallayout> | 
 | 2063 |             Within the text file, you can see exactly how each variable is | 
 | 2064 |             expanded and used by the OpenEmbedded build system. | 
 | 2065 |         </para> | 
 | 2066 |     </section> | 
 | 2067 |  | 
 | 2068 |     <section id='working-with-a-dirty-kernel-version-string'> | 
 | 2069 |         <title>Working with a "Dirty" Kernel Version String</title> | 
 | 2070 |  | 
 | 2071 |         <para> | 
 | 2072 |             If you build a kernel image and the version string has a | 
 | 2073 |             "+" or a "-dirty" at the end, uncommitted modifications exist | 
 | 2074 |             in the kernel's source directory. | 
 | 2075 |             Follow these steps to clean up the version string: | 
 | 2076 |             <orderedlist> | 
 | 2077 |                 <listitem><para> | 
 | 2078 |                     <emphasis>Discover the Uncommitted Changes:</emphasis> | 
 | 2079 |                     Go to the kernel's locally cloned Git repository | 
 | 2080 |                     (source directory) and use the following Git command | 
 | 2081 |                     to list the files that have been changed, added, or | 
 | 2082 |                     removed: | 
 | 2083 |                     <literallayout class='monospaced'> | 
 | 2084 |      $ git status | 
 | 2085 |                     </literallayout> | 
 | 2086 |                     </para></listitem> | 
 | 2087 |                 <listitem><para> | 
 | 2088 |                     <emphasis>Commit the Changes:</emphasis> | 
 | 2089 |                     You should commit those changes to the kernel source | 
 | 2090 |                     tree regardless of whether or not you will save, | 
 | 2091 |                     export, or use the changes: | 
 | 2092 |                     <literallayout class='monospaced'> | 
 | 2093 |      $ git add | 
 | 2094 |      $ git commit -s -a -m "getting rid of -dirty" | 
 | 2095 |                     </literallayout> | 
 | 2096 |                     </para></listitem> | 
 | 2097 |                 <listitem><para> | 
 | 2098 |                     <emphasis>Rebuild the Kernel Image:</emphasis> | 
 | 2099 |                     Once you commit the changes, rebuild the kernel.</para> | 
 | 2100 |  | 
 | 2101 |                     <para>Depending on your particular kernel development | 
 | 2102 |                     workflow, the commands you use to rebuild the | 
 | 2103 |                     kernel might differ. | 
 | 2104 |                     For information on building the kernel image when | 
 | 2105 |                     using <filename>devtool</filename>, see the | 
 | 2106 |                     "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" | 
 | 2107 |                     section. | 
 | 2108 |                     For information on building the kernel image when | 
 | 2109 |                     using Bitbake, see the | 
 | 2110 |                     "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>" | 
 | 2111 |                     section. | 
 | 2112 |                     </para></listitem> | 
 | 2113 |             </orderedlist> | 
 | 2114 |         </para> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2115 |     </section> | 
 | 2116 |  | 
 | 2117 |     <section id='working-with-your-own-sources'> | 
 | 2118 |         <title>Working With Your Own Sources</title> | 
 | 2119 |  | 
 | 2120 |         <para> | 
 | 2121 |             If you cannot work with one of the Linux kernel | 
 | 2122 |             versions supported by existing linux-yocto recipes, you can | 
 | 2123 |             still make use of the Yocto Project Linux kernel tooling by | 
 | 2124 |             working with your own sources. | 
 | 2125 |             When you use your own sources, you will not be able to | 
 | 2126 |             leverage the existing kernel | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2127 |             <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> and | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2128 |             stabilization work of the linux-yocto sources. | 
 | 2129 |             However, you will be able to manage your own Metadata in the same | 
 | 2130 |             format as the linux-yocto sources. | 
 | 2131 |             Maintaining format compatibility facilitates converging with | 
 | 2132 |             linux-yocto on a future, mutually-supported kernel version. | 
 | 2133 |         </para> | 
 | 2134 |  | 
 | 2135 |         <para> | 
 | 2136 |             To help you use your own sources, the Yocto Project provides a | 
 | 2137 |             linux-yocto custom recipe | 
 | 2138 |             (<filename>linux-yocto-custom.bb</filename>) that uses | 
 | 2139 |             <filename>kernel.org</filename> sources | 
 | 2140 |             and the Yocto Project Linux kernel tools for managing | 
 | 2141 |             kernel Metadata. | 
 | 2142 |             You can find this recipe in the | 
 | 2143 |             <filename>poky</filename> Git repository of the | 
 | 2144 |             Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink> | 
 | 2145 |             at: | 
 | 2146 |             <literallayout class="monospaced"> | 
 | 2147 |      poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb | 
 | 2148 |             </literallayout> | 
 | 2149 |         </para> | 
 | 2150 |  | 
 | 2151 |         <para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2152 |             Here are some basic steps you can use to work with your own | 
 | 2153 |             sources: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2154 |             <orderedlist> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2155 |                 <listitem><para> | 
 | 2156 |                     <emphasis>Create a Copy of the Kernel Recipe:</emphasis> | 
 | 2157 |                     Copy the <filename>linux-yocto-custom.bb</filename> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2158 |                     recipe to your layer and give it a meaningful name. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2159 |                     The name should include the version of the Yocto Linux | 
 | 2160 |                     kernel you are using (e.g. | 
 | 2161 |                     <filename>linux-yocto-myproject_4.12.bb</filename>, | 
 | 2162 |                     where "4.12" is the base version of the Linux kernel | 
 | 2163 |                     with which you would be working). | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2164 |                     </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2165 |                 <listitem><para> | 
 | 2166 |                     <emphasis>Create a Directory for Your Patches:</emphasis> | 
 | 2167 |                     In the same directory inside your layer, create a matching | 
 | 2168 |                     directory to store your patches and configuration files | 
 | 2169 |                     (e.g. <filename>linux-yocto-myproject</filename>). | 
 | 2170 |                     </para></listitem> | 
 | 2171 |                 <listitem><para> | 
 | 2172 |                     <emphasis>Ensure You Have Configurations:</emphasis> | 
 | 2173 |                     Make sure you have either a <filename>defconfig</filename> | 
 | 2174 |                     file or configuration fragment files in your layer. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2175 |                     When you use the <filename>linux-yocto-custom.bb</filename> | 
 | 2176 |                     recipe, you must specify a configuration. | 
 | 2177 |                     If you do not have a <filename>defconfig</filename> file, | 
 | 2178 |                     you can run the following: | 
 | 2179 |                     <literallayout class='monospaced'> | 
 | 2180 |      $ make defconfig | 
 | 2181 |                     </literallayout> | 
 | 2182 |                     After running the command, copy the resulting | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2183 |                     <filename>.config</filename> file to the | 
 | 2184 |                     <filename>files</filename> directory in your layer | 
 | 2185 |                     as "defconfig" and then add it to the | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2186 |                     <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 2187 |                     variable in the recipe.</para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2188 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2189 |                     <para>Running the <filename>make defconfig</filename> | 
 | 2190 |                     command results in the default configuration for your | 
 | 2191 |                     architecture as defined by your kernel. | 
 | 2192 |                     However, no guarantee exists that this configuration is | 
 | 2193 |                     valid for your use case, or that your board will even boot. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2194 |                     This is particularly true for non-x86 architectures.</para> | 
 | 2195 |  | 
 | 2196 |                     <para>To use non-x86 <filename>defconfig</filename> files, | 
 | 2197 |                     you need to be more specific and find one that matches your | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2198 |                     board (i.e. for arm, you look in | 
 | 2199 |                     <filename>arch/arm/configs</filename> and use the one that | 
 | 2200 |                     is the best starting point for your board). | 
 | 2201 |                     </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2202 |                 <listitem><para> | 
 | 2203 |                     <emphasis>Edit the Recipe:</emphasis> | 
 | 2204 |                     Edit the following variables in your recipe as appropriate | 
 | 2205 |                     for your project: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2206 |                     <itemizedlist> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2207 |                         <listitem><para> | 
 | 2208 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2209 |                             The <filename>SRC_URI</filename> should specify | 
 | 2210 |                             a Git repository that uses one of the supported Git | 
 | 2211 |                             fetcher protocols (i.e. <filename>file</filename>, | 
 | 2212 |                             <filename>git</filename>, <filename>http</filename>, | 
 | 2213 |                             and so forth). | 
 | 2214 |                             The <filename>SRC_URI</filename> variable should | 
 | 2215 |                             also specify either a <filename>defconfig</filename> | 
 | 2216 |                             file or some configuration fragment files. | 
 | 2217 |                             The skeleton recipe provides an example | 
 | 2218 |                             <filename>SRC_URI</filename> as a syntax reference. | 
 | 2219 |                             </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2220 |                         <listitem><para> | 
 | 2221 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION'><filename>LINUX_VERSION</filename></ulink>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2222 |                             The Linux kernel version you are using (e.g. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2223 |                             "4.12"). | 
 | 2224 |                             </para></listitem> | 
 | 2225 |                         <listitem><para> | 
 | 2226 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION_EXTENSION'><filename>LINUX_VERSION_EXTENSION</filename></ulink>: | 
 | 2227 |                             The Linux kernel | 
 | 2228 |                             <filename>CONFIG_LOCALVERSION</filename> that is | 
 | 2229 |                             compiled into the resulting kernel and visible | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2230 |                             through the <filename>uname</filename> command. | 
 | 2231 |                             </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2232 |                         <listitem><para> | 
 | 2233 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2234 |                             The commit ID from which you want to build. | 
 | 2235 |                             </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2236 |                         <listitem><para> | 
 | 2237 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>: | 
 | 2238 |                             Treat this variable the same as you would in any | 
 | 2239 |                             other recipe. | 
 | 2240 |                             Increment the variable to indicate to the | 
 | 2241 |                             OpenEmbedded build system that the recipe has | 
 | 2242 |                             changed. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2243 |                             </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2244 |                         <listitem><para> | 
 | 2245 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2246 |                             The default <filename>PV</filename> assignment is | 
 | 2247 |                             typically adequate. | 
 | 2248 |                             It combines the <filename>LINUX_VERSION</filename> | 
 | 2249 |                             with the Source Control Manager (SCM) revision | 
 | 2250 |                             as derived from the | 
 | 2251 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink> | 
 | 2252 |                             variable. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2253 |                             The combined results are a string with the | 
 | 2254 |                             following form: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2255 |                             <literallayout class='monospaced'> | 
 | 2256 |      3.19.11+git1+68a635bf8dfb64b02263c1ac80c948647cc76d5f_1+218bd8d2022b9852c60d32f0d770931e3cf343e2 | 
 | 2257 |                             </literallayout> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2258 |                             While lengthy, the extra verbosity in | 
 | 2259 |                             <filename>PV</filename> helps ensure you are using | 
 | 2260 |                             the exact sources from which you intend to build. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2261 |                             </para></listitem> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2262 |                         <listitem><para> | 
 | 2263 |                             <ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'><filename>COMPATIBLE_MACHINE</filename></ulink>: | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2264 |                             A list of the machines supported by your new recipe. | 
 | 2265 |                             This variable in the example recipe is set | 
 | 2266 |                             by default to a regular expression that matches | 
 | 2267 |                             only the empty string, "(^$)". | 
 | 2268 |                             This default setting triggers an explicit build | 
 | 2269 |                             failure. | 
 | 2270 |                             You must change it to match a list of the machines | 
 | 2271 |                             that your new recipe supports. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2272 |                             For example, to support the | 
 | 2273 |                             <filename>qemux86</filename> and | 
 | 2274 |                             <filename>qemux86-64</filename> machines, use | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2275 |                             the following form: | 
 | 2276 |                             <literallayout class='monospaced'> | 
 | 2277 |      COMPATIBLE_MACHINE = "qemux86|qemux86-64" | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2278 |                             </literallayout> | 
 | 2279 |                             </para></listitem> | 
 | 2280 |                     </itemizedlist> | 
 | 2281 |                     </para></listitem> | 
 | 2282 |                 <listitem><para> | 
 | 2283 |                     <emphasis>Customize Your Recipe as Needed:</emphasis> | 
 | 2284 |                     Provide further customizations to your recipe | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2285 |                     as needed just as you would customize an existing | 
 | 2286 |                     linux-yocto recipe. | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2287 |                     See the | 
 | 2288 |                     "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>" | 
 | 2289 |                     section for information. | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2290 |                     </para></listitem> | 
 | 2291 |             </orderedlist> | 
 | 2292 |         </para> | 
 | 2293 |     </section> | 
 | 2294 |  | 
 | 2295 |     <section id='working-with-out-of-tree-modules'> | 
 | 2296 |         <title>Working with Out-of-Tree Modules</title> | 
 | 2297 |  | 
 | 2298 |         <para> | 
 | 2299 |             This section describes steps to build out-of-tree modules on | 
 | 2300 |             your target and describes how to incorporate out-of-tree modules | 
 | 2301 |             in the build. | 
 | 2302 |         </para> | 
 | 2303 |  | 
 | 2304 |         <section id='building-out-of-tree-modules-on-the-target'> | 
 | 2305 |             <title>Building Out-of-Tree Modules on the Target</title> | 
 | 2306 |  | 
 | 2307 |             <para> | 
 | 2308 |                 While the traditional Yocto Project development model would be | 
 | 2309 |                 to include kernel modules as part of the normal build | 
 | 2310 |                 process, you might find it useful to build modules on the | 
 | 2311 |                 target. | 
 | 2312 |                 This could be the case if your target system is capable | 
 | 2313 |                 and powerful enough to handle the necessary compilation. | 
 | 2314 |                 Before deciding to build on your target, however, you should | 
 | 2315 |                 consider the benefits of using a proper cross-development | 
 | 2316 |                 environment from your build host. | 
 | 2317 |             </para> | 
 | 2318 |  | 
 | 2319 |             <para> | 
 | 2320 |                 If you want to be able to build out-of-tree modules on | 
 | 2321 |                 the target, there are some steps you need to take | 
 | 2322 |                 on the target that is running your SDK image. | 
 | 2323 |                 Briefly, the <filename>kernel-dev</filename> package | 
 | 2324 |                 is installed by default on all | 
 | 2325 |                 <filename>*.sdk</filename> images and the | 
 | 2326 |                 <filename>kernel-devsrc</filename> package is installed | 
 | 2327 |                 on many of the <filename>*.sdk</filename> images. | 
 | 2328 |                 However, you need to create some scripts prior to | 
 | 2329 |                 attempting to build the out-of-tree modules on the target | 
 | 2330 |                 that is running that image. | 
 | 2331 |             </para> | 
 | 2332 |  | 
 | 2333 |             <para> | 
 | 2334 |                 Prior to attempting to build the out-of-tree modules, | 
 | 2335 |                 you need to be on the target as root and you need to | 
 | 2336 |                 change to the <filename>/usr/src/kernel</filename> directory. | 
 | 2337 |                 Next, <filename>make</filename> the scripts: | 
 | 2338 |                 <literallayout class='monospaced'> | 
 | 2339 |      # cd /usr/src/kernel | 
 | 2340 |      # make scripts | 
 | 2341 |                 </literallayout> | 
 | 2342 |                 Because all SDK image recipes include | 
 | 2343 |                 <filename>dev-pkgs</filename>, the | 
 | 2344 |                 <filename>kernel-dev</filename> packages will be installed | 
 | 2345 |                 as part of the SDK image and the | 
 | 2346 |                 <filename>kernel-devsrc</filename> packages will be installed | 
 | 2347 |                 as part of applicable SDK images. | 
 | 2348 |                 The SDK uses the scripts when building out-of-tree | 
 | 2349 |                 modules. | 
 | 2350 |                 Once you have switched to that directory and created the | 
 | 2351 |                 scripts, you should be able to build your out-of-tree modules | 
 | 2352 |                 on the target. | 
 | 2353 |             </para> | 
 | 2354 |         </section> | 
 | 2355 |  | 
 | 2356 |         <section id='incorporating-out-of-tree-modules'> | 
 | 2357 |             <title>Incorporating Out-of-Tree Modules</title> | 
 | 2358 |  | 
 | 2359 |             <para> | 
 | 2360 |                 While it is always preferable to work with sources integrated | 
 | 2361 |                 into the Linux kernel sources, if you need an external kernel | 
 | 2362 |                 module, the <filename>hello-mod.bb</filename> recipe is | 
 | 2363 |                 available as a template from which you can create your | 
 | 2364 |                 own out-of-tree Linux kernel module recipe. | 
 | 2365 |             </para> | 
 | 2366 |  | 
 | 2367 |             <para> | 
 | 2368 |                 This template recipe is located in the | 
 | 2369 |                 <filename>poky</filename> Git repository of the | 
 | 2370 |                 Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink> | 
 | 2371 |                 at: | 
 | 2372 |                 <literallayout class="monospaced"> | 
 | 2373 |      poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb | 
 | 2374 |                 </literallayout> | 
 | 2375 |             </para> | 
 | 2376 |  | 
 | 2377 |             <para> | 
 | 2378 |                 To get started, copy this recipe to your layer and give it a | 
 | 2379 |                 meaningful name (e.g. <filename>mymodule_1.0.bb</filename>). | 
 | 2380 |                 In the same directory, create a new directory named | 
 | 2381 |                 <filename>files</filename> where you can store any source files, | 
 | 2382 |                 patches, or other files necessary for building | 
 | 2383 |                 the module that do not come with the sources. | 
 | 2384 |                 Finally, update the recipe as needed for the module. | 
 | 2385 |                 Typically, you will need to set the following variables: | 
 | 2386 |                 <itemizedlist> | 
 | 2387 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> | 
 | 2388 |                         </para></listitem> | 
 | 2389 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE*</filename></ulink> | 
 | 2390 |                         </para></listitem> | 
 | 2391 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 2392 |                         </para></listitem> | 
 | 2393 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> | 
 | 2394 |                         </para></listitem> | 
 | 2395 |                 </itemizedlist> | 
 | 2396 |             </para> | 
 | 2397 |  | 
 | 2398 |             <para> | 
 | 2399 |                 Depending on the build system used by the module sources, | 
 | 2400 |                 you might need to make some adjustments. | 
 | 2401 |                 For example, a typical module <filename>Makefile</filename> | 
 | 2402 |                 looks much like the one provided with the | 
 | 2403 |                 <filename>hello-mod</filename> template: | 
 | 2404 |                 <literallayout class='monospaced'> | 
 | 2405 |      obj-m := hello.o | 
 | 2406 |  | 
 | 2407 |      SRC := $(shell pwd) | 
 | 2408 |  | 
 | 2409 |      all: | 
 | 2410 |          $(MAKE) -C $(KERNEL_SRC) M=$(SRC) | 
 | 2411 |  | 
 | 2412 |      modules_install: | 
 | 2413 |          $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install | 
 | 2414 |      ... | 
 | 2415 |                 </literallayout> | 
 | 2416 |             </para> | 
 | 2417 |  | 
 | 2418 |             <para> | 
 | 2419 |                 The important point to note here is the | 
 | 2420 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_SRC'><filename>KERNEL_SRC</filename></ulink> | 
 | 2421 |                 variable. | 
 | 2422 |                 The | 
 | 2423 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-module'><filename>module</filename></ulink> | 
 | 2424 |                 class sets this variable and the | 
 | 2425 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_PATH'><filename>KERNEL_PATH</filename></ulink> | 
 | 2426 |                 variable to | 
 | 2427 |                 <filename>${<ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>}</filename> | 
 | 2428 |                 with the necessary Linux kernel build information to build | 
 | 2429 |                 modules. | 
 | 2430 |                 If your module <filename>Makefile</filename> uses a different | 
 | 2431 |                 variable, you might want to override the | 
 | 2432 |                 <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile()</filename></ulink> | 
 | 2433 |                 step, or create a patch to | 
 | 2434 |                 the <filename>Makefile</filename> to work with the more typical | 
 | 2435 |                 <filename>KERNEL_SRC</filename> or | 
 | 2436 |                 <filename>KERNEL_PATH</filename> variables. | 
 | 2437 |             </para> | 
 | 2438 |  | 
 | 2439 |             <para> | 
 | 2440 |                 After you have prepared your recipe, you will likely want to | 
 | 2441 |                 include the module in your images. | 
 | 2442 |                 To do this, see the documentation for the following variables in | 
 | 2443 |                 the Yocto Project Reference Manual and set one of them | 
 | 2444 |                 appropriately for your machine configuration file: | 
 | 2445 |                 <itemizedlist> | 
 | 2446 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RDEPENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RDEPENDS</filename></ulink> | 
 | 2447 |                         </para></listitem> | 
 | 2448 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink> | 
 | 2449 |                         </para></listitem> | 
 | 2450 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RDEPENDS'><filename>MACHINE_EXTRA_RDEPENDS</filename></ulink> | 
 | 2451 |                         </para></listitem> | 
 | 2452 |                     <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RRECOMMENDS'><filename>MACHINE_EXTRA_RRECOMMENDS</filename></ulink> | 
 | 2453 |                         </para></listitem> | 
 | 2454 |                 </itemizedlist> | 
 | 2455 |             </para> | 
 | 2456 |  | 
 | 2457 |             <para> | 
 | 2458 |                 Modules are often not required for boot and can be excluded from | 
 | 2459 |                 certain build configurations. | 
 | 2460 |                 The following allows for the most flexibility: | 
 | 2461 |                 <literallayout class='monospaced'> | 
 | 2462 |      MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" | 
 | 2463 |                 </literallayout> | 
 | 2464 |                 The value is derived by appending the module filename without | 
 | 2465 |                 the <filename>.ko</filename> extension to the string | 
 | 2466 |                 "kernel-module-". | 
 | 2467 |             </para> | 
 | 2468 |  | 
 | 2469 |             <para> | 
 | 2470 |                 Because the variable is | 
 | 2471 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> | 
 | 2472 |                 and not a | 
 | 2473 |                 <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> | 
 | 2474 |                 variable, the build will not fail if this module is not | 
 | 2475 |                 available to include in the image. | 
 | 2476 |             </para> | 
 | 2477 |         </section> | 
 | 2478 |     </section> | 
 | 2479 |  | 
 | 2480 |  | 
 | 2481 |     <section id='inspecting-changes-and-commits'> | 
 | 2482 |         <title>Inspecting Changes and Commits</title> | 
 | 2483 |  | 
 | 2484 |         <para> | 
 | 2485 |             A common question when working with a kernel is: | 
 | 2486 |             "What changes have been applied to this tree?" | 
 | 2487 |             Rather than using "grep" across directories to see what has | 
 | 2488 |             changed, you can use Git to inspect or search the kernel tree. | 
 | 2489 |             Using Git is an efficient way to see what has changed in the tree. | 
 | 2490 |         </para> | 
 | 2491 |  | 
 | 2492 |         <section id='what-changed-in-a-kernel'> | 
 | 2493 |             <title>What Changed in a Kernel?</title> | 
 | 2494 |  | 
 | 2495 |             <para> | 
 | 2496 |                 Following are a few examples that show how to use Git | 
 | 2497 |                 commands to examine changes. | 
 | 2498 |                 These examples are by no means the only way to see changes. | 
 | 2499 |                 <note> | 
 | 2500 |                     In the following examples, unless you provide a commit | 
 | 2501 |                     range, <filename>kernel.org</filename> history is blended | 
 | 2502 |                     with Yocto Project kernel changes. | 
 | 2503 |                     You can form ranges by using branch names from the | 
 | 2504 |                     kernel tree as the upper and lower commit markers with | 
 | 2505 |                     the Git commands. | 
 | 2506 |                     You can see the branch names through the web interface | 
 | 2507 |                     to the Yocto Project source repositories at | 
 | 2508 |                     <ulink url='http://git.yoctoproject.org/cgit.cgi'></ulink>. | 
 | 2509 |                 </note> | 
 | 2510 |                 To see a full range of the changes, use the | 
 | 2511 |                 <filename>git whatchanged</filename> command and specify a | 
 | 2512 |                 commit range for the branch | 
 | 2513 |                 (<replaceable>commit</replaceable><filename>..</filename><replaceable>commit</replaceable>). | 
 | 2514 |             </para> | 
 | 2515 |  | 
 | 2516 |             <para> | 
 | 2517 |                 Here is an example that looks at what has changed in the | 
 | 2518 |                 <filename>emenlow</filename> branch of the | 
 | 2519 |                 <filename>linux-yocto-3.19</filename> kernel. | 
 | 2520 |                 The lower commit range is the commit associated with the | 
 | 2521 |                 <filename>standard/base</filename> branch, while | 
 | 2522 |                 the upper commit range is the commit associated with the | 
 | 2523 |                 <filename>standard/emenlow</filename> branch. | 
 | 2524 |                 <literallayout class='monospaced'> | 
 | 2525 |      $ git whatchanged origin/standard/base..origin/standard/emenlow | 
 | 2526 |                 </literallayout> | 
 | 2527 |             </para> | 
 | 2528 |  | 
 | 2529 |             <para> | 
 | 2530 |                 To see short, one line summaries of changes use the | 
 | 2531 |                 <filename>git log</filename> command: | 
 | 2532 |                 <literallayout class='monospaced'> | 
 | 2533 |      $ git log --oneline origin/standard/base..origin/standard/emenlow | 
 | 2534 |                 </literallayout> | 
 | 2535 |             </para> | 
 | 2536 |  | 
 | 2537 |             <para> | 
 | 2538 |                 Use this command to see code differences for the changes: | 
 | 2539 |                 <literallayout class='monospaced'> | 
 | 2540 |      $ git diff origin/standard/base..origin/standard/emenlow | 
 | 2541 |                 </literallayout> | 
 | 2542 |             </para> | 
 | 2543 |  | 
 | 2544 |             <para> | 
 | 2545 |                 Use this command to see the commit log messages and the | 
 | 2546 |                 text differences: | 
 | 2547 |                 <literallayout class='monospaced'> | 
 | 2548 |      $ git show origin/standard/base..origin/standard/emenlow | 
 | 2549 |                 </literallayout> | 
 | 2550 |             </para> | 
 | 2551 |  | 
 | 2552 |             <para> | 
 | 2553 |                 Use this command to create individual patches for | 
 | 2554 |                 each change. | 
 | 2555 |                 Here is an example that that creates patch files for each | 
 | 2556 |                 commit and places them in your <filename>Documents</filename> | 
 | 2557 |                 directory: | 
 | 2558 |                 <literallayout class='monospaced'> | 
 | 2559 |      $ git format-patch -o $HOME/Documents origin/standard/base..origin/standard/emenlow | 
 | 2560 |                 </literallayout> | 
 | 2561 |             </para> | 
 | 2562 |         </section> | 
 | 2563 |  | 
 | 2564 |         <section id='showing-a-particular-feature-or-branch-change'> | 
 | 2565 |             <title>Showing a Particular Feature or Branch Change</title> | 
 | 2566 |  | 
 | 2567 |             <para> | 
 | 2568 |                 Tags in the Yocto Project kernel tree divide changes for | 
 | 2569 |                 significant features or branches. | 
 | 2570 |                 The <filename>git show</filename> <replaceable>tag</replaceable> | 
 | 2571 |                 command shows changes based on a tag. | 
 | 2572 |                 Here is an example that shows <filename>systemtap</filename> | 
 | 2573 |                 changes: | 
 | 2574 |                 <literallayout class='monospaced'> | 
 | 2575 |      $ git show systemtap | 
 | 2576 |                 </literallayout> | 
 | 2577 |                 You can use the | 
 | 2578 |                 <filename>git branch --contains</filename> <replaceable>tag</replaceable> | 
 | 2579 |                 command to show the branches that contain a particular feature. | 
 | 2580 |                 This command shows the branches that contain the | 
 | 2581 |                 <filename>systemtap</filename> feature: | 
 | 2582 |                 <literallayout class='monospaced'> | 
 | 2583 |      $ git branch --contains systemtap | 
 | 2584 |                 </literallayout> | 
 | 2585 |             </para> | 
 | 2586 |         </section> | 
 | 2587 |     </section> | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2588 |  | 
 | 2589 |     <section id='adding-recipe-space-kernel-features'> | 
 | 2590 |         <title>Adding Recipe-Space Kernel Features</title> | 
 | 2591 |  | 
 | 2592 |         <para> | 
 | 2593 |             You can add kernel features in the | 
 | 2594 |             <link linkend='recipe-space-metadata'>recipe-space</link> by | 
 | 2595 |             using the | 
 | 2596 |             <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink> | 
 | 2597 |             variable and by specifying the feature's <filename>.scc</filename> | 
 | 2598 |             file path in the | 
 | 2599 |             <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | 
 | 2600 |             statement. | 
 | 2601 |             When you add features using this method, the OpenEmbedded build | 
 | 2602 |             system checks to be sure the features are present. | 
 | 2603 |             If the features are not present, the build stops. | 
 | 2604 |             Kernel features are the last elements processed for configuring | 
 | 2605 |             and patching the kernel. | 
 | 2606 |             Therefore, adding features in this manner is a way | 
 | 2607 |             to enforce specific features are present and enabled | 
 | 2608 |             without needing to do a full audit of any other layer's additions | 
 | 2609 |             to the <filename>SRC_URI</filename> statement. | 
 | 2610 |         </para> | 
 | 2611 |  | 
 | 2612 |         <para> | 
 | 2613 |             You add a kernel feature by providing the feature as part of the | 
 | 2614 |             <filename>KERNEL_FEATURES</filename> variable and by providing the | 
 | 2615 |             path to the feature's <filename>.scc</filename> file, which is | 
 | 2616 |             relative to the root of the kernel Metadata. | 
 | 2617 |             The OpenEmbedded build system searches all forms of kernel | 
 | 2618 |             Metadata on the <filename>SRC_URI</filename> statement regardless | 
 | 2619 |             of whether the Metadata is in the "kernel-cache", system kernel | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2620 |             Metadata, or a recipe-space Metadata (i.e. part of the kernel | 
 | 2621 |             recipe). | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2622 |             See the | 
 | 2623 |             "<link linkend='kernel-metadata-location'>Kernel Metadata Location</link>" | 
 | 2624 |             section for additional information. | 
 | 2625 |         </para> | 
 | 2626 |  | 
 | 2627 |         <para> | 
 | 2628 |             When you specify the feature's <filename>.scc</filename> file | 
 | 2629 |             on the <filename>SRC_URI</filename> statement, the OpenEmbedded | 
 | 2630 |             build system adds the directory of that | 
 | 2631 |             <filename>.scc</filename> file along with all its subdirectories | 
 | 2632 |             to the kernel feature search path. | 
 | 2633 |             Because subdirectories are searched, you can reference a single | 
 | 2634 |             <filename>.scc</filename> file in the | 
 | 2635 |             <filename>SRC_URI</filename> statement to reference multiple kernel | 
 | 2636 |             features. | 
 | 2637 |         </para> | 
 | 2638 |  | 
 | 2639 |         <para> | 
 | 2640 |             Consider the following example that adds the "test.scc" feature | 
 | 2641 |             to the build. | 
 | 2642 |             <orderedlist> | 
 | 2643 |                 <listitem><para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2644 |                     <emphasis>Create the Feature File:</emphasis> | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2645 |                     Create a <filename>.scc</filename> file and locate it | 
 | 2646 |                     just as you would any other patch file, | 
 | 2647 |                     <filename>.cfg</filename> file, or fetcher item | 
 | 2648 |                     you specify in the <filename>SRC_URI</filename> | 
 | 2649 |                     statement. | 
 | 2650 |                     <note><title>Notes</title> | 
 | 2651 |                         <itemizedlist> | 
 | 2652 |                             <listitem><para> | 
 | 2653 |                                 You must add the directory of the | 
 | 2654 |                                 <filename>.scc</filename> file to the fetcher's | 
 | 2655 |                                 search path in the same manner as you would | 
 | 2656 |                                 add a <filename>.patch</filename> file. | 
 | 2657 |                                 </para></listitem> | 
 | 2658 |                             <listitem><para> | 
 | 2659 |                                 You can create additional | 
 | 2660 |                                 <filename>.scc</filename> files beneath the | 
 | 2661 |                                 directory that contains the file you are | 
 | 2662 |                                 adding. | 
 | 2663 |                                 All subdirectories are searched during the | 
 | 2664 |                                 build as potential feature directories. | 
 | 2665 |                                 </para></listitem> | 
 | 2666 |                         </itemizedlist> | 
 | 2667 |                     </note> | 
 | 2668 |                     Continuing with the example, suppose the "test.scc" | 
 | 2669 |                     feature you are adding has a | 
 | 2670 |                     <filename>test.scc</filename> file in the following | 
 | 2671 |                     directory: | 
 | 2672 |                     <literallayout class='monospaced'> | 
 | 2673 |      <replaceable>my_recipe</replaceable> | 
 | 2674 |         | | 
 | 2675 |         +-linux-yocto | 
 | 2676 |            | | 
 | 2677 |            +-test.cfg | 
 | 2678 |            +-test.scc | 
 | 2679 |                     </literallayout> | 
 | 2680 |                     In this example, the <filename>linux-yocto</filename> | 
 | 2681 |                     directory has both the feature | 
 | 2682 |                     <filename>test.scc</filename> file and a similarly | 
 | 2683 |                     named configuration fragment file | 
 | 2684 |                     <filename>test.cfg</filename>. | 
 | 2685 |                     </para></listitem> | 
 | 2686 |                 <listitem><para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2687 |                     <emphasis>Add the Feature File to <filename>SRC_URI</filename>:</emphasis> | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2688 |                     Add the <filename>.scc</filename> file to the | 
 | 2689 |                     recipe's <filename>SRC_URI</filename> statement: | 
 | 2690 |                     <literallayout class='monospaced'> | 
 | 2691 |      SRC_URI_append = " file://test.scc" | 
 | 2692 |                     </literallayout> | 
 | 2693 |                     The leading space before the path is important as the | 
 | 2694 |                     path is appended to the existing path. | 
 | 2695 |                     </para></listitem> | 
 | 2696 |                 <listitem><para> | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2697 |                     <emphasis>Specify the Feature as a Kernel Feature:</emphasis> | 
 | 2698 |                     Use the <filename>KERNEL_FEATURES</filename> statement | 
 | 2699 |                     to specify the feature as a kernel feature: | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2700 |                     <literallayout class='monospaced'> | 
 | 2701 |      KERNEL_FEATURES_append = " test.scc" | 
 | 2702 |                     </literallayout> | 
 | 2703 |                     The OpenEmbedded build system processes the kernel feature | 
 | 2704 |                     when it builds the kernel. | 
 | 2705 |                     <note> | 
 | 2706 |                         If other features are contained below "test.scc", | 
 | 2707 |                         then their directories are relative to the directory | 
 | 2708 |                         containing the <filename>test.scc</filename> file. | 
 | 2709 |                     </note> | 
 | 2710 |                     </para></listitem> | 
 | 2711 |             </orderedlist> | 
 | 2712 |         </para> | 
 | 2713 |     </section> | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2714 | </chapter> | 
 | 2715 | <!-- | 
 | 2716 | vim: expandtab tw=80 ts=4 | 
 | 2717 | --> |