1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-SA-2.0-UK 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun************************ 4*4882a593SmuzhiyunAdvanced Kernel Concepts 5*4882a593Smuzhiyun************************ 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunYocto Project Kernel Development and Maintenance 8*4882a593Smuzhiyun================================================ 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunKernels available through the Yocto Project (Yocto Linux kernels), like 11*4882a593Smuzhiyunother kernels, are based off the Linux kernel releases from 12*4882a593Smuzhiyunhttps://www.kernel.org. At the beginning of a major Linux kernel 13*4882a593Smuzhiyundevelopment cycle, the Yocto Project team chooses a Linux kernel based 14*4882a593Smuzhiyunon factors such as release timing, the anticipated release timing of 15*4882a593Smuzhiyunfinal upstream ``kernel.org`` versions, and Yocto Project feature 16*4882a593Smuzhiyunrequirements. Typically, the Linux kernel chosen is in the final stages 17*4882a593Smuzhiyunof development by the Linux community. In other words, the Linux kernel 18*4882a593Smuzhiyunis in the release candidate or "rc" phase and has yet to reach final 19*4882a593Smuzhiyunrelease. But, by being in the final stages of external development, the 20*4882a593Smuzhiyunteam knows that the ``kernel.org`` final release will clearly be within 21*4882a593Smuzhiyunthe early stages of the Yocto Project development window. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunThis balance allows the Yocto Project team to deliver the most 24*4882a593Smuzhiyunup-to-date Yocto Linux kernel possible, while still ensuring that the 25*4882a593Smuzhiyunteam has a stable official release for the baseline Linux kernel 26*4882a593Smuzhiyunversion. 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunAs implied earlier, the ultimate source for Yocto Linux kernels are 29*4882a593Smuzhiyunreleased kernels from ``kernel.org``. In addition to a foundational 30*4882a593Smuzhiyunkernel from ``kernel.org``, the available Yocto Linux kernels contain a 31*4882a593Smuzhiyunmix of important new mainline developments, non-mainline developments 32*4882a593Smuzhiyun(when no alternative exists), Board Support Package (BSP) developments, 33*4882a593Smuzhiyunand custom features. These additions result in a commercially released 34*4882a593SmuzhiyunYocto Project Linux kernel that caters to specific embedded designer 35*4882a593Smuzhiyunneeds for targeted hardware. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunYou can find a web interface to the Yocto Linux kernels in the 38*4882a593Smuzhiyun:ref:`overview-manual/development-environment:yocto project source repositories` 39*4882a593Smuzhiyunat :yocto_git:`/`. If you look at the interface, you will see to 40*4882a593Smuzhiyunthe left a grouping of Git repositories titled "Yocto Linux Kernel". 41*4882a593SmuzhiyunWithin this group, you will find several Linux Yocto kernels developed 42*4882a593Smuzhiyunand included with Yocto Project releases: 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun- *linux-yocto-4.1:* The stable Yocto Project kernel to use with 45*4882a593Smuzhiyun the Yocto Project Release 2.0. This kernel is based on the Linux 4.1 46*4882a593Smuzhiyun released kernel. 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun- *linux-yocto-4.4:* The stable Yocto Project kernel to use with 49*4882a593Smuzhiyun the Yocto Project Release 2.1. This kernel is based on the Linux 4.4 50*4882a593Smuzhiyun released kernel. 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun- *linux-yocto-4.6:* A temporary kernel that is not tied to any 53*4882a593Smuzhiyun Yocto Project release. 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun- *linux-yocto-4.8:* The stable yocto Project kernel to use with 56*4882a593Smuzhiyun the Yocto Project Release 2.2. 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun- *linux-yocto-4.9:* The stable Yocto Project kernel to use with 59*4882a593Smuzhiyun the Yocto Project Release 2.3. This kernel is based on the Linux 4.9 60*4882a593Smuzhiyun released kernel. 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun- *linux-yocto-4.10:* The default stable Yocto Project kernel to 63*4882a593Smuzhiyun use with the Yocto Project Release 2.3. This kernel is based on the 64*4882a593Smuzhiyun Linux 4.10 released kernel. 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun- *linux-yocto-4.12:* The default stable Yocto Project kernel to 67*4882a593Smuzhiyun use with the Yocto Project Release 2.4. This kernel is based on the 68*4882a593Smuzhiyun Linux 4.12 released kernel. 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun- *yocto-kernel-cache:* The ``linux-yocto-cache`` contains patches 71*4882a593Smuzhiyun and configurations for the linux-yocto kernel tree. This repository 72*4882a593Smuzhiyun is useful when working on the linux-yocto kernel. For more 73*4882a593Smuzhiyun information on this "Advanced Kernel Metadata", see the 74*4882a593Smuzhiyun ":doc:`/kernel-dev/advanced`" Chapter. 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun- *linux-yocto-dev:* A development kernel based on the latest 77*4882a593Smuzhiyun upstream release candidate available. 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun.. note:: 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun Long Term Support Initiative (LTSI) for Yocto Linux kernels is as 82*4882a593Smuzhiyun follows: 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun - For Yocto Project releases 1.7, 1.8, and 2.0, the LTSI kernel is 85*4882a593Smuzhiyun ``linux-yocto-3.14``. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun - For Yocto Project releases 2.1, 2.2, and 2.3, the LTSI kernel is 88*4882a593Smuzhiyun ``linux-yocto-4.1``. 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun - For Yocto Project release 2.4, the LTSI kernel is 91*4882a593Smuzhiyun ``linux-yocto-4.9`` 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun - ``linux-yocto-4.4`` is an LTS kernel. 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunOnce a Yocto Linux kernel is officially released, the Yocto Project team 96*4882a593Smuzhiyungoes into their next development cycle, or upward revision (uprev) 97*4882a593Smuzhiyuncycle, while still continuing maintenance on the released kernel. It is 98*4882a593Smuzhiyunimportant to note that the most sustainable and stable way to include 99*4882a593Smuzhiyunfeature development upstream is through a kernel uprev process. 100*4882a593SmuzhiyunBack-porting hundreds of individual fixes and minor features from 101*4882a593Smuzhiyunvarious kernel versions is not sustainable and can easily compromise 102*4882a593Smuzhiyunquality. 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunDuring the uprev cycle, the Yocto Project team uses an ongoing analysis 105*4882a593Smuzhiyunof Linux kernel development, BSP support, and release timing to select 106*4882a593Smuzhiyunthe best possible ``kernel.org`` Linux kernel version on which to base 107*4882a593Smuzhiyunsubsequent Yocto Linux kernel development. The team continually monitors 108*4882a593SmuzhiyunLinux community kernel development to look for significant features of 109*4882a593Smuzhiyuninterest. The team does consider back-porting large features if they 110*4882a593Smuzhiyunhave a significant advantage. User or community demand can also trigger 111*4882a593Smuzhiyuna back-port or creation of new functionality in the Yocto Project 112*4882a593Smuzhiyunbaseline kernel during the uprev cycle. 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunGenerally speaking, every new Linux kernel both adds features and 115*4882a593Smuzhiyunintroduces new bugs. These consequences are the basic properties of 116*4882a593Smuzhiyunupstream Linux kernel development and are managed by the Yocto Project 117*4882a593Smuzhiyunteam's Yocto Linux kernel development strategy. It is the Yocto Project 118*4882a593Smuzhiyunteam's policy to not back-port minor features to the released Yocto 119*4882a593SmuzhiyunLinux kernel. They only consider back-porting significant technological 120*4882a593Smuzhiyunjumps - and, that is done after a complete gap analysis. The reason 121*4882a593Smuzhiyunfor this policy is that back-porting any small to medium sized change 122*4882a593Smuzhiyunfrom an evolving Linux kernel can easily create mismatches, 123*4882a593Smuzhiyunincompatibilities and very subtle errors. 124*4882a593Smuzhiyun 125*4882a593SmuzhiyunThe policies described in this section result in both a stable and a 126*4882a593Smuzhiyuncutting edge Yocto Linux kernel that mixes forward ports of existing 127*4882a593SmuzhiyunLinux kernel features and significant and critical new functionality. 128*4882a593SmuzhiyunForward porting Linux kernel functionality into the Yocto Linux kernels 129*4882a593Smuzhiyunavailable through the Yocto Project can be thought of as a "micro 130*4882a593Smuzhiyunuprev". The many "micro uprevs" produce a Yocto Linux kernel version 131*4882a593Smuzhiyunwith a mix of important new mainline, non-mainline, BSP developments and 132*4882a593Smuzhiyunfeature integrations. This Yocto Linux kernel gives insight into new 133*4882a593Smuzhiyunfeatures and allows focused amounts of testing to be done on the kernel, 134*4882a593Smuzhiyunwhich prevents surprises when selecting the next major uprev. The 135*4882a593Smuzhiyunquality of these cutting edge Yocto Linux kernels is evolving and the 136*4882a593Smuzhiyunkernels are used in leading edge feature and BSP development. 137*4882a593Smuzhiyun 138*4882a593SmuzhiyunYocto Linux Kernel Architecture and Branching Strategies 139*4882a593Smuzhiyun======================================================== 140*4882a593Smuzhiyun 141*4882a593SmuzhiyunAs mentioned earlier, a key goal of the Yocto Project is to present the 142*4882a593Smuzhiyundeveloper with a kernel that has a clear and continuous history that is 143*4882a593Smuzhiyunvisible to the user. The architecture and mechanisms, in particular the 144*4882a593Smuzhiyunbranching strategies, used achieve that goal in a manner similar to 145*4882a593Smuzhiyunupstream Linux kernel development in ``kernel.org``. 146*4882a593Smuzhiyun 147*4882a593SmuzhiyunYou can think of a Yocto Linux kernel as consisting of a baseline Linux 148*4882a593Smuzhiyunkernel with added features logically structured on top of the baseline. 149*4882a593SmuzhiyunThe features are tagged and organized by way of a branching strategy 150*4882a593Smuzhiyunimplemented by the Yocto Project team using the Source Code Manager 151*4882a593Smuzhiyun(SCM) Git. 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun.. note:: 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun - Git is the obvious SCM for meeting the Yocto Linux kernel 156*4882a593Smuzhiyun organizational and structural goals described in this section. Not 157*4882a593Smuzhiyun only is Git the SCM for Linux kernel development in ``kernel.org`` 158*4882a593Smuzhiyun but, Git continues to grow in popularity and supports many 159*4882a593Smuzhiyun different work flows, front-ends and management techniques. 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun - You can find documentation on Git at https://git-scm.com/doc. You can 162*4882a593Smuzhiyun also get an introduction to Git as it applies to the Yocto Project in the 163*4882a593Smuzhiyun ":ref:`overview-manual/development-environment:git`" section in the Yocto Project 164*4882a593Smuzhiyun Overview and Concepts Manual. The latter reference provides an 165*4882a593Smuzhiyun overview of Git and presents a minimal set of Git commands that 166*4882a593Smuzhiyun allows you to be functional using Git. You can use as much, or as 167*4882a593Smuzhiyun little, of what Git has to offer to accomplish what you need for 168*4882a593Smuzhiyun your project. You do not have to be a "Git Expert" in order to use 169*4882a593Smuzhiyun it with the Yocto Project. 170*4882a593Smuzhiyun 171*4882a593SmuzhiyunUsing Git's tagging and branching features, the Yocto Project team 172*4882a593Smuzhiyuncreates kernel branches at points where functionality is no longer 173*4882a593Smuzhiyunshared and thus, needs to be isolated. For example, board-specific 174*4882a593Smuzhiyunincompatibilities would require different functionality and would 175*4882a593Smuzhiyunrequire a branch to separate the features. Likewise, for specific kernel 176*4882a593Smuzhiyunfeatures, the same branching strategy is used. 177*4882a593Smuzhiyun 178*4882a593SmuzhiyunThis "tree-like" architecture results in a structure that has features 179*4882a593Smuzhiyunorganized to be specific for particular functionality, single kernel 180*4882a593Smuzhiyuntypes, or a subset of kernel types. Thus, the user has the ability to 181*4882a593Smuzhiyunsee the added features and the commits that make up those features. In 182*4882a593Smuzhiyunaddition to being able to see added features, the user can also view the 183*4882a593Smuzhiyunhistory of what made up the baseline Linux kernel. 184*4882a593Smuzhiyun 185*4882a593SmuzhiyunAnother consequence of this strategy results in not having to store the 186*4882a593Smuzhiyunsame feature twice internally in the tree. Rather, the kernel team 187*4882a593Smuzhiyunstores the unique differences required to apply the feature onto the 188*4882a593Smuzhiyunkernel type in question. 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun.. note:: 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun The Yocto Project team strives to place features in the tree such 193*4882a593Smuzhiyun that features can be shared by all boards and kernel types where 194*4882a593Smuzhiyun possible. However, during development cycles or when large features 195*4882a593Smuzhiyun are merged, the team cannot always follow this practice. In those 196*4882a593Smuzhiyun cases, the team uses isolated branches to merge features. 197*4882a593Smuzhiyun 198*4882a593SmuzhiyunBSP-specific code additions are handled in a similar manner to 199*4882a593Smuzhiyunkernel-specific additions. Some BSPs only make sense given certain 200*4882a593Smuzhiyunkernel types. So, for these types, the team creates branches off the end 201*4882a593Smuzhiyunof that kernel type for all of the BSPs that are supported on that 202*4882a593Smuzhiyunkernel type. From the perspective of the tools that create the BSP 203*4882a593Smuzhiyunbranch, the BSP is really no different than a feature. Consequently, the 204*4882a593Smuzhiyunsame branching strategy applies to BSPs as it does to kernel features. 205*4882a593SmuzhiyunSo again, rather than store the BSP twice, the team only stores the 206*4882a593Smuzhiyununique differences for the BSP across the supported multiple kernels. 207*4882a593Smuzhiyun 208*4882a593SmuzhiyunWhile this strategy can result in a tree with a significant number of 209*4882a593Smuzhiyunbranches, it is important to realize that from the developer's point of 210*4882a593Smuzhiyunview, there is a linear path that travels from the baseline 211*4882a593Smuzhiyun``kernel.org``, through a select group of features and ends with their 212*4882a593SmuzhiyunBSP-specific commits. In other words, the divisions of the kernel are 213*4882a593Smuzhiyuntransparent and are not relevant to the developer on a day-to-day basis. 214*4882a593SmuzhiyunFrom the developer's perspective, this path is the development branch. 215*4882a593SmuzhiyunThe developer does not need to be aware of the existence of 216*4882a593Smuzhiyunany other branches at all. Of course, it can make sense to have these 217*4882a593Smuzhiyunbranches in the tree, should a person decide to explore them. For 218*4882a593Smuzhiyunexample, a comparison between two BSPs at either the commit level or at 219*4882a593Smuzhiyunthe line-by-line code ``diff`` level is now a trivial operation. 220*4882a593Smuzhiyun 221*4882a593SmuzhiyunThe following illustration shows the conceptual Yocto Linux kernel. 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun.. image:: figures/kernel-architecture-overview.png 224*4882a593Smuzhiyun :align: center 225*4882a593Smuzhiyun 226*4882a593SmuzhiyunIn the illustration, the "Kernel.org Branch Point" marks the specific 227*4882a593Smuzhiyunspot (or Linux kernel release) from which the Yocto Linux kernel is 228*4882a593Smuzhiyuncreated. From this point forward in the tree, features and differences 229*4882a593Smuzhiyunare organized and tagged. 230*4882a593Smuzhiyun 231*4882a593SmuzhiyunThe "Yocto Project Baseline Kernel" contains functionality that is 232*4882a593Smuzhiyuncommon to every kernel type and BSP that is organized further along in 233*4882a593Smuzhiyunthe tree. Placing these common features in the tree this way means 234*4882a593Smuzhiyunfeatures do not have to be duplicated along individual branches of the 235*4882a593Smuzhiyuntree structure. 236*4882a593Smuzhiyun 237*4882a593SmuzhiyunFrom the "Yocto Project Baseline Kernel", branch points represent 238*4882a593Smuzhiyunspecific functionality for individual Board Support Packages (BSPs) as 239*4882a593Smuzhiyunwell as real-time kernels. The illustration represents this through 240*4882a593Smuzhiyunthree BSP-specific branches and a real-time kernel branch. Each branch 241*4882a593Smuzhiyunrepresents some unique functionality for the BSP or for a real-time 242*4882a593SmuzhiyunYocto Linux kernel. 243*4882a593Smuzhiyun 244*4882a593SmuzhiyunIn this example structure, the "Real-time (rt) Kernel" branch has common 245*4882a593Smuzhiyunfeatures for all real-time Yocto Linux kernels and contains more 246*4882a593Smuzhiyunbranches for individual BSP-specific real-time kernels. The illustration 247*4882a593Smuzhiyunshows three branches as an example. Each branch points the way to 248*4882a593Smuzhiyunspecific, unique features for a respective real-time kernel as they 249*4882a593Smuzhiyunapply to a given BSP. 250*4882a593Smuzhiyun 251*4882a593SmuzhiyunThe resulting tree structure presents a clear path of markers (or 252*4882a593Smuzhiyunbranches) to the developer that, for all practical purposes, is the 253*4882a593SmuzhiyunYocto Linux kernel needed for any given set of requirements. 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun.. note:: 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun Keep in mind the figure does not take into account all the supported 258*4882a593Smuzhiyun Yocto Linux kernels, but rather shows a single generic kernel just 259*4882a593Smuzhiyun for conceptual purposes. Also keep in mind that this structure 260*4882a593Smuzhiyun represents the 261*4882a593Smuzhiyun :ref:`overview-manual/development-environment:yocto project source repositories` 262*4882a593Smuzhiyun that are either pulled from during the build or established on the 263*4882a593Smuzhiyun host development system prior to the build by either cloning a 264*4882a593Smuzhiyun particular kernel's Git repository or by downloading and unpacking a 265*4882a593Smuzhiyun tarball. 266*4882a593Smuzhiyun 267*4882a593SmuzhiyunWorking with the kernel as a structured tree follows recognized 268*4882a593Smuzhiyuncommunity best practices. In particular, the kernel as shipped with the 269*4882a593Smuzhiyunproduct, should be considered an "upstream source" and viewed as a 270*4882a593Smuzhiyunseries of historical and documented modifications (commits). These 271*4882a593Smuzhiyunmodifications represent the development and stabilization done by the 272*4882a593SmuzhiyunYocto Project kernel development team. 273*4882a593Smuzhiyun 274*4882a593SmuzhiyunBecause commits only change at significant release points in the product 275*4882a593Smuzhiyunlife cycle, developers can work on a branch created from the last 276*4882a593Smuzhiyunrelevant commit in the shipped Yocto Project Linux kernel. As mentioned 277*4882a593Smuzhiyunpreviously, the structure is transparent to the developer because the 278*4882a593Smuzhiyunkernel tree is left in this state after cloning and building the kernel. 279*4882a593Smuzhiyun 280*4882a593SmuzhiyunKernel Build File Hierarchy 281*4882a593Smuzhiyun=========================== 282*4882a593Smuzhiyun 283*4882a593SmuzhiyunUpstream storage of all the available kernel source code is one thing, 284*4882a593Smuzhiyunwhile representing and using the code on your host development system is 285*4882a593Smuzhiyunanother. Conceptually, you can think of the kernel source repositories 286*4882a593Smuzhiyunas all the source files necessary for all the supported Yocto Linux 287*4882a593Smuzhiyunkernels. As a developer, you are just interested in the source files for 288*4882a593Smuzhiyunthe kernel on which you are working. And, furthermore, you need them 289*4882a593Smuzhiyunavailable on your host system. 290*4882a593Smuzhiyun 291*4882a593SmuzhiyunKernel source code is available on your host system several different 292*4882a593Smuzhiyunways: 293*4882a593Smuzhiyun 294*4882a593Smuzhiyun- *Files Accessed While using devtool:* ``devtool``, which is 295*4882a593Smuzhiyun available with the Yocto Project, is the preferred method by which to 296*4882a593Smuzhiyun modify the kernel. See the ":ref:`kernel-dev/intro:kernel modification workflow`" section. 297*4882a593Smuzhiyun 298*4882a593Smuzhiyun- *Cloned Repository:* If you are working in the kernel all the time, 299*4882a593Smuzhiyun you probably would want to set up your own local Git repository of 300*4882a593Smuzhiyun the Yocto Linux kernel tree. For information on how to clone a Yocto 301*4882a593Smuzhiyun Linux kernel Git repository, see the 302*4882a593Smuzhiyun ":ref:`kernel-dev/common:preparing the build host to work on the kernel`" 303*4882a593Smuzhiyun section. 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun- *Temporary Source Files from a Build:* If you just need to make some 306*4882a593Smuzhiyun patches to the kernel using a traditional BitBake workflow (i.e. not 307*4882a593Smuzhiyun using the ``devtool``), you can access temporary kernel source files 308*4882a593Smuzhiyun that were extracted and used during a kernel build. 309*4882a593Smuzhiyun 310*4882a593SmuzhiyunThe temporary kernel source files resulting from a build using BitBake 311*4882a593Smuzhiyunhave a particular hierarchy. When you build the kernel on your 312*4882a593Smuzhiyundevelopment system, all files needed for the build are taken from the 313*4882a593Smuzhiyunsource repositories pointed to by the 314*4882a593Smuzhiyun:term:`SRC_URI` variable and gathered 315*4882a593Smuzhiyunin a temporary work area where they are subsequently used to create the 316*4882a593Smuzhiyununique kernel. Thus, in a sense, the process constructs a local source 317*4882a593Smuzhiyuntree specific to your kernel from which to generate the new kernel 318*4882a593Smuzhiyunimage. 319*4882a593Smuzhiyun 320*4882a593SmuzhiyunThe following figure shows the temporary file structure created on your 321*4882a593Smuzhiyunhost system when you build the kernel using Bitbake. This 322*4882a593Smuzhiyun:term:`Build Directory` contains all the 323*4882a593Smuzhiyunsource files used during the build. 324*4882a593Smuzhiyun 325*4882a593Smuzhiyun.. image:: figures/kernel-overview-2-generic.png 326*4882a593Smuzhiyun :align: center 327*4882a593Smuzhiyun 328*4882a593SmuzhiyunAgain, for additional information on the Yocto Project kernel's 329*4882a593Smuzhiyunarchitecture and its branching strategy, see the 330*4882a593Smuzhiyun":ref:`kernel-dev/concepts-appx:yocto linux kernel architecture and branching strategies`" 331*4882a593Smuzhiyunsection. You can also reference the 332*4882a593Smuzhiyun":ref:`kernel-dev/common:using \`\`devtool\`\` to patch the kernel`" 333*4882a593Smuzhiyunand 334*4882a593Smuzhiyun":ref:`kernel-dev/common:using traditional kernel development to patch the kernel`" 335*4882a593Smuzhiyunsections for detailed example that modifies the kernel. 336*4882a593Smuzhiyun 337*4882a593SmuzhiyunDetermining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase 338*4882a593Smuzhiyun======================================================================================= 339*4882a593Smuzhiyun 340*4882a593SmuzhiyunThis section describes part of the kernel configuration audit phase that 341*4882a593Smuzhiyunmost developers can ignore. For general information on kernel 342*4882a593Smuzhiyunconfiguration including ``menuconfig``, ``defconfig`` files, and 343*4882a593Smuzhiyunconfiguration fragments, see the 344*4882a593Smuzhiyun":ref:`kernel-dev/common:configuring the kernel`" section. 345*4882a593Smuzhiyun 346*4882a593SmuzhiyunDuring this part of the audit phase, the contents of the final 347*4882a593Smuzhiyun``.config`` file are compared against the fragments specified by the 348*4882a593Smuzhiyunsystem. These fragments can be system fragments, distro fragments, or 349*4882a593Smuzhiyunuser-specified configuration elements. Regardless of their origin, the 350*4882a593SmuzhiyunOpenEmbedded build system warns the user if a specific option is not 351*4882a593Smuzhiyunincluded in the final kernel configuration. 352*4882a593Smuzhiyun 353*4882a593SmuzhiyunBy default, in order to not overwhelm the user with configuration 354*4882a593Smuzhiyunwarnings, the system only reports missing "hardware" options as they 355*4882a593Smuzhiyuncould result in a boot failure or indicate that important hardware is 356*4882a593Smuzhiyunnot available. 357*4882a593Smuzhiyun 358*4882a593SmuzhiyunTo determine whether or not a given option is "hardware" or 359*4882a593Smuzhiyun"non-hardware", the kernel Metadata in ``yocto-kernel-cache`` contains 360*4882a593Smuzhiyunfiles that classify individual or groups of options as either hardware 361*4882a593Smuzhiyunor non-hardware. To better show this, consider a situation where the 362*4882a593Smuzhiyun``yocto-kernel-cache`` contains the following files:: 363*4882a593Smuzhiyun 364*4882a593Smuzhiyun yocto-kernel-cache/features/drm-psb/hardware.cfg 365*4882a593Smuzhiyun yocto-kernel-cache/features/kgdb/hardware.cfg 366*4882a593Smuzhiyun yocto-kernel-cache/ktypes/base/hardware.cfg 367*4882a593Smuzhiyun yocto-kernel-cache/bsp/mti-malta32/hardware.cfg 368*4882a593Smuzhiyun yocto-kernel-cache/bsp/qemu-ppc32/hardware.cfg 369*4882a593Smuzhiyun yocto-kernel-cache/bsp/qemuarma9/hardware.cfg 370*4882a593Smuzhiyun yocto-kernel-cache/bsp/mti-malta64/hardware.cfg 371*4882a593Smuzhiyun yocto-kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg 372*4882a593Smuzhiyun yocto-kernel-cache/bsp/common-pc/hardware.cfg 373*4882a593Smuzhiyun yocto-kernel-cache/bsp/common-pc-64/hardware.cfg 374*4882a593Smuzhiyun yocto-kernel-cache/features/rfkill/non-hardware.cfg 375*4882a593Smuzhiyun yocto-kernel-cache/ktypes/base/non-hardware.cfg 376*4882a593Smuzhiyun yocto-kernel-cache/features/aufs/non-hardware.kcf 377*4882a593Smuzhiyun yocto-kernel-cache/features/ocf/non-hardware.kcf 378*4882a593Smuzhiyun yocto-kernel-cache/ktypes/base/non-hardware.kcf 379*4882a593Smuzhiyun yocto-kernel-cache/ktypes/base/hardware.kcf 380*4882a593Smuzhiyun yocto-kernel-cache/bsp/qemu-ppc32/hardware.kcf 381*4882a593Smuzhiyun 382*4882a593SmuzhiyunHere are explanations for the various files: 383*4882a593Smuzhiyun 384*4882a593Smuzhiyun- ``hardware.kcf``: Specifies a list of kernel Kconfig files that 385*4882a593Smuzhiyun contain hardware options only. 386*4882a593Smuzhiyun 387*4882a593Smuzhiyun- ``non-hardware.kcf``: Specifies a list of kernel Kconfig files that 388*4882a593Smuzhiyun contain non-hardware options only. 389*4882a593Smuzhiyun 390*4882a593Smuzhiyun- ``hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options that 391*4882a593Smuzhiyun are hardware, regardless of whether or not they are within a Kconfig 392*4882a593Smuzhiyun file specified by a hardware or non-hardware Kconfig file (i.e. 393*4882a593Smuzhiyun ``hardware.kcf`` or ``non-hardware.kcf``). 394*4882a593Smuzhiyun 395*4882a593Smuzhiyun- ``non-hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options 396*4882a593Smuzhiyun that are not hardware, regardless of whether or not they are within a 397*4882a593Smuzhiyun Kconfig file specified by a hardware or non-hardware Kconfig file 398*4882a593Smuzhiyun (i.e. ``hardware.kcf`` or ``non-hardware.kcf``). 399*4882a593Smuzhiyun 400*4882a593SmuzhiyunHere is a specific example using the 401*4882a593Smuzhiyun``kernel-cache/bsp/mti-malta32/hardware.cfg``:: 402*4882a593Smuzhiyun 403*4882a593Smuzhiyun CONFIG_SERIAL_8250 404*4882a593Smuzhiyun CONFIG_SERIAL_8250_CONSOLE 405*4882a593Smuzhiyun CONFIG_SERIAL_8250_NR_UARTS 406*4882a593Smuzhiyun CONFIG_SERIAL_8250_PCI 407*4882a593Smuzhiyun CONFIG_SERIAL_CORE 408*4882a593Smuzhiyun CONFIG_SERIAL_CORE_CONSOLE 409*4882a593Smuzhiyun CONFIG_VGA_ARB 410*4882a593Smuzhiyun 411*4882a593SmuzhiyunThe kernel configuration audit automatically detects 412*4882a593Smuzhiyunthese files (hence the names must be exactly the ones discussed here), 413*4882a593Smuzhiyunand uses them as inputs when generating warnings about the final 414*4882a593Smuzhiyun``.config`` file. 415*4882a593Smuzhiyun 416*4882a593SmuzhiyunA user-specified kernel Metadata repository, or recipe space feature, 417*4882a593Smuzhiyuncan use these same files to classify options that are found within its 418*4882a593Smuzhiyun``.cfg`` files as hardware or non-hardware, to prevent the OpenEmbedded 419*4882a593Smuzhiyunbuild system from producing an error or warning when an option is not in 420*4882a593Smuzhiyunthe final ``.config`` file. 421