summaryrefslogtreecommitdiffstats
path: root/documentation/kernel-dev/kernel-dev-advanced.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/kernel-dev/kernel-dev-advanced.rst')
-rw-r--r--documentation/kernel-dev/kernel-dev-advanced.rst762
1 files changed, 762 insertions, 0 deletions
diff --git a/documentation/kernel-dev/kernel-dev-advanced.rst b/documentation/kernel-dev/kernel-dev-advanced.rst
new file mode 100644
index 0000000000..be76bd7b52
--- /dev/null
+++ b/documentation/kernel-dev/kernel-dev-advanced.rst
@@ -0,0 +1,762 @@
1*******************************************************
2Working with Advanced Metadata (``yocto-kernel-cache``)
3*******************************************************
4
5.. _kernel-dev-advanced-overview:
6
7Overview
8========
9
10In addition to supporting configuration fragments and patches, the Yocto
11Project kernel tools also support rich
12`Metadata <&YOCTO_DOCS_REF_URL;#metadata>`__ that you can use to define
13complex policies and Board Support Package (BSP) support. The purpose of
14the Metadata and the tools that manage it is to help you manage the
15complexity of the configuration and sources used to support multiple
16BSPs and Linux kernel types.
17
18Kernel Metadata exists in many places. One area in the Yocto Project
19`Source Repositories <&YOCTO_DOCS_OM_URL;#source-repositories>`__ is the
20``yocto-kernel-cache`` Git repository. You can find this repository
21grouped under the "Yocto Linux Kernel" heading in the `Yocto Project
22Source Repositories <&YOCTO_GIT_URL;>`__.
23
24Kernel development tools ("kern-tools") exist also in the Yocto Project
25Source Repositories under the "Yocto Linux Kernel" heading in the
26``yocto-kernel-tools`` Git repository. The recipe that builds these
27tools is ``meta/recipes-kernel/kern-tools/kern-tools-native_git.bb`` in
28the `Source Directory <&YOCTO_DOCS_REF_URL;#source-directory>`__ (e.g.
29``poky``).
30
31Using Kernel Metadata in a Recipe
32=================================
33
34As mentioned in the introduction, the Yocto Project contains kernel
35Metadata, which is located in the ``yocto-kernel-cache`` Git repository.
36This Metadata defines Board Support Packages (BSPs) that correspond to
37definitions in linux-yocto recipes for corresponding BSPs. A BSP
38consists of an aggregation of kernel policy and enabled
39hardware-specific features. The BSP can be influenced from within the
40linux-yocto recipe.
41
42.. note::
43
44 A Linux kernel recipe that contains kernel Metadata (e.g. inherits
45 from the
46 linux-yocto.inc
47 file) is said to be a "linux-yocto style" recipe.
48
49Every linux-yocto style recipe must define the
50```KMACHINE`` <&YOCTO_DOCS_REF_URL;#var-KMACHINE>`__ variable. This
51variable is typically set to the same value as the ``MACHINE`` variable,
52which is used by `BitBake <&YOCTO_DOCS_REF_URL;#bitbake-term>`__.
53However, in some cases, the variable might instead refer to the
54underlying platform of the ``MACHINE``.
55
56Multiple BSPs can reuse the same ``KMACHINE`` name if they are built
57using the same BSP description. Multiple Corei7-based BSPs could share
58the same "intel-corei7-64" value for ``KMACHINE``. It is important to
59realize that ``KMACHINE`` is just for kernel mapping, while ``MACHINE``
60is the machine type within a BSP Layer. Even with this distinction,
61however, these two variables can hold the same value. See the `BSP
62Descriptions <#bsp-descriptions>`__ section for more information.
63
64Every linux-yocto style recipe must also indicate the Linux kernel
65source repository branch used to build the Linux kernel. The
66```KBRANCH`` <&YOCTO_DOCS_REF_URL;#var-KBRANCH>`__ variable must be set
67to indicate the branch.
68
69.. note::
70
71 You can use the
72 KBRANCH
73 value to define an alternate branch typically with a machine override
74 as shown here from the
75 meta-yocto-bsp
76 layer:
77 ::
78
79 KBRANCH_edgerouter = "standard/edgerouter"
80
81
82The linux-yocto style recipes can optionally define the following
83variables: KERNEL_FEATURES LINUX_KERNEL_TYPE
84
85```LINUX_KERNEL_TYPE`` <&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE>`__
86defines the kernel type to be used in assembling the configuration. If
87you do not specify a ``LINUX_KERNEL_TYPE``, it defaults to "standard".
88Together with ``KMACHINE``, ``LINUX_KERNEL_TYPE`` defines the search
89arguments used by the kernel tools to find the appropriate description
90within the kernel Metadata with which to build out the sources and
91configuration. The linux-yocto recipes define "standard", "tiny", and
92"preempt-rt" kernel types. See the "`Kernel Types <#kernel-types>`__"
93section for more information on kernel types.
94
95During the build, the kern-tools search for the BSP description file
96that most closely matches the ``KMACHINE`` and ``LINUX_KERNEL_TYPE``
97variables passed in from the recipe. The tools use the first BSP
98description it finds that match both variables. If the tools cannot find
99a match, they issue a warning.
100
101The tools first search for the ``KMACHINE`` and then for the
102``LINUX_KERNEL_TYPE``. If the tools cannot find a partial match, they
103will use the sources from the ``KBRANCH`` and any configuration
104specified in the ```SRC_URI`` <&YOCTO_DOCS_REF_URL;#var-SRC_URI>`__.
105
106You can use the
107```KERNEL_FEATURES`` <&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES>`__
108variable to include features (configuration fragments, patches, or both)
109that are not already included by the ``KMACHINE`` and
110``LINUX_KERNEL_TYPE`` variable combination. For example, to include a
111feature specified as "features/netfilter/netfilter.scc", specify:
112KERNEL_FEATURES += "features/netfilter/netfilter.scc" To include a
113feature called "cfg/sound.scc" just for the ``qemux86`` machine,
114specify: KERNEL_FEATURES_append_qemux86 = " cfg/sound.scc" The value of
115the entries in ``KERNEL_FEATURES`` are dependent on their location
116within the kernel Metadata itself. The examples here are taken from the
117``yocto-kernel-cache`` repository. Each branch of this repository
118contains "features" and "cfg" subdirectories at the top-level. For more
119information, see the "`Kernel Metadata
120Syntax <#kernel-metadata-syntax>`__" section.
121
122Kernel Metadata Syntax
123======================
124
125The kernel Metadata consists of three primary types of files: ``scc``
126 [1]_ description files, configuration fragments, and patches. The
127``scc`` files define variables and include or otherwise reference any of
128the three file types. The description files are used to aggregate all
129types of kernel Metadata into what ultimately describes the sources and
130the configuration required to build a Linux kernel tailored to a
131specific machine.
132
133The ``scc`` description files are used to define two fundamental types
134of kernel Metadata:
135
136- Features
137
138- Board Support Packages (BSPs)
139
140Features aggregate sources in the form of patches and configuration
141fragments into a modular reusable unit. You can use features to
142implement conceptually separate kernel Metadata descriptions such as
143pure configuration fragments, simple patches, complex features, and
144kernel types. `Kernel types <#kernel-types>`__ define general kernel
145features and policy to be reused in the BSPs.
146
147BSPs define hardware-specific features and aggregate them with kernel
148types to form the final description of what will be assembled and built.
149
150While the kernel Metadata syntax does not enforce any logical separation
151of configuration fragments, patches, features or kernel types, best
152practices dictate a logical separation of these types of Metadata. The
153following Metadata file hierarchy is recommended: base/ bsp/ cfg/
154features/ ktypes/ patches/
155
156The ``bsp`` directory contains the `BSP
157descriptions <#bsp-descriptions>`__. The remaining directories all
158contain "features". Separating ``bsp`` from the rest of the structure
159aids conceptualizing intended usage.
160
161Use these guidelines to help place your ``scc`` description files within
162the structure:
163
164- If your file contains only configuration fragments, place the file in
165 the ``cfg`` directory.
166
167- If your file contains only source-code fixes, place the file in the
168 ``patches`` directory.
169
170- If your file encapsulates a major feature, often combining sources
171 and configurations, place the file in ``features`` directory.
172
173- If your file aggregates non-hardware configuration and patches in
174 order to define a base kernel policy or major kernel type to be
175 reused across multiple BSPs, place the file in ``ktypes`` directory.
176
177These distinctions can easily become blurred - especially as out-of-tree
178features slowly merge upstream over time. Also, remember that how the
179description files are placed is a purely logical organization and has no
180impact on the functionality of the kernel Metadata. There is no impact
181because all of ``cfg``, ``features``, ``patches``, and ``ktypes``,
182contain "features" as far as the kernel tools are concerned.
183
184Paths used in kernel Metadata files are relative to base, which is
185either
186```FILESEXTRAPATHS`` <&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS>`__ if
187you are creating Metadata in `recipe-space <#recipe-space-metadata>`__,
188or the top level of
189```yocto-kernel-cache`` <&YOCTO_GIT_URL;/cgit/cgit.cgi/yocto-kernel-cache/tree/>`__
190if you are creating `Metadata outside of the
191recipe-space <#metadata-outside-the-recipe-space>`__.
192
193Configuration
194-------------
195
196The simplest unit of kernel Metadata is the configuration-only feature.
197This feature consists of one or more Linux kernel configuration
198parameters in a configuration fragment file (``.cfg``) and a ``.scc``
199file that describes the fragment.
200
201As an example, consider the Symmetric Multi-Processing (SMP) fragment
202used with the ``linux-yocto-4.12`` kernel as defined outside of the
203recipe space (i.e. ``yocto-kernel-cache``). This Metadata consists of
204two files: ``smp.scc`` and ``smp.cfg``. You can find these files in the
205``cfg`` directory of the ``yocto-4.12`` branch in the
206``yocto-kernel-cache`` Git repository: cfg/smp.scc: define
207KFEATURE_DESCRIPTION "Enable SMP for 32 bit builds" define
208KFEATURE_COMPATIBILITY all kconf hardware smp.cfg cfg/smp.cfg:
209CONFIG_SMP=y CONFIG_SCHED_SMT=y # Increase default NR_CPUS from 8 to 64
210so that platform with # more than 8 processors can be all activated at
211boot time CONFIG_NR_CPUS=64 # The following is needed when setting
212NR_CPUS to something # greater than 8 on x86 architectures, it should be
213automatically # disregarded by Kconfig when using a different arch
214CONFIG_X86_BIGSMP=y You can find general information on configuration
215fragment files in the "`Creating Configuration
216Fragments <#creating-config-fragments>`__" section.
217
218Within the ``smp.scc`` file, the
219```KFEATURE_DESCRIPTION`` <&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION>`__
220statement provides a short description of the fragment. Higher level
221kernel tools use this description.
222
223Also within the ``smp.scc`` file, the ``kconf`` command includes the
224actual configuration fragment in an ``.scc`` file, and the "hardware"
225keyword identifies the fragment as being hardware enabling, as opposed
226to general policy, which would use the "non-hardware" keyword. The
227distinction is made for the benefit of the configuration validation
228tools, which warn you if a hardware fragment overrides a policy set by a
229non-hardware fragment.
230
231.. note::
232
233 The description file can include multiple
234 kconf
235 statements, one per fragment.
236
237As described in the "`Validating
238Configuration <#validating-configuration>`__" section, you can use the
239following BitBake command to audit your configuration: $ bitbake
240linux-yocto -c kernel_configcheck -f
241
242Patches
243-------
244
245Patch descriptions are very similar to configuration fragment
246descriptions, which are described in the previous section. However,
247instead of a ``.cfg`` file, these descriptions work with source patches
248(i.e. ``.patch`` files).
249
250A typical patch includes a description file and the patch itself. As an
251example, consider the build patches used with the ``linux-yocto-4.12``
252kernel as defined outside of the recipe space (i.e.
253``yocto-kernel-cache``). This Metadata consists of several files:
254``build.scc`` and a set of ``*.patch`` files. You can find these files
255in the ``patches/build`` directory of the ``yocto-4.12`` branch in the
256``yocto-kernel-cache`` Git repository.
257
258The following listings show the ``build.scc`` file and part of the
259``modpost-mask-trivial-warnings.patch`` file: patches/build/build.scc:
260patch arm-serialize-build-targets.patch patch
261powerpc-serialize-image-targets.patch patch
262kbuild-exclude-meta-directory-from-distclean-processi.patch # applied by
263kgit # patch kbuild-add-meta-files-to-the-ignore-li.patch patch
264modpost-mask-trivial-warnings.patch patch
265menuconfig-check-lxdiaglog.sh-Allow-specification-of.patch
266patches/build/modpost-mask-trivial-warnings.patch: From
267bd48931bc142bdd104668f3a062a1f22600aae61 Mon Sep 17 00:00:00 2001 From:
268Paul Gortmaker <paul.gortmaker@windriver.com> Date: Sun, 25 Jan 2009
26917:58:09 -0500 Subject: [PATCH] modpost: mask trivial warnings Newer
270HOSTCC will complain about various stdio fcns because . . . char
271\*dump_write = NULL, \*files_source = NULL; int opt; -- 2.10.1 generated
272by cgit v0.10.2 at 2017-09-28 15:23:23 (GMT) The description file can
273include multiple patch statements where each statement handles a single
274patch. In the example ``build.scc`` file, five patch statements exist
275for the five patches in the directory.
276
277You can create a typical ``.patch`` file using ``diff -Nurp`` or
278``git format-patch`` commands. For information on how to create patches,
279see the "`Using ``devtool`` to Patch the
280Kernel <#using-devtool-to-patch-the-kernel>`__" and "`Using Traditional
281Kernel Development to Patch the
282Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__"
283sections.
284
285Features
286--------
287
288Features are complex kernel Metadata types that consist of configuration
289fragments, patches, and possibly other feature description files. As an
290example, consider the following generic listing: features/myfeature.scc
291define KFEATURE_DESCRIPTION "Enable myfeature" patch
2920001-myfeature-core.patch patch 0002-myfeature-interface.patch include
293cfg/myfeature_dependency.scc kconf non-hardware myfeature.cfg This
294example shows how the ``patch`` and ``kconf`` commands are used as well
295as how an additional feature description file is included with the
296``include`` command.
297
298Typically, features are less granular than configuration fragments and
299are more likely than configuration fragments and patches to be the types
300of things you want to specify in the ``KERNEL_FEATURES`` variable of the
301Linux kernel recipe. See the "`Using Kernel Metadata in a
302Recipe <#using-kernel-metadata-in-a-recipe>`__" section earlier in the
303manual.
304
305Kernel Types
306------------
307
308A kernel type defines a high-level kernel policy by aggregating
309non-hardware configuration fragments with patches you want to use when
310building a Linux kernel of a specific type (e.g. a real-time kernel).
311Syntactically, kernel types are no different than features as described
312in the "`Features <#features>`__" section. The
313```LINUX_KERNEL_TYPE`` <&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE>`__
314variable in the kernel recipe selects the kernel type. For example, in
315the ``linux-yocto_4.12.bb`` kernel recipe found in
316``poky/meta/recipes-kernel/linux``, a
317```require`` <&YOCTO_DOCS_BB_URL;#require-inclusion>`__ directive
318includes the ``poky/meta/recipes-kernel/linux/linux-yocto.inc`` file,
319which has the following statement that defines the default kernel type:
320LINUX_KERNEL_TYPE ??= "standard"
321
322Another example would be the real-time kernel (i.e.
323``linux-yocto-rt_4.12.bb``). This kernel recipe directly sets the kernel
324type as follows: LINUX_KERNEL_TYPE = "preempt-rt"
325
326.. note::
327
328 You can find kernel recipes in the
329 meta/recipes-kernel/linux
330 directory of the
331 Source Directory
332 (e.g.
333 poky/meta/recipes-kernel/linux/linux-yocto_4.12.bb
334 ). See the "
335 Using Kernel Metadata in a Recipe
336 " section for more information.
337
338Three kernel types ("standard", "tiny", and "preempt-rt") are supported
339for Linux Yocto kernels:
340
341- "standard": Includes the generic Linux kernel policy of the Yocto
342 Project linux-yocto kernel recipes. This policy includes, among other
343 things, which file systems, networking options, core kernel features,
344 and debugging and tracing options are supported.
345
346- "preempt-rt": Applies the ``PREEMPT_RT`` patches and the
347 configuration options required to build a real-time Linux kernel.
348 This kernel type inherits from the "standard" kernel type.
349
350- "tiny": Defines a bare minimum configuration meant to serve as a base
351 for very small Linux kernels. The "tiny" kernel type is independent
352 from the "standard" configuration. Although the "tiny" kernel type
353 does not currently include any source changes, it might in the
354 future.
355
356For any given kernel type, the Metadata is defined by the ``.scc`` (e.g.
357``standard.scc``). Here is a partial listing for the ``standard.scc``
358file, which is found in the ``ktypes/standard`` directory of the
359``yocto-kernel-cache`` Git repository: # Include this kernel type
360fragment to get the standard features and # configuration values. #
361Note: if only the features are desired, but not the configuration # then
362this should be included as: # include ktypes/standard/standard.scc nocfg
363# if no chained configuration is desired, include it as: # include
364ktypes/standard/standard.scc nocfg inherit include ktypes/base/base.scc
365branch standard kconf non-hardware standard.cfg include
366features/kgdb/kgdb.scc . . . include cfg/net/ip6_nf.scc include
367cfg/net/bridge.scc include cfg/systemd.scc include
368features/rfkill/rfkill.scc
369
370As with any ``.scc`` file, a kernel type definition can aggregate other
371``.scc`` files with ``include`` commands. These definitions can also
372directly pull in configuration fragments and patches with the ``kconf``
373and ``patch`` commands, respectively.
374
375.. note::
376
377 It is not strictly necessary to create a kernel type
378 .scc
379 file. The Board Support Package (BSP) file can implicitly define the
380 kernel type using a
381 define
382 KTYPE
383 myktype
384 line. See the "
385 BSP Descriptions
386 " section for more information.
387
388BSP Descriptions
389----------------
390
391BSP descriptions (i.e. ``*.scc`` files) combine kernel types with
392hardware-specific features. The hardware-specific Metadata is typically
393defined independently in the BSP layer, and then aggregated with each
394supported kernel type.
395
396.. note::
397
398 For BSPs supported by the Yocto Project, the BSP description files
399 are located in the
400 bsp
401 directory of the
402 yocto-kernel-cache
403 repository organized under the "Yocto Linux Kernel" heading in the
404 Yocto Project Source Repositories
405 .
406
407This section overviews the BSP description structure, the aggregation
408concepts, and presents a detailed example using a BSP supported by the
409Yocto Project (i.e. BeagleBone Board). For complete information on BSP
410layer file hierarchy, see the `Yocto Project Board Support Package (BSP)
411Developer's Guide <&YOCTO_DOCS_BSP_URL;>`__.
412
413.. _bsp-description-file-overview:
414
415Overview
416~~~~~~~~
417
418For simplicity, consider the following root BSP layer description files
419for the BeagleBone board. These files employ both a structure and naming
420convention for consistency. The naming convention for the file is as
421follows: bsp_root_name-kernel_type.scc Here are some example root layer
422BSP filenames for the BeagleBone Board BSP, which is supported by the
423Yocto Project: beaglebone-standard.scc beaglebone-preempt-rt.scc Each
424file uses the root name (i.e "beaglebone") BSP name followed by the
425kernel type.
426
427Examine the ``beaglebone-standard.scc`` file: define KMACHINE beaglebone
428define KTYPE standard define KARCH arm include
429ktypes/standard/standard.scc branch beaglebone include beaglebone.scc #
430default policy for standard kernels include
431features/latencytop/latencytop.scc include
432features/profiling/profiling.scc Every top-level BSP description file
433should define the ```KMACHINE`` <&YOCTO_DOCS_REF_URL;#var-KMACHINE>`__,
434```KTYPE`` <&YOCTO_DOCS_REF_URL;#var-KTYPE>`__, and
435```KARCH`` <&YOCTO_DOCS_REF_URL;#var-KARCH>`__ variables. These
436variables allow the OpenEmbedded build system to identify the
437description as meeting the criteria set by the recipe being built. This
438example supports the "beaglebone" machine for the "standard" kernel and
439the "arm" architecture.
440
441Be aware that a hard link between the ``KTYPE`` variable and a kernel
442type description file does not exist. Thus, if you do not have the
443kernel type defined in your kernel Metadata as it is here, you only need
444to ensure that the
445```LINUX_KERNEL_TYPE`` <&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE>`__
446variable in the kernel recipe and the ``KTYPE`` variable in the BSP
447description file match.
448
449To separate your kernel policy from your hardware configuration, you
450include a kernel type (``ktype``), such as "standard". In the previous
451example, this is done using the following: include
452ktypes/standard/standard.scc This file aggregates all the configuration
453fragments, patches, and features that make up your standard kernel
454policy. See the "`Kernel Types <#kernel-types>`__" section for more
455information.
456
457To aggregate common configurations and features specific to the kernel
458for mybsp, use the following: include mybsp.scc You can see that in the
459BeagleBone example with the following: include beaglebone.scc For
460information on how to break a complete ``.config`` file into the various
461configuration fragments, see the "`Creating Configuration
462Fragments <#creating-config-fragments>`__" section.
463
464Finally, if you have any configurations specific to the hardware that
465are not in a ``*.scc`` file, you can include them as follows: kconf
466hardware mybsp-extra.cfg The BeagleBone example does not include these
467types of configurations. However, the Malta 32-bit board does
468("mti-malta32"). Here is the ``mti-malta32-le-standard.scc`` file:
469define KMACHINE mti-malta32-le define KMACHINE qemumipsel define KTYPE
470standard define KARCH mips include ktypes/standard/standard.scc branch
471mti-malta32 include mti-malta32.scc kconf hardware mti-malta32-le.cfg
472
473.. _bsp-description-file-example-minnow:
474
475Example
476~~~~~~~
477
478Many real-world examples are more complex. Like any other ``.scc`` file,
479BSP descriptions can aggregate features. Consider the Minnow BSP
480definition given the ``linux-yocto-4.4`` branch of the
481``yocto-kernel-cache`` (i.e.
482``yocto-kernel-cache/bsp/minnow/minnow.scc``):
483
484.. note::
485
486 Although the Minnow Board BSP is unused, the Metadata remains and is
487 being used here just as an example.
488
489include cfg/x86.scc include features/eg20t/eg20t.scc include
490cfg/dmaengine.scc include features/power/intel.scc include cfg/efi.scc
491include features/usb/ehci-hcd.scc include features/usb/ohci-hcd.scc
492include features/usb/usb-gadgets.scc include
493features/usb/touchscreen-composite.scc include cfg/timer/hpet.scc
494include features/leds/leds.scc include features/spi/spidev.scc include
495features/i2c/i2cdev.scc include features/mei/mei-txe.scc # Earlyprintk
496and port debug requires 8250 kconf hardware cfg/8250.cfg kconf hardware
497minnow.cfg kconf hardware minnow-dev.cfg
498
499The ``minnow.scc`` description file includes a hardware configuration
500fragment (``minnow.cfg``) specific to the Minnow BSP as well as several
501more general configuration fragments and features enabling hardware
502found on the machine. This ``minnow.scc`` description file is then
503included in each of the three "minnow" description files for the
504supported kernel types (i.e. "standard", "preempt-rt", and "tiny").
505Consider the "minnow" description for the "standard" kernel type (i.e.
506``minnow-standard.scc``: define KMACHINE minnow define KTYPE standard
507define KARCH i386 include ktypes/standard include minnow.scc # Extra
508minnow configs above the minimal defined in minnow.scc include
509cfg/efi-ext.scc include features/media/media-all.scc include
510features/sound/snd_hda_intel.scc # The following should really be in
511standard.scc # USB live-image support include cfg/usb-mass-storage.scc
512include cfg/boot-live.scc # Basic profiling include
513features/latencytop/latencytop.scc include
514features/profiling/profiling.scc # Requested drivers that don't have an
515existing scc kconf hardware minnow-drivers-extra.cfg The ``include``
516command midway through the file includes the ``minnow.scc`` description
517that defines all enabled hardware for the BSP that is common to all
518kernel types. Using this command significantly reduces duplication.
519
520Now consider the "minnow" description for the "tiny" kernel type (i.e.
521``minnow-tiny.scc``): define KMACHINE minnow define KTYPE tiny define
522KARCH i386 include ktypes/tiny include minnow.scc As you might expect,
523the "tiny" description includes quite a bit less. In fact, it includes
524only the minimal policy defined by the "tiny" kernel type and the
525hardware-specific configuration required for booting the machine along
526with the most basic functionality of the system as defined in the base
527"minnow" description file.
528
529Notice again the three critical variables:
530```KMACHINE`` <&YOCTO_DOCS_REF_URL;#var-KMACHINE>`__,
531```KTYPE`` <&YOCTO_DOCS_REF_URL;#var-KTYPE>`__, and
532```KARCH`` <&YOCTO_DOCS_REF_URL;#var-KARCH>`__. Of these variables, only
533``KTYPE`` has changed to specify the "tiny" kernel type.
534
535Kernel Metadata Location
536========================
537
538Kernel Metadata always exists outside of the kernel tree either defined
539in a kernel recipe (recipe-space) or outside of the recipe. Where you
540choose to define the Metadata depends on what you want to do and how you
541intend to work. Regardless of where you define the kernel Metadata, the
542syntax used applies equally.
543
544If you are unfamiliar with the Linux kernel and only wish to apply a
545configuration and possibly a couple of patches provided to you by
546others, the recipe-space method is recommended. This method is also a
547good approach if you are working with Linux kernel sources you do not
548control or if you just do not want to maintain a Linux kernel Git
549repository on your own. For partial information on how you can define
550kernel Metadata in the recipe-space, see the "`Modifying an Existing
551Recipe <#modifying-an-existing-recipe>`__" section.
552
553Conversely, if you are actively developing a kernel and are already
554maintaining a Linux kernel Git repository of your own, you might find it
555more convenient to work with kernel Metadata kept outside the
556recipe-space. Working with Metadata in this area can make iterative
557development of the Linux kernel more efficient outside of the BitBake
558environment.
559
560Recipe-Space Metadata
561---------------------
562
563When stored in recipe-space, the kernel Metadata files reside in a
564directory hierarchy below
565```FILESEXTRAPATHS`` <&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS>`__. For
566a linux-yocto recipe or for a Linux kernel recipe derived by copying and
567modifying
568``oe-core/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb`` to
569a recipe in your layer, ``FILESEXTRAPATHS`` is typically set to
570``${``\ ```THISDIR`` <&YOCTO_DOCS_REF_URL;#var-THISDIR>`__\ ``}/${``\ ```PN`` <&YOCTO_DOCS_REF_URL;#var-PN>`__\ ``}``.
571See the "`Modifying an Existing
572Recipe <#modifying-an-existing-recipe>`__" section for more information.
573
574Here is an example that shows a trivial tree of kernel Metadata stored
575in recipe-space within a BSP layer: meta-my_bsp_layer/ \`--
576recipes-kernel \`-- linux \`-- linux-yocto \|-- bsp-standard.scc \|--
577bsp.cfg \`-- standard.cfg
578
579When the Metadata is stored in recipe-space, you must take steps to
580ensure BitBake has the necessary information to decide what files to
581fetch and when they need to be fetched again. It is only necessary to
582specify the ``.scc`` files on the
583```SRC_URI`` <&YOCTO_DOCS_REF_URL;#var-SRC_URI>`__. BitBake parses them
584and fetches any files referenced in the ``.scc`` files by the
585``include``, ``patch``, or ``kconf`` commands. Because of this, it is
586necessary to bump the recipe ```PR`` <&YOCTO_DOCS_REF_URL;#var-PR>`__
587value when changing the content of files not explicitly listed in the
588``SRC_URI``.
589
590If the BSP description is in recipe space, you cannot simply list the
591``*.scc`` in the ``SRC_URI`` statement. You need to use the following
592form from your kernel append file: SRC_URI_append_myplatform = " \\
593file://myplatform;type=kmeta;destsuffix=myplatform \\ "
594
595Metadata Outside the Recipe-Space
596---------------------------------
597
598When stored outside of the recipe-space, the kernel Metadata files
599reside in a separate repository. The OpenEmbedded build system adds the
600Metadata to the build as a "type=kmeta" repository through the
601```SRC_URI`` <&YOCTO_DOCS_REF_URL;#var-SRC_URI>`__ variable. As an
602example, consider the following ``SRC_URI`` statement from the
603``linux-yocto_4.12.bb`` kernel recipe: SRC_URI =
604"git://git.yoctoproject.org/linux-yocto-4.12.git;name=machine;branch=${KBRANCH};
605\\
606git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}"
607``${KMETA}``, in this context, is simply used to name the directory into
608which the Git fetcher places the Metadata. This behavior is no different
609than any multi-repository ``SRC_URI`` statement used in a recipe (e.g.
610see the previous section).
611
612You can keep kernel Metadata in a "kernel-cache", which is a directory
613containing configuration fragments. As with any Metadata kept outside
614the recipe-space, you simply need to use the ``SRC_URI`` statement with
615the "type=kmeta" attribute. Doing so makes the kernel Metadata available
616during the configuration phase.
617
618If you modify the Metadata, you must not forget to update the ``SRCREV``
619statements in the kernel's recipe. In particular, you need to update the
620``SRCREV_meta`` variable to match the commit in the ``KMETA`` branch you
621wish to use. Changing the data in these branches and not updating the
622``SRCREV`` statements to match will cause the build to fetch an older
623commit.
624
625Organizing Your Source
626======================
627
628Many recipes based on the ``linux-yocto-custom.bb`` recipe use Linux
629kernel sources that have only a single branch - "master". This type of
630repository structure is fine for linear development supporting a single
631machine and architecture. However, if you work with multiple boards and
632architectures, a kernel source repository with multiple branches is more
633efficient. For example, suppose you need a series of patches for one
634board to boot. Sometimes, these patches are works-in-progress or
635fundamentally wrong, yet they are still necessary for specific boards.
636In these situations, you most likely do not want to include these
637patches in every kernel you build (i.e. have the patches as part of the
638lone "master" branch). It is situations like these that give rise to
639multiple branches used within a Linux kernel sources Git repository.
640
641Repository organization strategies exist that maximize source reuse,
642remove redundancy, and logically order your changes. This section
643presents strategies for the following cases:
644
645- Encapsulating patches in a feature description and only including the
646 patches in the BSP descriptions of the applicable boards.
647
648- Creating a machine branch in your kernel source repository and
649 applying the patches on that branch only.
650
651- Creating a feature branch in your kernel source repository and
652 merging that branch into your BSP when needed.
653
654The approach you take is entirely up to you and depends on what works
655best for your development model.
656
657Encapsulating Patches
658---------------------
659
660if you are reusing patches from an external tree and are not working on
661the patches, you might find the encapsulated feature to be appropriate.
662Given this scenario, you do not need to create any branches in the
663source repository. Rather, you just take the static patches you need and
664encapsulate them within a feature description. Once you have the feature
665description, you simply include that into the BSP description as
666described in the "`BSP Descriptions <#bsp-descriptions>`__" section.
667
668You can find information on how to create patches and BSP descriptions
669in the "`Patches <#patches>`__" and "`BSP
670Descriptions <#bsp-descriptions>`__" sections.
671
672Machine Branches
673----------------
674
675When you have multiple machines and architectures to support, or you are
676actively working on board support, it is more efficient to create
677branches in the repository based on individual machines. Having machine
678branches allows common source to remain in the "master" branch with any
679features specific to a machine stored in the appropriate machine branch.
680This organization method frees you from continually reintegrating your
681patches into a feature.
682
683Once you have a new branch, you can set up your kernel Metadata to use
684the branch a couple different ways. In the recipe, you can specify the
685new branch as the ``KBRANCH`` to use for the board as follows: KBRANCH =
686"mynewbranch" Another method is to use the ``branch`` command in the BSP
687description: mybsp.scc: define KMACHINE mybsp define KTYPE standard
688define KARCH i386 include standard.scc branch mynewbranch include
689mybsp-hw.scc
690
691If you find yourself with numerous branches, you might consider using a
692hierarchical branching system similar to what the Yocto Linux Kernel Git
693repositories use: common/kernel_type/machine
694
695If you had two kernel types, "standard" and "small" for instance, three
696machines, and common as ``mydir``, the branches in your Git repository
697might look like this: mydir/base mydir/standard/base
698mydir/standard/machine_a mydir/standard/machine_b
699mydir/standard/machine_c mydir/small/base mydir/small/machine_a
700
701This organization can help clarify the branch relationships. In this
702case, ``mydir/standard/machine_a`` includes everything in ``mydir/base``
703and ``mydir/standard/base``. The "standard" and "small" branches add
704sources specific to those kernel types that for whatever reason are not
705appropriate for the other branches.
706
707.. note::
708
709 The "base" branches are an artifact of the way Git manages its data
710 internally on the filesystem: Git will not allow you to use
711 mydir/standard
712 and
713 mydir/standard/machine_a
714 because it would have to create a file and a directory named
715 "standard".
716
717Feature Branches
718----------------
719
720When you are actively developing new features, it can be more efficient
721to work with that feature as a branch, rather than as a set of patches
722that have to be regularly updated. The Yocto Project Linux kernel tools
723provide for this with the ``git merge`` command.
724
725To merge a feature branch into a BSP, insert the ``git merge`` command
726after any ``branch`` commands: mybsp.scc: define KMACHINE mybsp define
727KTYPE standard define KARCH i386 include standard.scc branch mynewbranch
728git merge myfeature include mybsp-hw.scc
729
730.. _scc-reference:
731
732SCC Description File Reference
733==============================
734
735This section provides a brief reference for the commands you can use
736within an SCC description file (``.scc``):
737
738- ``branch [ref]``: Creates a new branch relative to the current branch
739 (typically ``${KTYPE}``) using the currently checked-out branch, or
740 "ref" if specified.
741
742- ``define``: Defines variables, such as
743 ```KMACHINE`` <&YOCTO_DOCS_REF_URL;#var-KMACHINE>`__,
744 ```KTYPE`` <&YOCTO_DOCS_REF_URL;#var-KTYPE>`__,
745 ```KARCH`` <&YOCTO_DOCS_REF_URL;#var-KARCH>`__, and
746 ```KFEATURE_DESCRIPTION`` <&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION>`__.
747
748- ``include SCC_FILE``: Includes an SCC file in the current file. The
749 file is parsed as if you had inserted it inline.
750
751- ``kconf [hardware|non-hardware] CFG_FILE``: Queues a configuration
752 fragment for merging into the final Linux ``.config`` file.
753
754- ``git merge GIT_BRANCH``: Merges the feature branch into the current
755 branch.
756
757- ``patch PATCH_FILE``: Applies the patch to the current Git branch.
758
759.. [1]
760 ``scc`` stands for Series Configuration Control, but the naming has
761 less significance in the current implementation of the tooling than
762 it had in the past. Consider ``scc`` files to be description files.