summaryrefslogtreecommitdiffstats
path: root/documentation/kernel-dev/kernel-dev-advanced.xml
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/kernel-dev/kernel-dev-advanced.xml')
-rw-r--r--documentation/kernel-dev/kernel-dev-advanced.xml1071
1 files changed, 1071 insertions, 0 deletions
diff --git a/documentation/kernel-dev/kernel-dev-advanced.xml b/documentation/kernel-dev/kernel-dev-advanced.xml
new file mode 100644
index 0000000000..4589e4b9fc
--- /dev/null
+++ b/documentation/kernel-dev/kernel-dev-advanced.xml
@@ -0,0 +1,1071 @@
1<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3[<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
4
5<chapter id='kernel-dev-advanced'>
6<title>Working with Advanced Metadata</title>
7
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
14 <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> that you can
15 use to define complex policies and Board Support Package (BSP) support.
16 The purpose of the Metadata and the tools that manage it, known as
17 the kern-tools (<filename>kern-tools-native_git.bb</filename>), is
18 to help you manage the complexity of the configuration and sources
19 used to support multiple BSPs and Linux kernel types.
20 </para>
21</section>
22
23<section id='using-kernel-metadata-in-a-recipe'>
24 <title>Using Kernel Metadata in a Recipe</title>
25
26 <para>
27 The kernel sources in the Yocto Project contain kernel Metadata, which is
28 located in the <filename>meta</filename> branches of the kernel source
29 Git repositories.
30 This Metadata defines Board Support Packages (BSPs) that
31 correspond to definitions in linux-yocto recipes for the same BSPs.
32 A BSP consists of an aggregation of kernel policy and hardware-specific
33 feature enablements.
34 The BSP can be influenced from within the linux-yocto recipe.
35 <note>
36 Linux kernel source that contains kernel Metadata is said to be
37 "linux-yocto style" kernel source.
38 A Linux kernel recipe that inherits from the
39 <filename>linux-yocto.inc</filename> include file is said to be a
40 "linux-yocto style" recipe.
41 </note>
42 </para>
43
44 <para>
45 Every linux-yocto style recipe must define the
46 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>
47 variable.
48 This variable is typically set to the same value as the
49 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
50 variable, which is used by BitBake (e.g. "routerstationpro" or "fri2").
51 Multiple BSPs can reuse the same <filename>KMACHINE</filename>
52 name if they are built using the same BSP description.
53 The "fri2" and "fri2-noemgd" BSP combination
54 in the <filename>meta-intel</filename>
55 layer is a good example of two BSPs using the same
56 <filename>KMACHINE</filename> value (i.e. "fri2").
57 See the <link linkend='bsp-descriptions'>BSP Descriptions</link> section
58 for more information.
59 </para>
60
61 <para>
62 The linux-yocto style recipes can optionally define the following
63 variables:
64 <literallayout class='monospaced'>
65 <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'>KBRANCH</ulink>
66 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'>KERNEL_FEATURES</ulink>
67 <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH_DEFAULT'>KBRANCH_DEFAULT</ulink>
68 <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'>LINUX_KERNEL_TYPE</ulink>
69 </literallayout>
70 <filename>KBRANCH_DEFAULT</filename> defines the Linux kernel source
71 repository's default branch to use to build the Linux kernel.
72 The value is used as the default for <filename>KBRANCH</filename>, which
73 can define an alternate branch typically with a machine override as
74 follows:
75 <literallayout class='monospaced'>
76 KBRANCH_fri2 = "standard/fri2"
77 </literallayout>
78 Unless you specify otherwise, <filename>KBRANCH_DEFAULT</filename>
79 initializes to "master".
80 </para>
81
82 <para>
83 <filename>LINUX_KERNEL_TYPE</filename> defines the kernel type to be
84 used in assembling the configuration.
85 If you do not specify a <filename>LINUX_KERNEL_TYPE</filename>,
86 it defaults to "standard".
87 Together with
88 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>,
89 <filename>LINUX_KERNEL_TYPE</filename> defines the search
90 arguments used by the kernel tools to find the
91 appropriate description within the kernel Metadata with which to
92 build out the sources and configuration.
93 The linux-yocto recipes define "standard", "tiny", and "preempt-rt"
94 kernel types.
95 See the <link linkend='kernel-types'>Kernel Types</link> section
96 for more information on kernel types.
97 </para>
98
99 <para>
100 During the build, the kern-tools search for the BSP description
101 file that most closely matches the <filename>KMACHINE</filename>
102 and <filename>LINUX_KERNEL_TYPE</filename> variables passed in from the
103 recipe.
104 The tools use the first BSP description it finds that match
105 both variables.
106 If the tools cannot find a match, they issue a warning such as
107 the following:
108 <literallayout class='monospaced'>
109 WARNING: Can't find any BSP hardware or required configuration fragments.
110 WARNING: Looked at meta/cfg/broken/fri2-broken/hdw_frags.txt and
111 meta/cfg/broken/fri2-broken/required_frags.txt in directory:
112 meta/cfg/broken/fri2-broken
113 </literallayout>
114 In this example, <filename>KMACHINE</filename> was set to "fri2-broken"
115 and <filename>LINUX_KERNEL_TYPE</filename> was set to "broken".
116 </para>
117
118 <para>
119 The tools first search for the <filename>KMACHINE</filename> and
120 then for the <filename>LINUX_KERNEL_TYPE</filename>.
121 If the tools cannot find a partial match, they will use the
122 sources from the <filename>KBRANCH</filename> and any configuration
123 specified in the
124 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
125 </para>
126
127 <para>
128 You can use the <filename>KERNEL_FEATURES</filename> variable
129 to include features (configuration fragments, patches, or both) that
130 are not already included by the <filename>KMACHINE</filename> and
131 <filename>LINUX_KERNEL_TYPE</filename> variable combination.
132 For example, to include a feature specified as "features/netfilter.scc",
133 specify:
134 <literallayout class='monospaced'>
135 KERNEL_FEATURES += "features/netfilter.scc"
136 </literallayout>
137 To include a feature called "cfg/sound.scc" just for the
138 <filename>qemux86</filename> machine, specify:
139 <literallayout class='monospaced'>
140 KERNEL_FEATURES_append_qemux86 = "cfg/sound.scc"
141 </literallayout>
142 The value of the entries in <filename>KERNEL_FEATURES</filename>
143 are dependent on their location within the kernel Metadata itself.
144 The examples here are taken from the
145 <filename>linux-yocto-3.4</filename> repository where "features"
146 and "cfg" are subdirectories within the
147 <filename>meta/cfg/kernel-cache</filename> directory.
148 For more information, see the
149 "<link linkend='kernel-metadata-syntax'>Kernel Metadata Syntax</link>" section.
150 <note>
151 The processing of the these variables has evolved some between the
152 0.9 and 1.3 releases of the Yocto Project and associated
153 kern-tools sources.
154 The descriptions in this section are accurate for 1.3 and later
155 releases of the Yocto Project.
156 </note>
157 </para>
158</section>
159
160<section id='kernel-metadata-location'>
161 <title>Kernel Metadata Location</title>
162
163 <para>
164 Kernel Metadata can be defined in either the kernel recipe
165 (recipe-space) or in the kernel tree (in-tree).
166 Where you choose to define the Metadata depends on what you want
167 to do and how you intend to work.
168 Regardless of where you define the kernel Metadata, the syntax used
169 applies equally.
170 </para>
171
172 <para>
173 If you are unfamiliar with the Linux kernel and only wish
174 to apply a configuration and possibly a couple of patches provided to
175 you by others, the recipe-space method is recommended.
176 This method is also a good approach if you are working with Linux kernel
177 sources you do not control or if you just do not want to maintain a
178 Linux kernel Git repository on your own.
179 For partial information on how you can define kernel Metadata in
180 the recipe-space, see the
181 "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>"
182 section.
183 </para>
184
185 <para>
186 Conversely, if you are actively developing a kernel and are already
187 maintaining a Linux kernel Git repository of your own, you might find
188 it more convenient to work with the kernel Metadata in the same
189 repository as the Linux kernel sources.
190 This method can make iterative development of the Linux kernel
191 more efficient outside of the BitBake environment.
192 </para>
193
194 <section id='recipe-space-metadata'>
195 <title>Recipe-Space Metadata</title>
196
197 <para>
198 When stored in recipe-space, the kernel Metadata files reside in a
199 directory hierarchy below
200 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>.
201 For a linux-yocto recipe or for a Linux kernel recipe derived
202 by copying and modifying
203 <filename>oe-core/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb</filename>
204 to a recipe in your layer, <filename>FILESEXTRAPATHS</filename>
205 is typically set to
206 <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>.
207 See the "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>"
208 section for more information.
209 </para>
210
211 <para>
212 Here is an example that shows a trivial tree of kernel Metadata
213 stored in recipe-space within a BSP layer:
214 <literallayout class='monospaced'>
215 meta-my_bsp_layer/
216 `-- recipes-kernel
217 `-- linux
218 `-- linux-yocto
219 |-- bsp-standard.scc
220 |-- bsp.cfg
221 `-- standard.cfg
222 </literallayout>
223 </para>
224
225 <para>
226 When the Metadata is stored in recipe-space, you must take
227 steps to ensure BitBake has the necessary information to decide
228 what files to fetch and when they need to be fetched again.
229 It is only necessary to specify the <filename>.scc</filename>
230 files on the
231 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>.
232 BitBake parses them and fetches any files referenced in the
233 <filename>.scc</filename> files by the <filename>include</filename>,
234 <filename>patch</filename>, or <filename>kconf</filename> commands.
235 Because of this, it is necessary to bump the recipe
236 <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>
237 value when changing the content of files not explicitly listed
238 in the <filename>SRC_URI</filename>.
239 </para>
240 </section>
241
242 <section id='in-tree-metadata'>
243 <title>In-Tree Metadata</title>
244
245 <para>
246 When stored in-tree, the kernel Metadata files reside in the
247 <filename>meta</filename> directory of the Linux kernel sources.
248 The <filename>meta</filename> directory can be present in the
249 same repository branch as the sources,
250 such as "master", or <filename>meta</filename> can be its own
251 orphan branch.
252 <note>
253 An orphan branch in Git is a branch with unique history and
254 content to the other branches in the repository.
255 Orphan branches are useful to track Metadata changes
256 independently from the sources of the Linux kernel, while
257 still keeping them together in the same repository.
258 </note>
259 For the purposes of this document, we will discuss all
260 in-tree Metadata as residing below the
261 <filename>meta/cfg/kernel-cache</filename> directory.
262 </para>
263
264 <para>
265 Following is an example that shows how a trivial tree of Metadata
266 is stored in a custom Linux kernel Git repository:
267 <literallayout class='monospaced'>
268 meta/
269 `-- cfg
270 `-- kernel-cache
271 |-- bsp-standard.scc
272 |-- bsp.cfg
273 `-- standard.cfg
274 </literallayout>
275 </para>
276
277 <para>
278 To use a branch different from where the sources reside,
279 specify the branch in the <filename>KMETA</filename> variable
280 in your Linux kernel recipe.
281 Here is an example:
282 <literallayout class='monospaced'>
283 KMETA = "meta"
284 </literallayout>
285 To use the same branch as the sources, set
286 <filename>KMETA</filename> to an empty string:
287 <literallayout class='monospaced'>
288 KMETA = ""
289 </literallayout>
290 If you are working with your own sources and want to create an
291 orphan <filename>meta</filename> branch, use these commands
292 from within your Linux kernel Git repository:
293 <literallayout class='monospaced'>
294 $ git checkout --orphan meta
295 $ git rm -rf .
296 $ git commit --allow-empty -m "Create orphan meta branch"
297 </literallayout>
298 </para>
299
300 <para>
301 If you modify the Metadata in the linux-yocto
302 <filename>meta</filename> branch, you must not forget to update
303 the
304 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
305 statements in the kernel's recipe.
306 In particular, you need to update the
307 <filename>SRCREV_meta</filename> variable to match the commit in
308 the <filename>KMETA</filename> branch you wish to use.
309 Changing the data in these branches and not updating the
310 <filename>SRCREV</filename> statements to match will cause the
311 build to fetch an older commit.
312 </para>
313 </section>
314</section>
315
316<section id='kernel-metadata-syntax'>
317 <title>Kernel Metadata Syntax</title>
318
319 <para>
320 The kernel Metadata consists of three primary types of files:
321 <filename>scc</filename>
322 <footnote>
323 <para>
324 <filename>scc</filename> stands for Series Configuration
325 Control, but the naming has less significance in the
326 current implementation of the tooling than it had in the
327 past.
328 Consider <filename>scc</filename> files to be description files.
329 </para>
330 </footnote>
331 description files, configuration fragments, and patches.
332 The <filename>scc</filename> files define variables and include or
333 otherwise reference any of the three file types.
334 The description files are used to aggregate all types of kernel
335 Metadata into
336 what ultimately describes the sources and the configuration required
337 to build a Linux kernel tailored to a specific machine.
338 </para>
339
340 <para>
341 The <filename>scc</filename> description files are used to define two
342 fundamental types of kernel Metadata:
343 <itemizedlist>
344 <listitem><para>Features</para></listitem>
345 <listitem><para>Board Support Packages (BSPs)</para></listitem>
346 </itemizedlist>
347 </para>
348
349 <para>
350 Features aggregate sources in the form of patches and configuration
351 fragments into a modular reusable unit.
352 You can use features to implement conceptually separate kernel
353 Metadata descriptions such as pure configuration fragments,
354 simple patches, complex features, and kernel types.
355 <link linkend='kernel-types'>Kernel types</link> define general
356 kernel features and policy to be reused in the BSPs.
357 </para>
358
359 <para>
360 BSPs define hardware-specific features and aggregate them with kernel
361 types to form the final description of what will be assembled and built.
362 </para>
363
364 <para>
365 While the kernel Metadata syntax does not enforce any logical
366 separation of configuration fragments, patches, features or kernel
367 types, best practices dictate a logical separation of these types
368 of Metadata.
369 The following Metadata file hierarchy is recommended:
370 <literallayout class='monospaced'>
371 &lt;base&gt;/
372 bsp/
373 cfg/
374 features/
375 ktypes/
376 patches/
377 </literallayout>
378 </para>
379
380 <para>
381 The <filename>bsp</filename> directory contains the
382 <link linkend='bsp-descriptions'>BSP descriptions</link>.
383 The remaining directories all contain "features".
384 Separating <filename>bsp</filename> from the rest of the structure
385 aids conceptualizing intended usage.
386 </para>
387
388 <para>
389 Use these guidelines to help place your <filename>scc</filename>
390 description files within the structure:
391 <itemizedlist>
392 <listitem><para>If your file contains
393 only configuration fragments, place the file in the
394 <filename>cfg</filename> directory.</para></listitem>
395 <listitem><para>If your file contains
396 only source-code fixes, place the file in the
397 <filename>patches</filename> directory.</para></listitem>
398 <listitem><para>If your file encapsulates
399 a major feature, often combining sources and configurations,
400 place the file in <filename>features</filename> directory.
401 </para></listitem>
402 <listitem><para>If your file aggregates
403 non-hardware configuration and patches in order to define a
404 base kernel policy or major kernel type to be reused across
405 multiple BSPs, place the file in <filename>ktypes</filename>
406 directory.
407 </para></listitem>
408 </itemizedlist>
409 </para>
410
411 <para>
412 These distinctions can easily become blurred - especially as
413 out-of-tree features slowly merge upstream over time.
414 Also, remember that how the description files are placed is
415 a purely logical organization and has no impact on the functionality
416 of the kernel Metadata.
417 There is no impact because all of <filename>cfg</filename>,
418 <filename>features</filename>, <filename>patches</filename>, and
419 <filename>ktypes</filename>, contain "features" as far as the kernel
420 tools are concerned.
421 </para>
422
423 <para>
424 Paths used in kernel Metadata files are relative to
425 <filename>&lt;base&gt;</filename>, which is either
426 <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
427 if you are creating Metadata in
428 <link linkend='recipe-space-metadata'>recipe-space</link>,
429 or <filename>meta/cfg/kernel-cache/</filename> if you are creating
430 Metadata <link linkend='in-tree-metadata'>in-tree</link>.
431 </para>
432
433 <section id='configuration'>
434 <title>Configuration</title>
435
436 <para>
437 The simplest unit of kernel Metadata is the configuration-only
438 feature.
439 This feature consists of one or more Linux kernel configuration
440 parameters in a configuration fragment file
441 (<filename>.cfg</filename>) and an <filename>.scc</filename> file
442 that describes the fragment.
443 </para>
444
445 <para>
446 The Symmetric Multi-Processing (SMP) fragment included in the
447 <filename>linux-yocto-3.4</filename> Git repository
448 consists of the following two files:
449 <literallayout class='monospaced'>
450 cfg/smp.scc:
451 define KFEATURE_DESCRIPTION "Enable SMP"
452 kconf hardware smp.cfg
453
454 cfg/smp.cfg:
455 CONFIG_SMP=y
456 CONFIG_SCHED_SMT=y
457 </literallayout>
458 You can find information on configuration fragment files in the
459 "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-config-fragments'>Creating Configuration Fragments</ulink>"
460 section of the Yocto Project Development Manual and in
461 the "<link linkend='generating-configuration-files'>Generating Configuration Files</link>"
462 section earlier in this manual.
463 </para>
464
465 <para>
466 <ulink url='&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION'><filename>KFEATURE_DESCRIPTION</filename></ulink>
467 provides a short description of the fragment.
468 Higher level kernel tools use this description.
469 </para>
470
471 <para>
472 The <filename>kconf</filename> command is used to include the
473 actual configuration fragment in an <filename>.scc</filename>
474 file, and the "hardware" keyword identifies the fragment as
475 being hardware enabling, as opposed to general policy,
476 which would use the "non-hardware" keyword.
477 The distinction is made for the benefit of the configuration
478 validation tools, which warn you if a hardware fragment
479 overrides a policy set by a non-hardware fragment.
480 <note>
481 The description file can include multiple
482 <filename>kconf</filename> statements, one per fragment.
483 </note>
484 </para>
485
486 <para>
487 As described in the
488 "<link linkend='generating-configuration-files'>Generating Configuration Files</link>"
489 section, you can use the following BitBake command to audit your
490 configuration:
491 <literallayout class='monospaced'>
492 $ bitbake linux-yocto -c kernel_configcheck -f
493 </literallayout>
494 </para>
495 </section>
496
497 <section id='patches'>
498 <title>Patches</title>
499
500 <para>
501 Patch descriptions are very similar to configuration fragment
502 descriptions, which are described in the previous section.
503 However, instead of a <filename>.cfg</filename> file, these
504 descriptions work with source patches.
505 </para>
506
507 <para>
508 A typical patch includes a description file and the patch itself:
509 <literallayout class='monospaced'>
510 patches/mypatch.scc:
511 patch mypatch.patch
512
513 patches/mypatch.patch:
514 &lt;typical-patch&gt;
515 </literallayout>
516 You can create the typical <filename>.patch</filename>
517 file using <filename>diff -Nurp</filename> or
518 <filename>git format-patch</filename>.
519 </para>
520
521 <para>
522 The description file can include multiple patch statements,
523 one per patch.
524 </para>
525 </section>
526
527 <section id='features'>
528 <title>Features</title>
529
530 <para>
531 Features are complex kernel Metadata types that consist
532 of configuration fragments (<filename>kconf</filename>), patches
533 (<filename>patch</filename>), and possibly other feature
534 description files (<filename>include</filename>).
535 </para>
536
537 <para>
538 Here is an example that shows a feature description file:
539 <literallayout class='monospaced'>
540 features/myfeature.scc
541 define KFEATURE_DESCRIPTION "Enable myfeature"
542
543 patch 0001-myfeature-core.patch
544 patch 0002-myfeature-interface.patch
545
546 include cfg/myfeature_dependency.scc
547 kconf non-hardware myfeature.cfg
548 </literallayout>
549 This example shows how the <filename>patch</filename> and
550 <filename>kconf</filename> commands are used as well as
551 how an additional feature description file is included.
552 </para>
553
554 <para>
555 Typically, features are less granular than configuration
556 fragments and are more likely than configuration fragments
557 and patches to be the types of things you want to specify
558 in the <filename>KERNEL_FEATURES</filename> variable of the
559 Linux kernel recipe.
560 See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>"
561 section earlier in the manual.
562 </para>
563 </section>
564
565 <section id='kernel-types'>
566 <title>Kernel Types</title>
567
568 <para>
569 A kernel type defines a high-level kernel policy by
570 aggregating non-hardware configuration fragments with
571 patches you want to use when building a Linux kernels of a
572 specific type.
573 Syntactically, kernel types are no different than features
574 as described in the "<link linkend='features'>Features</link>"
575 section.
576 The <filename>LINUX_KERNEL_TYPE</filename> variable in the kernel
577 recipe selects the kernel type.
578 See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>"
579 section for more information.
580 </para>
581
582 <para>
583 As an example, the <filename>linux-yocto-3.4</filename>
584 tree defines three kernel types: "standard",
585 "tiny", and "preempt-rt":
586 <itemizedlist>
587 <listitem><para>"standard":
588 Includes the generic Linux kernel policy of the Yocto
589 Project linux-yocto kernel recipes.
590 This policy includes, among other things, which file
591 systems, networking options, core kernel features, and
592 debugging and tracing options are supported.
593 </para></listitem>
594 <listitem><para>"preempt-rt":
595 Applies the <filename>PREEMPT_RT</filename>
596 patches and the configuration options required to
597 build a real-time Linux kernel.
598 This kernel type inherits from the "standard" kernel type.
599 </para></listitem>
600 <listitem><para>"tiny":
601 Defines a bare minimum configuration meant to serve as a
602 base for very small Linux kernels.
603 The "tiny" kernel type is independent from the "standard"
604 configuration.
605 Although the "tiny" kernel type does not currently include
606 any source changes, it might in the future.
607 </para></listitem>
608 </itemizedlist>
609 </para>
610
611 <para>
612 The "standard" kernel type is defined by
613 <filename>standard.scc</filename>:
614 <literallayout class='monospaced'>
615 # Include this kernel type fragment to get the standard features and
616 # configuration values.
617
618 # Include all standard features
619 include standard-nocfg.scc
620
621 kconf non-hardware standard.cfg
622
623 # individual cfg block section
624 include cfg/fs/devtmpfs.scc
625 include cfg/fs/debugfs.scc
626 include cfg/fs/btrfs.scc
627 include cfg/fs/ext2.scc
628 include cfg/fs/ext3.scc
629 include cfg/fs/ext4.scc
630
631 include cfg/net/ipv6.scc
632 include cfg/net/ip_nf.scc
633 include cfg/net/ip6_nf.scc
634 include cfg/net/bridge.scc
635 </literallayout>
636 </para>
637
638 <para>
639 As with any <filename>.scc</filename> file, a
640 kernel type definition can aggregate other
641 <filename>.scc</filename> files with
642 <filename>include</filename> commands.
643 These definitions can also directly pull in
644 configuration fragments and patches with the
645 <filename>kconf</filename> and <filename>patch</filename>
646 commands, respectively.
647 </para>
648
649 <note>
650 It is not strictly necessary to create a kernel type
651 <filename>.scc</filename> file.
652 The Board Support Package (BSP) file can implicitly define
653 the kernel type using a <filename>define
654 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'>KTYPE</ulink> myktype</filename>
655 line.
656 See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
657 section for more information.
658 </note>
659 </section>
660
661 <section id='bsp-descriptions'>
662 <title>BSP Descriptions</title>
663
664 <para>
665 BSP descriptions combine kernel types with hardware-specific
666 features.
667 The hardware-specific portion is typically defined
668 independently, and then aggregated with each supported kernel
669 type.
670 Consider this simple BSP description that supports the "mybsp"
671 machine:
672 <literallayout class='monospaced'>
673 mybsp.scc:
674 define KMACHINE mybsp
675 define KTYPE standard
676 define KARCH i386
677
678 kconf mybsp.cfg
679 </literallayout>
680 Every BSP description should define the
681 <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>,
682 <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>,
683 and <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink>
684 variables.
685 These variables allow the OpenEmbedded build system to identify
686 the description as meeting the criteria set by the recipe being
687 built.
688 This simple example supports the "mybsp" machine for the "standard"
689 kernel and the "i386" architecture.
690 </para>
691
692 <para>
693 Be aware that a hard link between the
694 <filename>KTYPE</filename> variable and a kernel type
695 description file does not exist.
696 Thus, if you do not have kernel types defined in your kernel
697 Metadata, you only need to ensure that the kernel recipe's
698 <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink>
699 variable and the <filename>KTYPE</filename> variable in the
700 BSP description file match.
701 <note>
702 Future versions of the tooling make the specification of
703 <filename>KTYPE</filename> in the BSP optional.
704 </note>
705 </para>
706
707 <para>
708 If you did want to separate your kernel policy from your
709 hardware configuration, you could do so by specifying a kernel
710 type, such as "standard" and including that description file
711 in the BSP description file.
712 See the "<link linkend='kernel-types'>Kernel Types</link>" section
713 for more information.
714 </para>
715
716 <para>
717 You might also have multiple hardware configurations that you
718 aggregate into a single hardware description file that you
719 could include in the BSP description file, rather than referencing
720 a single <filename>.cfg</filename> file.
721 Consider the following:
722 <literallayout class='monospaced'>
723 mybsp.scc:
724 define KMACHINE mybsp
725 define KTYPE standard
726 define KARCH i386
727
728 include standard.scc
729 include mybsp-hw.scc
730 </literallayout>
731 </para>
732
733 <para>
734 In the above example, <filename>standard.scc</filename>
735 aggregates all the configuration fragments, patches, and
736 features that make up your standard kernel policy whereas
737 <filename>mybsp-hw.scc</filename> aggregates all those necessary
738 to support the hardware available on the "mybsp" machine.
739 For information on how to break a complete
740 <filename>.config</filename> file into the various
741 configuration fragments, see the
742 "<link linkend='generating-configuration-files'>Generating Configuration Files</link>"
743 section.
744 </para>
745
746 <para>
747 Many real-world examples are more complex.
748 Like any other <filename>.scc</filename> file, BSP
749 descriptions can aggregate features.
750 Consider the Fish River Island 2 (fri2)
751 BSP definition from the <filename>linux-yocto-3.4</filename>
752 Git repository:
753 <literallayout class='monospaced'>
754 fri2.scc:
755 kconf hardware fri2.cfg
756
757 include cfg/x86.scc
758 include features/eg20t/eg20t.scc
759 include cfg/dmaengine.scc
760 include features/ericsson-3g/f5521gw.scc
761 include features/power/intel.scc
762 include cfg/efi.scc
763 include features/usb/ehci-hcd.scc
764 include features/usb/ohci-hcd.scc
765 include features/iwlwifi/iwlwifi.scc
766 </literallayout>
767 </para>
768
769 <para>
770 The <filename>fri2.scc</filename> description file includes
771 a hardware configuration fragment
772 (<filename>fri2.cfg</filename>) specific to the Fish River
773 Island 2 BSP as well as several more general configuration
774 fragments and features enabling hardware found on the
775 machine.
776 This description file is then included in each of the three
777 "fri2" description files for the supported kernel types
778 (i.e. "standard", "preempt-rt", and "tiny").
779 Consider the "fri2" description for the "standard" kernel
780 type:
781 <literallayout class='monospaced'>
782 fri2-standard.scc:
783 define KMACHINE fri2
784 define KTYPE standard
785 define KARCH i386
786
787 include ktypes/standard/standard.scc
788 branch fri2
789
790 git merge emgd-1.14
791
792 include fri2.scc
793
794 # Extra fri2 configs above the minimal defined in fri2.scc
795 include cfg/efi-ext.scc
796 include features/drm-emgd/drm-emgd.scc
797 include cfg/vesafb.scc
798
799 # default policy for standard kernels
800 include cfg/usb-mass-storage.scc
801 </literallayout>
802 The <filename>include</filename> command midway through the file
803 includes the <filename>fri2.scc</filename> description that
804 defines all hardware enablements for the BSP that is common to all
805 kernel types.
806 Using this command significantly reduces duplication.
807 </para>
808
809 <para>
810 This "fri2" standard description introduces a few more variables
811 and commands that are worth further discussion.
812 Notice the <filename>branch fri2</filename> command, which creates
813 a machine-specific branch into which source changes are applied.
814 With this branch set up, the <filename>git merge</filename> command
815 uses Git to merge in a feature branch named "emgd-1.14".
816 You could also handle this with the <filename>patch</filename>
817 command.
818 However, for commonly used features such as this, feature branches
819 are a convenient mechanism.
820 See the "<link linkend='feature-branches'>Feature Branches</link>"
821 section for more information.
822 </para>
823
824 <para>
825 Now consider the "fri2" description for the "tiny" kernel type:
826 <literallayout class='monospaced'>
827 fri2-tiny.scc:
828 define KMACHINE fri2
829 define KTYPE tiny
830 define KARCH i386
831
832 include ktypes/tiny/tiny.scc
833 branch fri2
834
835 include fri2.scc
836 </literallayout>
837 As you might expect, the "tiny" description includes quite a
838 bit less.
839 In fact, it includes only the minimal policy defined by the
840 "tiny" kernel type and the hardware-specific configuration required
841 for booting the machine along with the most basic functionality of
842 the system as defined in the base "fri2" description file.
843 </para>
844
845 <para>
846 Notice again the three critical variables:
847 <filename>KMACHINE</filename>, <filename>KTYPE</filename>,
848 and <filename>KARCH</filename>.
849 Of these variables, only the <filename>KTYPE</filename> has changed.
850 It is now set to "tiny".
851 </para>
852 </section>
853</section>
854
855<section id='organizing-your-source'>
856 <title>Organizing Your Source</title>
857
858 <para>
859 Many recipes based on the <filename>linux-yocto-custom.bb</filename>
860 recipe use Linux kernel sources that have only a single
861 branch - "master".
862 This type of repository structure is fine for linear development
863 supporting a single machine and architecture.
864 However, if you work with multiple boards and architectures,
865 a kernel source repository with multiple branches is more
866 efficient.
867 For example, suppose you need a series of patches for one board to boot.
868 Sometimes, these patches are works-in-progress or fundamentally wrong,
869 yet they are still necessary for specific boards.
870 In these situations, you most likely do not want to include these
871 patches in every kernel you build (i.e. have the patches as part of
872 the lone "master" branch).
873 It is situations like these that give rise to multiple branches used
874 within a Linux kernel sources Git repository.
875 </para>
876
877 <para>
878 Repository organization strategies exist that maximize source reuse,
879 remove redundancy, and logically order your changes.
880 This section presents strategies for the following cases:
881 <itemizedlist>
882 <listitem><para>Encapsulating patches in a feature description
883 and only including the patches in the BSP descriptions of
884 the applicable boards.</para></listitem>
885 <listitem><para>Creating a machine branch in your
886 kernel source repository and applying the patches on that
887 branch only.</para></listitem>
888 <listitem><para>Creating a feature branch in your
889 kernel source repository and merging that branch into your
890 BSP when needed.</para></listitem>
891 </itemizedlist>
892 </para>
893
894 <para>
895 The approach you take is entirely up to you
896 and depends on what works best for your development model.
897 </para>
898
899 <section id='encapsulating-patches'>
900 <title>Encapsulating Patches</title>
901
902 <para>
903 if you are reusing patches from an external tree and are not
904 working on the patches, you might find the encapsulated feature
905 to be appropriate.
906 Given this scenario, you do not need to create any branches in the
907 source repository.
908 Rather, you just take the static patches you need and encapsulate
909 them within a feature description.
910 Once you have the feature description, you simply include that into
911 the BSP description as described in the
912 "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
913 section.
914 </para>
915
916 <para>
917 You can find information on how to create patches and BSP
918 descriptions in the "<link linkend='patches'>Patches</link>" and
919 "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
920 sections.
921 </para>
922 </section>
923
924 <section id='machine-branches'>
925 <title>Machine Branches</title>
926
927 <para>
928 When you have multiple machines and architectures to support,
929 or you are actively working on board support, it is more
930 efficient to create branches in the repository based on
931 individual machines.
932 Having machine branches allows common source to remain in the
933 "master" branch with any features specific to a machine stored
934 in the appropriate machine branch.
935 This organization method frees you from continually reintegrating
936 your patches into a feature.
937 </para>
938
939 <para>
940 Once you have a new branch, you can set up your kernel Metadata
941 to use the branch a couple different ways.
942 In the recipe, you can specify the new branch as the
943 <filename>KBRANCH</filename> to use for the board as
944 follows:
945 <literallayout class='monospaced'>
946 KBRANCH = "mynewbranch"
947 </literallayout>
948 Another method is to use the <filename>branch</filename> command
949 in the BSP description:
950 <literallayout class='monospaced'>
951 mybsp.scc:
952 define KMACHINE mybsp
953 define KTYPE standard
954 define KARCH i386
955 include standard.scc
956
957 branch mynewbranch
958
959 include mybsp-hw.scc
960 </literallayout>
961 </para>
962
963 <para>
964 If you find
965 yourself with numerous branches, you might consider using a
966 hierarchical branching system similar to what the linux-yocto Linux
967 kernel repositories use:
968 <literallayout class='monospaced'>
969 &lt;common&gt;/&lt;kernel_type&gt;/&lt;machine&gt;
970 </literallayout>
971 </para>
972
973 <para>
974 If you had two kernel types, "standard" and "small" for
975 instance, and three machines, the branches in your
976 Git repository might look like this:
977 <literallayout class='monospaced'>
978 common/base
979 common/standard/base
980 common/standard/machine_a
981 common/standard/machine_b
982 common/standard/machine_c
983 common/small/base
984 common/small/machine_a
985 </literallayout>
986 </para>
987
988 <para>
989 This organization can help clarify the branch relationships.
990 In this case, <filename>common/standard/machine_a</filename>
991 includes everything in <filename>common/base</filename> and
992 <filename>common/standard/base</filename>.
993 The "standard" and "small" branches add sources specific to those
994 kernel types that for whatever reason are not appropriate for the
995 other branches.
996 <note>The "base" branches are an artifact of the way Git manages
997 its data internally on the filesystem: Git will not allow you
998 to use <filename>common/standard</filename> and
999 <filename>common/standard/machine_a</filename> because it
1000 would have to create a file and a directory named "standard".
1001 </note>
1002 </para>
1003 </section>
1004
1005 <section id='feature-branches'>
1006 <title>Feature Branches</title>
1007
1008 <para>
1009 When you are actively developing new features, it can be more
1010 efficient to work with that feature as a branch, rather than
1011 as a set of patches that have to be regularly updated.
1012 The Yocto Project Linux kernel tools provide for this with
1013 the <filename>git merge</filename> command.
1014 </para>
1015
1016 <para>
1017 To merge a feature branch into a BSP, insert the
1018 <filename>git merge</filename> command after any
1019 <filename>branch</filename> commands:
1020 <literallayout class='monospaced'>
1021 mybsp.scc:
1022 define KMACHINE mybsp
1023 define KTYPE standard
1024 define KARCH i386
1025 include standard.scc
1026
1027 branch mynewbranch
1028 git merge myfeature
1029
1030 include mybsp-hw.scc
1031 </literallayout>
1032 </para>
1033 </section>
1034</section>
1035
1036<section id='scc-reference'>
1037 <title>SCC Description File Reference</title>
1038
1039 <para>
1040 This section provides a brief reference for the commands you can use
1041 within an SCC description file (<filename>.scc</filename>):
1042 <itemizedlist>
1043 <listitem><para><filename>branch [ref]</filename>:
1044 Creates a new branch relative to the current branch
1045 (typically <filename>${KTYPE}</filename>) using
1046 the currently checked-out branch, or "ref" if specified.
1047 </para></listitem>
1048 <listitem><para><filename>define</filename>:
1049 Defines variables, such as <filename>KMACHINE</filename>,
1050 <filename>KTYPE</filename>, <filename>KARCH</filename>,
1051 and <filename>KFEATURE_DESCRIPTION</filename>.</para></listitem>
1052 <listitem><para><filename>include SCC_FILE</filename>:
1053 Includes an SCC file in the current file.
1054 The file is parsed as if you had inserted it inline.
1055 </para></listitem>
1056 <listitem><para><filename>kconf [hardware|non-hardware] CFG_FILE</filename>:
1057 Queues a configuration fragment for merging into the final
1058 Linux <filename>.config</filename> file.</para></listitem>
1059 <listitem><para><filename>git merge GIT_BRANCH</filename>:
1060 Merges the feature branch into the current branch.
1061 </para></listitem>
1062 <listitem><para><filename>patch PATCH_FILE</filename>:
1063 Applies the patch to the current Git branch.</para></listitem>
1064 </itemizedlist>
1065 </para>
1066</section>
1067
1068</chapter>
1069<!--
1070vim: expandtab tw=80 ts=4
1071-->