blob: 5c76ed23912eea60c5b450a80a95805c25785bed [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3[<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
4
5<chapter id='kernel-dev-advanced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05006<title>Working with Advanced Metadata (<filename>yocto-kernel-cache</filename>)</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8<section id='kernel-dev-advanced-overview'>
9 <title>Overview</title>
10
11 <para>
12 In addition to supporting configuration fragments and patches, the
13 Yocto Project kernel tools also support rich
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014 <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> that you can
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 use to define complex policies and Board Support Package (BSP) support.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016 The purpose of the Metadata and the tools that manage it is
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 to help you manage the complexity of the configuration and sources
18 used to support multiple BSPs and Linux kernel types.
19 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020
21 <para>
22 Kernel Metadata exists in many places.
23 One area in the Yocto Project
Brad Bishop316dfdd2018-06-25 12:45:53 -040024 <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025 is the <filename>yocto-kernel-cache</filename> Git repository.
26 You can find this repository grouped under the "Yocto Linux Kernel"
27 heading in the
28 <ulink url='&YOCTO_GIT_URL;'>Yocto Project Source Repositories</ulink>.
29 </para>
30
31 <para>
32 Kernel development tools ("kern-tools") exist also in the Yocto
33 Project Source Repositories under the "Yocto Linux Kernel" heading
34 in the <filename>yocto-kernel-tools</filename> Git repository.
35 The recipe that builds these tools is
36 <filename>meta/recipes-kernel/kern-tools/kern-tools-native_git.bb</filename>
37 in the
38 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
39 (e.g. <filename>poky</filename>).
40 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041</section>
42
43<section id='using-kernel-metadata-in-a-recipe'>
44 <title>Using Kernel Metadata in a Recipe</title>
45
46 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047 As mentioned in the introduction, the Yocto Project contains kernel
48 Metadata, which is located in the
49 <filename>yocto-kernel-cache</filename> Git repository.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 This Metadata defines Board Support Packages (BSPs) that
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051 correspond to definitions in linux-yocto recipes for corresponding BSPs.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050052 A BSP consists of an aggregation of kernel policy and enabled
53 hardware-specific features.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 The BSP can be influenced from within the linux-yocto recipe.
55 <note>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056 A Linux kernel recipe that contains kernel Metadata (e.g.
57 inherits from the <filename>linux-yocto.inc</filename> file)
58 is said to be a "linux-yocto style" recipe.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 </note>
60 </para>
61
62 <para>
63 Every linux-yocto style recipe must define the
64 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>
65 variable.
66 This variable is typically set to the same value as the
Brad Bishop316dfdd2018-06-25 12:45:53 -040067 <filename>MACHINE</filename> variable, which is used by
Brad Bishopd7bf8c12018-02-25 22:55:05 -050068 <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 However, in some cases, the variable might instead refer to the
70 underlying platform of the <filename>MACHINE</filename>.
71 </para>
72
73 <para>
74 Multiple BSPs can reuse the same <filename>KMACHINE</filename>
75 name if they are built using the same BSP description.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050076 Multiple Corei7-based BSPs could share the same "intel-corei7-64"
77 value for <filename>KMACHINE</filename>.
78 It is important to realize that <filename>KMACHINE</filename> is
Brad Bishop316dfdd2018-06-25 12:45:53 -040079 just for kernel mapping, while <filename>MACHINE</filename>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050080 is the machine type within a BSP Layer.
81 Even with this distinction, however, these two variables can hold
82 the same value.
83 See the <link linkend='bsp-descriptions'>BSP Descriptions</link>
84 section for more information.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 </para>
86
87 <para>
88 Every linux-yocto style recipe must also indicate the Linux kernel
89 source repository branch used to build the Linux kernel.
90 The <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
91 variable must be set to indicate the branch.
92 <note>
93 You can use the <filename>KBRANCH</filename> value to define an
94 alternate branch typically with a machine override as shown here
Brad Bishopd7bf8c12018-02-25 22:55:05 -050095 from the <filename>meta-yocto-bsp</filename> layer:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050097 KBRANCH_edgerouter = "standard/edgerouter"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098 </literallayout>
99 </note>
100 </para>
101
102 <para>
103 The linux-yocto style recipes can optionally define the following
104 variables:
105 <literallayout class='monospaced'>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500106 KERNEL_FEATURES
107 LINUX_KERNEL_TYPE
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 </literallayout>
109 </para>
110
111 <para>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink>
113 defines the kernel type to be
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 used in assembling the configuration.
115 If you do not specify a <filename>LINUX_KERNEL_TYPE</filename>,
116 it defaults to "standard".
Brad Bishop316dfdd2018-06-25 12:45:53 -0400117 Together with <filename>KMACHINE</filename>,
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 <filename>LINUX_KERNEL_TYPE</filename> defines the search
119 arguments used by the kernel tools to find the
120 appropriate description within the kernel Metadata with which to
121 build out the sources and configuration.
122 The linux-yocto recipes define "standard", "tiny", and "preempt-rt"
123 kernel types.
124 See the "<link linkend='kernel-types'>Kernel Types</link>" section
125 for more information on kernel types.
126 </para>
127
128 <para>
129 During the build, the kern-tools search for the BSP description
130 file that most closely matches the <filename>KMACHINE</filename>
131 and <filename>LINUX_KERNEL_TYPE</filename> variables passed in from the
132 recipe.
133 The tools use the first BSP description it finds that match
134 both variables.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500135 If the tools cannot find a match, they issue a warning.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 </para>
137
138 <para>
139 The tools first search for the <filename>KMACHINE</filename> and
140 then for the <filename>LINUX_KERNEL_TYPE</filename>.
141 If the tools cannot find a partial match, they will use the
142 sources from the <filename>KBRANCH</filename> and any configuration
143 specified in the
144 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
145 </para>
146
147 <para>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500148 You can use the
149 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
150 variable
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151 to include features (configuration fragments, patches, or both) that
152 are not already included by the <filename>KMACHINE</filename> and
153 <filename>LINUX_KERNEL_TYPE</filename> variable combination.
154 For example, to include a feature specified as
155 "features/netfilter/netfilter.scc",
156 specify:
157 <literallayout class='monospaced'>
158 KERNEL_FEATURES += "features/netfilter/netfilter.scc"
159 </literallayout>
160 To include a feature called "cfg/sound.scc" just for the
161 <filename>qemux86</filename> machine, specify:
162 <literallayout class='monospaced'>
163 KERNEL_FEATURES_append_qemux86 = " cfg/sound.scc"
164 </literallayout>
165 The value of the entries in <filename>KERNEL_FEATURES</filename>
166 are dependent on their location within the kernel Metadata itself.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500167 The examples here are taken from the
168 <filename>yocto-kernel-cache</filename> repository.
169 Each branch of this repository contains "features" and "cfg"
170 subdirectories at the top-level.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 For more information, see the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500172 "<link linkend='kernel-metadata-syntax'>Kernel Metadata Syntax</link>"
173 section.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 </para>
175</section>
176
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177<section id='kernel-metadata-syntax'>
178 <title>Kernel Metadata Syntax</title>
179
180 <para>
181 The kernel Metadata consists of three primary types of files:
182 <filename>scc</filename>
183 <footnote>
184 <para>
185 <filename>scc</filename> stands for Series Configuration
186 Control, but the naming has less significance in the
187 current implementation of the tooling than it had in the
188 past.
189 Consider <filename>scc</filename> files to be description files.
190 </para>
191 </footnote>
192 description files, configuration fragments, and patches.
193 The <filename>scc</filename> files define variables and include or
194 otherwise reference any of the three file types.
195 The description files are used to aggregate all types of kernel
196 Metadata into
197 what ultimately describes the sources and the configuration required
198 to build a Linux kernel tailored to a specific machine.
199 </para>
200
201 <para>
202 The <filename>scc</filename> description files are used to define two
203 fundamental types of kernel Metadata:
204 <itemizedlist>
205 <listitem><para>Features</para></listitem>
206 <listitem><para>Board Support Packages (BSPs)</para></listitem>
207 </itemizedlist>
208 </para>
209
210 <para>
211 Features aggregate sources in the form of patches and configuration
212 fragments into a modular reusable unit.
213 You can use features to implement conceptually separate kernel
214 Metadata descriptions such as pure configuration fragments,
215 simple patches, complex features, and kernel types.
216 <link linkend='kernel-types'>Kernel types</link> define general
217 kernel features and policy to be reused in the BSPs.
218 </para>
219
220 <para>
221 BSPs define hardware-specific features and aggregate them with kernel
222 types to form the final description of what will be assembled and built.
223 </para>
224
225 <para>
226 While the kernel Metadata syntax does not enforce any logical
227 separation of configuration fragments, patches, features or kernel
228 types, best practices dictate a logical separation of these types
229 of Metadata.
230 The following Metadata file hierarchy is recommended:
231 <literallayout class='monospaced'>
232 <replaceable>base</replaceable>/
233 bsp/
234 cfg/
235 features/
236 ktypes/
237 patches/
238 </literallayout>
239 </para>
240
241 <para>
242 The <filename>bsp</filename> directory contains the
243 <link linkend='bsp-descriptions'>BSP descriptions</link>.
244 The remaining directories all contain "features".
245 Separating <filename>bsp</filename> from the rest of the structure
246 aids conceptualizing intended usage.
247 </para>
248
249 <para>
250 Use these guidelines to help place your <filename>scc</filename>
251 description files within the structure:
252 <itemizedlist>
253 <listitem><para>If your file contains
254 only configuration fragments, place the file in the
255 <filename>cfg</filename> directory.</para></listitem>
256 <listitem><para>If your file contains
257 only source-code fixes, place the file in the
258 <filename>patches</filename> directory.</para></listitem>
259 <listitem><para>If your file encapsulates
260 a major feature, often combining sources and configurations,
261 place the file in <filename>features</filename> directory.
262 </para></listitem>
263 <listitem><para>If your file aggregates
264 non-hardware configuration and patches in order to define a
265 base kernel policy or major kernel type to be reused across
266 multiple BSPs, place the file in <filename>ktypes</filename>
267 directory.
268 </para></listitem>
269 </itemizedlist>
270 </para>
271
272 <para>
273 These distinctions can easily become blurred - especially as
274 out-of-tree features slowly merge upstream over time.
275 Also, remember that how the description files are placed is
276 a purely logical organization and has no impact on the functionality
277 of the kernel Metadata.
278 There is no impact because all of <filename>cfg</filename>,
279 <filename>features</filename>, <filename>patches</filename>, and
280 <filename>ktypes</filename>, contain "features" as far as the kernel
281 tools are concerned.
282 </para>
283
284 <para>
285 Paths used in kernel Metadata files are relative to
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500286 <replaceable>base</replaceable>, which is either
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500287 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
288 if you are creating Metadata in
289 <link linkend='recipe-space-metadata'>recipe-space</link>,
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500290 or the top level of
291 <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/yocto-kernel-cache/tree/'><filename>yocto-kernel-cache</filename></ulink>
292 if you are creating
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500293 <link linkend='metadata-outside-the-recipe-space'>Metadata outside of the recipe-space</link>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 </para>
295
296 <section id='configuration'>
297 <title>Configuration</title>
298
299 <para>
300 The simplest unit of kernel Metadata is the configuration-only
301 feature.
302 This feature consists of one or more Linux kernel configuration
303 parameters in a configuration fragment file
304 (<filename>.cfg</filename>) and a <filename>.scc</filename> file
305 that describes the fragment.
306 </para>
307
308 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500309 As an example, consider the Symmetric Multi-Processing (SMP)
310 fragment used with the <filename>linux-yocto-4.12</filename>
311 kernel as defined outside of the recipe space (i.e.
312 <filename>yocto-kernel-cache</filename>).
313 This Metadata consists of two files: <filename>smp.scc</filename>
314 and <filename>smp.cfg</filename>.
315 You can find these files in the <filename>cfg</filename> directory
316 of the <filename>yocto-4.12</filename> branch in the
317 <filename>yocto-kernel-cache</filename> Git repository:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500318 <literallayout class='monospaced'>
319 cfg/smp.scc:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500320 define KFEATURE_DESCRIPTION "Enable SMP for 32 bit builds"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500321 define KFEATURE_COMPATIBILITY all
322
323 kconf hardware smp.cfg
324
325 cfg/smp.cfg:
326 CONFIG_SMP=y
327 CONFIG_SCHED_SMT=y
328 # Increase default NR_CPUS from 8 to 64 so that platform with
329 # more than 8 processors can be all activated at boot time
330 CONFIG_NR_CPUS=64
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500331 # The following is needed when setting NR_CPUS to something
332 # greater than 8 on x86 architectures, it should be automatically
333 # disregarded by Kconfig when using a different arch
334 CONFIG_X86_BIGSMP=y
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500335 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500336 You can find general information on configuration fragment files in
337 the
338 "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>"
339 section.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500340 </para>
341
342 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500343 Within the <filename>smp.scc</filename> file, the
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500344 <ulink url='&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION'><filename>KFEATURE_DESCRIPTION</filename></ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500345 statement provides a short description of the fragment.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346 Higher level kernel tools use this description.
347 </para>
348
349 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500350 Also within the <filename>smp.scc</filename> file, the
351 <filename>kconf</filename> command includes the
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500352 actual configuration fragment in an <filename>.scc</filename>
353 file, and the "hardware" keyword identifies the fragment as
354 being hardware enabling, as opposed to general policy,
355 which would use the "non-hardware" keyword.
356 The distinction is made for the benefit of the configuration
357 validation tools, which warn you if a hardware fragment
358 overrides a policy set by a non-hardware fragment.
359 <note>
360 The description file can include multiple
361 <filename>kconf</filename> statements, one per fragment.
362 </note>
363 </para>
364
365 <para>
366 As described in the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500367 "<link linkend='validating-configuration'>Validating Configuration</link>"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500368 section, you can use the following BitBake command to audit your
369 configuration:
370 <literallayout class='monospaced'>
371 $ bitbake linux-yocto -c kernel_configcheck -f
372 </literallayout>
373 </para>
374 </section>
375
376 <section id='patches'>
377 <title>Patches</title>
378
379 <para>
380 Patch descriptions are very similar to configuration fragment
381 descriptions, which are described in the previous section.
382 However, instead of a <filename>.cfg</filename> file, these
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500383 descriptions work with source patches (i.e.
384 <filename>.patch</filename> files).
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500385 </para>
386
387 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500388 A typical patch includes a description file and the patch itself.
389 As an example, consider the build patches used with the
390 <filename>linux-yocto-4.12</filename> kernel as defined outside of
391 the recipe space (i.e. <filename>yocto-kernel-cache</filename>).
392 This Metadata consists of several files:
393 <filename>build.scc</filename> and a set of
394 <filename>*.patch</filename> files.
395 You can find these files in the <filename>patches/build</filename>
396 directory of the <filename>yocto-4.12</filename> branch in the
397 <filename>yocto-kernel-cache</filename> Git repository.
398 </para>
399
400 <para>
401 The following listings show the <filename>build.scc</filename>
402 file and part of the
403 <filename>modpost-mask-trivial-warnings.patch</filename> file:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500404 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500405 patches/build/build.scc:
406 patch arm-serialize-build-targets.patch
407 patch powerpc-serialize-image-targets.patch
408 patch kbuild-exclude-meta-directory-from-distclean-processi.patch
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500409
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500410 # applied by kgit
411 # patch kbuild-add-meta-files-to-the-ignore-li.patch
412
413 patch modpost-mask-trivial-warnings.patch
414 patch menuconfig-check-lxdiaglog.sh-Allow-specification-of.patch
415
416 patches/build/modpost-mask-trivial-warnings.patch:
417 From bd48931bc142bdd104668f3a062a1f22600aae61 Mon Sep 17 00:00:00 2001
418 From: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
419 Date: Sun, 25 Jan 2009 17:58:09 -0500
420 Subject: [PATCH] modpost: mask trivial warnings
421
422 Newer HOSTCC will complain about various stdio fcns because
423 .
424 .
425 .
426 char *dump_write = NULL, *files_source = NULL;
427 int opt;
428 --
429 2.10.1
430
431 generated by cgit v0.10.2 at 2017-09-28 15:23:23 (GMT)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500432 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500433 The description file can include multiple patch statements where
434 each statement handles a single patch.
435 In the example <filename>build.scc</filename> file, five patch
436 statements exist for the five patches in the directory.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500437 </para>
438
439 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500440 You can create a typical <filename>.patch</filename> file using
441 <filename>diff -Nurp</filename> or
442 <filename>git format-patch</filename> commands.
443 For information on how to create patches, see the
444 "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
445 and
446 "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
447 sections.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500448 </para>
449 </section>
450
451 <section id='features'>
452 <title>Features</title>
453
454 <para>
455 Features are complex kernel Metadata types that consist
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500456 of configuration fragments, patches, and possibly other feature
457 description files.
458 As an example, consider the following generic listing:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500459 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500460 features/<replaceable>myfeature</replaceable>.scc
461 define KFEATURE_DESCRIPTION "Enable <replaceable>myfeature</replaceable>"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500462
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500463 patch 0001-<replaceable>myfeature</replaceable>-core.patch
464 patch 0002-<replaceable>myfeature</replaceable>-interface.patch
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500465
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500466 include cfg/<replaceable>myfeature</replaceable>_dependency.scc
467 kconf non-hardware <replaceable>myfeature</replaceable>.cfg
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500468 </literallayout>
469 This example shows how the <filename>patch</filename> and
470 <filename>kconf</filename> commands are used as well as
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500471 how an additional feature description file is included with
472 the <filename>include</filename> command.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500473 </para>
474
475 <para>
476 Typically, features are less granular than configuration
477 fragments and are more likely than configuration fragments
478 and patches to be the types of things you want to specify
479 in the <filename>KERNEL_FEATURES</filename> variable of the
480 Linux kernel recipe.
481 See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>"
482 section earlier in the manual.
483 </para>
484 </section>
485
486 <section id='kernel-types'>
487 <title>Kernel Types</title>
488
489 <para>
490 A kernel type defines a high-level kernel policy by
491 aggregating non-hardware configuration fragments with
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500492 patches you want to use when building a Linux kernel of a
493 specific type (e.g. a real-time kernel).
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500494 Syntactically, kernel types are no different than features
495 as described in the "<link linkend='features'>Features</link>"
496 section.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500497 The
498 <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink>
499 variable in the kernel recipe selects the kernel type.
500 For example, in the <filename>linux-yocto_4.12.bb</filename>
501 kernel recipe found in
502 <filename>poky/meta/recipes-kernel/linux</filename>, a
503 <ulink url='&YOCTO_DOCS_BB_URL;#require-inclusion'><filename>require</filename></ulink>
504 directive includes the
505 <filename>poky/meta/recipes-kernel/linux/linux-yocto.inc</filename>
506 file, which has the following statement that defines the default
507 kernel type:
508 <literallayout class='monospaced'>
509 LINUX_KERNEL_TYPE ??= "standard"
510 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500511 </para>
512
513 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500514 Another example would be the real-time kernel (i.e.
515 <filename>linux-yocto-rt_4.12.bb</filename>).
516 This kernel recipe directly sets the kernel type as follows:
517 <literallayout class='monospaced'>
518 LINUX_KERNEL_TYPE = "preempt-rt"
519 </literallayout>
520 <note>
521 You can find kernel recipes in the
522 <filename>meta/recipes-kernel/linux</filename> directory of the
523 <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
524 (e.g. <filename>poky/meta/recipes-kernel/linux/linux-yocto_4.12.bb</filename>).
525 See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>"
526 section for more information.
527 </note>
528 </para>
529
530 <para>
531 Three kernel types ("standard", "tiny", and "preempt-rt") are
532 supported for Linux Yocto kernels:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500533 <itemizedlist>
534 <listitem><para>"standard":
535 Includes the generic Linux kernel policy of the Yocto
536 Project linux-yocto kernel recipes.
537 This policy includes, among other things, which file
538 systems, networking options, core kernel features, and
539 debugging and tracing options are supported.
540 </para></listitem>
541 <listitem><para>"preempt-rt":
542 Applies the <filename>PREEMPT_RT</filename>
543 patches and the configuration options required to
544 build a real-time Linux kernel.
545 This kernel type inherits from the "standard" kernel type.
546 </para></listitem>
547 <listitem><para>"tiny":
548 Defines a bare minimum configuration meant to serve as a
549 base for very small Linux kernels.
550 The "tiny" kernel type is independent from the "standard"
551 configuration.
552 Although the "tiny" kernel type does not currently include
553 any source changes, it might in the future.
554 </para></listitem>
555 </itemizedlist>
556 </para>
557
558 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500559 For any given kernel type, the Metadata is defined by the
560 <filename>.scc</filename> (e.g. <filename>standard.scc</filename>).
561 Here is a partial listing for the <filename>standard.scc</filename>
562 file, which is found in the <filename>ktypes/standard</filename>
563 directory of the <filename>yocto-kernel-cache</filename> Git
564 repository:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500565 <literallayout class='monospaced'>
566 # Include this kernel type fragment to get the standard features and
567 # configuration values.
568
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500569 # Note: if only the features are desired, but not the configuration
570 # then this should be included as:
571 # include ktypes/standard/standard.scc nocfg
572 # if no chained configuration is desired, include it as:
573 # include ktypes/standard/standard.scc nocfg inherit
574
575
576
577 include ktypes/base/base.scc
578 branch standard
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500579
580 kconf non-hardware standard.cfg
581
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500582 include features/kgdb/kgdb.scc
583 .
584 .
585 .
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500586
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500587 include cfg/net/ip6_nf.scc
588 include cfg/net/bridge.scc
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500589
590 include cfg/systemd.scc
591
592 include features/rfkill/rfkill.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500593 </literallayout>
594 </para>
595
596 <para>
597 As with any <filename>.scc</filename> file, a
598 kernel type definition can aggregate other
599 <filename>.scc</filename> files with
600 <filename>include</filename> commands.
601 These definitions can also directly pull in
602 configuration fragments and patches with the
603 <filename>kconf</filename> and <filename>patch</filename>
604 commands, respectively.
605 </para>
606
607 <note>
608 It is not strictly necessary to create a kernel type
609 <filename>.scc</filename> file.
610 The Board Support Package (BSP) file can implicitly define
611 the kernel type using a <filename>define
612 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'>KTYPE</ulink> myktype</filename>
613 line.
614 See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
615 section for more information.
616 </note>
617 </section>
618
619 <section id='bsp-descriptions'>
620 <title>BSP Descriptions</title>
621
622 <para>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500623 BSP descriptions (i.e. <filename>*.scc</filename> files)
624 combine kernel types with hardware-specific features.
625 The hardware-specific Metadata is typically defined
626 independently in the BSP layer, and then aggregated with each
627 supported kernel type.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500628 <note>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500629 For BSPs supported by the Yocto Project, the BSP description
630 files are located in the <filename>bsp</filename> directory
Brad Bishop316dfdd2018-06-25 12:45:53 -0400631 of the
632 <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/yocto-kernel-cache/tree/bsp'><filename>yocto-kernel-cache</filename></ulink>
633 repository organized under the "Yocto Linux Kernel" heading
634 in the
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500635 <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500636 </note>
637 </para>
638
639 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500640 This section overviews the BSP description structure, the
641 aggregation concepts, and presents a detailed example using
642 a BSP supported by the Yocto Project (i.e. BeagleBone Board).
Brad Bishop316dfdd2018-06-25 12:45:53 -0400643 For complete information on BSP layer file hierarchy, see the
644 <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500645 </para>
646
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500647 <section id='bsp-description-file-overview'>
648 <title>Overview</title>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500649
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500650 <para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400651 For simplicity, consider the following root BSP layer
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500652 description files for the BeagleBone board.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400653 These files employ both a structure and naming convention
654 for consistency.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500655 The naming convention for the file is as follows:
656 <literallayout class='monospaced'>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400657 <replaceable>bsp_root_name</replaceable>-<replaceable>kernel_type</replaceable>.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500658 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400659 Here are some example root layer BSP filenames for the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500660 BeagleBone Board BSP, which is supported by the Yocto Project:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500661 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500662 beaglebone-standard.scc
663 beaglebone-preempt-rt.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500664 </literallayout>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400665 Each file uses the root name (i.e "beaglebone") BSP name
666 followed by the kernel type.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500667 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500668
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500669 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500670 Examine the <filename>beaglebone-standard.scc</filename>
671 file:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500672 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500673 define KMACHINE beaglebone
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500674 define KTYPE standard
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500675 define KARCH arm
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500676
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500677 include ktypes/standard/standard.scc
678 branch beaglebone
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500679
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500680 include beaglebone.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500681
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500682 # default policy for standard kernels
683 include features/latencytop/latencytop.scc
684 include features/profiling/profiling.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500685 </literallayout>
686 Every top-level BSP description file should define the
687 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>,
688 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>,
689 and <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink>
690 variables.
691 These variables allow the OpenEmbedded build system to identify
692 the description as meeting the criteria set by the recipe being
693 built.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500694 This example supports the "beaglebone" machine for the
695 "standard" kernel and the "arm" architecture.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500696 </para>
697
698 <para>
699 Be aware that a hard link between the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500700 <filename>KTYPE</filename> variable and a kernel type
701 description file does not exist.
702 Thus, if you do not have the kernel type defined in your kernel
703 Metadata as it is here, you only need to ensure that the
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500704 <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500705 variable in the kernel recipe and the
706 <filename>KTYPE</filename> variable in the BSP description
707 file match.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500708 </para>
709
710 <para>
711 To separate your kernel policy from your hardware configuration,
712 you include a kernel type (<filename>ktype</filename>), such as
713 "standard".
714 In the previous example, this is done using the following:
715 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500716 include ktypes/standard/standard.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500717 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500718 This file aggregates all the configuration fragments, patches,
719 and features that make up your standard kernel policy.
720 See the "<link linkend='kernel-types'>Kernel Types</link>"
721 section for more information.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500722 </para>
723
724 <para>
725 To aggregate common configurations and features specific to the
726 kernel for <replaceable>mybsp</replaceable>, use the following:
727 <literallayout class='monospaced'>
728 include <replaceable>mybsp</replaceable>.scc
729 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500730 You can see that in the BeagleBone example with the following:
731 <literallayout class='monospaced'>
732 include beaglebone.scc
733 </literallayout>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500734 For information on how to break a complete
735 <filename>.config</filename> file into the various
736 configuration fragments, see the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500737 "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500738 section.
739 </para>
740
741 <para>
742 Finally, if you have any configurations specific to the
743 hardware that are not in a <filename>*.scc</filename> file,
744 you can include them as follows:
745 <literallayout class='monospaced'>
746 kconf hardware <replaceable>mybsp</replaceable>-<replaceable>extra</replaceable>.cfg
747 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500748 The BeagleBone example does not include these types of
749 configurations.
750 However, the Malta 32-bit board does ("mti-malta32").
751 Here is the <filename>mti-malta32-le-standard.scc</filename>
752 file:
753 <literallayout class='monospaced'>
754 define KMACHINE mti-malta32-le
755 define KMACHINE qemumipsel
756 define KTYPE standard
757 define KARCH mips
758
759 include ktypes/standard/standard.scc
760 branch mti-malta32
761
762 include mti-malta32.scc
763 kconf hardware mti-malta32-le.cfg
764 </literallayout>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500765 </para>
766 </section>
767
768 <section id='bsp-description-file-example-minnow'>
769 <title>Example</title>
770
771 <para>
772 Many real-world examples are more complex.
773 Like any other <filename>.scc</filename> file, BSP
774 descriptions can aggregate features.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500775 Consider the Minnow BSP definition given the
776 <filename>linux-yocto-4.4</filename> branch of the
777 <filename>yocto-kernel-cache</filename> (i.e.
778 <filename>yocto-kernel-cache/bsp/minnow/minnow.scc</filename>):
779 <note>
780 Although the Minnow Board BSP is unused, the Metadata
781 remains and is being used here just as an example.
782 </note>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500783 <literallayout class='monospaced'>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500784 include cfg/x86.scc
785 include features/eg20t/eg20t.scc
786 include cfg/dmaengine.scc
787 include features/power/intel.scc
788 include cfg/efi.scc
789 include features/usb/ehci-hcd.scc
790 include features/usb/ohci-hcd.scc
791 include features/usb/usb-gadgets.scc
792 include features/usb/touchscreen-composite.scc
793 include cfg/timer/hpet.scc
794 include features/leds/leds.scc
795 include features/spi/spidev.scc
796 include features/i2c/i2cdev.scc
797 include features/mei/mei-txe.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500798
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500799 # Earlyprintk and port debug requires 8250
800 kconf hardware cfg/8250.cfg
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500801
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500802 kconf hardware minnow.cfg
803 kconf hardware minnow-dev.cfg
804 </literallayout>
805 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500806
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500807 <para>
808 The <filename>minnow.scc</filename> description file includes
809 a hardware configuration fragment
810 (<filename>minnow.cfg</filename>) specific to the Minnow
811 BSP as well as several more general configuration
812 fragments and features enabling hardware found on the
813 machine.
814 This <filename>minnow.scc</filename> description file is then
815 included in each of the three
816 "minnow" description files for the supported kernel types
817 (i.e. "standard", "preempt-rt", and "tiny").
818 Consider the "minnow" description for the "standard" kernel
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500819 type (i.e. <filename>minnow-standard.scc</filename>:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500820 <literallayout class='monospaced'>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500821 define KMACHINE minnow
822 define KTYPE standard
823 define KARCH i386
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500824
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500825 include ktypes/standard
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500826
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500827 include minnow.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500828
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500829 # Extra minnow configs above the minimal defined in minnow.scc
830 include cfg/efi-ext.scc
831 include features/media/media-all.scc
832 include features/sound/snd_hda_intel.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500833
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500834 # The following should really be in standard.scc
835 # USB live-image support
836 include cfg/usb-mass-storage.scc
837 include cfg/boot-live.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500838
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500839 # Basic profiling
840 include features/latencytop/latencytop.scc
841 include features/profiling/profiling.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500842
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500843 # Requested drivers that don't have an existing scc
844 kconf hardware minnow-drivers-extra.cfg
845 </literallayout>
846 The <filename>include</filename> command midway through the file
847 includes the <filename>minnow.scc</filename> description that
848 defines all enabled hardware for the BSP that is common to
849 all kernel types.
850 Using this command significantly reduces duplication.
851 </para>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500852
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500853 <para>
854 Now consider the "minnow" description for the "tiny" kernel
Brad Bishop316dfdd2018-06-25 12:45:53 -0400855 type (i.e. <filename>minnow-tiny.scc</filename>):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500856 <literallayout class='monospaced'>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500857 define KMACHINE minnow
858 define KTYPE tiny
859 define KARCH i386
860
861 include ktypes/tiny
862
863 include minnow.scc
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500864 </literallayout>
865 As you might expect, the "tiny" description includes quite a
866 bit less.
867 In fact, it includes only the minimal policy defined by the
868 "tiny" kernel type and the hardware-specific configuration
869 required for booting the machine along with the most basic
870 functionality of the system as defined in the base "minnow"
871 description file.
872 </para>
873
874 <para>
875 Notice again the three critical variables:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500876 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>,
877 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>,
878 and
879 <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink>.
880 Of these variables, only <filename>KTYPE</filename>
881 has changed to specify the "tiny" kernel type.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500882 </para>
883 </section>
884 </section>
885</section>
886
887<section id='kernel-metadata-location'>
888 <title>Kernel Metadata Location</title>
889
890 <para>
891 Kernel Metadata always exists outside of the kernel tree either
892 defined in a kernel recipe (recipe-space) or outside of the recipe.
893 Where you choose to define the Metadata depends on what you want
894 to do and how you intend to work.
895 Regardless of where you define the kernel Metadata, the syntax used
896 applies equally.
897 </para>
898
899 <para>
900 If you are unfamiliar with the Linux kernel and only wish
901 to apply a configuration and possibly a couple of patches provided to
902 you by others, the recipe-space method is recommended.
903 This method is also a good approach if you are working with Linux kernel
904 sources you do not control or if you just do not want to maintain a
905 Linux kernel Git repository on your own.
906 For partial information on how you can define kernel Metadata in
907 the recipe-space, see the
908 "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>"
909 section.
910 </para>
911
912 <para>
913 Conversely, if you are actively developing a kernel and are already
914 maintaining a Linux kernel Git repository of your own, you might find
915 it more convenient to work with kernel Metadata kept outside the
916 recipe-space.
917 Working with Metadata in this area can make iterative development of
918 the Linux kernel more efficient outside of the BitBake environment.
919 </para>
920
921 <section id='recipe-space-metadata'>
922 <title>Recipe-Space Metadata</title>
923
924 <para>
925 When stored in recipe-space, the kernel Metadata files reside in a
926 directory hierarchy below
927 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>.
928 For a linux-yocto recipe or for a Linux kernel recipe derived
929 by copying and modifying
930 <filename>oe-core/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb</filename>
931 to a recipe in your layer, <filename>FILESEXTRAPATHS</filename>
932 is typically set to
933 <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>.
934 See the "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>"
935 section for more information.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500936 </para>
937
938 <para>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500939 Here is an example that shows a trivial tree of kernel Metadata
940 stored in recipe-space within a BSP layer:
941 <literallayout class='monospaced'>
942 meta-<replaceable>my_bsp_layer</replaceable>/
943 `-- recipes-kernel
944 `-- linux
945 `-- linux-yocto
946 |-- bsp-standard.scc
947 |-- bsp.cfg
948 `-- standard.cfg
949 </literallayout>
950 </para>
951
952 <para>
953 When the Metadata is stored in recipe-space, you must take
954 steps to ensure BitBake has the necessary information to decide
955 what files to fetch and when they need to be fetched again.
956 It is only necessary to specify the <filename>.scc</filename>
957 files on the
958 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
959 BitBake parses them and fetches any files referenced in the
960 <filename>.scc</filename> files by the <filename>include</filename>,
961 <filename>patch</filename>, or <filename>kconf</filename> commands.
962 Because of this, it is necessary to bump the recipe
963 <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
964 value when changing the content of files not explicitly listed
965 in the <filename>SRC_URI</filename>.
966 </para>
967
968 <para>
969 If the BSP description is in recipe space, you cannot simply list
970 the <filename>*.scc</filename> in the <filename>SRC_URI</filename>
971 statement.
972 You need to use the following form from your kernel append file:
973 <literallayout class='monospaced'>
974 SRC_URI_append_<replaceable>myplatform</replaceable> = " \
975 file://<replaceable>myplatform</replaceable>;type=kmeta;destsuffix=<replaceable>myplatform</replaceable> \
976 "
977 </literallayout>
978 </para>
979 </section>
980
981 <section id='metadata-outside-the-recipe-space'>
982 <title>Metadata Outside the Recipe-Space</title>
983
984 <para>
985 When stored outside of the recipe-space, the kernel Metadata
986 files reside in a separate repository.
987 The OpenEmbedded build system adds the Metadata to the build as
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500988 a "type=kmeta" repository through the
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500989 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
990 variable.
991 As an example, consider the following <filename>SRC_URI</filename>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500992 statement from the <filename>linux-yocto_4.12.bb</filename>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500993 kernel recipe:
994 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500995 SRC_URI = "git://git.yoctoproject.org/linux-yocto-4.12.git;name=machine;branch=${KBRANCH}; \
996 git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500997 </literallayout>
998 <filename>${KMETA}</filename>, in this context, is simply used to
999 name the directory into which the Git fetcher places the Metadata.
1000 This behavior is no different than any multi-repository
1001 <filename>SRC_URI</filename> statement used in a recipe (e.g.
1002 see the previous section).
1003 </para>
1004
1005 <para>
1006 You can keep kernel Metadata in a "kernel-cache", which is a
1007 directory containing configuration fragments.
1008 As with any Metadata kept outside the recipe-space, you simply
1009 need to use the <filename>SRC_URI</filename> statement with the
1010 "type=kmeta" attribute.
1011 Doing so makes the kernel Metadata available during the
1012 configuration phase.
1013 </para>
1014
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001015 <para>
1016 If you modify the Metadata, you must not forget to update the
Brad Bishop316dfdd2018-06-25 12:45:53 -04001017 <filename>SRCREV</filename> statements in the kernel's recipe.
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001018 In particular, you need to update the
1019 <filename>SRCREV_meta</filename> variable to match the commit in
1020 the <filename>KMETA</filename> branch you wish to use.
1021 Changing the data in these branches and not updating the
1022 <filename>SRCREV</filename> statements to match will cause the
1023 build to fetch an older commit.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001024 </para>
1025 </section>
1026</section>
1027
1028<section id='organizing-your-source'>
1029 <title>Organizing Your Source</title>
1030
1031 <para>
1032 Many recipes based on the <filename>linux-yocto-custom.bb</filename>
1033 recipe use Linux kernel sources that have only a single
1034 branch - "master".
1035 This type of repository structure is fine for linear development
1036 supporting a single machine and architecture.
1037 However, if you work with multiple boards and architectures,
1038 a kernel source repository with multiple branches is more
1039 efficient.
1040 For example, suppose you need a series of patches for one board to boot.
1041 Sometimes, these patches are works-in-progress or fundamentally wrong,
1042 yet they are still necessary for specific boards.
1043 In these situations, you most likely do not want to include these
1044 patches in every kernel you build (i.e. have the patches as part of
1045 the lone "master" branch).
1046 It is situations like these that give rise to multiple branches used
1047 within a Linux kernel sources Git repository.
1048 </para>
1049
1050 <para>
1051 Repository organization strategies exist that maximize source reuse,
1052 remove redundancy, and logically order your changes.
1053 This section presents strategies for the following cases:
1054 <itemizedlist>
1055 <listitem><para>Encapsulating patches in a feature description
1056 and only including the patches in the BSP descriptions of
1057 the applicable boards.</para></listitem>
1058 <listitem><para>Creating a machine branch in your
1059 kernel source repository and applying the patches on that
1060 branch only.</para></listitem>
1061 <listitem><para>Creating a feature branch in your
1062 kernel source repository and merging that branch into your
1063 BSP when needed.</para></listitem>
1064 </itemizedlist>
1065 </para>
1066
1067 <para>
1068 The approach you take is entirely up to you
1069 and depends on what works best for your development model.
1070 </para>
1071
1072 <section id='encapsulating-patches'>
1073 <title>Encapsulating Patches</title>
1074
1075 <para>
1076 if you are reusing patches from an external tree and are not
1077 working on the patches, you might find the encapsulated feature
1078 to be appropriate.
1079 Given this scenario, you do not need to create any branches in the
1080 source repository.
1081 Rather, you just take the static patches you need and encapsulate
1082 them within a feature description.
1083 Once you have the feature description, you simply include that into
1084 the BSP description as described in the
1085 "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
1086 section.
1087 </para>
1088
1089 <para>
1090 You can find information on how to create patches and BSP
1091 descriptions in the "<link linkend='patches'>Patches</link>" and
1092 "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
1093 sections.
1094 </para>
1095 </section>
1096
1097 <section id='machine-branches'>
1098 <title>Machine Branches</title>
1099
1100 <para>
1101 When you have multiple machines and architectures to support,
1102 or you are actively working on board support, it is more
1103 efficient to create branches in the repository based on
1104 individual machines.
1105 Having machine branches allows common source to remain in the
1106 "master" branch with any features specific to a machine stored
1107 in the appropriate machine branch.
1108 This organization method frees you from continually reintegrating
1109 your patches into a feature.
1110 </para>
1111
1112 <para>
1113 Once you have a new branch, you can set up your kernel Metadata
1114 to use the branch a couple different ways.
1115 In the recipe, you can specify the new branch as the
1116 <filename>KBRANCH</filename> to use for the board as
1117 follows:
1118 <literallayout class='monospaced'>
1119 KBRANCH = "mynewbranch"
1120 </literallayout>
1121 Another method is to use the <filename>branch</filename> command
1122 in the BSP description:
1123 <literallayout class='monospaced'>
1124 mybsp.scc:
1125 define KMACHINE mybsp
1126 define KTYPE standard
1127 define KARCH i386
1128 include standard.scc
1129
1130 branch mynewbranch
1131
1132 include mybsp-hw.scc
1133 </literallayout>
1134 </para>
1135
1136 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001137 If you find yourself with numerous branches, you might consider
1138 using a hierarchical branching system similar to what the
1139 Yocto Linux Kernel Git repositories use:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001140 <literallayout class='monospaced'>
1141 <replaceable>common</replaceable>/<replaceable>kernel_type</replaceable>/<replaceable>machine</replaceable>
1142 </literallayout>
1143 </para>
1144
1145 <para>
1146 If you had two kernel types, "standard" and "small" for
1147 instance, three machines, and <replaceable>common</replaceable>
1148 as <filename>mydir</filename>, the branches in your
1149 Git repository might look like this:
1150 <literallayout class='monospaced'>
1151 mydir/base
1152 mydir/standard/base
1153 mydir/standard/machine_a
1154 mydir/standard/machine_b
1155 mydir/standard/machine_c
1156 mydir/small/base
1157 mydir/small/machine_a
1158 </literallayout>
1159 </para>
1160
1161 <para>
1162 This organization can help clarify the branch relationships.
1163 In this case, <filename>mydir/standard/machine_a</filename>
1164 includes everything in <filename>mydir/base</filename> and
1165 <filename>mydir/standard/base</filename>.
1166 The "standard" and "small" branches add sources specific to those
1167 kernel types that for whatever reason are not appropriate for the
1168 other branches.
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001169 <note>
1170 The "base" branches are an artifact of the way Git manages
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001171 its data internally on the filesystem: Git will not allow you
1172 to use <filename>mydir/standard</filename> and
1173 <filename>mydir/standard/machine_a</filename> because it
1174 would have to create a file and a directory named "standard".
1175 </note>
1176 </para>
1177 </section>
1178
1179 <section id='feature-branches'>
1180 <title>Feature Branches</title>
1181
1182 <para>
1183 When you are actively developing new features, it can be more
1184 efficient to work with that feature as a branch, rather than
1185 as a set of patches that have to be regularly updated.
1186 The Yocto Project Linux kernel tools provide for this with
1187 the <filename>git merge</filename> command.
1188 </para>
1189
1190 <para>
1191 To merge a feature branch into a BSP, insert the
1192 <filename>git merge</filename> command after any
1193 <filename>branch</filename> commands:
1194 <literallayout class='monospaced'>
1195 mybsp.scc:
1196 define KMACHINE mybsp
1197 define KTYPE standard
1198 define KARCH i386
1199 include standard.scc
1200
1201 branch mynewbranch
1202 git merge myfeature
1203
1204 include mybsp-hw.scc
1205 </literallayout>
1206 </para>
1207 </section>
1208</section>
1209
1210<section id='scc-reference'>
1211 <title>SCC Description File Reference</title>
1212
1213 <para>
1214 This section provides a brief reference for the commands you can use
1215 within an SCC description file (<filename>.scc</filename>):
1216 <itemizedlist>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001217 <listitem><para>
1218 <filename>branch [ref]</filename>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001219 Creates a new branch relative to the current branch
1220 (typically <filename>${KTYPE}</filename>) using
1221 the currently checked-out branch, or "ref" if specified.
1222 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001223 <listitem><para>
1224 <filename>define</filename>:
Brad Bishop316dfdd2018-06-25 12:45:53 -04001225 Defines variables, such as
1226 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>,
1227 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>,
1228 <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink>,
1229 and
1230 <ulink url='&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION'><filename>KFEATURE_DESCRIPTION</filename></ulink>.
1231 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001232 <listitem><para>
1233 <filename>include SCC_FILE</filename>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001234 Includes an SCC file in the current file.
1235 The file is parsed as if you had inserted it inline.
1236 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001237 <listitem><para>
1238 <filename>kconf [hardware|non-hardware] CFG_FILE</filename>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001239 Queues a configuration fragment for merging into the final
1240 Linux <filename>.config</filename> file.</para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001241 <listitem><para>
1242 <filename>git merge GIT_BRANCH</filename>:
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001243 Merges the feature branch into the current branch.
1244 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001245 <listitem><para>
1246 <filename>patch PATCH_FILE</filename>:
1247 Applies the patch to the current Git branch.
1248 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001249 </itemizedlist>
1250 </para>
1251</section>
1252
1253</chapter>
1254<!--
1255vim: expandtab tw=80 ts=4
1256-->