diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /documentation/kernel-dev | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/kernel-dev')
| -rw-r--r-- | documentation/kernel-dev/advanced.rst | 912 | ||||
| -rw-r--r-- | documentation/kernel-dev/common.rst | 1855 | ||||
| -rw-r--r-- | documentation/kernel-dev/concepts-appx.rst | 420 | ||||
| -rw-r--r-- | documentation/kernel-dev/faq.rst | 76 | ||||
| -rwxr-xr-x | documentation/kernel-dev/figures/kernel-architecture-overview.png | bin | 40748 -> 0 bytes | |||
| -rw-r--r-- | documentation/kernel-dev/figures/kernel-dev-flow.png | bin | 53197 -> 0 bytes | |||
| -rw-r--r-- | documentation/kernel-dev/figures/kernel-dev-title.png | bin | 13453 -> 0 bytes | |||
| -rw-r--r-- | documentation/kernel-dev/figures/kernel-overview-2-generic.png | bin | 49230 -> 0 bytes | |||
| -rw-r--r-- | documentation/kernel-dev/index.rst | 20 | ||||
| -rw-r--r-- | documentation/kernel-dev/intro.rst | 178 | ||||
| -rw-r--r-- | documentation/kernel-dev/maint-appx.rst | 233 |
11 files changed, 0 insertions, 3694 deletions
diff --git a/documentation/kernel-dev/advanced.rst b/documentation/kernel-dev/advanced.rst deleted file mode 100644 index 4c463503f6..0000000000 --- a/documentation/kernel-dev/advanced.rst +++ /dev/null | |||
| @@ -1,912 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ******************************************************* | ||
| 4 | Working with Advanced Metadata (``yocto-kernel-cache``) | ||
| 5 | ******************************************************* | ||
| 6 | |||
| 7 | Overview | ||
| 8 | ======== | ||
| 9 | |||
| 10 | In addition to supporting configuration fragments and patches, the Yocto | ||
| 11 | Project kernel tools also support rich | ||
| 12 | :term:`Metadata` that you can use to define | ||
| 13 | complex policies and Board Support Package (BSP) support. The purpose of | ||
| 14 | the Metadata and the tools that manage it is to help you manage the | ||
| 15 | complexity of the configuration and sources used to support multiple | ||
| 16 | BSPs and Linux kernel types. | ||
| 17 | |||
| 18 | Kernel Metadata exists in many places. One area in the | ||
| 19 | :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 20 | is the ``yocto-kernel-cache`` Git repository. You can find this repository | ||
| 21 | grouped under the "Yocto Linux Kernel" heading in the | ||
| 22 | :yocto_git:`Yocto Project Source Repositories <>`. | ||
| 23 | |||
| 24 | Kernel development tools ("kern-tools") are also available in the Yocto Project | ||
| 25 | Source Repositories under the "Yocto Linux Kernel" heading in the | ||
| 26 | ``yocto-kernel-tools`` Git repository. The recipe that builds these | ||
| 27 | tools is ``meta/recipes-kernel/kern-tools/kern-tools-native_git.bb`` in | ||
| 28 | the :term:`Source Directory` (e.g. | ||
| 29 | ``poky``). | ||
| 30 | |||
| 31 | Using Kernel Metadata in a Recipe | ||
| 32 | ================================= | ||
| 33 | |||
| 34 | As mentioned in the introduction, the Yocto Project contains kernel | ||
| 35 | Metadata, which is located in the ``yocto-kernel-cache`` Git repository. | ||
| 36 | This Metadata defines Board Support Packages (BSPs) that correspond to | ||
| 37 | definitions in linux-yocto recipes for corresponding BSPs. A BSP | ||
| 38 | consists of an aggregation of kernel policy and enabled | ||
| 39 | hardware-specific features. The BSP can be influenced from within the | ||
| 40 | linux-yocto recipe. | ||
| 41 | |||
| 42 | .. note:: | ||
| 43 | |||
| 44 | A Linux kernel recipe that contains kernel Metadata (e.g. inherits | ||
| 45 | from the ``linux-yocto.inc`` file) is said to be a "linux-yocto style" recipe. | ||
| 46 | |||
| 47 | Every linux-yocto style recipe must define the | ||
| 48 | :term:`KMACHINE` variable. This | ||
| 49 | variable is typically set to the same value as the :term:`MACHINE` variable, | ||
| 50 | which is used by :term:`BitBake`. | ||
| 51 | However, in some cases, the variable might instead refer to the | ||
| 52 | underlying platform of the :term:`MACHINE`. | ||
| 53 | |||
| 54 | Multiple BSPs can reuse the same :term:`KMACHINE` name if they are built | ||
| 55 | using the same BSP description. Multiple Corei7-based BSPs could share | ||
| 56 | the same "intel-corei7-64" value for :term:`KMACHINE`. It is important to | ||
| 57 | realize that :term:`KMACHINE` is just for kernel mapping, while :term:`MACHINE` | ||
| 58 | is the machine type within a BSP Layer. Even with this distinction, | ||
| 59 | however, these two variables can hold the same value. See the | ||
| 60 | ":ref:`kernel-dev/advanced:bsp descriptions`" section for more information. | ||
| 61 | |||
| 62 | Every linux-yocto style recipe must also indicate the Linux kernel | ||
| 63 | source repository branch used to build the Linux kernel. The | ||
| 64 | :term:`KBRANCH` variable must be set | ||
| 65 | to indicate the branch. | ||
| 66 | |||
| 67 | .. note:: | ||
| 68 | |||
| 69 | You can use the :term:`KBRANCH` value to define an alternate branch typically | ||
| 70 | with a machine override as shown here from the ``meta-yocto-bsp`` layer:: | ||
| 71 | |||
| 72 | KBRANCH:beaglebone-yocto = "standard/beaglebone" | ||
| 73 | |||
| 74 | The linux-yocto style recipes can optionally define the following | ||
| 75 | variables: | ||
| 76 | |||
| 77 | - :term:`KERNEL_FEATURES` | ||
| 78 | |||
| 79 | - :term:`LINUX_KERNEL_TYPE` | ||
| 80 | |||
| 81 | :term:`LINUX_KERNEL_TYPE` | ||
| 82 | defines the kernel type to be used in assembling the configuration. If | ||
| 83 | you do not specify a :term:`LINUX_KERNEL_TYPE`, it defaults to "standard". | ||
| 84 | Together with :term:`KMACHINE`, :term:`LINUX_KERNEL_TYPE` defines the search | ||
| 85 | arguments used by the kernel tools to find the appropriate description | ||
| 86 | within the kernel Metadata with which to build out the sources and | ||
| 87 | configuration. The linux-yocto recipes define "standard", "tiny", and | ||
| 88 | "preempt-rt" kernel types. See the ":ref:`kernel-dev/advanced:kernel types`" | ||
| 89 | section for more information on kernel types. | ||
| 90 | |||
| 91 | During the build, the kern-tools search for the BSP description file | ||
| 92 | that most closely matches the :term:`KMACHINE` and :term:`LINUX_KERNEL_TYPE` | ||
| 93 | variables passed in from the recipe. The tools use the first BSP | ||
| 94 | description they find that matches both variables. If the tools cannot find | ||
| 95 | a match, they issue a warning. | ||
| 96 | |||
| 97 | The tools first search for the :term:`KMACHINE` and then for the | ||
| 98 | :term:`LINUX_KERNEL_TYPE`. If the tools cannot find a partial match, they | ||
| 99 | will use the sources from the :term:`KBRANCH` and any configuration | ||
| 100 | specified in the :term:`SRC_URI`. | ||
| 101 | |||
| 102 | You can use the | ||
| 103 | :term:`KERNEL_FEATURES` | ||
| 104 | variable to include features (configuration fragments, patches, or both) | ||
| 105 | that are not already included by the :term:`KMACHINE` and | ||
| 106 | :term:`LINUX_KERNEL_TYPE` variable combination. For example, to include a | ||
| 107 | feature specified as "features/netfilter/netfilter.scc", specify:: | ||
| 108 | |||
| 109 | KERNEL_FEATURES += "features/netfilter/netfilter.scc" | ||
| 110 | |||
| 111 | To include a | ||
| 112 | feature called "cfg/sound.scc" just for the ``qemux86`` machine, | ||
| 113 | specify:: | ||
| 114 | |||
| 115 | KERNEL_FEATURES:append:qemux86 = " cfg/sound.scc" | ||
| 116 | |||
| 117 | The value of | ||
| 118 | the entries in :term:`KERNEL_FEATURES` are dependent on their location | ||
| 119 | within the kernel Metadata itself. The examples here are taken from the | ||
| 120 | ``yocto-kernel-cache`` repository. Each branch of this repository | ||
| 121 | contains "features" and "cfg" subdirectories at the top-level. For more | ||
| 122 | information, see the ":ref:`kernel-dev/advanced:kernel metadata syntax`" | ||
| 123 | section. | ||
| 124 | |||
| 125 | Kernel Metadata Syntax | ||
| 126 | ====================== | ||
| 127 | |||
| 128 | The kernel Metadata consists of three primary types of files: ``scc`` | ||
| 129 | [1]_ description files, configuration fragments, and patches. The | ||
| 130 | ``scc`` files define variables and include or otherwise reference any of | ||
| 131 | the three file types. The description files are used to aggregate all | ||
| 132 | types of kernel Metadata into what ultimately describes the sources and | ||
| 133 | the configuration required to build a Linux kernel tailored to a | ||
| 134 | specific machine. | ||
| 135 | |||
| 136 | The ``scc`` description files are used to define two fundamental types | ||
| 137 | of kernel Metadata: | ||
| 138 | |||
| 139 | - Features | ||
| 140 | |||
| 141 | - Board Support Packages (BSPs) | ||
| 142 | |||
| 143 | Features aggregate sources in the form of patches and configuration | ||
| 144 | fragments into a modular reusable unit. You can use features to | ||
| 145 | implement conceptually separate kernel Metadata descriptions such as | ||
| 146 | pure configuration fragments, simple patches, complex features, and | ||
| 147 | kernel types. :ref:`kernel-dev/advanced:kernel types` define general kernel | ||
| 148 | features and policy to be reused in the BSPs. | ||
| 149 | |||
| 150 | BSPs define hardware-specific features and aggregate them with kernel | ||
| 151 | types to form the final description of what will be assembled and built. | ||
| 152 | |||
| 153 | While the kernel Metadata syntax does not enforce any logical separation | ||
| 154 | of configuration fragments, patches, features or kernel types, best | ||
| 155 | practices dictate a logical separation of these types of Metadata. The | ||
| 156 | following Metadata file hierarchy is recommended:: | ||
| 157 | |||
| 158 | base/ | ||
| 159 | bsp/ | ||
| 160 | cfg/ | ||
| 161 | features/ | ||
| 162 | ktypes/ | ||
| 163 | patches/ | ||
| 164 | |||
| 165 | The ``bsp`` directory contains the :ref:`kernel-dev/advanced:bsp descriptions`. | ||
| 166 | The remaining directories all contain "features". Separating ``bsp`` from the | ||
| 167 | rest of the structure aids conceptualizing intended usage. | ||
| 168 | |||
| 169 | Use these guidelines to help place your ``scc`` description files within | ||
| 170 | the structure: | ||
| 171 | |||
| 172 | - If your file contains only configuration fragments, place the file in | ||
| 173 | the ``cfg`` directory. | ||
| 174 | |||
| 175 | - If your file contains only source-code fixes, place the file in the | ||
| 176 | ``patches`` directory. | ||
| 177 | |||
| 178 | - If your file encapsulates a major feature, often combining sources | ||
| 179 | and configurations, place the file in ``features`` directory. | ||
| 180 | |||
| 181 | - If your file aggregates non-hardware configuration and patches in | ||
| 182 | order to define a base kernel policy or major kernel type to be | ||
| 183 | reused across multiple BSPs, place the file in ``ktypes`` directory. | ||
| 184 | |||
| 185 | These distinctions can easily become blurred --- especially as out-of-tree | ||
| 186 | features slowly merge upstream over time. Also, remember that how the | ||
| 187 | description files are placed is a purely logical organization and has no | ||
| 188 | impact on the functionality of the kernel Metadata. There is no impact | ||
| 189 | because all of ``cfg``, ``features``, ``patches``, and ``ktypes``, | ||
| 190 | contain "features" as far as the kernel tools are concerned. | ||
| 191 | |||
| 192 | Paths used in kernel Metadata files are relative to base, which is | ||
| 193 | either | ||
| 194 | :term:`FILESEXTRAPATHS` if | ||
| 195 | you are creating Metadata in | ||
| 196 | :ref:`recipe-space <kernel-dev/advanced:recipe-space metadata>`, | ||
| 197 | or the top level of | ||
| 198 | :yocto_git:`yocto-kernel-cache </yocto-kernel-cache/tree/>` | ||
| 199 | if you are creating | ||
| 200 | :ref:`kernel-dev/advanced:metadata outside the recipe-space`. | ||
| 201 | |||
| 202 | .. [1] | ||
| 203 | ``scc`` stands for Series Configuration Control, but the naming has | ||
| 204 | less significance in the current implementation of the tooling than | ||
| 205 | it had in the past. Consider ``scc`` files to be description files. | ||
| 206 | |||
| 207 | Configuration | ||
| 208 | ------------- | ||
| 209 | |||
| 210 | The simplest unit of kernel Metadata is the configuration-only feature. | ||
| 211 | This feature consists of one or more Linux kernel configuration | ||
| 212 | parameters in a configuration fragment file (``.cfg``) and a ``.scc`` | ||
| 213 | file that describes the fragment. | ||
| 214 | |||
| 215 | As an example, consider the Symmetric Multi-Processing (SMP) fragment | ||
| 216 | used with the ``linux-yocto-4.12`` kernel as defined outside of the | ||
| 217 | recipe space (i.e. ``yocto-kernel-cache``). This Metadata consists of | ||
| 218 | two files: ``smp.scc`` and ``smp.cfg``. You can find these files in the | ||
| 219 | ``cfg`` directory of the ``yocto-4.12`` branch in the | ||
| 220 | ``yocto-kernel-cache`` Git repository:: | ||
| 221 | |||
| 222 | cfg/smp.scc: | ||
| 223 | define KFEATURE_DESCRIPTION "Enable SMP for 32 bit builds" | ||
| 224 | define KFEATURE_COMPATIBILITY all | ||
| 225 | |||
| 226 | kconf hardware smp.cfg | ||
| 227 | |||
| 228 | cfg/smp.cfg: | ||
| 229 | CONFIG_SMP=y | ||
| 230 | CONFIG_SCHED_SMT=y | ||
| 231 | # Increase default NR_CPUS from 8 to 64 so that platform with | ||
| 232 | # more than 8 processors can be all activated at boot time | ||
| 233 | CONFIG_NR_CPUS=64 | ||
| 234 | # The following is needed when setting NR_CPUS to something | ||
| 235 | # greater than 8 on x86 architectures, it should be automatically | ||
| 236 | # disregarded by Kconfig when using a different arch | ||
| 237 | CONFIG_X86_BIGSMP=y | ||
| 238 | |||
| 239 | You can find general information on configuration | ||
| 240 | fragment files in the ":ref:`kernel-dev/common:creating configuration fragments`" section. | ||
| 241 | |||
| 242 | Within the ``smp.scc`` file, the | ||
| 243 | :term:`KFEATURE_DESCRIPTION` | ||
| 244 | statement provides a short description of the fragment. Higher level | ||
| 245 | kernel tools use this description. | ||
| 246 | |||
| 247 | Also within the ``smp.scc`` file, the ``kconf`` command includes the | ||
| 248 | actual configuration fragment in an ``.scc`` file, and the "hardware" | ||
| 249 | keyword identifies the fragment as being hardware enabling, as opposed | ||
| 250 | to general policy, which would use the "non-hardware" keyword. The | ||
| 251 | distinction is made for the benefit of the configuration validation | ||
| 252 | tools, which warn you if a hardware fragment overrides a policy set by a | ||
| 253 | non-hardware fragment. | ||
| 254 | |||
| 255 | .. note:: | ||
| 256 | |||
| 257 | The description file can include multiple ``kconf`` statements, one per | ||
| 258 | fragment. | ||
| 259 | |||
| 260 | As described in the | ||
| 261 | ":ref:`kernel-dev/common:validating configuration`" section, you can | ||
| 262 | use the following BitBake command to audit your configuration:: | ||
| 263 | |||
| 264 | $ bitbake linux-yocto -c kernel_configcheck -f | ||
| 265 | |||
| 266 | Patches | ||
| 267 | ------- | ||
| 268 | |||
| 269 | Patch descriptions are very similar to configuration fragment | ||
| 270 | descriptions, which are described in the previous section. However, | ||
| 271 | instead of a ``.cfg`` file, these descriptions work with source patches | ||
| 272 | (i.e. ``.patch`` files). | ||
| 273 | |||
| 274 | A typical patch includes a description file and the patch itself. As an | ||
| 275 | example, consider the build patches used with the ``linux-yocto-4.12`` | ||
| 276 | kernel as defined outside of the recipe space (i.e. | ||
| 277 | ``yocto-kernel-cache``). This Metadata consists of several files: | ||
| 278 | ``build.scc`` and a set of ``*.patch`` files. You can find these files | ||
| 279 | in the ``patches/build`` directory of the ``yocto-4.12`` branch in the | ||
| 280 | ``yocto-kernel-cache`` Git repository. | ||
| 281 | |||
| 282 | The following listings show the ``build.scc`` file and part of the | ||
| 283 | ``modpost-mask-trivial-warnings.patch`` file:: | ||
| 284 | |||
| 285 | patches/build/build.scc: | ||
| 286 | patch arm-serialize-build-targets.patch | ||
| 287 | patch powerpc-serialize-image-targets.patch | ||
| 288 | patch kbuild-exclude-meta-directory-from-distclean-processi.patch | ||
| 289 | |||
| 290 | # applied by kgit | ||
| 291 | # patch kbuild-add-meta-files-to-the-ignore-li.patch | ||
| 292 | |||
| 293 | patch modpost-mask-trivial-warnings.patch | ||
| 294 | patch menuconfig-check-lxdiaglog.sh-Allow-specification-of.patch | ||
| 295 | |||
| 296 | patches/build/modpost-mask-trivial-warnings.patch: | ||
| 297 | From bd48931bc142bdd104668f3a062a1f22600aae61 Mon Sep 17 00:00:00 2001 | ||
| 298 | From: Paul Gortmaker <paul.gortmaker@windriver.com> | ||
| 299 | Date: Sun, 25 Jan 2009 17:58:09 -0500 | ||
| 300 | Subject: [PATCH] modpost: mask trivial warnings | ||
| 301 | |||
| 302 | Newer HOSTCC will complain about various stdio fcns because | ||
| 303 | . | ||
| 304 | . | ||
| 305 | . | ||
| 306 | char *dump_write = NULL, *files_source = NULL; | ||
| 307 | int opt; | ||
| 308 | -- | ||
| 309 | 2.10.1 | ||
| 310 | |||
| 311 | generated by cgit v0.10.2 at 2017-09-28 15:23:23 (GMT) | ||
| 312 | |||
| 313 | The description file can | ||
| 314 | include multiple patch statements where each statement handles a single | ||
| 315 | patch. In the example ``build.scc`` file, there are five patch statements | ||
| 316 | for the five patches in the directory. | ||
| 317 | |||
| 318 | You can create a typical ``.patch`` file using ``diff -Nurp`` or | ||
| 319 | ``git format-patch`` commands. For information on how to create patches, | ||
| 320 | see the ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 321 | and ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 322 | sections. | ||
| 323 | |||
| 324 | Features | ||
| 325 | -------- | ||
| 326 | |||
| 327 | Features are complex kernel Metadata types that consist of configuration | ||
| 328 | fragments, patches, and possibly other feature description files. As an | ||
| 329 | example, consider the following generic listing:: | ||
| 330 | |||
| 331 | features/myfeature.scc | ||
| 332 | define KFEATURE_DESCRIPTION "Enable myfeature" | ||
| 333 | |||
| 334 | patch 0001-myfeature-core.patch | ||
| 335 | patch 0002-myfeature-interface.patch | ||
| 336 | |||
| 337 | include cfg/myfeature_dependency.scc | ||
| 338 | kconf non-hardware myfeature.cfg | ||
| 339 | |||
| 340 | This example shows how the ``patch`` and ``kconf`` commands are used as well | ||
| 341 | as how an additional feature description file is included with the | ||
| 342 | ``include`` command. | ||
| 343 | |||
| 344 | Typically, features are less granular than configuration fragments and | ||
| 345 | are more likely than configuration fragments and patches to be the types | ||
| 346 | of things you want to specify in the :term:`KERNEL_FEATURES` variable of the | ||
| 347 | Linux kernel recipe. See the | ||
| 348 | ":ref:`kernel-dev/advanced:using kernel metadata in a recipe`" section earlier | ||
| 349 | in the manual. | ||
| 350 | |||
| 351 | Kernel Types | ||
| 352 | ------------ | ||
| 353 | |||
| 354 | A kernel type defines a high-level kernel policy by aggregating non-hardware | ||
| 355 | configuration fragments with patches you want to use when building a Linux | ||
| 356 | kernel of a specific type (e.g. a real-time kernel). Syntactically, kernel | ||
| 357 | types are no different than features as described in the | ||
| 358 | ":ref:`kernel-dev/advanced:features`" section. The :term:`LINUX_KERNEL_TYPE` | ||
| 359 | variable in the kernel recipe selects the kernel type. For example, in the | ||
| 360 | ``linux-yocto_4.12.bb`` kernel recipe found in ``poky/meta/recipes-kernel/linux``, a | ||
| 361 | :ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>` | ||
| 362 | directive includes the ``poky/meta/recipes-kernel/linux/linux-yocto.inc`` file, | ||
| 363 | which has the following statement that defines the default kernel type:: | ||
| 364 | |||
| 365 | LINUX_KERNEL_TYPE ??= "standard" | ||
| 366 | |||
| 367 | Another example would be the real-time kernel (i.e. | ||
| 368 | ``linux-yocto-rt_4.12.bb``). This kernel recipe directly sets the kernel | ||
| 369 | type as follows:: | ||
| 370 | |||
| 371 | LINUX_KERNEL_TYPE = "preempt-rt" | ||
| 372 | |||
| 373 | .. note:: | ||
| 374 | |||
| 375 | You can find kernel recipes in the ``meta/recipes-kernel/linux`` directory | ||
| 376 | of the :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 377 | (e.g. ``poky/meta/recipes-kernel/linux/linux-yocto_4.12.bb``). See the | ||
| 378 | ":ref:`kernel-dev/advanced:using kernel metadata in a recipe`" | ||
| 379 | section for more information. | ||
| 380 | |||
| 381 | Three kernel types ("standard", "tiny", and "preempt-rt") are supported | ||
| 382 | for Linux Yocto kernels: | ||
| 383 | |||
| 384 | - "standard": Includes the generic Linux kernel policy of the Yocto | ||
| 385 | Project linux-yocto kernel recipes. This policy includes, among other | ||
| 386 | things, which file systems, networking options, core kernel features, | ||
| 387 | and debugging and tracing options are supported. | ||
| 388 | |||
| 389 | - "preempt-rt": Applies the ``PREEMPT_RT`` patches and the | ||
| 390 | configuration options required to build a real-time Linux kernel. | ||
| 391 | This kernel type inherits from the "standard" kernel type. | ||
| 392 | |||
| 393 | - "tiny": Defines a bare minimum configuration meant to serve as a base | ||
| 394 | for very small Linux kernels. The "tiny" kernel type is independent | ||
| 395 | from the "standard" configuration. Although the "tiny" kernel type | ||
| 396 | does not currently include any source changes, it might in the | ||
| 397 | future. | ||
| 398 | |||
| 399 | For any given kernel type, the Metadata is defined by the ``.scc`` (e.g. | ||
| 400 | ``standard.scc``). Here is a partial listing for the ``standard.scc`` | ||
| 401 | file, which is found in the ``ktypes/standard`` directory of the | ||
| 402 | ``yocto-kernel-cache`` Git repository:: | ||
| 403 | |||
| 404 | # Include this kernel type fragment to get the standard features and | ||
| 405 | # configuration values. | ||
| 406 | |||
| 407 | # Note: if only the features are desired, but not the configuration | ||
| 408 | # then this should be included as: | ||
| 409 | # include ktypes/standard/standard.scc nocfg | ||
| 410 | # if no chained configuration is desired, include it as: | ||
| 411 | # include ktypes/standard/standard.scc nocfg inherit | ||
| 412 | |||
| 413 | |||
| 414 | |||
| 415 | include ktypes/base/base.scc | ||
| 416 | branch standard | ||
| 417 | |||
| 418 | kconf non-hardware standard.cfg | ||
| 419 | |||
| 420 | include features/kgdb/kgdb.scc | ||
| 421 | . | ||
| 422 | . | ||
| 423 | . | ||
| 424 | |||
| 425 | include cfg/net/ip6_nf.scc | ||
| 426 | include cfg/net/bridge.scc | ||
| 427 | |||
| 428 | include cfg/systemd.scc | ||
| 429 | |||
| 430 | include features/rfkill/rfkill.scc | ||
| 431 | |||
| 432 | As with any ``.scc`` file, a kernel type definition can aggregate other | ||
| 433 | ``.scc`` files with ``include`` commands. These definitions can also | ||
| 434 | directly pull in configuration fragments and patches with the ``kconf`` | ||
| 435 | and ``patch`` commands, respectively. | ||
| 436 | |||
| 437 | .. note:: | ||
| 438 | |||
| 439 | It is not strictly necessary to create a kernel type ``.scc`` | ||
| 440 | file. The Board Support Package (BSP) file can implicitly define the | ||
| 441 | kernel type using a ``define`` :term:`KTYPE` ``myktype`` line. See the | ||
| 442 | ":ref:`kernel-dev/advanced:bsp descriptions`" section for more | ||
| 443 | information. | ||
| 444 | |||
| 445 | BSP Descriptions | ||
| 446 | ---------------- | ||
| 447 | |||
| 448 | BSP descriptions (i.e. ``*.scc`` files) combine kernel types with | ||
| 449 | hardware-specific features. The hardware-specific Metadata is typically | ||
| 450 | defined independently in the BSP layer, and then aggregated with each | ||
| 451 | supported kernel type. | ||
| 452 | |||
| 453 | .. note:: | ||
| 454 | |||
| 455 | For BSPs supported by the Yocto Project, the BSP description files | ||
| 456 | are located in the ``bsp`` directory of the ``yocto-kernel-cache`` | ||
| 457 | repository organized under the "Yocto Linux Kernel" heading in the | ||
| 458 | :yocto_git:`Yocto Project Source Repositories <>`. | ||
| 459 | |||
| 460 | This section overviews the BSP description structure, the aggregation | ||
| 461 | concepts, and presents a detailed example using a BSP supported by the | ||
| 462 | Yocto Project (i.e. BeagleBone Board). For complete information on BSP | ||
| 463 | layer file hierarchy, see the :doc:`/bsp-guide/index`. | ||
| 464 | |||
| 465 | Description Overview | ||
| 466 | ~~~~~~~~~~~~~~~~~~~~ | ||
| 467 | |||
| 468 | For simplicity, consider the following root BSP layer description files | ||
| 469 | for the BeagleBone board. These files employ both a structure and naming | ||
| 470 | convention for consistency. The naming convention for the file is as | ||
| 471 | follows:: | ||
| 472 | |||
| 473 | bsp_root_name-kernel_type.scc | ||
| 474 | |||
| 475 | Here are some example root layer | ||
| 476 | BSP filenames for the BeagleBone Board BSP, which is supported by the | ||
| 477 | Yocto Project:: | ||
| 478 | |||
| 479 | beaglebone-standard.scc | ||
| 480 | beaglebone-preempt-rt.scc | ||
| 481 | |||
| 482 | Each file uses the root name (i.e "beaglebone") BSP name followed by the | ||
| 483 | kernel type. | ||
| 484 | |||
| 485 | Examine the ``beaglebone-standard.scc`` file:: | ||
| 486 | |||
| 487 | define KMACHINE beaglebone | ||
| 488 | define KTYPE standard | ||
| 489 | define KARCH arm | ||
| 490 | |||
| 491 | include ktypes/standard/standard.scc | ||
| 492 | branch beaglebone | ||
| 493 | |||
| 494 | include beaglebone.scc | ||
| 495 | |||
| 496 | # default policy for standard kernels | ||
| 497 | include features/latencytop/latencytop.scc | ||
| 498 | include features/profiling/profiling.scc | ||
| 499 | |||
| 500 | Every top-level BSP description file | ||
| 501 | should define the :term:`KMACHINE`, | ||
| 502 | :term:`KTYPE`, and | ||
| 503 | :term:`KARCH` variables. These | ||
| 504 | variables allow the OpenEmbedded build system to identify the | ||
| 505 | description as meeting the criteria set by the recipe being built. This | ||
| 506 | example supports the "beaglebone" machine for the "standard" kernel and | ||
| 507 | the "arm" architecture. | ||
| 508 | |||
| 509 | Be aware that there is no hard link between the :term:`KTYPE` variable and a kernel | ||
| 510 | type description file. Thus, if you do not have the | ||
| 511 | kernel type defined in your kernel Metadata as it is here, you only need | ||
| 512 | to ensure that the | ||
| 513 | :term:`LINUX_KERNEL_TYPE` | ||
| 514 | variable in the kernel recipe and the :term:`KTYPE` variable in the BSP | ||
| 515 | description file match. | ||
| 516 | |||
| 517 | To separate your kernel policy from your hardware configuration, you | ||
| 518 | include a kernel type (``ktype``), such as "standard". In the previous | ||
| 519 | example, this is done using the following:: | ||
| 520 | |||
| 521 | include ktypes/standard/standard.scc | ||
| 522 | |||
| 523 | This file aggregates all the configuration | ||
| 524 | fragments, patches, and features that make up your standard kernel | ||
| 525 | policy. See the ":ref:`kernel-dev/advanced:kernel types`" section for more | ||
| 526 | information. | ||
| 527 | |||
| 528 | To aggregate common configurations and features specific to the kernel | ||
| 529 | for `mybsp`, use the following:: | ||
| 530 | |||
| 531 | include mybsp.scc | ||
| 532 | |||
| 533 | You can see that in the BeagleBone example with the following:: | ||
| 534 | |||
| 535 | include beaglebone.scc | ||
| 536 | |||
| 537 | For information on how to break a complete ``.config`` file into the various | ||
| 538 | configuration fragments, see the ":ref:`kernel-dev/common:creating configuration fragments`" section. | ||
| 539 | |||
| 540 | Finally, if you have any configurations specific to the hardware that | ||
| 541 | are not in a ``*.scc`` file, you can include them as follows:: | ||
| 542 | |||
| 543 | kconf hardware mybsp-extra.cfg | ||
| 544 | |||
| 545 | The BeagleBone example does not include these | ||
| 546 | types of configurations. However, the Malta 32-bit board does | ||
| 547 | ("mti-malta32"). Here is the ``mti-malta32-le-standard.scc`` file:: | ||
| 548 | |||
| 549 | define KMACHINE mti-malta32-le | ||
| 550 | define KMACHINE qemumipsel | ||
| 551 | define KTYPE standard | ||
| 552 | define KARCH mips | ||
| 553 | |||
| 554 | include ktypes/standard/standard.scc | ||
| 555 | branch mti-malta32 | ||
| 556 | |||
| 557 | include mti-malta32.scc | ||
| 558 | kconf hardware mti-malta32-le.cfg | ||
| 559 | |||
| 560 | Example | ||
| 561 | ~~~~~~~ | ||
| 562 | |||
| 563 | Many real-world examples are more complex. Like any other ``.scc`` file, | ||
| 564 | BSP descriptions can aggregate features. Consider the Minnow BSP | ||
| 565 | definition given the ``linux-yocto-4.4`` branch of the | ||
| 566 | ``yocto-kernel-cache`` (i.e. ``yocto-kernel-cache/bsp/minnow/minnow.scc``):: | ||
| 567 | |||
| 568 | include cfg/x86.scc | ||
| 569 | include features/eg20t/eg20t.scc | ||
| 570 | include cfg/dmaengine.scc | ||
| 571 | include features/power/intel.scc | ||
| 572 | include cfg/efi.scc | ||
| 573 | include features/usb/ehci-hcd.scc | ||
| 574 | include features/usb/ohci-hcd.scc | ||
| 575 | include features/usb/usb-gadgets.scc | ||
| 576 | include features/usb/touchscreen-composite.scc | ||
| 577 | include cfg/timer/hpet.scc | ||
| 578 | include features/leds/leds.scc | ||
| 579 | include features/spi/spidev.scc | ||
| 580 | include features/i2c/i2cdev.scc | ||
| 581 | include features/mei/mei-txe.scc | ||
| 582 | |||
| 583 | # Earlyprintk and port debug requires 8250 | ||
| 584 | kconf hardware cfg/8250.cfg | ||
| 585 | |||
| 586 | kconf hardware minnow.cfg | ||
| 587 | kconf hardware minnow-dev.cfg | ||
| 588 | |||
| 589 | .. note:: | ||
| 590 | |||
| 591 | Although the Minnow Board BSP is unused, the Metadata remains and is | ||
| 592 | being used here just as an example. | ||
| 593 | |||
| 594 | The ``minnow.scc`` description file includes a hardware configuration | ||
| 595 | fragment (``minnow.cfg``) specific to the Minnow BSP as well as several | ||
| 596 | more general configuration fragments and features enabling hardware | ||
| 597 | found on the machine. This ``minnow.scc`` description file is then | ||
| 598 | included in each of the three "minnow" description files for the | ||
| 599 | supported kernel types (i.e. "standard", "preempt-rt", and "tiny"). | ||
| 600 | Consider the "minnow" description for the "standard" kernel type (i.e. | ||
| 601 | ``minnow-standard.scc``):: | ||
| 602 | |||
| 603 | define KMACHINE minnow | ||
| 604 | define KTYPE standard | ||
| 605 | define KARCH i386 | ||
| 606 | |||
| 607 | include ktypes/standard | ||
| 608 | |||
| 609 | include minnow.scc | ||
| 610 | |||
| 611 | # Extra minnow configs above the minimal defined in minnow.scc | ||
| 612 | include cfg/efi-ext.scc | ||
| 613 | include features/media/media-all.scc | ||
| 614 | include features/sound/snd_hda_intel.scc | ||
| 615 | |||
| 616 | # The following should really be in standard.scc | ||
| 617 | # USB live-image support | ||
| 618 | include cfg/usb-mass-storage.scc | ||
| 619 | include cfg/boot-live.scc | ||
| 620 | |||
| 621 | # Basic profiling | ||
| 622 | include features/latencytop/latencytop.scc | ||
| 623 | include features/profiling/profiling.scc | ||
| 624 | |||
| 625 | # Requested drivers that don't have an existing scc | ||
| 626 | kconf hardware minnow-drivers-extra.cfg | ||
| 627 | |||
| 628 | The ``include`` command midway through the file includes the ``minnow.scc`` description | ||
| 629 | that defines all enabled hardware for the BSP that is common to all | ||
| 630 | kernel types. Using this command significantly reduces duplication. | ||
| 631 | |||
| 632 | Now consider the "minnow" description for the "tiny" kernel type (i.e. | ||
| 633 | ``minnow-tiny.scc``):: | ||
| 634 | |||
| 635 | define KMACHINE minnow | ||
| 636 | define KTYPE tiny | ||
| 637 | define KARCH i386 | ||
| 638 | |||
| 639 | include ktypes/tiny | ||
| 640 | |||
| 641 | include minnow.scc | ||
| 642 | |||
| 643 | As you might expect, | ||
| 644 | the "tiny" description includes quite a bit less. In fact, it includes | ||
| 645 | only the minimal policy defined by the "tiny" kernel type and the | ||
| 646 | hardware-specific configuration required for booting the machine along | ||
| 647 | with the most basic functionality of the system as defined in the base | ||
| 648 | "minnow" description file. | ||
| 649 | |||
| 650 | Notice again the three critical variables: | ||
| 651 | :term:`KMACHINE`, | ||
| 652 | :term:`KTYPE`, and | ||
| 653 | :term:`KARCH`. Of these variables, only | ||
| 654 | :term:`KTYPE` has changed to specify the "tiny" kernel type. | ||
| 655 | |||
| 656 | Kernel Metadata Location | ||
| 657 | ======================== | ||
| 658 | |||
| 659 | Kernel Metadata always exists outside of the kernel tree either defined | ||
| 660 | in a kernel recipe (recipe-space) or outside of the recipe. Where you | ||
| 661 | choose to define the Metadata depends on what you want to do and how you | ||
| 662 | intend to work. Regardless of where you define the kernel Metadata, the | ||
| 663 | syntax used applies equally. | ||
| 664 | |||
| 665 | If you are unfamiliar with the Linux kernel and only wish to apply a | ||
| 666 | configuration and possibly a couple of patches provided to you by | ||
| 667 | others, the recipe-space method is recommended. This method is also a | ||
| 668 | good approach if you are working with Linux kernel sources you do not | ||
| 669 | control or if you just do not want to maintain a Linux kernel Git | ||
| 670 | repository on your own. For partial information on how you can define | ||
| 671 | kernel Metadata in the recipe-space, see the | ||
| 672 | ":ref:`kernel-dev/common:modifying an existing recipe`" section. | ||
| 673 | |||
| 674 | Conversely, if you are actively developing a kernel and are already | ||
| 675 | maintaining a Linux kernel Git repository of your own, you might find it | ||
| 676 | more convenient to work with kernel Metadata kept outside the | ||
| 677 | recipe-space. Working with Metadata in this area can make iterative | ||
| 678 | development of the Linux kernel more efficient outside of the BitBake | ||
| 679 | environment. | ||
| 680 | |||
| 681 | Recipe-Space Metadata | ||
| 682 | --------------------- | ||
| 683 | |||
| 684 | When stored in recipe-space, the kernel Metadata files reside in a | ||
| 685 | directory hierarchy below :term:`FILESEXTRAPATHS`. For | ||
| 686 | a linux-yocto recipe or for a Linux kernel recipe derived by copying | ||
| 687 | :oe_git:`meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb | ||
| 688 | </openembedded-core/tree/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb>` | ||
| 689 | into your layer and modifying it, :term:`FILESEXTRAPATHS` is typically set to | ||
| 690 | ``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}``. | ||
| 691 | See the ":ref:`kernel-dev/common:modifying an existing recipe`" | ||
| 692 | section for more information. | ||
| 693 | |||
| 694 | Here is an example that shows a trivial tree of kernel Metadata stored | ||
| 695 | in recipe-space within a BSP layer:: | ||
| 696 | |||
| 697 | meta-my_bsp_layer/ | ||
| 698 | `-- recipes-kernel | ||
| 699 | `-- linux | ||
| 700 | `-- linux-yocto | ||
| 701 | |-- bsp-standard.scc | ||
| 702 | |-- bsp.cfg | ||
| 703 | `-- standard.cfg | ||
| 704 | |||
| 705 | When the Metadata is stored in recipe-space, you must take steps to | ||
| 706 | ensure BitBake has the necessary information to decide what files to | ||
| 707 | fetch and when they need to be fetched again. It is only necessary to | ||
| 708 | specify the ``.scc`` files on the | ||
| 709 | :term:`SRC_URI`. BitBake parses them | ||
| 710 | and fetches any files referenced in the ``.scc`` files by the | ||
| 711 | ``include``, ``patch``, or ``kconf`` commands. Because of this, it is | ||
| 712 | necessary to bump the recipe :term:`PR` | ||
| 713 | value when changing the content of files not explicitly listed in the | ||
| 714 | :term:`SRC_URI`. | ||
| 715 | |||
| 716 | If the BSP description is in recipe space, you cannot simply list the | ||
| 717 | ``*.scc`` in the :term:`SRC_URI` statement. You need to use the following | ||
| 718 | form from your kernel append file:: | ||
| 719 | |||
| 720 | SRC_URI:append:myplatform = " \ | ||
| 721 | file://myplatform;type=kmeta;destsuffix=myplatform \ | ||
| 722 | " | ||
| 723 | |||
| 724 | Metadata Outside the Recipe-Space | ||
| 725 | --------------------------------- | ||
| 726 | |||
| 727 | When stored outside of the recipe-space, the kernel Metadata files | ||
| 728 | reside in a separate repository. The OpenEmbedded build system adds the | ||
| 729 | Metadata to the build as a "type=kmeta" repository through the | ||
| 730 | :term:`SRC_URI` variable. As an | ||
| 731 | example, consider the following :term:`SRC_URI` statement from the | ||
| 732 | ``linux-yocto_5.15.bb`` kernel recipe:: | ||
| 733 | |||
| 734 | SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH};protocol=https \ | ||
| 735 | git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.15;destsuffix=${KMETA};protocol=https" | ||
| 736 | |||
| 737 | ``${KMETA}``, in this context, is simply used to name the directory into | ||
| 738 | which the Git fetcher places the Metadata. This behavior is no different | ||
| 739 | than any multi-repository :term:`SRC_URI` statement used in a recipe (e.g. | ||
| 740 | see the previous section). | ||
| 741 | |||
| 742 | You can keep kernel Metadata in a "kernel-cache", which is a directory | ||
| 743 | containing configuration fragments. As with any Metadata kept outside | ||
| 744 | the recipe-space, you simply need to use the :term:`SRC_URI` statement with | ||
| 745 | the "type=kmeta" attribute. Doing so makes the kernel Metadata available | ||
| 746 | during the configuration phase. | ||
| 747 | |||
| 748 | If you modify the Metadata, you must not forget to update the :term:`SRCREV` | ||
| 749 | statements in the kernel's recipe. In particular, you need to update the | ||
| 750 | ``SRCREV_meta`` variable to match the commit in the ``KMETA`` branch you | ||
| 751 | wish to use. Changing the data in these branches and not updating the | ||
| 752 | :term:`SRCREV` statements to match will cause the build to fetch an older | ||
| 753 | commit. | ||
| 754 | |||
| 755 | Organizing Your Source | ||
| 756 | ====================== | ||
| 757 | |||
| 758 | Many recipes based on the ``linux-yocto-custom.bb`` recipe use Linux | ||
| 759 | kernel sources that have only a single branch. This type of | ||
| 760 | repository structure is fine for linear development supporting a single | ||
| 761 | machine and architecture. However, if you work with multiple boards and | ||
| 762 | architectures, a kernel source repository with multiple branches is more | ||
| 763 | efficient. For example, suppose you need a series of patches for one | ||
| 764 | board to boot. Sometimes, these patches are works-in-progress or | ||
| 765 | fundamentally wrong, yet they are still necessary for specific boards. | ||
| 766 | In these situations, you most likely do not want to include these | ||
| 767 | patches in every kernel you build (i.e. have the patches as part of the | ||
| 768 | default branch). It is situations like these that give rise to | ||
| 769 | multiple branches used within a Linux kernel sources Git repository. | ||
| 770 | |||
| 771 | Here are repository organization strategies maximizing source reuse, | ||
| 772 | removing redundancy, and logically ordering your changes. This section | ||
| 773 | presents strategies for the following cases: | ||
| 774 | |||
| 775 | - Encapsulating patches in a feature description and only including the | ||
| 776 | patches in the BSP descriptions of the applicable boards. | ||
| 777 | |||
| 778 | - Creating a machine branch in your kernel source repository and | ||
| 779 | applying the patches on that branch only. | ||
| 780 | |||
| 781 | - Creating a feature branch in your kernel source repository and | ||
| 782 | merging that branch into your BSP when needed. | ||
| 783 | |||
| 784 | The approach you take is entirely up to you and depends on what works | ||
| 785 | best for your development model. | ||
| 786 | |||
| 787 | Encapsulating Patches | ||
| 788 | --------------------- | ||
| 789 | |||
| 790 | If you are reusing patches from an external tree and are not working on | ||
| 791 | the patches, you might find the encapsulated feature to be appropriate. | ||
| 792 | Given this scenario, you do not need to create any branches in the | ||
| 793 | source repository. Rather, you just take the static patches you need and | ||
| 794 | encapsulate them within a feature description. Once you have the feature | ||
| 795 | description, you simply include that into the BSP description as | ||
| 796 | described in the ":ref:`kernel-dev/advanced:bsp descriptions`" section. | ||
| 797 | |||
| 798 | You can find information on how to create patches and BSP descriptions | ||
| 799 | in the ":ref:`kernel-dev/advanced:patches`" and | ||
| 800 | ":ref:`kernel-dev/advanced:bsp descriptions`" sections. | ||
| 801 | |||
| 802 | Machine Branches | ||
| 803 | ---------------- | ||
| 804 | |||
| 805 | When you have multiple machines and architectures to support, or you are | ||
| 806 | actively working on board support, it is more efficient to create | ||
| 807 | branches in the repository based on individual machines. Having machine | ||
| 808 | branches allows common source to remain in the development branch with any | ||
| 809 | features specific to a machine stored in the appropriate machine branch. | ||
| 810 | This organization method frees you from continually reintegrating your | ||
| 811 | patches into a feature. | ||
| 812 | |||
| 813 | Once you have a new branch, you can set up your kernel Metadata to use | ||
| 814 | the branch a couple different ways. In the recipe, you can specify the | ||
| 815 | new branch as the :term:`KBRANCH` to use for the board as follows:: | ||
| 816 | |||
| 817 | KBRANCH = "mynewbranch" | ||
| 818 | |||
| 819 | Another method is to use the ``branch`` command in the BSP | ||
| 820 | description:: | ||
| 821 | |||
| 822 | mybsp.scc: | ||
| 823 | define KMACHINE mybsp | ||
| 824 | define KTYPE standard | ||
| 825 | define KARCH i386 | ||
| 826 | include standard.scc | ||
| 827 | |||
| 828 | branch mynewbranch | ||
| 829 | |||
| 830 | include mybsp-hw.scc | ||
| 831 | |||
| 832 | If you find yourself with numerous branches, you might consider using a | ||
| 833 | hierarchical branching system similar to what the Yocto Linux Kernel Git | ||
| 834 | repositories use:: | ||
| 835 | |||
| 836 | common/kernel_type/machine | ||
| 837 | |||
| 838 | If you had two kernel types, "standard" and "small" for instance, three | ||
| 839 | machines, and common as ``mydir``, the branches in your Git repository | ||
| 840 | might look like this:: | ||
| 841 | |||
| 842 | mydir/base | ||
| 843 | mydir/standard/base | ||
| 844 | mydir/standard/machine_a | ||
| 845 | mydir/standard/machine_b | ||
| 846 | mydir/standard/machine_c | ||
| 847 | mydir/small/base | ||
| 848 | mydir/small/machine_a | ||
| 849 | |||
| 850 | This organization can help clarify the branch relationships. In this | ||
| 851 | case, ``mydir/standard/machine_a`` includes everything in ``mydir/base`` | ||
| 852 | and ``mydir/standard/base``. The "standard" and "small" branches add | ||
| 853 | sources specific to those kernel types that for whatever reason are not | ||
| 854 | appropriate for the other branches. | ||
| 855 | |||
| 856 | .. note:: | ||
| 857 | |||
| 858 | The "base" branches are an artifact of the way Git manages its data | ||
| 859 | internally on the filesystem: Git will not allow you to use | ||
| 860 | ``mydir/standard`` and ``mydir/standard/machine_a`` because it would have to | ||
| 861 | create a file and a directory named "standard". | ||
| 862 | |||
| 863 | Feature Branches | ||
| 864 | ---------------- | ||
| 865 | |||
| 866 | When you are actively developing new features, it can be more efficient | ||
| 867 | to work with that feature as a branch, rather than as a set of patches | ||
| 868 | that have to be regularly updated. The Yocto Project Linux kernel tools | ||
| 869 | provide for this with the ``git merge`` command. | ||
| 870 | |||
| 871 | To merge a feature branch into a BSP, insert the ``git merge`` command | ||
| 872 | after any ``branch`` commands:: | ||
| 873 | |||
| 874 | mybsp.scc: | ||
| 875 | define KMACHINE mybsp | ||
| 876 | define KTYPE standard | ||
| 877 | define KARCH i386 | ||
| 878 | include standard.scc | ||
| 879 | |||
| 880 | branch mynewbranch | ||
| 881 | git merge myfeature | ||
| 882 | |||
| 883 | include mybsp-hw.scc | ||
| 884 | |||
| 885 | SCC Description File Reference | ||
| 886 | ============================== | ||
| 887 | |||
| 888 | This section provides a brief reference for the commands you can use | ||
| 889 | within an SCC description file (``.scc``): | ||
| 890 | |||
| 891 | - ``branch [ref]``: Creates a new branch relative to the current branch | ||
| 892 | (typically ``${KTYPE}``) using the currently checked-out branch, or | ||
| 893 | "ref" if specified. | ||
| 894 | |||
| 895 | - ``define``: Defines variables, such as | ||
| 896 | :term:`KMACHINE`, | ||
| 897 | :term:`KTYPE`, | ||
| 898 | :term:`KARCH`, and | ||
| 899 | :term:`KFEATURE_DESCRIPTION`. | ||
| 900 | |||
| 901 | - ``include SCC_FILE``: Includes an SCC file in the current file. The | ||
| 902 | file is parsed as if you had inserted it inline. | ||
| 903 | |||
| 904 | - ``kconf [hardware|non-hardware] CFG_FILE``: Queues a configuration | ||
| 905 | fragment for merging into the final Linux ``.config`` file. | ||
| 906 | |||
| 907 | - ``git merge GIT_BRANCH``: Merges the feature branch into the current | ||
| 908 | branch. | ||
| 909 | |||
| 910 | - ``patch PATCH_FILE``: Applies the patch to the current Git branch. | ||
| 911 | |||
| 912 | |||
diff --git a/documentation/kernel-dev/common.rst b/documentation/kernel-dev/common.rst deleted file mode 100644 index bd6c3fb2cf..0000000000 --- a/documentation/kernel-dev/common.rst +++ /dev/null | |||
| @@ -1,1855 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ************ | ||
| 4 | Common Tasks | ||
| 5 | ************ | ||
| 6 | |||
| 7 | This chapter presents several common tasks you perform when you work | ||
| 8 | with the Yocto Project Linux kernel. These tasks include preparing your | ||
| 9 | host development system for kernel development, preparing a layer, | ||
| 10 | modifying an existing recipe, patching the kernel, configuring the | ||
| 11 | kernel, iterative development, working with your own sources, and | ||
| 12 | incorporating out-of-tree modules. | ||
| 13 | |||
| 14 | .. note:: | ||
| 15 | |||
| 16 | The examples presented in this chapter work with the Yocto Project | ||
| 17 | 2.4 Release and forward. | ||
| 18 | |||
| 19 | Preparing the Build Host to Work on the Kernel | ||
| 20 | ============================================== | ||
| 21 | |||
| 22 | Before you can do any kernel development, you need to be sure your build | ||
| 23 | host is set up to use the Yocto Project. For information on how to get | ||
| 24 | set up, see the ":doc:`/dev-manual/start`" section in | ||
| 25 | the Yocto Project Development Tasks Manual. Part of preparing the system | ||
| 26 | is creating a local Git repository of the | ||
| 27 | :term:`Source Directory` (``poky``) on your system. Follow the steps in the | ||
| 28 | ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`" | ||
| 29 | section in the Yocto Project Development Tasks Manual to set up your | ||
| 30 | Source Directory. | ||
| 31 | |||
| 32 | .. note:: | ||
| 33 | |||
| 34 | Be sure you check out the appropriate development branch or you | ||
| 35 | create your local branch by checking out a specific tag to get the | ||
| 36 | desired version of Yocto Project. See the | ||
| 37 | ":ref:`dev-manual/start:checking out by branch in poky`" and | ||
| 38 | ":ref:`dev-manual/start:checking out by tag in poky`" | ||
| 39 | sections in the Yocto Project Development Tasks Manual for more information. | ||
| 40 | |||
| 41 | Kernel development is best accomplished using | ||
| 42 | :ref:`devtool <sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow>` | ||
| 43 | and not through traditional kernel workflow methods. The remainder of | ||
| 44 | this section provides information for both scenarios. | ||
| 45 | |||
| 46 | Getting Ready to Develop Using ``devtool`` | ||
| 47 | ------------------------------------------ | ||
| 48 | |||
| 49 | Follow these steps to prepare to update the kernel image using | ||
| 50 | ``devtool``. Completing this procedure leaves you with a clean kernel | ||
| 51 | image and ready to make modifications as described in the | ||
| 52 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 53 | section: | ||
| 54 | |||
| 55 | #. *Initialize the BitBake Environment:* | ||
| 56 | you need to initialize the BitBake build environment by sourcing | ||
| 57 | the build environment script (i.e. :ref:`structure-core-script`):: | ||
| 58 | |||
| 59 | $ cd poky | ||
| 60 | $ source oe-init-build-env | ||
| 61 | |||
| 62 | .. note:: | ||
| 63 | |||
| 64 | The previous commands assume the | ||
| 65 | :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 66 | (i.e. ``poky``) have been cloned using Git and the local repository is named | ||
| 67 | "poky". | ||
| 68 | |||
| 69 | #. *Prepare Your local.conf File:* By default, the :term:`MACHINE` variable | ||
| 70 | is set to "qemux86-64", which is fine if you are building for the QEMU | ||
| 71 | emulator in 64-bit mode. However, if you are not, you need to set the | ||
| 72 | :term:`MACHINE` variable appropriately in your ``conf/local.conf`` file | ||
| 73 | found in the :term:`Build Directory` (i.e. ``poky/build`` in this example). | ||
| 74 | |||
| 75 | Also, since you are preparing to work on the kernel image, you need | ||
| 76 | to set the :term:`MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS` variable to include | ||
| 77 | kernel modules. | ||
| 78 | |||
| 79 | In this example we wish to build for qemux86 so we must set the | ||
| 80 | :term:`MACHINE` variable to "qemux86" and also add the "kernel-modules". | ||
| 81 | As described we do this by appending to ``conf/local.conf``:: | ||
| 82 | |||
| 83 | MACHINE = "qemux86" | ||
| 84 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" | ||
| 85 | |||
| 86 | #. *Create a Layer for Patches:* You need to create a layer to hold | ||
| 87 | patches created for the kernel image. You can use the | ||
| 88 | ``bitbake-layers create-layer`` command as follows:: | ||
| 89 | |||
| 90 | $ cd poky/build | ||
| 91 | $ bitbake-layers create-layer ../../meta-mylayer | ||
| 92 | NOTE: Starting bitbake server... | ||
| 93 | Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer' | ||
| 94 | $ | ||
| 95 | |||
| 96 | .. note:: | ||
| 97 | |||
| 98 | For background information on working with common and BSP layers, | ||
| 99 | see the | ||
| 100 | ":ref:`dev-manual/layers:understanding and creating layers`" | ||
| 101 | section in the Yocto Project Development Tasks Manual and the | ||
| 102 | ":ref:`bsp-guide/bsp:bsp layers`" section in the Yocto Project Board | ||
| 103 | Support (BSP) Developer's Guide, respectively. For information on how to | ||
| 104 | use the ``bitbake-layers create-layer`` command to quickly set up a layer, | ||
| 105 | see the | ||
| 106 | ":ref:`dev-manual/layers:creating a general layer using the \`\`bitbake-layers\`\` script`" | ||
| 107 | section in the Yocto Project Development Tasks Manual. | ||
| 108 | |||
| 109 | #. *Inform the BitBake Build Environment About Your Layer:* As directed | ||
| 110 | when you created your layer, you need to add the layer to the | ||
| 111 | :term:`BBLAYERS` variable in the | ||
| 112 | ``bblayers.conf`` file as follows:: | ||
| 113 | |||
| 114 | $ cd poky/build | ||
| 115 | $ bitbake-layers add-layer ../../meta-mylayer | ||
| 116 | NOTE: Starting bitbake server... | ||
| 117 | $ | ||
| 118 | |||
| 119 | #. *Build the Clean Image:* The final step in preparing to work on the | ||
| 120 | kernel is to build an initial image using ``bitbake``:: | ||
| 121 | |||
| 122 | $ bitbake core-image-minimal | ||
| 123 | Parsing recipes: 100% |##########################################| Time: 0:00:05 | ||
| 124 | Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors. | ||
| 125 | WARNING: No packages to add, building image core-image-minimal unmodified | ||
| 126 | Loading cache: 100% |############################################| Time: 0:00:00 | ||
| 127 | Loaded 1299 entries from dependency cache. | ||
| 128 | NOTE: Resolving any missing task queue dependencies | ||
| 129 | Initializing tasks: 100% |#######################################| Time: 0:00:07 | ||
| 130 | Checking sstate mirror object availability: 100% |###############| Time: 0:00:00 | ||
| 131 | NOTE: Executing SetScene Tasks | ||
| 132 | NOTE: Executing RunQueue Tasks | ||
| 133 | NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded. | ||
| 134 | |||
| 135 | If you were | ||
| 136 | building for actual hardware and not for emulation, you could flash | ||
| 137 | the image to a USB stick on ``/dev/sdd`` and boot your device. For an | ||
| 138 | example that uses a Minnowboard, see the | ||
| 139 | :yocto_wiki:`TipsAndTricks/KernelDevelopmentWithEsdk </TipsAndTricks/KernelDevelopmentWithEsdk>` | ||
| 140 | Wiki page. | ||
| 141 | |||
| 142 | At this point you have set up to start making modifications to the | ||
| 143 | kernel. For a continued example, see the | ||
| 144 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 145 | section. | ||
| 146 | |||
| 147 | Getting Ready for Traditional Kernel Development | ||
| 148 | ------------------------------------------------ | ||
| 149 | |||
| 150 | Getting ready for traditional kernel development using the Yocto Project | ||
| 151 | involves many of the same steps as described in the previous section. | ||
| 152 | However, you need to establish a local copy of the kernel source since | ||
| 153 | you will be editing these files. | ||
| 154 | |||
| 155 | Follow these steps to prepare to update the kernel image using | ||
| 156 | traditional kernel development flow with the Yocto Project. Completing | ||
| 157 | this procedure leaves you ready to make modifications to the kernel | ||
| 158 | source as described in the ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 159 | section: | ||
| 160 | |||
| 161 | #. *Initialize the BitBake Environment:* Before you can do anything | ||
| 162 | using BitBake, you need to initialize the BitBake build environment | ||
| 163 | by sourcing the build environment script (i.e. | ||
| 164 | :ref:`structure-core-script`). | ||
| 165 | Also, for this example, be sure that the local branch you have | ||
| 166 | checked out for ``poky`` is the Yocto Project &DISTRO_NAME; branch. If | ||
| 167 | you need to checkout out the &DISTRO_NAME; branch, see the | ||
| 168 | ":ref:`dev-manual/start:checking out by branch in poky`" | ||
| 169 | section in the Yocto Project Development Tasks Manual:: | ||
| 170 | |||
| 171 | $ cd poky | ||
| 172 | $ git branch | ||
| 173 | master | ||
| 174 | * &DISTRO_NAME_NO_CAP; | ||
| 175 | $ source oe-init-build-env | ||
| 176 | |||
| 177 | .. note:: | ||
| 178 | |||
| 179 | The previous commands assume the | ||
| 180 | :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 181 | (i.e. ``poky``) have been cloned using Git and the local repository is named | ||
| 182 | "poky". | ||
| 183 | |||
| 184 | #. *Prepare Your local.conf File:* By default, the :term:`MACHINE` variable is | ||
| 185 | set to "qemux86-64", which is fine if you are building for the QEMU emulator | ||
| 186 | in 64-bit mode. However, if you are not, you need to set the :term:`MACHINE` | ||
| 187 | variable appropriately in your ``conf/local.conf`` file found in the | ||
| 188 | :term:`Build Directory` (i.e. ``poky/build`` in this example). | ||
| 189 | |||
| 190 | Also, since you are preparing to work on the kernel image, you need | ||
| 191 | to set the | ||
| 192 | :term:`MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS` | ||
| 193 | variable to include kernel modules. | ||
| 194 | |||
| 195 | In this example we wish to build for qemux86 so we must set the | ||
| 196 | :term:`MACHINE` variable to "qemux86" and also add the "kernel-modules". | ||
| 197 | As described we do this by appending to ``conf/local.conf``:: | ||
| 198 | |||
| 199 | MACHINE = "qemux86" | ||
| 200 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" | ||
| 201 | |||
| 202 | #. *Create a Layer for Patches:* You need to create a layer to hold | ||
| 203 | patches created for the kernel image. You can use the | ||
| 204 | ``bitbake-layers create-layer`` command as follows:: | ||
| 205 | |||
| 206 | $ cd poky/build | ||
| 207 | $ bitbake-layers create-layer ../../meta-mylayer | ||
| 208 | NOTE: Starting bitbake server... | ||
| 209 | Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer' | ||
| 210 | |||
| 211 | .. note:: | ||
| 212 | |||
| 213 | For background information on working with common and BSP layers, | ||
| 214 | see the | ||
| 215 | ":ref:`dev-manual/layers:understanding and creating layers`" | ||
| 216 | section in the Yocto Project Development Tasks Manual and the | ||
| 217 | ":ref:`bsp-guide/bsp:bsp layers`" section in the Yocto Project Board | ||
| 218 | Support (BSP) Developer's Guide, respectively. For information on how to | ||
| 219 | use the ``bitbake-layers create-layer`` command to quickly set up a layer, | ||
| 220 | see the | ||
| 221 | ":ref:`dev-manual/layers:creating a general layer using the \`\`bitbake-layers\`\` script`" | ||
| 222 | section in the Yocto Project Development Tasks Manual. | ||
| 223 | |||
| 224 | #. *Inform the BitBake Build Environment About Your Layer:* As directed | ||
| 225 | when you created your layer, you need to add the layer to the | ||
| 226 | :term:`BBLAYERS` variable in the | ||
| 227 | ``bblayers.conf`` file as follows:: | ||
| 228 | |||
| 229 | $ cd poky/build | ||
| 230 | $ bitbake-layers add-layer ../../meta-mylayer | ||
| 231 | NOTE: Starting bitbake server ... | ||
| 232 | $ | ||
| 233 | |||
| 234 | #. *Create a Local Copy of the Kernel Git Repository:* You can find Git | ||
| 235 | repositories of supported Yocto Project kernels organized under | ||
| 236 | "Yocto Linux Kernel" in the Yocto Project Source Repositories at | ||
| 237 | :yocto_git:`/`. | ||
| 238 | |||
| 239 | For simplicity, it is recommended that you create your copy of the | ||
| 240 | kernel Git repository outside of the | ||
| 241 | :term:`Source Directory`, which is | ||
| 242 | usually named ``poky``. Also, be sure you are in the | ||
| 243 | ``standard/base`` branch. | ||
| 244 | |||
| 245 | The following commands show how to create a local copy of the | ||
| 246 | ``linux-yocto-4.12`` kernel and be in the ``standard/base`` branch:: | ||
| 247 | |||
| 248 | $ cd ~ | ||
| 249 | $ git clone git://git.yoctoproject.org/linux-yocto-4.12 --branch standard/base | ||
| 250 | Cloning into 'linux-yocto-4.12'... | ||
| 251 | remote: Counting objects: 6097195, done. | ||
| 252 | remote: Compressing objects: 100% (901026/901026), done. | ||
| 253 | remote: Total 6097195 (delta 5152604), reused 6096847 (delta 5152256) | ||
| 254 | Receiving objects: 100% (6097195/6097195), 1.24 GiB | 7.81 MiB/s, done. | ||
| 255 | Resolving deltas: 100% (5152604/5152604), done. Checking connectivity... done. | ||
| 256 | Checking out files: 100% (59846/59846), done. | ||
| 257 | |||
| 258 | .. note:: | ||
| 259 | |||
| 260 | The ``linux-yocto-4.12`` kernel can be used with the Yocto Project 2.4 | ||
| 261 | release and forward. | ||
| 262 | You cannot use the ``linux-yocto-4.12`` kernel with releases prior to | ||
| 263 | Yocto Project 2.4. | ||
| 264 | |||
| 265 | #. *Create a Local Copy of the Kernel Cache Git Repository:* For | ||
| 266 | simplicity, it is recommended that you create your copy of the kernel | ||
| 267 | cache Git repository outside of the | ||
| 268 | :term:`Source Directory`, which is | ||
| 269 | usually named ``poky``. Also, for this example, be sure you are in | ||
| 270 | the ``yocto-4.12`` branch. | ||
| 271 | |||
| 272 | The following commands show how to create a local copy of the | ||
| 273 | ``yocto-kernel-cache`` and switch to the ``yocto-4.12`` branch:: | ||
| 274 | |||
| 275 | $ cd ~ | ||
| 276 | $ git clone git://git.yoctoproject.org/yocto-kernel-cache --branch yocto-4.12 | ||
| 277 | Cloning into 'yocto-kernel-cache'... | ||
| 278 | remote: Counting objects: 22639, done. | ||
| 279 | remote: Compressing objects: 100% (9761/9761), done. | ||
| 280 | remote: Total 22639 (delta 12400), reused 22586 (delta 12347) | ||
| 281 | Receiving objects: 100% (22639/22639), 22.34 MiB | 6.27 MiB/s, done. | ||
| 282 | Resolving deltas: 100% (12400/12400), done. | ||
| 283 | Checking connectivity... done. | ||
| 284 | |||
| 285 | At this point, you are ready to start making modifications to the kernel | ||
| 286 | using traditional kernel development steps. For a continued example, see | ||
| 287 | the ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 288 | section. | ||
| 289 | |||
| 290 | Creating and Preparing a Layer | ||
| 291 | ============================== | ||
| 292 | |||
| 293 | If you are going to be modifying kernel recipes, it is recommended that | ||
| 294 | you create and prepare your own layer in which to do your work. Your | ||
| 295 | layer contains its own :term:`BitBake` | ||
| 296 | append files (``.bbappend``) and provides a convenient mechanism to | ||
| 297 | create your own recipe files (``.bb``) as well as store and use kernel | ||
| 298 | patch files. For background information on working with layers, see the | ||
| 299 | ":ref:`dev-manual/layers:understanding and creating layers`" | ||
| 300 | section in the Yocto Project Development Tasks Manual. | ||
| 301 | |||
| 302 | .. note:: | ||
| 303 | |||
| 304 | The Yocto Project comes with many tools that simplify tasks you need | ||
| 305 | to perform. One such tool is the ``bitbake-layers create-layer`` | ||
| 306 | command, which simplifies creating a new layer. See the | ||
| 307 | ":ref:`dev-manual/layers:creating a general layer using the \`\`bitbake-layers\`\` script`" | ||
| 308 | section in the Yocto Project Development Tasks Manual for | ||
| 309 | information on how to use this script to quick set up a new layer. | ||
| 310 | |||
| 311 | To better understand the layer you create for kernel development, the | ||
| 312 | following section describes how to create a layer without the aid of | ||
| 313 | tools. These steps assume creation of a layer named ``mylayer`` in your | ||
| 314 | home directory: | ||
| 315 | |||
| 316 | #. *Create Structure*: Create the layer's structure:: | ||
| 317 | |||
| 318 | $ mkdir -p meta-mylayer/conf meta-mylayer/recipes-kernel/linux/linux-yocto | ||
| 319 | |||
| 320 | The ``conf`` directory holds your configuration files, while the | ||
| 321 | ``recipes-kernel`` directory holds your append file and eventual | ||
| 322 | patch files. | ||
| 323 | |||
| 324 | #. *Create the Layer Configuration File*: Move to the | ||
| 325 | ``meta-mylayer/conf`` directory and create the ``layer.conf`` file as | ||
| 326 | follows:: | ||
| 327 | |||
| 328 | # We have a conf and classes directory, add to BBPATH | ||
| 329 | BBPATH .= ":${LAYERDIR}" | ||
| 330 | |||
| 331 | # We have recipes-* directories, add to BBFILES | ||
| 332 | BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ | ||
| 333 | ${LAYERDIR}/recipes-*/*/*.bbappend" | ||
| 334 | |||
| 335 | BBFILE_COLLECTIONS += "mylayer" | ||
| 336 | BBFILE_PATTERN_mylayer = "^${LAYERDIR}/" | ||
| 337 | BBFILE_PRIORITY_mylayer = "5" | ||
| 338 | |||
| 339 | Notice ``mylayer`` as part of the last three statements. | ||
| 340 | |||
| 341 | #. *Create the Kernel Recipe Append File*: Move to the | ||
| 342 | ``meta-mylayer/recipes-kernel/linux`` directory and create the | ||
| 343 | kernel's append file. This example uses the ``linux-yocto-4.12`` | ||
| 344 | kernel. Thus, the name of the append file is | ||
| 345 | ``linux-yocto_4.12.bbappend``:: | ||
| 346 | |||
| 347 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 348 | |||
| 349 | SRC_URI += "file://patch-file-one.patch" | ||
| 350 | SRC_URI += "file://patch-file-two.patch" | ||
| 351 | SRC_URI += "file://patch-file-three.patch" | ||
| 352 | |||
| 353 | The :term:`FILESEXTRAPATHS` and :term:`SRC_URI` statements | ||
| 354 | enable the OpenEmbedded build system to find patch files. For more | ||
| 355 | information on using append files, see the | ||
| 356 | ":ref:`dev-manual/layers:appending other layers metadata with your layer`" | ||
| 357 | section in the Yocto Project Development Tasks Manual. | ||
| 358 | |||
| 359 | Modifying an Existing Recipe | ||
| 360 | ============================ | ||
| 361 | |||
| 362 | In many cases, you can customize an existing linux-yocto recipe to meet | ||
| 363 | the needs of your project. Each release of the Yocto Project provides a | ||
| 364 | few Linux kernel recipes from which you can choose. These are located in | ||
| 365 | the :term:`Source Directory` in | ||
| 366 | ``meta/recipes-kernel/linux``. | ||
| 367 | |||
| 368 | Modifying an existing recipe can consist of the following: | ||
| 369 | |||
| 370 | - :ref:`kernel-dev/common:creating the append file` | ||
| 371 | |||
| 372 | - :ref:`kernel-dev/common:applying patches` | ||
| 373 | |||
| 374 | - :ref:`kernel-dev/common:changing the configuration` | ||
| 375 | |||
| 376 | Before modifying an existing recipe, be sure that you have created a | ||
| 377 | minimal, custom layer from which you can work. See the | ||
| 378 | ":ref:`kernel-dev/common:creating and preparing a layer`" section for | ||
| 379 | information. | ||
| 380 | |||
| 381 | Creating the Append File | ||
| 382 | ------------------------ | ||
| 383 | |||
| 384 | You create this file in your custom layer. You also name it accordingly | ||
| 385 | based on the linux-yocto recipe you are using. For example, if you are | ||
| 386 | modifying the ``meta/recipes-kernel/linux/linux-yocto_6.1.bb`` recipe, | ||
| 387 | the append file will typically be located as follows within your custom | ||
| 388 | layer: | ||
| 389 | |||
| 390 | .. code-block:: none | ||
| 391 | |||
| 392 | your-layer/recipes-kernel/linux/linux-yocto_6.1.bbappend | ||
| 393 | |||
| 394 | The append file should initially extend the | ||
| 395 | :term:`FILESPATH` search path by | ||
| 396 | prepending the directory that contains your files to the | ||
| 397 | :term:`FILESEXTRAPATHS` | ||
| 398 | variable as follows:: | ||
| 399 | |||
| 400 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 401 | |||
| 402 | The path ``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}`` | ||
| 403 | expands to "linux-yocto" in the current directory for this example. If | ||
| 404 | you add any new files that modify the kernel recipe and you have | ||
| 405 | extended :term:`FILESPATH` as described above, you must place the files in | ||
| 406 | your layer in the following area:: | ||
| 407 | |||
| 408 | your-layer/recipes-kernel/linux/linux-yocto/ | ||
| 409 | |||
| 410 | .. note:: | ||
| 411 | |||
| 412 | If you are working on a new machine Board Support Package (BSP), be | ||
| 413 | sure to refer to the :doc:`/bsp-guide/index`. | ||
| 414 | |||
| 415 | As an example, consider the following append file used by the BSPs in | ||
| 416 | ``meta-yocto-bsp``: | ||
| 417 | |||
| 418 | .. code-block:: none | ||
| 419 | |||
| 420 | meta-yocto-bsp/recipes-kernel/linux/linux-yocto_6.1.bbappend | ||
| 421 | |||
| 422 | Here are the contents of this file. Be aware that the actual commit ID | ||
| 423 | strings in this example listing might be different than the actual | ||
| 424 | strings in the file from the ``meta-yocto-bsp`` layer upstream:: | ||
| 425 | |||
| 426 | KBRANCH:genericx86 = "v6.1/standard/base" | ||
| 427 | KBRANCH:genericx86-64 = "v6.1/standard/base" | ||
| 428 | KBRANCH:beaglebone-yocto = "v6.1/standard/beaglebone" | ||
| 429 | |||
| 430 | KMACHINE:genericx86 ?= "common-pc" | ||
| 431 | KMACHINE:genericx86-64 ?= "common-pc-64" | ||
| 432 | KMACHINE:beaglebone-yocto ?= "beaglebone" | ||
| 433 | |||
| 434 | SRCREV_machine:genericx86 ?= "6ec439b4b456ce929c4c07fe457b5d6a4b468e86" | ||
| 435 | SRCREV_machine:genericx86-64 ?= "6ec439b4b456ce929c4c07fe457b5d6a4b468e86" | ||
| 436 | SRCREV_machine:beaglebone-yocto ?= "423e1996694b61fbfc8ec3bf062fc6461d64fde1" | ||
| 437 | |||
| 438 | COMPATIBLE_MACHINE:genericx86 = "genericx86" | ||
| 439 | COMPATIBLE_MACHINE:genericx86-64 = "genericx86-64" | ||
| 440 | COMPATIBLE_MACHINE:beaglebone-yocto = "beaglebone-yocto" | ||
| 441 | |||
| 442 | LINUX_VERSION:genericx86 = "6.1.30" | ||
| 443 | LINUX_VERSION:genericx86-64 = "6.1.30" | ||
| 444 | LINUX_VERSION:beaglebone-yocto = "6.1.20" | ||
| 445 | |||
| 446 | This append file | ||
| 447 | contains statements used to support several BSPs that ship with the | ||
| 448 | Yocto Project. The file defines machines using the | ||
| 449 | :term:`COMPATIBLE_MACHINE` | ||
| 450 | variable and uses the | ||
| 451 | :term:`KMACHINE` variable to ensure | ||
| 452 | the machine name used by the OpenEmbedded build system maps to the | ||
| 453 | machine name used by the Linux Yocto kernel. The file also uses the | ||
| 454 | optional :term:`KBRANCH` variable to | ||
| 455 | ensure the build process uses the appropriate kernel branch. | ||
| 456 | |||
| 457 | Although this particular example does not use it, the | ||
| 458 | :term:`KERNEL_FEATURES` | ||
| 459 | variable could be used to enable features specific to the kernel. The | ||
| 460 | append file points to specific commits in the | ||
| 461 | :term:`Source Directory` Git repository and | ||
| 462 | the ``meta`` Git repository branches to identify the exact kernel needed | ||
| 463 | to build the BSP. | ||
| 464 | |||
| 465 | One thing missing in this particular BSP, which you will typically need | ||
| 466 | when developing a BSP, is the kernel configuration file (``.config``) | ||
| 467 | for your BSP. When developing a BSP, you probably have a kernel | ||
| 468 | configuration file or a set of kernel configuration files that, when | ||
| 469 | taken together, define the kernel configuration for your BSP. You can | ||
| 470 | accomplish this definition by putting the configurations in a file or a | ||
| 471 | set of files inside a directory located at the same level as your | ||
| 472 | kernel's append file and having the same name as the kernel's main | ||
| 473 | recipe file. With all these conditions met, simply reference those files | ||
| 474 | in the :term:`SRC_URI` statement in | ||
| 475 | the append file. | ||
| 476 | |||
| 477 | For example, suppose you had some configuration options in a file called | ||
| 478 | ``network_configs.cfg``. You can place that file inside a directory | ||
| 479 | named ``linux-yocto`` and then add a :term:`SRC_URI` statement such as the | ||
| 480 | following to the append file. When the OpenEmbedded build system builds | ||
| 481 | the kernel, the configuration options are picked up and applied:: | ||
| 482 | |||
| 483 | SRC_URI += "file://network_configs.cfg" | ||
| 484 | |||
| 485 | To group related configurations into multiple files, you perform a | ||
| 486 | similar procedure. Here is an example that groups separate | ||
| 487 | configurations specifically for Ethernet and graphics into their own | ||
| 488 | files and adds the configurations by using a :term:`SRC_URI` statement like | ||
| 489 | the following in your append file:: | ||
| 490 | |||
| 491 | SRC_URI += "file://myconfig.cfg \ | ||
| 492 | file://eth.cfg \ | ||
| 493 | file://gfx.cfg" | ||
| 494 | |||
| 495 | Another variable you can use in your kernel recipe append file is the | ||
| 496 | :term:`FILESEXTRAPATHS` | ||
| 497 | variable. When you use this statement, you are extending the locations | ||
| 498 | used by the OpenEmbedded system to look for files and patches as the | ||
| 499 | recipe is processed. | ||
| 500 | |||
| 501 | .. note:: | ||
| 502 | |||
| 503 | There are other ways of grouping and defining configuration | ||
| 504 | options. For example, if you are working with a local clone of the | ||
| 505 | kernel repository, you could checkout the kernel's ``meta`` branch, | ||
| 506 | make your changes, and then push the changes to the local bare clone | ||
| 507 | of the kernel. The result is that you directly add configuration | ||
| 508 | options to the ``meta`` branch for your BSP. The configuration | ||
| 509 | options will likely end up in that location anyway if the BSP gets | ||
| 510 | added to the Yocto Project. | ||
| 511 | |||
| 512 | In general, however, the Yocto Project maintainers take care of | ||
| 513 | moving the :term:`SRC_URI`-specified configuration options to the | ||
| 514 | kernel's ``meta`` branch. Not only is it easier for BSP developers | ||
| 515 | not to have to put those configurations in the branch, | ||
| 516 | but having the maintainers do it allows them to apply 'global' | ||
| 517 | knowledge about the kinds of common configuration options multiple | ||
| 518 | BSPs in the tree are typically using. This allows for promotion of | ||
| 519 | common configurations into common features. | ||
| 520 | |||
| 521 | Applying Patches | ||
| 522 | ---------------- | ||
| 523 | |||
| 524 | If you have a single patch or a small series of patches that you want to | ||
| 525 | apply to the Linux kernel source, you can do so just as you would with | ||
| 526 | any other recipe. You first copy the patches to the path added to | ||
| 527 | :term:`FILESEXTRAPATHS` in | ||
| 528 | your ``.bbappend`` file as described in the previous section, and then | ||
| 529 | reference them in :term:`SRC_URI` | ||
| 530 | statements. | ||
| 531 | |||
| 532 | For example, you can apply a three-patch series by adding the following | ||
| 533 | lines to your linux-yocto ``.bbappend`` file in your layer:: | ||
| 534 | |||
| 535 | SRC_URI += "file://0001-first-change.patch" | ||
| 536 | SRC_URI += "file://0002-second-change.patch" | ||
| 537 | SRC_URI += "file://0003-third-change.patch" | ||
| 538 | |||
| 539 | The next time you run BitBake to build | ||
| 540 | the Linux kernel, BitBake detects the change in the recipe and fetches | ||
| 541 | and applies the patches before building the kernel. | ||
| 542 | |||
| 543 | For a detailed example showing how to patch the kernel using | ||
| 544 | ``devtool``, see the | ||
| 545 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 546 | and | ||
| 547 | ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 548 | sections. | ||
| 549 | |||
| 550 | Changing the Configuration | ||
| 551 | -------------------------- | ||
| 552 | |||
| 553 | You can make wholesale or incremental changes to the final ``.config`` | ||
| 554 | file used for the eventual Linux kernel configuration by including a | ||
| 555 | ``defconfig`` file and by specifying configuration fragments in the | ||
| 556 | :term:`SRC_URI` to be applied to that | ||
| 557 | file. | ||
| 558 | |||
| 559 | If you have a complete, working Linux kernel ``.config`` file you want | ||
| 560 | to use for the configuration, as before, copy that file to the | ||
| 561 | appropriate ``${PN}`` directory in your layer's ``recipes-kernel/linux`` | ||
| 562 | directory, and rename the copied file to "defconfig". Then, add the | ||
| 563 | following lines to the linux-yocto ``.bbappend`` file in your layer:: | ||
| 564 | |||
| 565 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 566 | SRC_URI += "file://defconfig" | ||
| 567 | |||
| 568 | The :term:`SRC_URI` tells the build system how to search | ||
| 569 | for the file, while the | ||
| 570 | :term:`FILESEXTRAPATHS` | ||
| 571 | extends the :term:`FILESPATH` | ||
| 572 | variable (search directories) to include the ``${PN}`` directory you | ||
| 573 | created to hold the configuration changes. | ||
| 574 | |||
| 575 | You can also use a regular ``defconfig`` file, as generated by the | ||
| 576 | :ref:`ref-tasks-savedefconfig` | ||
| 577 | task instead of a complete ``.config`` file. This only specifies the | ||
| 578 | non-default configuration values. You need to additionally set | ||
| 579 | :term:`KCONFIG_MODE` | ||
| 580 | in the linux-yocto ``.bbappend`` file in your layer:: | ||
| 581 | |||
| 582 | KCONFIG_MODE = "alldefconfig" | ||
| 583 | |||
| 584 | .. note:: | ||
| 585 | |||
| 586 | The build system applies the configurations from the ``defconfig`` | ||
| 587 | file before applying any subsequent configuration fragments. The | ||
| 588 | final kernel configuration is a combination of the configurations in | ||
| 589 | the ``defconfig`` file and any configuration fragments you provide. You need | ||
| 590 | to realize that if you have any configuration fragments, the build system | ||
| 591 | applies these on top of and after applying the existing ``defconfig`` file | ||
| 592 | configurations. | ||
| 593 | |||
| 594 | Generally speaking, the preferred approach is to determine the | ||
| 595 | incremental change you want to make and add that as a configuration | ||
| 596 | fragment. For example, if you want to add support for a basic serial | ||
| 597 | console, create a file named ``8250.cfg`` in the ``${PN}`` directory | ||
| 598 | with the following content (without indentation):: | ||
| 599 | |||
| 600 | CONFIG_SERIAL_8250=y | ||
| 601 | CONFIG_SERIAL_8250_CONSOLE=y | ||
| 602 | CONFIG_SERIAL_8250_PCI=y | ||
| 603 | CONFIG_SERIAL_8250_NR_UARTS=4 | ||
| 604 | CONFIG_SERIAL_8250_RUNTIME_UARTS=4 | ||
| 605 | CONFIG_SERIAL_CORE=y | ||
| 606 | CONFIG_SERIAL_CORE_CONSOLE=y | ||
| 607 | |||
| 608 | Next, include this | ||
| 609 | configuration fragment and extend the :term:`FILESPATH` variable in your | ||
| 610 | ``.bbappend`` file:: | ||
| 611 | |||
| 612 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 613 | SRC_URI += "file://8250.cfg" | ||
| 614 | |||
| 615 | The next time you run BitBake to build the | ||
| 616 | Linux kernel, BitBake detects the change in the recipe and fetches and | ||
| 617 | applies the new configuration before building the kernel. | ||
| 618 | |||
| 619 | For a detailed example showing how to configure the kernel, see the | ||
| 620 | ":ref:`kernel-dev/common:configuring the kernel`" section. | ||
| 621 | |||
| 622 | Using an "In-Tree"Â Â ``defconfig`` File | ||
| 623 | -------------------------------------- | ||
| 624 | |||
| 625 | It might be desirable to have kernel configuration fragment support | ||
| 626 | through a ``defconfig`` file that is pulled from the kernel source tree | ||
| 627 | for the configured machine. By default, the OpenEmbedded build system | ||
| 628 | looks for ``defconfig`` files in the layer used for Metadata, which is | ||
| 629 | "out-of-tree", and then configures them using the following:: | ||
| 630 | |||
| 631 | SRC_URI += "file://defconfig" | ||
| 632 | |||
| 633 | If you do not want to maintain copies of | ||
| 634 | ``defconfig`` files in your layer but would rather allow users to use | ||
| 635 | the default configuration from the kernel tree and still be able to add | ||
| 636 | configuration fragments to the | ||
| 637 | :term:`SRC_URI` through, for example, | ||
| 638 | append files, you can direct the OpenEmbedded build system to use a | ||
| 639 | ``defconfig`` file that is "in-tree". | ||
| 640 | |||
| 641 | To specify an "in-tree" ``defconfig`` file, use the following statement | ||
| 642 | form:: | ||
| 643 | |||
| 644 | KBUILD_DEFCONFIG:<machine> ?= "defconfig_file" | ||
| 645 | |||
| 646 | Here is an example that assigns the :term:`KBUILD_DEFCONFIG` variable utilizing | ||
| 647 | an override for the "raspberrypi2" :term:`MACHINE` and provides the path to the | ||
| 648 | "in-tree" ``defconfig`` file to be used for a Raspberry Pi 2, which is based on | ||
| 649 | the Broadcom 2708/2709 chipset:: | ||
| 650 | |||
| 651 | KBUILD_DEFCONFIG:raspberrypi2 ?= "bcm2709_defconfig" | ||
| 652 | |||
| 653 | If the build system detects a statement that identifies an "out-of-tree" | ||
| 654 | ``defconfig`` file, your :term:`KBUILD_DEFCONFIG` variable will take precedence | ||
| 655 | over it. | ||
| 656 | |||
| 657 | See the | ||
| 658 | :term:`KBUILD_DEFCONFIG` | ||
| 659 | variable description for more information. | ||
| 660 | |||
| 661 | Using ``devtool`` to Patch the Kernel | ||
| 662 | ===================================== | ||
| 663 | |||
| 664 | The steps in this procedure show you how you can patch the kernel using | ||
| 665 | ``devtool``. | ||
| 666 | |||
| 667 | .. note:: | ||
| 668 | |||
| 669 | Before attempting this procedure, be sure you have performed the | ||
| 670 | steps to get ready for updating the kernel as described in the | ||
| 671 | ":ref:`kernel-dev/common:getting ready to develop using ``devtool```" | ||
| 672 | section. | ||
| 673 | |||
| 674 | Patching the kernel involves changing or adding configurations to an | ||
| 675 | existing kernel, changing or adding recipes to the kernel that are | ||
| 676 | needed to support specific hardware features, or even altering the | ||
| 677 | source code itself. | ||
| 678 | |||
| 679 | This example creates a simple patch by adding some QEMU emulator console | ||
| 680 | output at boot time through ``printk`` statements in the kernel's | ||
| 681 | ``calibrate.c`` source code file. Applying the patch and booting the | ||
| 682 | modified image causes the added messages to appear on the emulator's | ||
| 683 | console. The example is a continuation of the setup procedure found in | ||
| 684 | the ":ref:`kernel-dev/common:getting ready to develop using ``devtool```" Section. | ||
| 685 | |||
| 686 | #. *Check Out the Kernel Source Files:* First you must use ``devtool`` | ||
| 687 | to checkout the kernel source code in its workspace. | ||
| 688 | |||
| 689 | .. note:: | ||
| 690 | |||
| 691 | See this step in the | ||
| 692 | ":ref:`kernel-dev/common:getting ready to develop using ``devtool```" | ||
| 693 | section for more information. | ||
| 694 | |||
| 695 | Use the following ``devtool`` command to check out the code:: | ||
| 696 | |||
| 697 | $ devtool modify linux-yocto | ||
| 698 | |||
| 699 | .. note:: | ||
| 700 | |||
| 701 | During the checkout operation, there is a bug that could cause | ||
| 702 | errors such as the following: | ||
| 703 | |||
| 704 | .. code-block:: none | ||
| 705 | |||
| 706 | ERROR: Taskhash mismatch 2c793438c2d9f8c3681fd5f7bc819efa versus | ||
| 707 | be3a89ce7c47178880ba7bf6293d7404 for | ||
| 708 | /path/to/esdk/layers/poky/meta/recipes-kernel/linux/linux-yocto_4.10.bb.do_unpack | ||
| 709 | |||
| 710 | |||
| 711 | You can safely ignore these messages. The source code is correctly | ||
| 712 | checked out. | ||
| 713 | |||
| 714 | #. *Edit the Source Files* Follow these steps to make some simple | ||
| 715 | changes to the source files: | ||
| 716 | |||
| 717 | #. *Change the working directory*: In the previous step, the output | ||
| 718 | noted where you can find the source files (e.g. | ||
| 719 | ``poky_sdk/workspace/sources/linux-yocto``). Change to where the | ||
| 720 | kernel source code is before making your edits to the | ||
| 721 | ``calibrate.c`` file:: | ||
| 722 | |||
| 723 | $ cd poky_sdk/workspace/sources/linux-yocto | ||
| 724 | |||
| 725 | #. *Edit the source file*: Edit the ``init/calibrate.c`` file to have | ||
| 726 | the following changes:: | ||
| 727 | |||
| 728 | void calibrate_delay(void) | ||
| 729 | { | ||
| 730 | unsigned long lpj; | ||
| 731 | static bool printed; | ||
| 732 | int this_cpu = smp_processor_id(); | ||
| 733 | |||
| 734 | printk("*************************************\n"); | ||
| 735 | printk("* *\n"); | ||
| 736 | printk("* HELLO YOCTO KERNEL *\n"); | ||
| 737 | printk("* *\n"); | ||
| 738 | printk("*************************************\n"); | ||
| 739 | |||
| 740 | if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { | ||
| 741 | . | ||
| 742 | . | ||
| 743 | . | ||
| 744 | |||
| 745 | #. *Build the Updated Kernel Source:* To build the updated kernel | ||
| 746 | source, use ``devtool``:: | ||
| 747 | |||
| 748 | $ devtool build linux-yocto | ||
| 749 | |||
| 750 | #. *Create the Image With the New Kernel:* Use the | ||
| 751 | ``devtool build-image`` command to create a new image that has the | ||
| 752 | new kernel:: | ||
| 753 | |||
| 754 | $ cd ~ | ||
| 755 | $ devtool build-image core-image-minimal | ||
| 756 | |||
| 757 | .. note:: | ||
| 758 | |||
| 759 | If the image you originally created resulted in a Wic file, you | ||
| 760 | can use an alternate method to create the new image with the | ||
| 761 | updated kernel. For an example, see the steps in the | ||
| 762 | :yocto_wiki:`TipsAndTricks/KernelDevelopmentWithEsdk </TipsAndTricks/KernelDevelopmentWithEsdk>` | ||
| 763 | Wiki Page. | ||
| 764 | |||
| 765 | #. *Test the New Image:* For this example, you can run the new image | ||
| 766 | using QEMU to verify your changes: | ||
| 767 | |||
| 768 | #. *Boot the image*: Boot the modified image in the QEMU emulator | ||
| 769 | using this command:: | ||
| 770 | |||
| 771 | $ runqemu qemux86 | ||
| 772 | |||
| 773 | #. *Verify the changes*: Log into the machine using ``root`` with no | ||
| 774 | password and then use the following shell command to scroll | ||
| 775 | through the console's boot output. | ||
| 776 | |||
| 777 | .. code-block:: none | ||
| 778 | |||
| 779 | # dmesg | less | ||
| 780 | |||
| 781 | You should see | ||
| 782 | the results of your ``printk`` statements as part of the output | ||
| 783 | when you scroll down the console window. | ||
| 784 | |||
| 785 | #. *Stage and commit your changes*: Change | ||
| 786 | your working directory to where you modified the ``calibrate.c`` file | ||
| 787 | and use these Git commands to stage and commit your changes:: | ||
| 788 | |||
| 789 | $ cd poky_sdk/workspace/sources/linux-yocto | ||
| 790 | $ git status | ||
| 791 | $ git add init/calibrate.c | ||
| 792 | $ git commit -m "calibrate: Add printk example" | ||
| 793 | |||
| 794 | #. *Export the Patches and Create an Append File:* To export your | ||
| 795 | commits as patches and create a ``.bbappend`` file, use the following | ||
| 796 | command. This example uses the previously established layer named ``meta-mylayer``:: | ||
| 797 | |||
| 798 | $ devtool finish linux-yocto ~/meta-mylayer | ||
| 799 | |||
| 800 | .. note:: | ||
| 801 | |||
| 802 | See Step 3 of the | ||
| 803 | ":ref:`kernel-dev/common:getting ready to develop using ``devtool```" | ||
| 804 | section for information on setting up this layer. | ||
| 805 | |||
| 806 | Once the command | ||
| 807 | finishes, the patches and the ``.bbappend`` file are located in the | ||
| 808 | ``~/meta-mylayer/recipes-kernel/linux`` directory. | ||
| 809 | |||
| 810 | #. *Build the Image With Your Modified Kernel:* You can now build an | ||
| 811 | image that includes your kernel patches. Execute the following | ||
| 812 | command from your :term:`Build Directory` in the terminal | ||
| 813 | set up to run BitBake:: | ||
| 814 | |||
| 815 | $ cd poky/build | ||
| 816 | $ bitbake core-image-minimal | ||
| 817 | |||
| 818 | Using Traditional Kernel Development to Patch the Kernel | ||
| 819 | ======================================================== | ||
| 820 | |||
| 821 | The steps in this procedure show you how you can patch the kernel using | ||
| 822 | traditional kernel development (i.e. not using ``devtool`` | ||
| 823 | as described in the | ||
| 824 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 825 | section). | ||
| 826 | |||
| 827 | .. note:: | ||
| 828 | |||
| 829 | Before attempting this procedure, be sure you have performed the | ||
| 830 | steps to get ready for updating the kernel as described in the | ||
| 831 | ":ref:`kernel-dev/common:getting ready for traditional kernel development`" | ||
| 832 | section. | ||
| 833 | |||
| 834 | Patching the kernel involves changing or adding configurations to an | ||
| 835 | existing kernel, changing or adding recipes to the kernel that are | ||
| 836 | needed to support specific hardware features, or even altering the | ||
| 837 | source code itself. | ||
| 838 | |||
| 839 | The example in this section creates a simple patch by adding some QEMU | ||
| 840 | emulator console output at boot time through ``printk`` statements in | ||
| 841 | the kernel's ``calibrate.c`` source code file. Applying the patch and | ||
| 842 | booting the modified image causes the added messages to appear on the | ||
| 843 | emulator's console. The example is a continuation of the setup procedure | ||
| 844 | found in the | ||
| 845 | ":ref:`kernel-dev/common:getting ready for traditional kernel development`" | ||
| 846 | Section. | ||
| 847 | |||
| 848 | #. *Edit the Source Files* Prior to this step, you should have used Git | ||
| 849 | to create a local copy of the repository for your kernel. Assuming | ||
| 850 | you created the repository as directed in the | ||
| 851 | ":ref:`kernel-dev/common:getting ready for traditional kernel development`" | ||
| 852 | section, use the following commands to edit the ``calibrate.c`` file: | ||
| 853 | |||
| 854 | #. *Change the working directory*: You need to locate the source | ||
| 855 | files in the local copy of the kernel Git repository. Change to | ||
| 856 | where the kernel source code is before making your edits to the | ||
| 857 | ``calibrate.c`` file:: | ||
| 858 | |||
| 859 | $ cd ~/linux-yocto-4.12/init | ||
| 860 | |||
| 861 | #. *Edit the source file*: Edit the ``calibrate.c`` file to have the | ||
| 862 | following changes:: | ||
| 863 | |||
| 864 | void calibrate_delay(void) | ||
| 865 | { | ||
| 866 | unsigned long lpj; | ||
| 867 | static bool printed; | ||
| 868 | int this_cpu = smp_processor_id(); | ||
| 869 | |||
| 870 | printk("*************************************\n"); | ||
| 871 | printk("* *\n"); | ||
| 872 | printk("* HELLO YOCTO KERNEL *\n"); | ||
| 873 | printk("* *\n"); | ||
| 874 | printk("*************************************\n"); | ||
| 875 | |||
| 876 | if (per_cpu(cpu_loops_per_jiffy, this_cpu)) { | ||
| 877 | . | ||
| 878 | . | ||
| 879 | . | ||
| 880 | |||
| 881 | #. *Stage and Commit Your Changes:* Use standard Git commands to stage | ||
| 882 | and commit the changes you just made:: | ||
| 883 | |||
| 884 | $ git add calibrate.c | ||
| 885 | $ git commit -m "calibrate.c - Added some printk statements" | ||
| 886 | |||
| 887 | If you do not | ||
| 888 | stage and commit your changes, the OpenEmbedded Build System will not | ||
| 889 | pick up the changes. | ||
| 890 | |||
| 891 | #. *Update Your local.conf File to Point to Your Source Files:* In | ||
| 892 | addition to your ``local.conf`` file specifying to use | ||
| 893 | "kernel-modules" and the "qemux86" machine, it must also point to the | ||
| 894 | updated kernel source files. Add | ||
| 895 | :term:`SRC_URI` and | ||
| 896 | :term:`SRCREV` statements similar | ||
| 897 | to the following to your ``local.conf``:: | ||
| 898 | |||
| 899 | $ cd poky/build/conf | ||
| 900 | |||
| 901 | Add the following to the ``local.conf``:: | ||
| 902 | |||
| 903 | SRC_URI:pn-linux-yocto = "git:///path-to/linux-yocto-4.12;protocol=file;name=machine;branch=standard/base; \ | ||
| 904 | git:///path-to/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}" | ||
| 905 | SRCREV_meta:qemux86 = "${AUTOREV}" | ||
| 906 | SRCREV_machine:qemux86 = "${AUTOREV}" | ||
| 907 | |||
| 908 | .. note:: | ||
| 909 | |||
| 910 | Be sure to replace `path-to` | ||
| 911 | with the pathname to your local Git repositories. Also, you must | ||
| 912 | be sure to specify the correct branch and machine types. For this | ||
| 913 | example, the branch is ``standard/base`` and the machine is ``qemux86``. | ||
| 914 | |||
| 915 | #. *Build the Image:* With the source modified, your changes staged and | ||
| 916 | committed, and the ``local.conf`` file pointing to the kernel files, | ||
| 917 | you can now use BitBake to build the image:: | ||
| 918 | |||
| 919 | $ cd poky/build | ||
| 920 | $ bitbake core-image-minimal | ||
| 921 | |||
| 922 | #. *Boot the image*: Boot the modified image in the QEMU emulator using | ||
| 923 | this command. When prompted to login to the QEMU console, use "root" | ||
| 924 | with no password:: | ||
| 925 | |||
| 926 | $ cd poky/build | ||
| 927 | $ runqemu qemux86 | ||
| 928 | |||
| 929 | #. *Look for Your Changes:* As QEMU booted, you might have seen your | ||
| 930 | changes rapidly scroll by. If not, use these commands to see your | ||
| 931 | changes: | ||
| 932 | |||
| 933 | .. code-block:: none | ||
| 934 | |||
| 935 | # dmesg | less | ||
| 936 | |||
| 937 | You should see the results of your | ||
| 938 | ``printk`` statements as part of the output when you scroll down the | ||
| 939 | console window. | ||
| 940 | |||
| 941 | #. *Generate the Patch File:* Once you are sure that your patch works | ||
| 942 | correctly, you can generate a ``*.patch`` file in the kernel source | ||
| 943 | repository:: | ||
| 944 | |||
| 945 | $ cd ~/linux-yocto-4.12/init | ||
| 946 | $ git format-patch -1 | ||
| 947 | 0001-calibrate.c-Added-some-printk-statements.patch | ||
| 948 | |||
| 949 | #. *Move the Patch File to Your Layer:* In order for subsequent builds | ||
| 950 | to pick up patches, you need to move the patch file you created in | ||
| 951 | the previous step to your layer ``meta-mylayer``. For this example, | ||
| 952 | the layer created earlier is located in your home directory as | ||
| 953 | ``meta-mylayer``. When the layer was created using the | ||
| 954 | ``yocto-create`` script, no additional hierarchy was created to | ||
| 955 | support patches. Before moving the patch file, you need to add | ||
| 956 | additional structure to your layer using the following commands:: | ||
| 957 | |||
| 958 | $ cd ~/meta-mylayer | ||
| 959 | $ mkdir -p recipes-kernel recipes-kernel/linux/linux-yocto | ||
| 960 | |||
| 961 | Once you have created this | ||
| 962 | hierarchy in your layer, you can move the patch file using the | ||
| 963 | following command:: | ||
| 964 | |||
| 965 | $ mv ~/linux-yocto-4.12/init/0001-calibrate.c-Added-some-printk-statements.patch ~/meta-mylayer/recipes-kernel/linux/linux-yocto | ||
| 966 | |||
| 967 | #. *Create the Append File:* Finally, you need to create the | ||
| 968 | ``linux-yocto_4.12.bbappend`` file and insert statements that allow | ||
| 969 | the OpenEmbedded build system to find the patch. The append file | ||
| 970 | needs to be in your layer's ``recipes-kernel/linux`` directory and it | ||
| 971 | must be named ``linux-yocto_4.12.bbappend`` and have the following | ||
| 972 | contents:: | ||
| 973 | |||
| 974 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 975 | SRC_URI += "file://0001-calibrate.c-Added-some-printk-statements.patch" | ||
| 976 | |||
| 977 | The :term:`FILESEXTRAPATHS` and :term:`SRC_URI` statements | ||
| 978 | enable the OpenEmbedded build system to find the patch file. | ||
| 979 | |||
| 980 | For more information on append files and patches, see the | ||
| 981 | ":ref:`kernel-dev/common:creating the append file`" and | ||
| 982 | ":ref:`kernel-dev/common:applying patches`" sections. You can also see the | ||
| 983 | ":ref:`dev-manual/layers:appending other layers metadata with your layer`" | ||
| 984 | section in the Yocto Project Development Tasks Manual. | ||
| 985 | |||
| 986 | .. note:: | ||
| 987 | |||
| 988 | To build ``core-image-minimal`` again and see the effects of your patch, | ||
| 989 | you can essentially eliminate the temporary source files saved in | ||
| 990 | ``poky/build/tmp/work/...`` and residual effects of the build by entering | ||
| 991 | the following sequence of commands:: | ||
| 992 | |||
| 993 | $ cd poky/build | ||
| 994 | $ bitbake -c cleanall linux-yocto | ||
| 995 | $ bitbake core-image-minimal -c cleanall | ||
| 996 | $ bitbake core-image-minimal | ||
| 997 | $ runqemu qemux86 | ||
| 998 | |||
| 999 | |||
| 1000 | Configuring the Kernel | ||
| 1001 | ====================== | ||
| 1002 | |||
| 1003 | Configuring the Yocto Project kernel consists of making sure the | ||
| 1004 | ``.config`` file has all the right information in it for the image you | ||
| 1005 | are building. You can use the ``menuconfig`` tool and configuration | ||
| 1006 | fragments to make sure your ``.config`` file is just how you need it. | ||
| 1007 | You can also save known configurations in a ``defconfig`` file that the | ||
| 1008 | build system can use for kernel configuration. | ||
| 1009 | |||
| 1010 | This section describes how to use ``menuconfig``, create and use | ||
| 1011 | configuration fragments, and how to interactively modify your | ||
| 1012 | ``.config`` file to create the leanest kernel configuration file | ||
| 1013 | possible. | ||
| 1014 | |||
| 1015 | For more information on kernel configuration, see the | ||
| 1016 | ":ref:`kernel-dev/common:changing the configuration`" section. | ||
| 1017 | |||
| 1018 | Using  ``menuconfig`` | ||
| 1019 | --------------------- | ||
| 1020 | |||
| 1021 | The easiest way to define kernel configurations is to set them through | ||
| 1022 | the ``menuconfig`` tool. This tool provides an interactive method with | ||
| 1023 | which to set kernel configurations. For general information on | ||
| 1024 | ``menuconfig``, see :wikipedia:`Menuconfig`. | ||
| 1025 | |||
| 1026 | To use the ``menuconfig`` tool in the Yocto Project development | ||
| 1027 | environment, you must do the following: | ||
| 1028 | |||
| 1029 | - Because you launch ``menuconfig`` using BitBake, you must be sure to | ||
| 1030 | set up your environment by running the :ref:`structure-core-script` script | ||
| 1031 | found in the :term:`Build Directory`. | ||
| 1032 | |||
| 1033 | - You must be sure of the state of your build's configuration in the | ||
| 1034 | :term:`Source Directory`. | ||
| 1035 | |||
| 1036 | - Your build host must have the following two packages installed:: | ||
| 1037 | |||
| 1038 | libncurses5-dev | ||
| 1039 | libtinfo-dev | ||
| 1040 | |||
| 1041 | The following commands initialize the BitBake environment, run the | ||
| 1042 | :ref:`ref-tasks-kernel_configme` | ||
| 1043 | task, and launch ``menuconfig``. These commands assume the Source | ||
| 1044 | Directory's top-level folder is ``poky``:: | ||
| 1045 | |||
| 1046 | $ cd poky | ||
| 1047 | $ source oe-init-build-env | ||
| 1048 | $ bitbake linux-yocto -c kernel_configme -f | ||
| 1049 | $ bitbake linux-yocto -c menuconfig | ||
| 1050 | |||
| 1051 | Once ``menuconfig`` comes up, its standard | ||
| 1052 | interface allows you to interactively examine and configure all the | ||
| 1053 | kernel configuration parameters. After making your changes, simply exit | ||
| 1054 | the tool and save your changes to create an updated version of the | ||
| 1055 | ``.config`` configuration file. | ||
| 1056 | |||
| 1057 | .. note:: | ||
| 1058 | |||
| 1059 | You can use the entire ``.config`` file as the ``defconfig`` file. For | ||
| 1060 | information on ``defconfig`` files, see the | ||
| 1061 | ":ref:`kernel-dev/common:changing the configuration`", | ||
| 1062 | ":ref:`kernel-dev/common:using an "in-tree" \`\`defconfig\`\` file`", | ||
| 1063 | and ":ref:`kernel-dev/common:creating a \`\`defconfig\`\` file`" | ||
| 1064 | sections. | ||
| 1065 | |||
| 1066 | Consider an example that configures the "CONFIG_SMP" setting for the | ||
| 1067 | ``linux-yocto-4.12`` kernel. | ||
| 1068 | |||
| 1069 | .. note:: | ||
| 1070 | |||
| 1071 | The OpenEmbedded build system recognizes this kernel as ``linux-yocto`` | ||
| 1072 | through Metadata (e.g. :term:`PREFERRED_VERSION`\ ``_linux-yocto ?= "4.12%"``). | ||
| 1073 | |||
| 1074 | Once ``menuconfig`` launches, use the interface to navigate through the | ||
| 1075 | selections to find the configuration settings in which you are | ||
| 1076 | interested. For this example, you deselect "CONFIG_SMP" by clearing the | ||
| 1077 | "Symmetric Multi-Processing Support" option. Using the interface, you | ||
| 1078 | can find the option under "Processor Type and Features". To deselect | ||
| 1079 | "CONFIG_SMP", use the arrow keys to highlight "Symmetric | ||
| 1080 | Multi-Processing Support" and enter "N" to clear the asterisk. When you | ||
| 1081 | are finished, exit out and save the change. | ||
| 1082 | |||
| 1083 | Saving the selections updates the ``.config`` configuration file. This is the | ||
| 1084 | file that the OpenEmbedded build system uses to configure the kernel during | ||
| 1085 | the build. You can find and examine this file in the :term:`Build Directory` | ||
| 1086 | in ``tmp/work/``. The actual ``.config`` is located in the | ||
| 1087 | area where the specific kernel is built. For example, if you were | ||
| 1088 | building a Linux Yocto kernel based on the ``linux-yocto-4.12`` kernel | ||
| 1089 | and you were building a QEMU image targeted for ``x86`` architecture, | ||
| 1090 | the ``.config`` file would be: | ||
| 1091 | |||
| 1092 | .. code-block:: none | ||
| 1093 | |||
| 1094 | poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18... | ||
| 1095 | ...967-r0/linux-qemux86-standard-build/.config | ||
| 1096 | |||
| 1097 | .. note:: | ||
| 1098 | |||
| 1099 | The previous example directory is artificially split and many of the | ||
| 1100 | characters in the actual filename are omitted in order to make it | ||
| 1101 | more readable. Also, depending on the kernel you are using, the exact | ||
| 1102 | pathname might differ. | ||
| 1103 | |||
| 1104 | Within the ``.config`` file, you can see the kernel settings. For | ||
| 1105 | example, the following entry shows that symmetric multi-processor | ||
| 1106 | support is not set:: | ||
| 1107 | |||
| 1108 | # CONFIG_SMP is not set | ||
| 1109 | |||
| 1110 | A good method to isolate changed configurations is to use a combination | ||
| 1111 | of the ``menuconfig`` tool and simple shell commands. Before changing | ||
| 1112 | configurations with ``menuconfig``, copy the existing ``.config`` and | ||
| 1113 | rename it to something else, use ``menuconfig`` to make as many changes | ||
| 1114 | as you want and save them, then compare the renamed configuration file | ||
| 1115 | against the newly created file. You can use the resulting differences as | ||
| 1116 | your base to create configuration fragments to permanently save in your | ||
| 1117 | kernel layer. | ||
| 1118 | |||
| 1119 | .. note:: | ||
| 1120 | |||
| 1121 | Be sure to make a copy of the ``.config`` file and do not just rename it. | ||
| 1122 | The build system needs an existing ``.config`` file from which to work. | ||
| 1123 | |||
| 1124 | Creating a  ``defconfig`` File | ||
| 1125 | ------------------------------ | ||
| 1126 | |||
| 1127 | A ``defconfig`` file in the context of the Yocto Project is often a | ||
| 1128 | ``.config`` file that is copied from a build or a ``defconfig`` taken | ||
| 1129 | from the kernel tree and moved into recipe space. You can use a | ||
| 1130 | ``defconfig`` file to retain a known set of kernel configurations from | ||
| 1131 | which the OpenEmbedded build system can draw to create the final | ||
| 1132 | ``.config`` file. | ||
| 1133 | |||
| 1134 | .. note:: | ||
| 1135 | |||
| 1136 | Out-of-the-box, the Yocto Project never ships a ``defconfig`` or ``.config`` | ||
| 1137 | file. The OpenEmbedded build system creates the final ``.config`` file used | ||
| 1138 | to configure the kernel. | ||
| 1139 | |||
| 1140 | To create a ``defconfig``, start with a complete, working Linux kernel | ||
| 1141 | ``.config`` file. Copy that file to the appropriate | ||
| 1142 | ``${``\ :term:`PN`\ ``}`` directory in | ||
| 1143 | your layer's ``recipes-kernel/linux`` directory, and rename the copied | ||
| 1144 | file to "defconfig" (e.g. | ||
| 1145 | ``~/meta-mylayer/recipes-kernel/linux/linux-yocto/defconfig``). Then, | ||
| 1146 | add the following lines to the linux-yocto ``.bbappend`` file in your | ||
| 1147 | layer:: | ||
| 1148 | |||
| 1149 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 1150 | SRC_URI += "file://defconfig" | ||
| 1151 | |||
| 1152 | The :term:`SRC_URI` tells the build system how to search for the file, while the | ||
| 1153 | :term:`FILESEXTRAPATHS` extends the :term:`FILESPATH` | ||
| 1154 | variable (search directories) to include the ``${PN}`` directory you | ||
| 1155 | created to hold the configuration changes. | ||
| 1156 | |||
| 1157 | .. note:: | ||
| 1158 | |||
| 1159 | The build system applies the configurations from the ``defconfig`` | ||
| 1160 | file before applying any subsequent configuration fragments. The | ||
| 1161 | final kernel configuration is a combination of the configurations in | ||
| 1162 | the ``defconfig`` file and any configuration fragments you provide. You need | ||
| 1163 | to realize that if you have any configuration fragments, the build system | ||
| 1164 | applies these on top of and after applying the existing ``defconfig`` file | ||
| 1165 | configurations. | ||
| 1166 | |||
| 1167 | For more information on configuring the kernel, see the | ||
| 1168 | ":ref:`kernel-dev/common:changing the configuration`" section. | ||
| 1169 | |||
| 1170 | Creating Configuration Fragments | ||
| 1171 | -------------------------------- | ||
| 1172 | |||
| 1173 | Configuration fragments are simply kernel options that appear in a file | ||
| 1174 | placed where the OpenEmbedded build system can find and apply them. The | ||
| 1175 | build system applies configuration fragments after applying | ||
| 1176 | configurations from a ``defconfig`` file. Thus, the final kernel | ||
| 1177 | configuration is a combination of the configurations in the | ||
| 1178 | ``defconfig`` file and then any configuration fragments you provide. The | ||
| 1179 | build system applies fragments on top of and after applying the existing | ||
| 1180 | defconfig file configurations. | ||
| 1181 | |||
| 1182 | Syntactically, the configuration statement is identical to what would | ||
| 1183 | appear in the ``.config`` file, which is in the :term:`Build Directory`. | ||
| 1184 | |||
| 1185 | .. note:: | ||
| 1186 | |||
| 1187 | For more information about where the ``.config`` file is located, see the | ||
| 1188 | example in the | ||
| 1189 | ":ref:`kernel-dev/common:using ``menuconfig```" | ||
| 1190 | section. | ||
| 1191 | |||
| 1192 | It is simple to create a configuration fragment. One method is to use | ||
| 1193 | shell commands. For example, issuing the following from the shell | ||
| 1194 | creates a configuration fragment file named ``my_smp.cfg`` that enables | ||
| 1195 | multi-processor support within the kernel:: | ||
| 1196 | |||
| 1197 | $ echo "CONFIG_SMP=y" >> my_smp.cfg | ||
| 1198 | |||
| 1199 | .. note:: | ||
| 1200 | |||
| 1201 | All configuration fragment files must use the ``.cfg`` extension in order | ||
| 1202 | for the OpenEmbedded build system to recognize them as a configuration | ||
| 1203 | fragment. | ||
| 1204 | |||
| 1205 | Another method is to create a configuration fragment using the | ||
| 1206 | differences between two configuration files: one previously created and | ||
| 1207 | saved, and one freshly created using the ``menuconfig`` tool. | ||
| 1208 | |||
| 1209 | To create a configuration fragment using this method, follow these | ||
| 1210 | steps: | ||
| 1211 | |||
| 1212 | #. *Complete a Build Through Kernel Configuration:* Complete a build at | ||
| 1213 | least through the kernel configuration task as follows:: | ||
| 1214 | |||
| 1215 | $ bitbake linux-yocto -c kernel_configme -f | ||
| 1216 | |||
| 1217 | This step ensures that you create a | ||
| 1218 | ``.config`` file from a known state. Because there are situations where | ||
| 1219 | your build state might become unknown, it is best to run this task | ||
| 1220 | prior to starting ``menuconfig``. | ||
| 1221 | |||
| 1222 | #. *Launch menuconfig:* Run the ``menuconfig`` command:: | ||
| 1223 | |||
| 1224 | $ bitbake linux-yocto -c menuconfig | ||
| 1225 | |||
| 1226 | #. *Create the Configuration Fragment:* Run the ``diffconfig`` command | ||
| 1227 | to prepare a configuration fragment. The resulting file | ||
| 1228 | ``fragment.cfg`` is placed in the | ||
| 1229 | ``${``\ :term:`WORKDIR`\ ``}`` | ||
| 1230 | directory:: | ||
| 1231 | |||
| 1232 | $ bitbake linux-yocto -c diffconfig | ||
| 1233 | |||
| 1234 | The ``diffconfig`` command creates a file that is a list of Linux kernel | ||
| 1235 | ``CONFIG_`` assignments. See the | ||
| 1236 | ":ref:`kernel-dev/common:changing the configuration`" section for additional | ||
| 1237 | information on how to use the output as a configuration fragment. | ||
| 1238 | |||
| 1239 | .. note:: | ||
| 1240 | |||
| 1241 | You can also use this method to create configuration fragments for a | ||
| 1242 | BSP. See the ":ref:`kernel-dev/advanced:bsp descriptions`" | ||
| 1243 | section for more information. | ||
| 1244 | |||
| 1245 | Where do you put your configuration fragment files? You can place these | ||
| 1246 | files in an area pointed to by | ||
| 1247 | :term:`SRC_URI` as directed by your | ||
| 1248 | ``bblayers.conf`` file, which is located in your layer. The OpenEmbedded | ||
| 1249 | build system picks up the configuration and adds it to the kernel's | ||
| 1250 | configuration. For example, suppose you had a set of configuration | ||
| 1251 | options in a file called ``myconfig.cfg``. If you put that file inside a | ||
| 1252 | directory named ``linux-yocto`` that resides in the same directory as | ||
| 1253 | the kernel's append file within your layer and then add the following | ||
| 1254 | statements to the kernel's append file, those configuration options will | ||
| 1255 | be picked up and applied when the kernel is built:: | ||
| 1256 | |||
| 1257 | FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" | ||
| 1258 | SRC_URI += "file://myconfig.cfg" | ||
| 1259 | |||
| 1260 | As mentioned earlier, you can group related configurations into multiple | ||
| 1261 | files and name them all in the :term:`SRC_URI` statement as well. For | ||
| 1262 | example, you could group separate configurations specifically for | ||
| 1263 | Ethernet and graphics into their own files and add those by using a | ||
| 1264 | :term:`SRC_URI` statement like the following in your append file:: | ||
| 1265 | |||
| 1266 | SRC_URI += "file://myconfig.cfg \ | ||
| 1267 | file://eth.cfg \ | ||
| 1268 | file://gfx.cfg" | ||
| 1269 | |||
| 1270 | Validating Configuration | ||
| 1271 | ------------------------ | ||
| 1272 | |||
| 1273 | You can use the | ||
| 1274 | :ref:`ref-tasks-kernel_configcheck` | ||
| 1275 | task to provide configuration validation:: | ||
| 1276 | |||
| 1277 | $ bitbake linux-yocto -c kernel_configcheck -f | ||
| 1278 | |||
| 1279 | Running this task produces warnings for when a | ||
| 1280 | requested configuration does not appear in the final ``.config`` file or | ||
| 1281 | when you override a policy configuration in a hardware configuration | ||
| 1282 | fragment. | ||
| 1283 | |||
| 1284 | In order to run this task, you must have an existing ``.config`` file. | ||
| 1285 | See the ":ref:`kernel-dev/common:using ``menuconfig```" section for | ||
| 1286 | information on how to create a configuration file. | ||
| 1287 | |||
| 1288 | Here is sample output from the :ref:`ref-tasks-kernel_configcheck` task: | ||
| 1289 | |||
| 1290 | .. code-block:: none | ||
| 1291 | |||
| 1292 | Loading cache: 100% |########################################################| Time: 0:00:00 | ||
| 1293 | Loaded 1275 entries from dependency cache. | ||
| 1294 | NOTE: Resolving any missing task queue dependencies | ||
| 1295 | |||
| 1296 | Build Configuration: | ||
| 1297 | . | ||
| 1298 | . | ||
| 1299 | . | ||
| 1300 | |||
| 1301 | NOTE: Executing SetScene Tasks | ||
| 1302 | NOTE: Executing RunQueue Tasks | ||
| 1303 | WARNING: linux-yocto-4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0 do_kernel_configcheck: | ||
| 1304 | [kernel config]: specified values did not make it into the kernel's final configuration: | ||
| 1305 | |||
| 1306 | ---------- CONFIG_X86_TSC ----------------- | ||
| 1307 | Config: CONFIG_X86_TSC | ||
| 1308 | From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc-cpu.cfg | ||
| 1309 | Requested value: CONFIG_X86_TSC=y | ||
| 1310 | Actual value: | ||
| 1311 | |||
| 1312 | |||
| 1313 | ---------- CONFIG_X86_BIGSMP ----------------- | ||
| 1314 | Config: CONFIG_X86_BIGSMP | ||
| 1315 | From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | ||
| 1316 | /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | ||
| 1317 | Requested value: # CONFIG_X86_BIGSMP is not set | ||
| 1318 | Actual value: | ||
| 1319 | |||
| 1320 | |||
| 1321 | ---------- CONFIG_NR_CPUS ----------------- | ||
| 1322 | Config: CONFIG_NR_CPUS | ||
| 1323 | From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | ||
| 1324 | /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc.cfg | ||
| 1325 | /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | ||
| 1326 | Requested value: CONFIG_NR_CPUS=8 | ||
| 1327 | Actual value: CONFIG_NR_CPUS=1 | ||
| 1328 | |||
| 1329 | |||
| 1330 | ---------- CONFIG_SCHED_SMT ----------------- | ||
| 1331 | Config: CONFIG_SCHED_SMT | ||
| 1332 | From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg | ||
| 1333 | /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig | ||
| 1334 | Requested value: CONFIG_SCHED_SMT=y | ||
| 1335 | Actual value: | ||
| 1336 | |||
| 1337 | |||
| 1338 | |||
| 1339 | NOTE: Tasks Summary: Attempted 288 tasks of which 285 didn't need to be rerun and all succeeded. | ||
| 1340 | |||
| 1341 | Summary: There were 3 WARNING messages shown. | ||
| 1342 | |||
| 1343 | .. note:: | ||
| 1344 | |||
| 1345 | The previous output example has artificial line breaks to make it | ||
| 1346 | more readable. | ||
| 1347 | |||
| 1348 | The output describes the various problems that you can encounter along | ||
| 1349 | with where to find the offending configuration items. You can use the | ||
| 1350 | information in the logs to adjust your configuration files and then | ||
| 1351 | repeat the | ||
| 1352 | :ref:`ref-tasks-kernel_configme` | ||
| 1353 | and | ||
| 1354 | :ref:`ref-tasks-kernel_configcheck` | ||
| 1355 | tasks until they produce no warnings. | ||
| 1356 | |||
| 1357 | For more information on how to use the ``menuconfig`` tool, see the | ||
| 1358 | :ref:`kernel-dev/common:using ``menuconfig``` section. | ||
| 1359 | |||
| 1360 | Fine-Tuning the Kernel Configuration File | ||
| 1361 | ----------------------------------------- | ||
| 1362 | |||
| 1363 | You can make sure the ``.config`` file is as lean or efficient as | ||
| 1364 | possible by reading the output of the kernel configuration fragment | ||
| 1365 | audit, noting any issues, making changes to correct the issues, and then | ||
| 1366 | repeating. | ||
| 1367 | |||
| 1368 | As part of the kernel build process, the :ref:`ref-tasks-kernel_configcheck` task | ||
| 1369 | runs. This task validates the kernel configuration by checking the final | ||
| 1370 | ``.config`` file against the input files. During the check, the task | ||
| 1371 | produces warning messages for the following issues: | ||
| 1372 | |||
| 1373 | - Requested options that did not make it into the final ``.config`` file. | ||
| 1374 | |||
| 1375 | - Configuration items that appear twice in the same configuration | ||
| 1376 | fragment. | ||
| 1377 | |||
| 1378 | - Configuration items tagged as "required" that were overridden. | ||
| 1379 | |||
| 1380 | - A board overrides a non-board specific option. | ||
| 1381 | |||
| 1382 | - Listed options not valid for the kernel being processed. In other | ||
| 1383 | words, the option does not appear anywhere. | ||
| 1384 | |||
| 1385 | .. note:: | ||
| 1386 | |||
| 1387 | The :ref:`ref-tasks-kernel_configcheck` task can also optionally report if | ||
| 1388 | an option is overridden during processing. | ||
| 1389 | |||
| 1390 | For each output warning, a message points to the file that contains a | ||
| 1391 | list of the options and a pointer to the configuration fragment that | ||
| 1392 | defines them. Collectively, the files are the key to streamlining the | ||
| 1393 | configuration. | ||
| 1394 | |||
| 1395 | To streamline the configuration, do the following: | ||
| 1396 | |||
| 1397 | #. *Use a Working Configuration:* Start with a full configuration that | ||
| 1398 | you know works. Be sure the configuration builds and boots | ||
| 1399 | successfully. Use this configuration file as your baseline. | ||
| 1400 | |||
| 1401 | #. *Run Configure and Check Tasks:* Separately run the | ||
| 1402 | :ref:`ref-tasks-kernel_configme` and :ref:`ref-tasks-kernel_configcheck` tasks:: | ||
| 1403 | |||
| 1404 | $ bitbake linux-yocto -c kernel_configme -f | ||
| 1405 | $ bitbake linux-yocto -c kernel_configcheck -f | ||
| 1406 | |||
| 1407 | #. *Process the Results:* Take the resulting list of files from the | ||
| 1408 | :ref:`ref-tasks-kernel_configcheck` task warnings and do the following: | ||
| 1409 | |||
| 1410 | - Drop values that are redefined in the fragment but do not change | ||
| 1411 | the final ``.config`` file. | ||
| 1412 | |||
| 1413 | - Analyze and potentially drop values from the ``.config`` file that | ||
| 1414 | override required configurations. | ||
| 1415 | |||
| 1416 | - Analyze and potentially remove non-board specific options. | ||
| 1417 | |||
| 1418 | - Remove repeated and invalid options. | ||
| 1419 | |||
| 1420 | #. *Re-Run Configure and Check Tasks:* After you have worked through the | ||
| 1421 | output of the kernel configuration audit, you can re-run the | ||
| 1422 | :ref:`ref-tasks-kernel_configme` and :ref:`ref-tasks-kernel_configcheck` tasks to see the | ||
| 1423 | results of your changes. If you have more issues, you can deal with | ||
| 1424 | them as described in the previous step. | ||
| 1425 | |||
| 1426 | Iteratively working through steps two through four eventually yields a | ||
| 1427 | minimal, streamlined configuration file. Once you have the best | ||
| 1428 | ``.config``, you can build the Linux Yocto kernel. | ||
| 1429 | |||
| 1430 | Expanding Variables | ||
| 1431 | =================== | ||
| 1432 | |||
| 1433 | Sometimes it is helpful to determine what a variable expands to during a | ||
| 1434 | build. You can examine the values of variables by examining the | ||
| 1435 | output of the ``bitbake -e`` command. The output is long and is more | ||
| 1436 | easily managed in a text file, which allows for easy searches:: | ||
| 1437 | |||
| 1438 | $ bitbake -e virtual/kernel > some_text_file | ||
| 1439 | |||
| 1440 | Within the text file, you can see | ||
| 1441 | exactly how each variable is expanded and used by the OpenEmbedded build | ||
| 1442 | system. | ||
| 1443 | |||
| 1444 | Working with a "Dirty" Kernel Version String | ||
| 1445 | ============================================ | ||
| 1446 | |||
| 1447 | If you build a kernel image and the version string has a "+" or a | ||
| 1448 | "-dirty" at the end, it means there are uncommitted modifications in the kernel's | ||
| 1449 | source directory. Follow these steps to clean up the version string: | ||
| 1450 | |||
| 1451 | #. *Discover the Uncommitted Changes:* Go to the kernel's locally cloned | ||
| 1452 | Git repository (source directory) and use the following Git command | ||
| 1453 | to list the files that have been changed, added, or removed:: | ||
| 1454 | |||
| 1455 | $ git status | ||
| 1456 | |||
| 1457 | #. *Commit the Changes:* You should commit those changes to the kernel | ||
| 1458 | source tree regardless of whether or not you will save, export, or | ||
| 1459 | use the changes:: | ||
| 1460 | |||
| 1461 | $ git add | ||
| 1462 | $ git commit -s -a -m "getting rid of -dirty" | ||
| 1463 | |||
| 1464 | #. *Rebuild the Kernel Image:* Once you commit the changes, rebuild the | ||
| 1465 | kernel. | ||
| 1466 | |||
| 1467 | Depending on your particular kernel development workflow, the | ||
| 1468 | commands you use to rebuild the kernel might differ. For information | ||
| 1469 | on building the kernel image when using ``devtool``, see the | ||
| 1470 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 1471 | section. For | ||
| 1472 | information on building the kernel image when using BitBake, see the | ||
| 1473 | ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 1474 | section. | ||
| 1475 | |||
| 1476 | Working With Your Own Sources | ||
| 1477 | ============================= | ||
| 1478 | |||
| 1479 | If you cannot work with one of the Linux kernel versions supported by | ||
| 1480 | existing linux-yocto recipes, you can still make use of the Yocto | ||
| 1481 | Project Linux kernel tooling by working with your own sources. When you | ||
| 1482 | use your own sources, you will not be able to leverage the existing | ||
| 1483 | kernel :term:`Metadata` and stabilization | ||
| 1484 | work of the linux-yocto sources. However, you will be able to manage | ||
| 1485 | your own Metadata in the same format as the linux-yocto sources. | ||
| 1486 | Maintaining format compatibility facilitates converging with linux-yocto | ||
| 1487 | on a future, mutually-supported kernel version. | ||
| 1488 | |||
| 1489 | To help you use your own sources, the Yocto Project provides a | ||
| 1490 | linux-yocto custom recipe that uses ``kernel.org`` sources and | ||
| 1491 | the Yocto Project Linux kernel tools for managing kernel Metadata. | ||
| 1492 | You can find this recipe in the ``poky`` Git repository: | ||
| 1493 | :yocto_git:`meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb | ||
| 1494 | </poky/tree/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb>`. | ||
| 1495 | |||
| 1496 | Here are some basic steps you can use to work with your own sources: | ||
| 1497 | |||
| 1498 | #. *Create a Copy of the Kernel Recipe:* Copy the | ||
| 1499 | ``linux-yocto-custom.bb`` recipe to your layer and give it a | ||
| 1500 | meaningful name. The name should include the version of the Yocto | ||
| 1501 | Linux kernel you are using (e.g. ``linux-yocto-myproject_4.12.bb``, | ||
| 1502 | where "4.12" is the base version of the Linux kernel with which you | ||
| 1503 | would be working). | ||
| 1504 | |||
| 1505 | #. *Create a Directory for Your Patches:* In the same directory inside | ||
| 1506 | your layer, create a matching directory to store your patches and | ||
| 1507 | configuration files (e.g. ``linux-yocto-myproject``). | ||
| 1508 | |||
| 1509 | #. *Ensure You Have Configurations:* Make sure you have either a | ||
| 1510 | ``defconfig`` file or configuration fragment files in your layer. | ||
| 1511 | When you use the ``linux-yocto-custom.bb`` recipe, you must specify a | ||
| 1512 | configuration. If you do not have a ``defconfig`` file, you can run | ||
| 1513 | the following:: | ||
| 1514 | |||
| 1515 | $ make defconfig | ||
| 1516 | |||
| 1517 | After running the command, copy the | ||
| 1518 | resulting ``.config`` file to the ``files`` directory in your layer | ||
| 1519 | as "defconfig" and then add it to the | ||
| 1520 | :term:`SRC_URI` variable in the | ||
| 1521 | recipe. | ||
| 1522 | |||
| 1523 | Running the ``make defconfig`` command results in the default | ||
| 1524 | configuration for your architecture as defined by your kernel. | ||
| 1525 | However, there is no guarantee that this configuration is valid for | ||
| 1526 | your use case, or that your board will even boot. This is | ||
| 1527 | particularly true for non-x86 architectures. | ||
| 1528 | |||
| 1529 | To use non-x86 ``defconfig`` files, you need to be more specific and | ||
| 1530 | find one that matches your board (i.e. for arm, you look in | ||
| 1531 | ``arch/arm/configs`` and use the one that is the best starting point | ||
| 1532 | for your board). | ||
| 1533 | |||
| 1534 | #. *Edit the Recipe:* Edit the following variables in your recipe as | ||
| 1535 | appropriate for your project: | ||
| 1536 | |||
| 1537 | - :term:`SRC_URI`: The | ||
| 1538 | :term:`SRC_URI` should specify a Git repository that uses one of the | ||
| 1539 | supported Git fetcher protocols (i.e. ``file``, ``git``, ``http``, | ||
| 1540 | and so forth). The :term:`SRC_URI` variable should also specify either | ||
| 1541 | a ``defconfig`` file or some configuration fragment files. The | ||
| 1542 | skeleton recipe provides an example :term:`SRC_URI` as a syntax | ||
| 1543 | reference. | ||
| 1544 | |||
| 1545 | - :term:`LINUX_VERSION`: | ||
| 1546 | The Linux kernel version you are using (e.g. "4.12"). | ||
| 1547 | |||
| 1548 | - :term:`LINUX_VERSION_EXTENSION`: | ||
| 1549 | The Linux kernel ``CONFIG_LOCALVERSION`` that is compiled into the | ||
| 1550 | resulting kernel and visible through the ``uname`` command. | ||
| 1551 | |||
| 1552 | - :term:`SRCREV`: The commit ID | ||
| 1553 | from which you want to build. | ||
| 1554 | |||
| 1555 | - :term:`PR`: Treat this variable the | ||
| 1556 | same as you would in any other recipe. Increment the variable to | ||
| 1557 | indicate to the OpenEmbedded build system that the recipe has | ||
| 1558 | changed. | ||
| 1559 | |||
| 1560 | - :term:`PV`: The default :term:`PV` | ||
| 1561 | assignment is typically adequate. It combines the value of | ||
| 1562 | :term:`LINUX_VERSION` and the value ``+git`` which adds source control | ||
| 1563 | information to :term:`PKGV` later during the packaging phase. | ||
| 1564 | |||
| 1565 | - :term:`COMPATIBLE_MACHINE`: | ||
| 1566 | A list of the machines supported by your new recipe. This variable | ||
| 1567 | in the example recipe is set by default to a regular expression | ||
| 1568 | that matches only the empty string, "(^$)". This default setting | ||
| 1569 | triggers an explicit build failure. You must change it to match a | ||
| 1570 | list of the machines that your new recipe supports. For example, | ||
| 1571 | to support the ``qemux86`` and ``qemux86-64`` machines, use the | ||
| 1572 | following form:: | ||
| 1573 | |||
| 1574 | COMPATIBLE_MACHINE = "qemux86|qemux86-64" | ||
| 1575 | |||
| 1576 | #. *Customize Your Recipe as Needed:* Provide further customizations to | ||
| 1577 | your recipe as needed just as you would customize an existing | ||
| 1578 | linux-yocto recipe. See the | ||
| 1579 | ":ref:`ref-manual/devtool-reference:modifying an existing recipe`" section | ||
| 1580 | for information. | ||
| 1581 | |||
| 1582 | Working with Out-of-Tree Modules | ||
| 1583 | ================================ | ||
| 1584 | |||
| 1585 | This section describes steps to build out-of-tree modules on your target | ||
| 1586 | and describes how to incorporate out-of-tree modules in the build. | ||
| 1587 | |||
| 1588 | Building Out-of-Tree Modules on the Target | ||
| 1589 | ------------------------------------------ | ||
| 1590 | |||
| 1591 | While the traditional Yocto Project development model would be to | ||
| 1592 | include kernel modules as part of the normal build process, you might | ||
| 1593 | find it useful to build modules on the target. This could be the case if | ||
| 1594 | your target system is capable and powerful enough to handle the | ||
| 1595 | necessary compilation. Before deciding to build on your target, however, | ||
| 1596 | you should consider the benefits of using a proper cross-development | ||
| 1597 | environment from your build host. | ||
| 1598 | |||
| 1599 | If you want to be able to build out-of-tree modules on the target, there | ||
| 1600 | are some steps you need to take on the target that is running your SDK | ||
| 1601 | image. Briefly, the ``kernel-dev`` package is installed by default on | ||
| 1602 | all ``*.sdk`` images and the ``kernel-devsrc`` package is installed on | ||
| 1603 | many of the ``*.sdk`` images. However, you need to create some scripts | ||
| 1604 | prior to attempting to build the out-of-tree modules on the target that | ||
| 1605 | is running that image. | ||
| 1606 | |||
| 1607 | Prior to attempting to build the out-of-tree modules, you need to be on | ||
| 1608 | the target as root and you need to change to the ``/usr/src/kernel`` | ||
| 1609 | directory. Next, ``make`` the scripts: | ||
| 1610 | |||
| 1611 | .. code-block:: none | ||
| 1612 | |||
| 1613 | # cd /usr/src/kernel | ||
| 1614 | # make scripts | ||
| 1615 | |||
| 1616 | Because all SDK image recipes include ``dev-pkgs``, the | ||
| 1617 | ``kernel-dev`` packages will be installed as part of the SDK image and | ||
| 1618 | the ``kernel-devsrc`` packages will be installed as part of applicable | ||
| 1619 | SDK images. The SDK uses the scripts when building out-of-tree modules. | ||
| 1620 | Once you have switched to that directory and created the scripts, you | ||
| 1621 | should be able to build your out-of-tree modules on the target. | ||
| 1622 | |||
| 1623 | Incorporating Out-of-Tree Modules | ||
| 1624 | --------------------------------- | ||
| 1625 | |||
| 1626 | While it is always preferable to work with sources integrated into the | ||
| 1627 | Linux kernel sources, if you need an external kernel module, the | ||
| 1628 | ``hello-mod.bb`` recipe is available as a template from which you can | ||
| 1629 | create your own out-of-tree Linux kernel module recipe. | ||
| 1630 | |||
| 1631 | This template recipe is located in the ``poky`` Git repository of the | ||
| 1632 | Yocto Project: | ||
| 1633 | :yocto_git:`meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb | ||
| 1634 | </poky/tree/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb>`. | ||
| 1635 | |||
| 1636 | To get started, copy this recipe to your layer and give it a meaningful | ||
| 1637 | name (e.g. ``mymodule_1.0.bb``). In the same directory, create a new | ||
| 1638 | directory named ``files`` where you can store any source files, patches, | ||
| 1639 | or other files necessary for building the module that do not come with | ||
| 1640 | the sources. Finally, update the recipe as needed for the module. | ||
| 1641 | Typically, you will need to set the following variables: | ||
| 1642 | |||
| 1643 | - :term:`DESCRIPTION` | ||
| 1644 | |||
| 1645 | - :term:`LICENSE* <LICENSE>` | ||
| 1646 | |||
| 1647 | - :term:`SRC_URI` | ||
| 1648 | |||
| 1649 | - :term:`PV` | ||
| 1650 | |||
| 1651 | Depending on the build system used by the module sources, you might need | ||
| 1652 | to make some adjustments. For example, a typical module ``Makefile`` | ||
| 1653 | looks much like the one provided with the ``hello-mod`` template:: | ||
| 1654 | |||
| 1655 | obj-m := hello.o | ||
| 1656 | |||
| 1657 | SRC := $(shell pwd) | ||
| 1658 | |||
| 1659 | all: | ||
| 1660 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) | ||
| 1661 | |||
| 1662 | modules_install: | ||
| 1663 | $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install | ||
| 1664 | ... | ||
| 1665 | |||
| 1666 | The important point to note here is the :term:`KERNEL_SRC` variable. The | ||
| 1667 | :ref:`ref-classes-module` class sets this variable and the :term:`KERNEL_PATH` | ||
| 1668 | variable to ``${STAGING_KERNEL_DIR}`` with the necessary Linux kernel build | ||
| 1669 | information to build modules. If your module ``Makefile`` uses a different | ||
| 1670 | variable, you might want to override the :ref:`ref-tasks-compile` step, or | ||
| 1671 | create a patch to the ``Makefile`` to work with the more typical | ||
| 1672 | :term:`KERNEL_SRC` or :term:`KERNEL_PATH` variables. | ||
| 1673 | |||
| 1674 | After you have prepared your recipe, you will likely want to include the | ||
| 1675 | module in your images. To do this, see the documentation for the | ||
| 1676 | following variables in the Yocto Project Reference Manual and set one of | ||
| 1677 | them appropriately for your machine configuration file: | ||
| 1678 | |||
| 1679 | - :term:`MACHINE_ESSENTIAL_EXTRA_RDEPENDS` | ||
| 1680 | |||
| 1681 | - :term:`MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS` | ||
| 1682 | |||
| 1683 | - :term:`MACHINE_EXTRA_RDEPENDS` | ||
| 1684 | |||
| 1685 | - :term:`MACHINE_EXTRA_RRECOMMENDS` | ||
| 1686 | |||
| 1687 | Modules are often not required for boot and can be excluded from certain | ||
| 1688 | build configurations. The following allows for the most flexibility:: | ||
| 1689 | |||
| 1690 | MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" | ||
| 1691 | |||
| 1692 | The value is | ||
| 1693 | derived by appending the module filename without the ``.ko`` extension | ||
| 1694 | to the string "kernel-module-". | ||
| 1695 | |||
| 1696 | Because the variable is | ||
| 1697 | :term:`RRECOMMENDS` and not a | ||
| 1698 | :term:`RDEPENDS` variable, the build | ||
| 1699 | will not fail if this module is not available to include in the image. | ||
| 1700 | |||
| 1701 | Inspecting Changes and Commits | ||
| 1702 | ============================== | ||
| 1703 | |||
| 1704 | A common question when working with a kernel is: "What changes have been | ||
| 1705 | applied to this tree?" Rather than using "grep" across directories to | ||
| 1706 | see what has changed, you can use Git to inspect or search the kernel | ||
| 1707 | tree. Using Git is an efficient way to see what has changed in the tree. | ||
| 1708 | |||
| 1709 | What Changed in a Kernel? | ||
| 1710 | ------------------------- | ||
| 1711 | |||
| 1712 | Here are a few examples that show how to use Git commands to | ||
| 1713 | examine changes. These examples are by no means the only way to see | ||
| 1714 | changes. | ||
| 1715 | |||
| 1716 | .. note:: | ||
| 1717 | |||
| 1718 | In the following examples, unless you provide a commit range, ``kernel.org`` | ||
| 1719 | history is blended with Yocto Project kernel changes. You can form | ||
| 1720 | ranges by using branch names from the kernel tree as the upper and | ||
| 1721 | lower commit markers with the Git commands. You can see the branch | ||
| 1722 | names through the web interface to the Yocto Project source | ||
| 1723 | repositories at :yocto_git:`/`. | ||
| 1724 | |||
| 1725 | To see a full range of the changes, use the ``git whatchanged`` command | ||
| 1726 | and specify a commit range for the branch (`commit`\ ``..``\ `commit`). | ||
| 1727 | |||
| 1728 | Here is an example that looks at what has changed in the ``emenlow`` | ||
| 1729 | branch of the ``linux-yocto-3.19`` kernel. The lower commit range is the | ||
| 1730 | commit associated with the ``standard/base`` branch, while the upper | ||
| 1731 | commit range is the commit associated with the ``standard/emenlow`` | ||
| 1732 | branch:: | ||
| 1733 | |||
| 1734 | $ git whatchanged origin/standard/base..origin/standard/emenlow | ||
| 1735 | |||
| 1736 | To see short, one line summaries of changes use the ``git log`` command:: | ||
| 1737 | |||
| 1738 | $ git log --oneline origin/standard/base..origin/standard/emenlow | ||
| 1739 | |||
| 1740 | Use this command to see code differences for the changes:: | ||
| 1741 | |||
| 1742 | $ git diff origin/standard/base..origin/standard/emenlow | ||
| 1743 | |||
| 1744 | Use this command to see the commit log messages and the text | ||
| 1745 | differences:: | ||
| 1746 | |||
| 1747 | $ git show origin/standard/base..origin/standard/emenlow | ||
| 1748 | |||
| 1749 | Use this command to create individual patches for each change. Here is | ||
| 1750 | an example that creates patch files for each commit and places them | ||
| 1751 | in your ``Documents`` directory:: | ||
| 1752 | |||
| 1753 | $ git format-patch -o $HOME/Documents origin/standard/base..origin/standard/emenlow | ||
| 1754 | |||
| 1755 | Showing a Particular Feature or Branch Change | ||
| 1756 | --------------------------------------------- | ||
| 1757 | |||
| 1758 | Tags in the Yocto Project kernel tree divide changes for significant | ||
| 1759 | features or branches. The ``git show``Â tag command shows changes based | ||
| 1760 | on a tag. Here is an example that shows ``systemtap`` changes:: | ||
| 1761 | |||
| 1762 | $ git show systemtap | ||
| 1763 | |||
| 1764 | You can use the ``git branch --contains``Â tag command to | ||
| 1765 | show the branches that contain a particular feature. This command shows | ||
| 1766 | the branches that contain the ``systemtap`` feature:: | ||
| 1767 | |||
| 1768 | $ git branch --contains systemtap | ||
| 1769 | |||
| 1770 | Adding Recipe-Space Kernel Features | ||
| 1771 | =================================== | ||
| 1772 | |||
| 1773 | You can add kernel features in the | ||
| 1774 | :ref:`recipe-space <kernel-dev/advanced:recipe-space metadata>` | ||
| 1775 | by using the :term:`KERNEL_FEATURES` | ||
| 1776 | variable and by specifying the feature's ``.scc`` file path in the | ||
| 1777 | :term:`SRC_URI` statement. When you | ||
| 1778 | add features using this method, the OpenEmbedded build system checks to | ||
| 1779 | be sure the features are present. If the features are not present, the | ||
| 1780 | build stops. Kernel features are the last elements processed for | ||
| 1781 | configuring and patching the kernel. Therefore, adding features in this | ||
| 1782 | manner is a way to enforce specific features are present and enabled | ||
| 1783 | without needing to do a full audit of any other layer's additions to the | ||
| 1784 | :term:`SRC_URI` statement. | ||
| 1785 | |||
| 1786 | You add a kernel feature by providing the feature as part of the | ||
| 1787 | :term:`KERNEL_FEATURES` variable and by providing the path to the feature's | ||
| 1788 | ``.scc`` file, which is relative to the root of the kernel Metadata. The | ||
| 1789 | OpenEmbedded build system searches all forms of kernel Metadata on the | ||
| 1790 | :term:`SRC_URI` statement regardless of whether the Metadata is in the | ||
| 1791 | "kernel-cache", system kernel Metadata, or a recipe-space Metadata (i.e. | ||
| 1792 | part of the kernel recipe). See the | ||
| 1793 | ":ref:`kernel-dev/advanced:kernel metadata location`" section for | ||
| 1794 | additional information. | ||
| 1795 | |||
| 1796 | When you specify the feature's ``.scc`` file on the :term:`SRC_URI` | ||
| 1797 | statement, the OpenEmbedded build system adds the directory of that | ||
| 1798 | ``.scc`` file along with all its subdirectories to the kernel feature | ||
| 1799 | search path. Because subdirectories are searched, you can reference a | ||
| 1800 | single ``.scc`` file in the :term:`SRC_URI` statement to reference multiple | ||
| 1801 | kernel features. | ||
| 1802 | |||
| 1803 | Consider the following example that adds the "test.scc" feature to the | ||
| 1804 | build. | ||
| 1805 | |||
| 1806 | #. *Create the Feature File:* Create a ``.scc`` file and locate it just | ||
| 1807 | as you would any other patch file, ``.cfg`` file, or fetcher item you | ||
| 1808 | specify in the :term:`SRC_URI` statement. | ||
| 1809 | |||
| 1810 | .. note:: | ||
| 1811 | |||
| 1812 | - You must add the directory of the ``.scc`` file to the | ||
| 1813 | fetcher's search path in the same manner as you would add a | ||
| 1814 | ``.patch`` file. | ||
| 1815 | |||
| 1816 | - You can create additional ``.scc`` files beneath the directory | ||
| 1817 | that contains the file you are adding. All subdirectories are | ||
| 1818 | searched during the build as potential feature directories. | ||
| 1819 | |||
| 1820 | Continuing with the example, suppose the "test.scc" feature you are | ||
| 1821 | adding has a ``test.scc`` file in the following directory:: | ||
| 1822 | |||
| 1823 | my_recipe | ||
| 1824 | | | ||
| 1825 | +-linux-yocto | ||
| 1826 | | | ||
| 1827 | +-test.cfg | ||
| 1828 | +-test.scc | ||
| 1829 | |||
| 1830 | In this example, the | ||
| 1831 | ``linux-yocto`` directory has both the feature ``test.scc`` file and | ||
| 1832 | a similarly named configuration fragment file ``test.cfg``. | ||
| 1833 | |||
| 1834 | #. *Add the Feature File to SRC_URI:* Add the ``.scc`` file to the | ||
| 1835 | recipe's :term:`SRC_URI` statement:: | ||
| 1836 | |||
| 1837 | SRC_URI += "file://test.scc" | ||
| 1838 | |||
| 1839 | The leading space before the path is important as the path is | ||
| 1840 | appended to the existing path. | ||
| 1841 | |||
| 1842 | #. *Specify the Feature as a Kernel Feature:* Use the | ||
| 1843 | :term:`KERNEL_FEATURES` statement to specify the feature as a kernel | ||
| 1844 | feature:: | ||
| 1845 | |||
| 1846 | KERNEL_FEATURES += "test.scc" | ||
| 1847 | |||
| 1848 | The OpenEmbedded build | ||
| 1849 | system processes the kernel feature when it builds the kernel. | ||
| 1850 | |||
| 1851 | .. note:: | ||
| 1852 | |||
| 1853 | If other features are contained below "test.scc", then their | ||
| 1854 | directories are relative to the directory containing the ``test.scc`` | ||
| 1855 | file. | ||
diff --git a/documentation/kernel-dev/concepts-appx.rst b/documentation/kernel-dev/concepts-appx.rst deleted file mode 100644 index 6a2fe4bb0b..0000000000 --- a/documentation/kernel-dev/concepts-appx.rst +++ /dev/null | |||
| @@ -1,420 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ************************ | ||
| 4 | Advanced Kernel Concepts | ||
| 5 | ************************ | ||
| 6 | |||
| 7 | Yocto Project Kernel Development and Maintenance | ||
| 8 | ================================================ | ||
| 9 | |||
| 10 | Kernels available through the Yocto Project (Yocto Linux kernels), like | ||
| 11 | other kernels, are based off the Linux kernel releases from | ||
| 12 | https://www.kernel.org. At the beginning of a major Linux kernel | ||
| 13 | development cycle, the Yocto Project team chooses a Linux kernel based | ||
| 14 | on factors such as release timing, the anticipated release timing of | ||
| 15 | final upstream ``kernel.org`` versions, and Yocto Project feature | ||
| 16 | requirements. Typically, the Linux kernel chosen is in the final stages | ||
| 17 | of development by the Linux community. In other words, the Linux kernel | ||
| 18 | is in the release candidate or "rc" phase and has yet to reach final | ||
| 19 | release. But, by being in the final stages of external development, the | ||
| 20 | team knows that the ``kernel.org`` final release will clearly be within | ||
| 21 | the early stages of the Yocto Project development window. | ||
| 22 | |||
| 23 | This balance allows the Yocto Project team to deliver the most | ||
| 24 | up-to-date Yocto Linux kernel possible, while still ensuring that the | ||
| 25 | team has a stable official release for the baseline Linux kernel | ||
| 26 | version. | ||
| 27 | |||
| 28 | As implied earlier, the ultimate source for Yocto Linux kernels are | ||
| 29 | released kernels from ``kernel.org``. In addition to a foundational | ||
| 30 | kernel from ``kernel.org``, the available Yocto Linux kernels contain a | ||
| 31 | mix of important new mainline developments, non-mainline developments | ||
| 32 | (when no alternative exists), Board Support Package (BSP) developments, | ||
| 33 | and custom features. These additions result in a commercially released | ||
| 34 | Yocto Project Linux kernel that caters to specific embedded designer | ||
| 35 | needs for targeted hardware. | ||
| 36 | |||
| 37 | You can find a web interface to the Yocto Linux kernels in the | ||
| 38 | :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 39 | at :yocto_git:`/`. If you look at the interface, you will see to | ||
| 40 | the left a grouping of Git repositories titled "Yocto Linux Kernel". | ||
| 41 | Within this group, you will find several Linux Yocto kernels developed | ||
| 42 | and included with Yocto Project releases: | ||
| 43 | |||
| 44 | - *linux-yocto-4.1:* The stable Yocto Project kernel to use with | ||
| 45 | the Yocto Project Release 2.0. This kernel is based on the Linux 4.1 | ||
| 46 | released kernel. | ||
| 47 | |||
| 48 | - *linux-yocto-4.4:* The stable Yocto Project kernel to use with | ||
| 49 | the Yocto Project Release 2.1. This kernel is based on the Linux 4.4 | ||
| 50 | released kernel. | ||
| 51 | |||
| 52 | - *linux-yocto-4.6:* A temporary kernel that is not tied to any | ||
| 53 | Yocto Project release. | ||
| 54 | |||
| 55 | - *linux-yocto-4.8:* The stable yocto Project kernel to use with | ||
| 56 | the Yocto Project Release 2.2. | ||
| 57 | |||
| 58 | - *linux-yocto-4.9:* The stable Yocto Project kernel to use with | ||
| 59 | the Yocto Project Release 2.3. This kernel is based on the Linux 4.9 | ||
| 60 | released kernel. | ||
| 61 | |||
| 62 | - *linux-yocto-4.10:* The default stable Yocto Project kernel to | ||
| 63 | use with the Yocto Project Release 2.3. This kernel is based on the | ||
| 64 | Linux 4.10 released kernel. | ||
| 65 | |||
| 66 | - *linux-yocto-4.12:* The default stable Yocto Project kernel to | ||
| 67 | use with the Yocto Project Release 2.4. This kernel is based on the | ||
| 68 | Linux 4.12 released kernel. | ||
| 69 | |||
| 70 | - *yocto-kernel-cache:* The ``linux-yocto-cache`` contains patches | ||
| 71 | and configurations for the linux-yocto kernel tree. This repository | ||
| 72 | is useful when working on the linux-yocto kernel. For more | ||
| 73 | information on this "Advanced Kernel Metadata", see the | ||
| 74 | ":doc:`/kernel-dev/advanced`" Chapter. | ||
| 75 | |||
| 76 | - *linux-yocto-dev:* A development kernel based on the latest | ||
| 77 | upstream release candidate available. | ||
| 78 | |||
| 79 | .. note:: | ||
| 80 | |||
| 81 | Long Term Support Initiative (LTSI) for Yocto Linux kernels is as | ||
| 82 | follows: | ||
| 83 | |||
| 84 | - For Yocto Project releases 1.7, 1.8, and 2.0, the LTSI kernel is | ||
| 85 | ``linux-yocto-3.14``. | ||
| 86 | |||
| 87 | - For Yocto Project releases 2.1, 2.2, and 2.3, the LTSI kernel is | ||
| 88 | ``linux-yocto-4.1``. | ||
| 89 | |||
| 90 | - For Yocto Project release 2.4, the LTSI kernel is | ||
| 91 | ``linux-yocto-4.9`` | ||
| 92 | |||
| 93 | - ``linux-yocto-4.4`` is an LTS kernel. | ||
| 94 | |||
| 95 | Once a Yocto Linux kernel is officially released, the Yocto Project team | ||
| 96 | goes into their next development cycle, or upward revision (uprev) | ||
| 97 | cycle, while still continuing maintenance on the released kernel. It is | ||
| 98 | important to note that the most sustainable and stable way to include | ||
| 99 | feature development upstream is through a kernel uprev process. | ||
| 100 | Back-porting hundreds of individual fixes and minor features from | ||
| 101 | various kernel versions is not sustainable and can easily compromise | ||
| 102 | quality. | ||
| 103 | |||
| 104 | During the uprev cycle, the Yocto Project team uses an ongoing analysis | ||
| 105 | of Linux kernel development, BSP support, and release timing to select | ||
| 106 | the best possible ``kernel.org`` Linux kernel version on which to base | ||
| 107 | subsequent Yocto Linux kernel development. The team continually monitors | ||
| 108 | Linux community kernel development to look for significant features of | ||
| 109 | interest. The team does consider back-porting large features if they | ||
| 110 | have a significant advantage. User or community demand can also trigger | ||
| 111 | a back-port or creation of new functionality in the Yocto Project | ||
| 112 | baseline kernel during the uprev cycle. | ||
| 113 | |||
| 114 | Generally speaking, every new Linux kernel both adds features and | ||
| 115 | introduces new bugs. These consequences are the basic properties of | ||
| 116 | upstream Linux kernel development and are managed by the Yocto Project | ||
| 117 | team's Yocto Linux kernel development strategy. It is the Yocto Project | ||
| 118 | team's policy to not back-port minor features to the released Yocto | ||
| 119 | Linux kernel. They only consider back-porting significant technological | ||
| 120 | jumps --- and, that is done after a complete gap analysis. The reason | ||
| 121 | for this policy is that back-porting any small to medium sized change | ||
| 122 | from an evolving Linux kernel can easily create mismatches, | ||
| 123 | incompatibilities and very subtle errors. | ||
| 124 | |||
| 125 | The policies described in this section result in both a stable and a | ||
| 126 | cutting edge Yocto Linux kernel that mixes forward ports of existing | ||
| 127 | Linux kernel features and significant and critical new functionality. | ||
| 128 | Forward porting Linux kernel functionality into the Yocto Linux kernels | ||
| 129 | available through the Yocto Project can be thought of as a "micro | ||
| 130 | uprev". The many "micro uprevs" produce a Yocto Linux kernel version | ||
| 131 | with a mix of important new mainline, non-mainline, BSP developments and | ||
| 132 | feature integrations. This Yocto Linux kernel gives insight into new | ||
| 133 | features and allows focused amounts of testing to be done on the kernel, | ||
| 134 | which prevents surprises when selecting the next major uprev. The | ||
| 135 | quality of these cutting edge Yocto Linux kernels is evolving and the | ||
| 136 | kernels are used in leading edge feature and BSP development. | ||
| 137 | |||
| 138 | Yocto Linux Kernel Architecture and Branching Strategies | ||
| 139 | ======================================================== | ||
| 140 | |||
| 141 | As mentioned earlier, a key goal of the Yocto Project is to present the | ||
| 142 | developer with a kernel that has a clear and continuous history that is | ||
| 143 | visible to the user. The architecture and mechanisms, in particular the | ||
| 144 | branching strategies, used achieve that goal in a manner similar to | ||
| 145 | upstream Linux kernel development in ``kernel.org``. | ||
| 146 | |||
| 147 | You can think of a Yocto Linux kernel as consisting of a baseline Linux | ||
| 148 | kernel with added features logically structured on top of the baseline. | ||
| 149 | The features are tagged and organized by way of a branching strategy | ||
| 150 | implemented by the Yocto Project team using the Source Code Manager | ||
| 151 | (SCM) Git. | ||
| 152 | |||
| 153 | .. note:: | ||
| 154 | |||
| 155 | - Git is the obvious SCM for meeting the Yocto Linux kernel | ||
| 156 | organizational and structural goals described in this section. Not | ||
| 157 | only is Git the SCM for Linux kernel development in ``kernel.org`` | ||
| 158 | but, Git continues to grow in popularity and supports many | ||
| 159 | different work flows, front-ends and management techniques. | ||
| 160 | |||
| 161 | - You can find documentation on Git at https://git-scm.com/doc. You can | ||
| 162 | also get an introduction to Git as it applies to the Yocto Project in the | ||
| 163 | ":ref:`overview-manual/development-environment:git`" section in the Yocto Project | ||
| 164 | Overview and Concepts Manual. The latter reference provides an | ||
| 165 | overview of Git and presents a minimal set of Git commands that | ||
| 166 | allows you to be functional using Git. You can use as much, or as | ||
| 167 | little, of what Git has to offer to accomplish what you need for | ||
| 168 | your project. You do not have to be a "Git Expert" in order to use | ||
| 169 | it with the Yocto Project. | ||
| 170 | |||
| 171 | Using Git's tagging and branching features, the Yocto Project team | ||
| 172 | creates kernel branches at points where functionality is no longer | ||
| 173 | shared and thus, needs to be isolated. For example, board-specific | ||
| 174 | incompatibilities would require different functionality and would | ||
| 175 | require a branch to separate the features. Likewise, for specific kernel | ||
| 176 | features, the same branching strategy is used. | ||
| 177 | |||
| 178 | This "tree-like" architecture results in a structure that has features | ||
| 179 | organized to be specific for particular functionality, single kernel | ||
| 180 | types, or a subset of kernel types. Thus, the user has the ability to | ||
| 181 | see the added features and the commits that make up those features. In | ||
| 182 | addition to being able to see added features, the user can also view the | ||
| 183 | history of what made up the baseline Linux kernel. | ||
| 184 | |||
| 185 | Another consequence of this strategy results in not having to store the | ||
| 186 | same feature twice internally in the tree. Rather, the kernel team | ||
| 187 | stores the unique differences required to apply the feature onto the | ||
| 188 | kernel type in question. | ||
| 189 | |||
| 190 | .. note:: | ||
| 191 | |||
| 192 | The Yocto Project team strives to place features in the tree such | ||
| 193 | that features can be shared by all boards and kernel types where | ||
| 194 | possible. However, during development cycles or when large features | ||
| 195 | are merged, the team cannot always follow this practice. In those | ||
| 196 | cases, the team uses isolated branches to merge features. | ||
| 197 | |||
| 198 | BSP-specific code additions are handled in a similar manner to | ||
| 199 | kernel-specific additions. Some BSPs only make sense given certain | ||
| 200 | kernel types. So, for these types, the team creates branches off the end | ||
| 201 | of that kernel type for all of the BSPs that are supported on that | ||
| 202 | kernel type. From the perspective of the tools that create the BSP | ||
| 203 | branch, the BSP is really no different than a feature. Consequently, the | ||
| 204 | same branching strategy applies to BSPs as it does to kernel features. | ||
| 205 | So again, rather than store the BSP twice, the team only stores the | ||
| 206 | unique differences for the BSP across the supported multiple kernels. | ||
| 207 | |||
| 208 | While this strategy can result in a tree with a significant number of | ||
| 209 | branches, it is important to realize that from the developer's point of | ||
| 210 | view, there is a linear path that travels from the baseline | ||
| 211 | ``kernel.org``, through a select group of features and ends with their | ||
| 212 | BSP-specific commits. In other words, the divisions of the kernel are | ||
| 213 | transparent and are not relevant to the developer on a day-to-day basis. | ||
| 214 | From the developer's perspective, this path is the development branch. | ||
| 215 | The developer does not need to be aware of the existence of | ||
| 216 | any other branches at all. Of course, it can make sense to have these | ||
| 217 | branches in the tree, should a person decide to explore them. For | ||
| 218 | example, a comparison between two BSPs at either the commit level or at | ||
| 219 | the line-by-line code ``diff`` level is now a trivial operation. | ||
| 220 | |||
| 221 | The following illustration shows the conceptual Yocto Linux kernel. | ||
| 222 | |||
| 223 | .. image:: figures/kernel-architecture-overview.png | ||
| 224 | :width: 100% | ||
| 225 | |||
| 226 | In the illustration, the "Kernel.org Branch Point" marks the specific | ||
| 227 | spot (or Linux kernel release) from which the Yocto Linux kernel is | ||
| 228 | created. From this point forward in the tree, features and differences | ||
| 229 | are organized and tagged. | ||
| 230 | |||
| 231 | The "Yocto Project Baseline Kernel" contains functionality that is | ||
| 232 | common to every kernel type and BSP that is organized further along in | ||
| 233 | the tree. Placing these common features in the tree this way means | ||
| 234 | features do not have to be duplicated along individual branches of the | ||
| 235 | tree structure. | ||
| 236 | |||
| 237 | From the "Yocto Project Baseline Kernel", branch points represent | ||
| 238 | specific functionality for individual Board Support Packages (BSPs) as | ||
| 239 | well as real-time kernels. The illustration represents this through | ||
| 240 | three BSP-specific branches and a real-time kernel branch. Each branch | ||
| 241 | represents some unique functionality for the BSP or for a real-time | ||
| 242 | Yocto Linux kernel. | ||
| 243 | |||
| 244 | In this example structure, the "Real-time (rt) Kernel" branch has common | ||
| 245 | features for all real-time Yocto Linux kernels and contains more | ||
| 246 | branches for individual BSP-specific real-time kernels. The illustration | ||
| 247 | shows three branches as an example. Each branch points the way to | ||
| 248 | specific, unique features for a respective real-time kernel as they | ||
| 249 | apply to a given BSP. | ||
| 250 | |||
| 251 | The resulting tree structure presents a clear path of markers (or | ||
| 252 | branches) to the developer that, for all practical purposes, is the | ||
| 253 | Yocto Linux kernel needed for any given set of requirements. | ||
| 254 | |||
| 255 | .. note:: | ||
| 256 | |||
| 257 | Keep in mind the figure does not take into account all the supported | ||
| 258 | Yocto Linux kernels, but rather shows a single generic kernel just | ||
| 259 | for conceptual purposes. Also keep in mind that this structure | ||
| 260 | represents the | ||
| 261 | :ref:`overview-manual/development-environment:yocto project source repositories` | ||
| 262 | that are either pulled from during the build or established on the | ||
| 263 | host development system prior to the build by either cloning a | ||
| 264 | particular kernel's Git repository or by downloading and unpacking a | ||
| 265 | tarball. | ||
| 266 | |||
| 267 | Working with the kernel as a structured tree follows recognized | ||
| 268 | community best practices. In particular, the kernel as shipped with the | ||
| 269 | product, should be considered an "upstream source" and viewed as a | ||
| 270 | series of historical and documented modifications (commits). These | ||
| 271 | modifications represent the development and stabilization done by the | ||
| 272 | Yocto Project kernel development team. | ||
| 273 | |||
| 274 | Because commits only change at significant release points in the product | ||
| 275 | life cycle, developers can work on a branch created from the last | ||
| 276 | relevant commit in the shipped Yocto Project Linux kernel. As mentioned | ||
| 277 | previously, the structure is transparent to the developer because the | ||
| 278 | kernel tree is left in this state after cloning and building the kernel. | ||
| 279 | |||
| 280 | Kernel Build File Hierarchy | ||
| 281 | =========================== | ||
| 282 | |||
| 283 | Upstream storage of all the available kernel source code is one thing, | ||
| 284 | while representing and using the code on your host development system is | ||
| 285 | another. Conceptually, you can think of the kernel source repositories | ||
| 286 | as all the source files necessary for all the supported Yocto Linux | ||
| 287 | kernels. As a developer, you are just interested in the source files for | ||
| 288 | the kernel on which you are working. And, furthermore, you need them | ||
| 289 | available on your host system. | ||
| 290 | |||
| 291 | Kernel source code is available on your host system several different | ||
| 292 | ways: | ||
| 293 | |||
| 294 | - *Files Accessed While using devtool:* ``devtool``, which is | ||
| 295 | available with the Yocto Project, is the preferred method by which to | ||
| 296 | modify the kernel. See the ":ref:`kernel-dev/intro:kernel modification workflow`" section. | ||
| 297 | |||
| 298 | - *Cloned Repository:* If you are working in the kernel all the time, | ||
| 299 | you probably would want to set up your own local Git repository of | ||
| 300 | the Yocto Linux kernel tree. For information on how to clone a Yocto | ||
| 301 | Linux kernel Git repository, see the | ||
| 302 | ":ref:`kernel-dev/common:preparing the build host to work on the kernel`" | ||
| 303 | section. | ||
| 304 | |||
| 305 | - *Temporary Source Files from a Build:* If you just need to make some | ||
| 306 | patches to the kernel using a traditional BitBake workflow (i.e. not | ||
| 307 | using the ``devtool``), you can access temporary kernel source files | ||
| 308 | that were extracted and used during a kernel build. | ||
| 309 | |||
| 310 | The temporary kernel source files resulting from a build using BitBake | ||
| 311 | have a particular hierarchy. When you build the kernel on your | ||
| 312 | development system, all files needed for the build are taken from the | ||
| 313 | source repositories pointed to by the | ||
| 314 | :term:`SRC_URI` variable and gathered | ||
| 315 | in a temporary work area where they are subsequently used to create the | ||
| 316 | unique kernel. Thus, in a sense, the process constructs a local source | ||
| 317 | tree specific to your kernel from which to generate the new kernel | ||
| 318 | image. | ||
| 319 | |||
| 320 | The following figure shows the temporary file structure created on your | ||
| 321 | host system when you build the kernel using BitBake. This | ||
| 322 | :term:`Build Directory` contains all the source files used during the build. | ||
| 323 | |||
| 324 | .. image:: figures/kernel-overview-2-generic.png | ||
| 325 | :align: center | ||
| 326 | :width: 70% | ||
| 327 | |||
| 328 | Again, for additional information on the Yocto Project kernel's | ||
| 329 | architecture and its branching strategy, see the | ||
| 330 | ":ref:`kernel-dev/concepts-appx:yocto linux kernel architecture and branching strategies`" | ||
| 331 | section. You can also reference the | ||
| 332 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 333 | and | ||
| 334 | ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 335 | sections for detailed example that modifies the kernel. | ||
| 336 | |||
| 337 | Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase | ||
| 338 | ======================================================================================= | ||
| 339 | |||
| 340 | This section describes part of the kernel configuration audit phase that | ||
| 341 | most developers can ignore. For general information on kernel | ||
| 342 | configuration including ``menuconfig``, ``defconfig`` files, and | ||
| 343 | configuration fragments, see the | ||
| 344 | ":ref:`kernel-dev/common:configuring the kernel`" section. | ||
| 345 | |||
| 346 | During this part of the audit phase, the contents of the final | ||
| 347 | ``.config`` file are compared against the fragments specified by the | ||
| 348 | system. These fragments can be system fragments, distro fragments, or | ||
| 349 | user-specified configuration elements. Regardless of their origin, the | ||
| 350 | OpenEmbedded build system warns the user if a specific option is not | ||
| 351 | included in the final kernel configuration. | ||
| 352 | |||
| 353 | By default, in order to not overwhelm the user with configuration | ||
| 354 | warnings, the system only reports missing "hardware" options as they | ||
| 355 | could result in a boot failure or indicate that important hardware is | ||
| 356 | not available. | ||
| 357 | |||
| 358 | To determine whether or not a given option is "hardware" or | ||
| 359 | "non-hardware", the kernel Metadata in ``yocto-kernel-cache`` contains | ||
| 360 | files that classify individual or groups of options as either hardware | ||
| 361 | or non-hardware. To better show this, consider a situation where the | ||
| 362 | ``yocto-kernel-cache`` contains the following files:: | ||
| 363 | |||
| 364 | yocto-kernel-cache/features/drm-psb/hardware.cfg | ||
| 365 | yocto-kernel-cache/features/kgdb/hardware.cfg | ||
| 366 | yocto-kernel-cache/ktypes/base/hardware.cfg | ||
| 367 | yocto-kernel-cache/bsp/mti-malta32/hardware.cfg | ||
| 368 | yocto-kernel-cache/bsp/qemu-ppc32/hardware.cfg | ||
| 369 | yocto-kernel-cache/bsp/qemuarma9/hardware.cfg | ||
| 370 | yocto-kernel-cache/bsp/mti-malta64/hardware.cfg | ||
| 371 | yocto-kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg | ||
| 372 | yocto-kernel-cache/bsp/common-pc/hardware.cfg | ||
| 373 | yocto-kernel-cache/bsp/common-pc-64/hardware.cfg | ||
| 374 | yocto-kernel-cache/features/rfkill/non-hardware.cfg | ||
| 375 | yocto-kernel-cache/ktypes/base/non-hardware.cfg | ||
| 376 | yocto-kernel-cache/features/aufs/non-hardware.kcf | ||
| 377 | yocto-kernel-cache/features/ocf/non-hardware.kcf | ||
| 378 | yocto-kernel-cache/ktypes/base/non-hardware.kcf | ||
| 379 | yocto-kernel-cache/ktypes/base/hardware.kcf | ||
| 380 | yocto-kernel-cache/bsp/qemu-ppc32/hardware.kcf | ||
| 381 | |||
| 382 | Here are explanations for the various files: | ||
| 383 | |||
| 384 | - ``hardware.kcf``: Specifies a list of kernel Kconfig files that | ||
| 385 | contain hardware options only. | ||
| 386 | |||
| 387 | - ``non-hardware.kcf``: Specifies a list of kernel Kconfig files that | ||
| 388 | contain non-hardware options only. | ||
| 389 | |||
| 390 | - ``hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options that | ||
| 391 | are hardware, regardless of whether or not they are within a Kconfig | ||
| 392 | file specified by a hardware or non-hardware Kconfig file (i.e. | ||
| 393 | ``hardware.kcf`` or ``non-hardware.kcf``). | ||
| 394 | |||
| 395 | - ``non-hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options | ||
| 396 | that are not hardware, regardless of whether or not they are within a | ||
| 397 | Kconfig file specified by a hardware or non-hardware Kconfig file | ||
| 398 | (i.e. ``hardware.kcf`` or ``non-hardware.kcf``). | ||
| 399 | |||
| 400 | Here is a specific example using the | ||
| 401 | ``kernel-cache/bsp/mti-malta32/hardware.cfg``:: | ||
| 402 | |||
| 403 | CONFIG_SERIAL_8250 | ||
| 404 | CONFIG_SERIAL_8250_CONSOLE | ||
| 405 | CONFIG_SERIAL_8250_NR_UARTS | ||
| 406 | CONFIG_SERIAL_8250_PCI | ||
| 407 | CONFIG_SERIAL_CORE | ||
| 408 | CONFIG_SERIAL_CORE_CONSOLE | ||
| 409 | CONFIG_VGA_ARB | ||
| 410 | |||
| 411 | The kernel configuration audit automatically detects | ||
| 412 | these files (hence the names must be exactly the ones discussed here), | ||
| 413 | and uses them as inputs when generating warnings about the final | ||
| 414 | ``.config`` file. | ||
| 415 | |||
| 416 | A user-specified kernel Metadata repository, or recipe space feature, | ||
| 417 | can use these same files to classify options that are found within its | ||
| 418 | ``.cfg`` files as hardware or non-hardware, to prevent the OpenEmbedded | ||
| 419 | build system from producing an error or warning when an option is not in | ||
| 420 | the final ``.config`` file. | ||
diff --git a/documentation/kernel-dev/faq.rst b/documentation/kernel-dev/faq.rst deleted file mode 100644 index 4dffa90dbd..0000000000 --- a/documentation/kernel-dev/faq.rst +++ /dev/null | |||
| @@ -1,76 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ********************** | ||
| 4 | Kernel Development FAQ | ||
| 5 | ********************** | ||
| 6 | |||
| 7 | Common Questions and Solutions | ||
| 8 | ============================== | ||
| 9 | |||
| 10 | Here are some solutions for common questions. | ||
| 11 | |||
| 12 | How do I use my own Linux kernel ``.config`` file? | ||
| 13 | -------------------------------------------------- | ||
| 14 | |||
| 15 | Refer to the | ||
| 16 | ":ref:`kernel-dev/common:changing the configuration`" | ||
| 17 | section for information. | ||
| 18 | |||
| 19 | How do I create configuration fragments? | ||
| 20 | ---------------------------------------- | ||
| 21 | |||
| 22 | A: Refer to the | ||
| 23 | ":ref:`kernel-dev/common:creating configuration fragments`" | ||
| 24 | section for information. | ||
| 25 | |||
| 26 | How do I use my own Linux kernel sources? | ||
| 27 | ----------------------------------------- | ||
| 28 | |||
| 29 | Refer to the | ||
| 30 | ":ref:`kernel-dev/common:working with your own sources`" | ||
| 31 | section for information. | ||
| 32 | |||
| 33 | How do I install/not-install the kernel image on the root filesystem? | ||
| 34 | --------------------------------------------------------------------- | ||
| 35 | |||
| 36 | The kernel image (e.g. ``vmlinuz``) is provided by the | ||
| 37 | ``kernel-image`` package. Image recipes depend on ``kernel-base``. To | ||
| 38 | specify whether or not the kernel image is installed in the generated | ||
| 39 | root filesystem, override ``RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base`` to include or not | ||
| 40 | include "kernel-image". See the | ||
| 41 | ":ref:`dev-manual/layers:appending other layers metadata with your layer`" | ||
| 42 | section in the | ||
| 43 | Yocto Project Development Tasks Manual for information on how to use an | ||
| 44 | append file to override metadata. | ||
| 45 | |||
| 46 | How do I install a specific kernel module? | ||
| 47 | ------------------------------------------ | ||
| 48 | |||
| 49 | Linux kernel modules are packaged individually. To ensure a | ||
| 50 | specific kernel module is included in an image, include it in the | ||
| 51 | appropriate machine :term:`RRECOMMENDS` variable. | ||
| 52 | These other variables are useful for installing specific modules: | ||
| 53 | - :term:`MACHINE_ESSENTIAL_EXTRA_RDEPENDS` | ||
| 54 | - :term:`MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS` | ||
| 55 | - :term:`MACHINE_EXTRA_RDEPENDS` | ||
| 56 | - :term:`MACHINE_EXTRA_RRECOMMENDS` | ||
| 57 | |||
| 58 | For example, set the following in the ``qemux86.conf`` file to include | ||
| 59 | the ``ab123`` kernel modules with images built for the ``qemux86`` | ||
| 60 | machine:: | ||
| 61 | |||
| 62 | MACHINE_EXTRA_RRECOMMENDS += "kernel-module-ab123" | ||
| 63 | |||
| 64 | For more information, see the | ||
| 65 | ":ref:`kernel-dev/common:incorporating out-of-tree modules`" section. | ||
| 66 | |||
| 67 | How do I change the Linux kernel command line? | ||
| 68 | ---------------------------------------------- | ||
| 69 | |||
| 70 | The Linux kernel command line is | ||
| 71 | typically specified in the machine config using the :term:`APPEND` variable. | ||
| 72 | For example, you can add some helpful debug information doing the | ||
| 73 | following:: | ||
| 74 | |||
| 75 | APPEND += "printk.time=y initcall_debug debug" | ||
| 76 | |||
diff --git a/documentation/kernel-dev/figures/kernel-architecture-overview.png b/documentation/kernel-dev/figures/kernel-architecture-overview.png deleted file mode 100755 index 2aad172db3..0000000000 --- a/documentation/kernel-dev/figures/kernel-architecture-overview.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/kernel-dev/figures/kernel-dev-flow.png b/documentation/kernel-dev/figures/kernel-dev-flow.png deleted file mode 100644 index 793a395e8f..0000000000 --- a/documentation/kernel-dev/figures/kernel-dev-flow.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/kernel-dev/figures/kernel-dev-title.png b/documentation/kernel-dev/figures/kernel-dev-title.png deleted file mode 100644 index 7a8dd54372..0000000000 --- a/documentation/kernel-dev/figures/kernel-dev-title.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/kernel-dev/figures/kernel-overview-2-generic.png b/documentation/kernel-dev/figures/kernel-overview-2-generic.png deleted file mode 100644 index ee2cdb206b..0000000000 --- a/documentation/kernel-dev/figures/kernel-overview-2-generic.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/documentation/kernel-dev/index.rst b/documentation/kernel-dev/index.rst deleted file mode 100644 index bd20e371e0..0000000000 --- a/documentation/kernel-dev/index.rst +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ============================================= | ||
| 4 | Yocto Project Linux Kernel Development Manual | ||
| 5 | ============================================= | ||
| 6 | |||
| 7 | | | ||
| 8 | |||
| 9 | .. toctree:: | ||
| 10 | :caption: Table of Contents | ||
| 11 | :numbered: | ||
| 12 | |||
| 13 | intro | ||
| 14 | common | ||
| 15 | advanced | ||
| 16 | concepts-appx | ||
| 17 | maint-appx | ||
| 18 | faq | ||
| 19 | |||
| 20 | .. include:: /boilerplate.rst | ||
diff --git a/documentation/kernel-dev/intro.rst b/documentation/kernel-dev/intro.rst deleted file mode 100644 index 7df342f8d5..0000000000 --- a/documentation/kernel-dev/intro.rst +++ /dev/null | |||
| @@ -1,178 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ************ | ||
| 4 | Introduction | ||
| 5 | ************ | ||
| 6 | |||
| 7 | Overview | ||
| 8 | ======== | ||
| 9 | |||
| 10 | Regardless of how you intend to make use of the Yocto Project, chances | ||
| 11 | are you will work with the Linux kernel. This manual describes how to | ||
| 12 | set up your build host to support kernel development, introduces the | ||
| 13 | kernel development process, provides background information on the Yocto | ||
| 14 | Linux kernel :term:`Metadata`, describes | ||
| 15 | common tasks you can perform using the kernel tools, shows you how to | ||
| 16 | use the kernel Metadata needed to work with the kernel inside the Yocto | ||
| 17 | Project, and provides insight into how the Yocto Project team develops | ||
| 18 | and maintains Yocto Linux kernel Git repositories and Metadata. | ||
| 19 | |||
| 20 | Each Yocto Project release has a set of Yocto Linux kernel recipes, | ||
| 21 | whose Git repositories you can view in the Yocto | ||
| 22 | :yocto_git:`Source Repositories <>` under the "Yocto Linux Kernel" | ||
| 23 | heading. New recipes for the release track the latest Linux kernel | ||
| 24 | upstream developments from https://www.kernel.org and introduce | ||
| 25 | newly-supported platforms. Previous recipes in the release are refreshed | ||
| 26 | and supported for at least one additional Yocto Project release. As they | ||
| 27 | align, these previous releases are updated to include the latest from | ||
| 28 | the Long Term Support Initiative (LTSI) project. You can learn more | ||
| 29 | about Yocto Linux kernels and LTSI in the | ||
| 30 | ":ref:`kernel-dev/concepts-appx:yocto project kernel development and maintenance`" section. | ||
| 31 | |||
| 32 | Also included is a Yocto Linux kernel development recipe | ||
| 33 | (``linux-yocto-dev.bb``) should you want to work with the very latest in | ||
| 34 | upstream Yocto Linux kernel development and kernel Metadata development. | ||
| 35 | |||
| 36 | .. note:: | ||
| 37 | |||
| 38 | For more on Yocto Linux kernels, see the | ||
| 39 | ":ref:`kernel-dev/concepts-appx:yocto project kernel development and maintenance`" | ||
| 40 | section. | ||
| 41 | |||
| 42 | The Yocto Project also provides a powerful set of kernel tools for | ||
| 43 | managing Yocto Linux kernel sources and configuration data. You can use | ||
| 44 | these tools to make a single configuration change, apply multiple | ||
| 45 | patches, or work with your own kernel sources. | ||
| 46 | |||
| 47 | In particular, the kernel tools allow you to generate configuration | ||
| 48 | fragments that specify only what you must, and nothing more. | ||
| 49 | Configuration fragments only need to contain the highest level visible | ||
| 50 | ``CONFIG`` options as presented by the Yocto Linux kernel ``menuconfig`` | ||
| 51 | system. Contrast this against a complete Yocto Linux kernel ``.config`` | ||
| 52 | file, which includes all the automatically selected ``CONFIG`` options. | ||
| 53 | This efficiency reduces your maintenance effort and allows you to | ||
| 54 | further separate your configuration in ways that make sense for your | ||
| 55 | project. A common split separates policy and hardware. For example, all | ||
| 56 | your kernels might support the ``proc`` and ``sys`` filesystems, but | ||
| 57 | only specific boards require sound, USB, or specific drivers. Specifying | ||
| 58 | these configurations individually allows you to aggregate them together | ||
| 59 | as needed, but maintains them in only one place. Similar logic applies | ||
| 60 | to separating source changes. | ||
| 61 | |||
| 62 | If you do not maintain your own kernel sources and need to make only | ||
| 63 | minimal changes to the sources, the released recipes provide a vetted | ||
| 64 | base upon which to layer your changes. Doing so allows you to benefit | ||
| 65 | from the continual kernel integration and testing performed during | ||
| 66 | development of the Yocto Project. | ||
| 67 | |||
| 68 | If, instead, you have a very specific Linux kernel source tree and are | ||
| 69 | unable to align with one of the official Yocto Linux kernel recipes, | ||
| 70 | you have a way to use the Yocto Project Linux kernel tools with your | ||
| 71 | own kernel sources. | ||
| 72 | |||
| 73 | The remainder of this manual provides instructions for completing | ||
| 74 | specific Linux kernel development tasks. These instructions assume you | ||
| 75 | are comfortable working with :oe_wiki:`BitBake </Bitbake>` recipes and basic | ||
| 76 | open-source development tools. Understanding these concepts will | ||
| 77 | facilitate the process of working with the kernel recipes. If you find | ||
| 78 | you need some additional background, please be sure to review and | ||
| 79 | understand the following documentation: | ||
| 80 | |||
| 81 | - :doc:`/brief-yoctoprojectqs/index` document. | ||
| 82 | |||
| 83 | - :doc:`/overview-manual/index`. | ||
| 84 | |||
| 85 | - :ref:`devtool | ||
| 86 | workflow <sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow>` | ||
| 87 | as described in the Yocto Project Application Development and the | ||
| 88 | Extensible Software Development Kit (eSDK) manual. | ||
| 89 | |||
| 90 | - The ":ref:`dev-manual/layers:understanding and creating layers`" | ||
| 91 | section in the Yocto Project Development Tasks Manual. | ||
| 92 | |||
| 93 | - The ":ref:`kernel-dev/intro:kernel modification workflow`" section. | ||
| 94 | |||
| 95 | Kernel Modification Workflow | ||
| 96 | ============================ | ||
| 97 | |||
| 98 | Kernel modification involves changing the Yocto Project kernel, which | ||
| 99 | could involve changing configuration options as well as adding new | ||
| 100 | kernel recipes. Configuration changes can be added in the form of | ||
| 101 | configuration fragments, while recipe modification comes through the | ||
| 102 | kernel's ``recipes-kernel`` area in a kernel layer you create. | ||
| 103 | |||
| 104 | This section presents a high-level overview of the Yocto Project kernel | ||
| 105 | modification workflow. The illustration and accompanying list provide | ||
| 106 | general information and references for further information. | ||
| 107 | |||
| 108 | .. image:: figures/kernel-dev-flow.png | ||
| 109 | :width: 100% | ||
| 110 | |||
| 111 | #. *Set up Your Host Development System to Support Development Using the | ||
| 112 | Yocto Project*: See the ":doc:`/dev-manual/start`" section in | ||
| 113 | the Yocto Project Development Tasks Manual for options on how to get | ||
| 114 | a build host ready to use the Yocto Project. | ||
| 115 | |||
| 116 | #. *Set Up Your Host Development System for Kernel Development:* It is | ||
| 117 | recommended that you use ``devtool`` for kernel | ||
| 118 | development. Alternatively, you can use traditional kernel | ||
| 119 | development methods with the Yocto Project. Either way, there are | ||
| 120 | steps you need to take to get the development environment ready. | ||
| 121 | |||
| 122 | Using ``devtool`` requires that you have a clean build | ||
| 123 | of the image. For | ||
| 124 | more information, see the | ||
| 125 | ":ref:`kernel-dev/common:getting ready to develop using ``devtool```" | ||
| 126 | section. | ||
| 127 | |||
| 128 | Using traditional kernel development requires that you have the | ||
| 129 | kernel source available in an isolated local Git repository. For more | ||
| 130 | information, see the | ||
| 131 | ":ref:`kernel-dev/common:getting ready for traditional kernel development`" | ||
| 132 | section. | ||
| 133 | |||
| 134 | #. *Make Changes to the Kernel Source Code if applicable:* Modifying the | ||
| 135 | kernel does not always mean directly changing source files. However, | ||
| 136 | if you have to do this, you make the changes to the files in the | ||
| 137 | Yocto's :term:`Build Directory` if you are using ``devtool``. For more | ||
| 138 | information, see the | ||
| 139 | ":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" | ||
| 140 | section. | ||
| 141 | |||
| 142 | If you are using traditional kernel development, you edit the source | ||
| 143 | files in the kernel's local Git repository. For more information, see the | ||
| 144 | ":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" | ||
| 145 | section. | ||
| 146 | |||
| 147 | #. *Make Kernel Configuration Changes if Applicable:* If your situation | ||
| 148 | calls for changing the kernel's configuration, you can use | ||
| 149 | :ref:`menuconfig <kernel-dev/common:using \`\`menuconfig\`\`>`, | ||
| 150 | which allows you to | ||
| 151 | interactively develop and test the configuration changes you are | ||
| 152 | making to the kernel. Saving changes you make with ``menuconfig`` | ||
| 153 | updates the kernel's ``.config`` file. | ||
| 154 | |||
| 155 | .. note:: | ||
| 156 | |||
| 157 | Try to resist the temptation to directly edit an existing ``.config`` | ||
| 158 | file, which is found in the :term:`Build Directory` among the source code | ||
| 159 | used for the build. Doing so, can produce unexpected results when | ||
| 160 | the OpenEmbedded build system regenerates the configuration file. | ||
| 161 | |||
| 162 | Once you are satisfied with the configuration changes made using | ||
| 163 | ``menuconfig`` and you have saved them, you can directly compare the | ||
| 164 | resulting ``.config`` file against an existing original and gather | ||
| 165 | those changes into a | ||
| 166 | :ref:`configuration fragment file <kernel-dev/common:creating configuration fragments>` to be | ||
| 167 | referenced from within the kernel's ``.bbappend`` file. | ||
| 168 | |||
| 169 | Additionally, if you are working in a BSP layer and need to modify | ||
| 170 | the BSP's kernel's configuration, you can use ``menuconfig``. | ||
| 171 | |||
| 172 | #. *Rebuild the Kernel Image With Your Changes:* Rebuilding the kernel | ||
| 173 | image applies your changes. Depending on your target hardware, you | ||
| 174 | can verify your changes on actual hardware or perhaps QEMU. | ||
| 175 | |||
| 176 | The remainder of this developer's guide covers common tasks typically | ||
| 177 | used during kernel development, advanced Metadata usage, and Yocto Linux | ||
| 178 | kernel maintenance concepts. | ||
diff --git a/documentation/kernel-dev/maint-appx.rst b/documentation/kernel-dev/maint-appx.rst deleted file mode 100644 index 53b7376089..0000000000 --- a/documentation/kernel-dev/maint-appx.rst +++ /dev/null | |||
| @@ -1,233 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | ****************** | ||
| 4 | Kernel Maintenance | ||
| 5 | ****************** | ||
| 6 | |||
| 7 | Tree Construction | ||
| 8 | ================= | ||
| 9 | |||
| 10 | This section describes construction of the Yocto Project kernel source | ||
| 11 | repositories as accomplished by the Yocto Project team to create Yocto | ||
| 12 | Linux kernel repositories. These kernel repositories are found under the | ||
| 13 | heading "Yocto Linux Kernel" at :yocto_git:`/` and | ||
| 14 | are shipped as part of a Yocto Project release. The team creates these | ||
| 15 | repositories by compiling and executing the set of feature descriptions | ||
| 16 | for every BSP and feature in the product. Those feature descriptions | ||
| 17 | list all necessary patches, configurations, branches, tags, and feature | ||
| 18 | divisions found in a Yocto Linux kernel. Thus, the Yocto Project Linux | ||
| 19 | kernel repository (or tree) and accompanying Metadata in the | ||
| 20 | ``yocto-kernel-cache`` are built. | ||
| 21 | |||
| 22 | The existence of these repositories allow you to access and clone a | ||
| 23 | particular Yocto Project Linux kernel repository and use it to build | ||
| 24 | images based on their configurations and features. | ||
| 25 | |||
| 26 | You can find the files used to describe all the valid features and BSPs | ||
| 27 | in the Yocto Project Linux kernel in any clone of the Yocto Project | ||
| 28 | Linux kernel source repository and ``yocto-kernel-cache`` Git trees. For | ||
| 29 | example, the following commands clone the Yocto Project baseline Linux | ||
| 30 | kernel that branches off ``linux.org`` version 4.12 and the | ||
| 31 | ``yocto-kernel-cache``, which contains stores of kernel Metadata:: | ||
| 32 | |||
| 33 | $ git clone git://git.yoctoproject.org/linux-yocto-4.12 | ||
| 34 | $ git clone git://git.yoctoproject.org/linux-kernel-cache | ||
| 35 | |||
| 36 | For more information on | ||
| 37 | how to set up a local Git repository of the Yocto Project Linux kernel | ||
| 38 | files, see the | ||
| 39 | ":ref:`kernel-dev/common:preparing the build host to work on the kernel`" | ||
| 40 | section. | ||
| 41 | |||
| 42 | Once you have cloned the kernel Git repository and the cache of Metadata | ||
| 43 | on your local machine, you can discover the branches that are available | ||
| 44 | in the repository using the following Git command:: | ||
| 45 | |||
| 46 | $ git branch -a | ||
| 47 | |||
| 48 | Checking out a branch allows you to work with a particular Yocto Linux | ||
| 49 | kernel. For example, the following commands check out the | ||
| 50 | "standard/beagleboard" branch of the Yocto Linux kernel repository and | ||
| 51 | the "yocto-4.12" branch of the ``yocto-kernel-cache`` repository:: | ||
| 52 | |||
| 53 | $ cd ~/linux-yocto-4.12 | ||
| 54 | $ git checkout -b my-kernel-4.12 remotes/origin/standard/beagleboard | ||
| 55 | $ cd ~/linux-kernel-cache | ||
| 56 | $ git checkout -b my-4.12-metadata remotes/origin/yocto-4.12 | ||
| 57 | |||
| 58 | .. note:: | ||
| 59 | |||
| 60 | Branches in the ``yocto-kernel-cache`` repository correspond to Yocto Linux | ||
| 61 | kernel versions (e.g. "yocto-4.12", "yocto-4.10", "yocto-4.9", and so forth). | ||
| 62 | |||
| 63 | Once you have checked out and switched to appropriate branches, you can | ||
| 64 | see a snapshot of all the kernel source files used to build that | ||
| 65 | particular Yocto Linux kernel for a particular board. | ||
| 66 | |||
| 67 | To see the features and configurations for a particular Yocto Linux | ||
| 68 | kernel, you need to examine the ``yocto-kernel-cache`` Git repository. | ||
| 69 | As mentioned, branches in the ``yocto-kernel-cache`` repository | ||
| 70 | correspond to Yocto Linux kernel versions (e.g. ``yocto-4.12``). | ||
| 71 | Branches contain descriptions in the form of ``.scc`` and ``.cfg`` | ||
| 72 | files. | ||
| 73 | |||
| 74 | You should realize, however, that browsing your local | ||
| 75 | ``yocto-kernel-cache`` repository for feature descriptions and patches | ||
| 76 | is not an effective way to determine what is in a particular kernel | ||
| 77 | branch. Instead, you should use Git directly to discover the changes in | ||
| 78 | a branch. Using Git is an efficient and flexible way to inspect changes | ||
| 79 | to the kernel. | ||
| 80 | |||
| 81 | .. note:: | ||
| 82 | |||
| 83 | Ground up reconstruction of the complete kernel tree is an action | ||
| 84 | only taken by the Yocto Project team during an active development | ||
| 85 | cycle. When you create a clone of the kernel Git repository, you are | ||
| 86 | simply making it efficiently available for building and development. | ||
| 87 | |||
| 88 | The following steps describe what happens when the Yocto Project Team | ||
| 89 | constructs the Yocto Project kernel source Git repository (or tree) | ||
| 90 | found at :yocto_git:`/` given the introduction of a new | ||
| 91 | top-level kernel feature or BSP. The following actions effectively | ||
| 92 | provide the Metadata and create the tree that includes the new feature, | ||
| 93 | patch, or BSP: | ||
| 94 | |||
| 95 | #. *Pass Feature to the OpenEmbedded Build System:* A top-level kernel | ||
| 96 | feature is passed to the kernel build subsystem. Normally, this | ||
| 97 | feature is a BSP for a particular kernel type. | ||
| 98 | |||
| 99 | #. *Locate Feature:* The file that describes the top-level feature is | ||
| 100 | located by searching these system directories: | ||
| 101 | |||
| 102 | - The in-tree kernel-cache directories, which are located in the | ||
| 103 | :yocto_git:`yocto-kernel-cache </yocto-kernel-cache/tree/bsp>` | ||
| 104 | repository organized under the "Yocto Linux Kernel" heading in the | ||
| 105 | :yocto_git:`Yocto Project Source Repositories <>`. | ||
| 106 | |||
| 107 | - Areas pointed to by :term:`SRC_URI` statements found in kernel recipes. | ||
| 108 | |||
| 109 | For a typical build, the target of the search is a feature | ||
| 110 | description in an ``.scc`` file whose name follows this format (e.g. | ||
| 111 | ``beaglebone-standard.scc`` and ``beaglebone-preempt-rt.scc``):: | ||
| 112 | |||
| 113 | bsp_root_name-kernel_type.scc | ||
| 114 | |||
| 115 | #. *Expand Feature:* Once located, the feature description is either | ||
| 116 | expanded into a simple script of actions, or into an existing | ||
| 117 | equivalent script that is already part of the shipped kernel. | ||
| 118 | |||
| 119 | #. *Append Extra Features:* Extra features are appended to the top-level | ||
| 120 | feature description. These features can come from the | ||
| 121 | :term:`KERNEL_FEATURES` | ||
| 122 | variable in recipes. | ||
| 123 | |||
| 124 | #. *Locate, Expand, and Append Each Feature:* Each extra feature is | ||
| 125 | located, expanded and appended to the script as described in step | ||
| 126 | three. | ||
| 127 | |||
| 128 | #. *Execute the Script:* The script is executed to produce files | ||
| 129 | ``.scc`` and ``.cfg`` files in appropriate directories of the | ||
| 130 | ``yocto-kernel-cache`` repository. These files are descriptions of | ||
| 131 | all the branches, tags, patches and configurations that need to be | ||
| 132 | applied to the base Git repository to completely create the source | ||
| 133 | (build) branch for the new BSP or feature. | ||
| 134 | |||
| 135 | #. *Clone Base Repository:* The base repository is cloned, and the | ||
| 136 | actions listed in the ``yocto-kernel-cache`` directories are applied | ||
| 137 | to the tree. | ||
| 138 | |||
| 139 | #. *Perform Cleanup:* The Git repositories are left with the desired | ||
| 140 | branches checked out and any required branching, patching and tagging | ||
| 141 | has been performed. | ||
| 142 | |||
| 143 | The kernel tree and cache are ready for developer consumption to be | ||
| 144 | locally cloned, configured, and built into a Yocto Project kernel | ||
| 145 | specific to some target hardware. | ||
| 146 | |||
| 147 | .. note:: | ||
| 148 | |||
| 149 | - The generated ``yocto-kernel-cache`` repository adds to the kernel | ||
| 150 | as shipped with the Yocto Project release. Any add-ons and | ||
| 151 | configuration data are applied to the end of an existing branch. | ||
| 152 | The full repository generation that is found in the official Yocto | ||
| 153 | Project kernel repositories at :yocto_git:`/` is the | ||
| 154 | combination of all supported boards and configurations. | ||
| 155 | |||
| 156 | - The technique the Yocto Project team uses is flexible and allows | ||
| 157 | for seamless blending of an immutable history with additional | ||
| 158 | patches specific to a deployment. Any additions to the kernel | ||
| 159 | become an integrated part of the branches. | ||
| 160 | |||
| 161 | - The full kernel tree that you see on :yocto_git:`/` is | ||
| 162 | generated through repeating the above steps for all valid BSPs. | ||
| 163 | The end result is a branched, clean history tree that makes up the | ||
| 164 | kernel for a given release. You can see the script (``kgit-scc``) | ||
| 165 | responsible for this in the | ||
| 166 | :yocto_git:`yocto-kernel-tools </yocto-kernel-tools/tree/tools>` | ||
| 167 | repository. | ||
| 168 | |||
| 169 | - The steps used to construct the full kernel tree are the same | ||
| 170 | steps that BitBake uses when it builds a kernel image. | ||
| 171 | |||
| 172 | Build Strategy | ||
| 173 | ============== | ||
| 174 | |||
| 175 | Once you have cloned a Yocto Linux kernel repository and the cache | ||
| 176 | repository (``yocto-kernel-cache``) onto your development system, you | ||
| 177 | can consider the compilation phase of kernel development, which is | ||
| 178 | building a kernel image. Some prerequisites are validated by | ||
| 179 | the build process before compilation starts: | ||
| 180 | |||
| 181 | - The :term:`SRC_URI` points to the | ||
| 182 | kernel Git repository. | ||
| 183 | |||
| 184 | - A BSP build branch with Metadata exists in the ``yocto-kernel-cache`` | ||
| 185 | repository. The branch is based on the Yocto Linux kernel version and | ||
| 186 | has configurations and features grouped under the | ||
| 187 | ``yocto-kernel-cache/bsp`` directory. For example, features and | ||
| 188 | configurations for the BeagleBone Board assuming a | ||
| 189 | ``linux-yocto_4.12`` kernel reside in the following area of the | ||
| 190 | ``yocto-kernel-cache`` repository: yocto-kernel-cache/bsp/beaglebone | ||
| 191 | |||
| 192 | .. note:: | ||
| 193 | |||
| 194 | In the previous example, the "yocto-4.12" branch is checked out in | ||
| 195 | the ``yocto-kernel-cache`` repository. | ||
| 196 | |||
| 197 | The OpenEmbedded build system makes sure these conditions are satisfied before | ||
| 198 | attempting compilation. Other means, however, do exist, such as | ||
| 199 | bootstrapping a BSP. | ||
| 200 | |||
| 201 | Before building a kernel, the build process verifies the tree and | ||
| 202 | configures the kernel by processing all of the configuration "fragments" | ||
| 203 | specified by feature descriptions in the ``.scc`` files. As the features | ||
| 204 | are compiled, associated kernel configuration fragments are noted and | ||
| 205 | recorded in the series of directories in their compilation order. The | ||
| 206 | fragments are migrated, pre-processed and passed to the Linux Kernel | ||
| 207 | Configuration subsystem (``lkc``) as raw input in the form of a | ||
| 208 | ``.config`` file. The ``lkc`` uses its own internal dependency | ||
| 209 | constraints to do the final processing of that information and generates | ||
| 210 | the final ``.config`` file that is used during compilation. | ||
| 211 | |||
| 212 | Using the board's architecture and other relevant values from the | ||
| 213 | board's template, kernel compilation is started and a kernel image is | ||
| 214 | produced. | ||
| 215 | |||
| 216 | The other thing that you notice once you configure a kernel is that the | ||
| 217 | build process generates a build tree that is separate from your kernel's | ||
| 218 | local Git source repository tree. This build tree has a name that uses | ||
| 219 | the following form, where ``${MACHINE}`` is the metadata name of the | ||
| 220 | machine (BSP) and "kernel_type" is one of the Yocto Project supported | ||
| 221 | kernel types (e.g. "standard"):: | ||
| 222 | |||
| 223 | linux-${MACHINE}-kernel_type-build | ||
| 224 | |||
| 225 | The existing support in the ``kernel.org`` tree achieves this default | ||
| 226 | functionality. | ||
| 227 | |||
| 228 | This behavior means that all the generated files for a particular | ||
| 229 | machine or BSP are now in the build tree directory. The files include | ||
| 230 | the final ``.config`` file, all the ``.o`` files, the ``.a`` files, and | ||
| 231 | so forth. Since each machine or BSP has its own separate | ||
| 232 | :term:`Build Directory` in its own separate branch of the Git repository, | ||
| 233 | you can easily switch between different builds. | ||
