Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 6 | <title>Working with Advanced Metadata (<filename>yocto-kernel-cache</filename>)</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 14 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> that you can |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | use to define complex policies and Board Support Package (BSP) support. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | The purpose of the Metadata and the tools that manage it is |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | to help you manage the complexity of the configuration and sources |
| 18 | used to support multiple BSPs and Linux kernel types. |
| 19 | </para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 20 | |
| 21 | <para> |
| 22 | Kernel Metadata exists in many places. |
| 23 | One area in the Yocto Project |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | </section> |
| 42 | |
| 43 | <section id='using-kernel-metadata-in-a-recipe'> |
| 44 | <title>Using Kernel Metadata in a Recipe</title> |
| 45 | |
| 46 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 47 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | This Metadata defines Board Support Packages (BSPs) that |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 51 | correspond to definitions in linux-yocto recipes for corresponding BSPs. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 52 | A BSP consists of an aggregation of kernel policy and enabled |
| 53 | hardware-specific features. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 54 | The BSP can be influenced from within the linux-yocto recipe. |
| 55 | <note> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 56 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | </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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 67 | <filename>MACHINE</filename> variable, which is used by |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 79 | just for kernel mapping, while <filename>MACHINE</filename> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 80 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 95 | from the <filename>meta-yocto-bsp</filename> layer: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 97 | KBRANCH_edgerouter = "standard/edgerouter" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 98 | </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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 106 | KERNEL_FEATURES |
| 107 | LINUX_KERNEL_TYPE |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | </literallayout> |
| 109 | </para> |
| 110 | |
| 111 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 112 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink> |
| 113 | defines the kernel type to be |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | used in assembling the configuration. |
| 115 | If you do not specify a <filename>LINUX_KERNEL_TYPE</filename>, |
| 116 | it defaults to "standard". |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 117 | Together with <filename>KMACHINE</filename>, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 135 | If the tools cannot find a match, they issue a warning. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 136 | </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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 148 | You can use the |
| 149 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink> |
| 150 | variable |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 151 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 167 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | For more information, see the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 172 | "<link linkend='kernel-metadata-syntax'>Kernel Metadata Syntax</link>" |
| 173 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | </para> |
| 175 | </section> |
| 176 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 286 | <replaceable>base</replaceable>, which is either |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 287 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 290 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 293 | <link linkend='metadata-outside-the-recipe-space'>Metadata outside of the recipe-space</link>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 294 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 309 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 318 | <literallayout class='monospaced'> |
| 319 | cfg/smp.scc: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 320 | define KFEATURE_DESCRIPTION "Enable SMP for 32 bit builds" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 321 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 331 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 335 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 336 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 340 | </para> |
| 341 | |
| 342 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 343 | Within the <filename>smp.scc</filename> file, the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 344 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KFEATURE_DESCRIPTION'><filename>KFEATURE_DESCRIPTION</filename></ulink> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 345 | statement provides a short description of the fragment. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 346 | Higher level kernel tools use this description. |
| 347 | </para> |
| 348 | |
| 349 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 350 | Also within the <filename>smp.scc</filename> file, the |
| 351 | <filename>kconf</filename> command includes the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 352 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 367 | "<link linkend='validating-configuration'>Validating Configuration</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 368 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 383 | descriptions work with source patches (i.e. |
| 384 | <filename>.patch</filename> files). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 385 | </para> |
| 386 | |
| 387 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 388 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 404 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 405 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 409 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 410 | # 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 <paul.gortmaker@windriver.com> |
| 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 432 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 433 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 437 | </para> |
| 438 | |
| 439 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 440 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 448 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 456 | of configuration fragments, patches, and possibly other feature |
| 457 | description files. |
| 458 | As an example, consider the following generic listing: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 459 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 460 | features/<replaceable>myfeature</replaceable>.scc |
| 461 | define KFEATURE_DESCRIPTION "Enable <replaceable>myfeature</replaceable>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 462 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 463 | patch 0001-<replaceable>myfeature</replaceable>-core.patch |
| 464 | patch 0002-<replaceable>myfeature</replaceable>-interface.patch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 465 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 466 | include cfg/<replaceable>myfeature</replaceable>_dependency.scc |
| 467 | kconf non-hardware <replaceable>myfeature</replaceable>.cfg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 468 | </literallayout> |
| 469 | This example shows how the <filename>patch</filename> and |
| 470 | <filename>kconf</filename> commands are used as well as |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 471 | how an additional feature description file is included with |
| 472 | the <filename>include</filename> command. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 473 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 492 | patches you want to use when building a Linux kernel of a |
| 493 | specific type (e.g. a real-time kernel). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 494 | Syntactically, kernel types are no different than features |
| 495 | as described in the "<link linkend='features'>Features</link>" |
| 496 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 497 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 511 | </para> |
| 512 | |
| 513 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 514 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 533 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 559 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 565 | <literallayout class='monospaced'> |
| 566 | # Include this kernel type fragment to get the standard features and |
| 567 | # configuration values. |
| 568 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 569 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 579 | |
| 580 | kconf non-hardware standard.cfg |
| 581 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 582 | include features/kgdb/kgdb.scc |
| 583 | . |
| 584 | . |
| 585 | . |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 586 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 587 | include cfg/net/ip6_nf.scc |
| 588 | include cfg/net/bridge.scc |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 589 | |
| 590 | include cfg/systemd.scc |
| 591 | |
| 592 | include features/rfkill/rfkill.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 593 | </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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 623 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 628 | <note> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 629 | For BSPs supported by the Yocto Project, the BSP description |
| 630 | files are located in the <filename>bsp</filename> directory |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 631 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 635 | <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 636 | </note> |
| 637 | </para> |
| 638 | |
| 639 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 640 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 643 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 645 | </para> |
| 646 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 647 | <section id='bsp-description-file-overview'> |
| 648 | <title>Overview</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 649 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 650 | <para> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 651 | For simplicity, consider the following root BSP layer |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 652 | description files for the BeagleBone board. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 653 | These files employ both a structure and naming convention |
| 654 | for consistency. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 655 | The naming convention for the file is as follows: |
| 656 | <literallayout class='monospaced'> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 657 | <replaceable>bsp_root_name</replaceable>-<replaceable>kernel_type</replaceable>.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 658 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 659 | Here are some example root layer BSP filenames for the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 660 | BeagleBone Board BSP, which is supported by the Yocto Project: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 661 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 662 | beaglebone-standard.scc |
| 663 | beaglebone-preempt-rt.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 664 | </literallayout> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 665 | Each file uses the root name (i.e "beaglebone") BSP name |
| 666 | followed by the kernel type. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 667 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 668 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 669 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 670 | Examine the <filename>beaglebone-standard.scc</filename> |
| 671 | file: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 672 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 673 | define KMACHINE beaglebone |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 674 | define KTYPE standard |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 675 | define KARCH arm |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 676 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 677 | include ktypes/standard/standard.scc |
| 678 | branch beaglebone |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 679 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 680 | include beaglebone.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 681 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 682 | # default policy for standard kernels |
| 683 | include features/latencytop/latencytop.scc |
| 684 | include features/profiling/profiling.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 685 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 694 | This example supports the "beaglebone" machine for the |
| 695 | "standard" kernel and the "arm" architecture. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 696 | </para> |
| 697 | |
| 698 | <para> |
| 699 | Be aware that a hard link between the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 700 | <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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 704 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 705 | variable in the kernel recipe and the |
| 706 | <filename>KTYPE</filename> variable in the BSP description |
| 707 | file match. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 708 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 716 | include ktypes/standard/standard.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 717 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 718 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 722 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 730 | You can see that in the BeagleBone example with the following: |
| 731 | <literallayout class='monospaced'> |
| 732 | include beaglebone.scc |
| 733 | </literallayout> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 734 | For information on how to break a complete |
| 735 | <filename>.config</filename> file into the various |
| 736 | configuration fragments, see the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 737 | "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 738 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 748 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 765 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 775 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 783 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 784 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 798 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 799 | # Earlyprintk and port debug requires 8250 |
| 800 | kconf hardware cfg/8250.cfg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 801 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 802 | kconf hardware minnow.cfg |
| 803 | kconf hardware minnow-dev.cfg |
| 804 | </literallayout> |
| 805 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 806 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 807 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 819 | type (i.e. <filename>minnow-standard.scc</filename>: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 820 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 821 | define KMACHINE minnow |
| 822 | define KTYPE standard |
| 823 | define KARCH i386 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 824 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 825 | include ktypes/standard |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 826 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 827 | include minnow.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 828 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 829 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 833 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 834 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 838 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 839 | # Basic profiling |
| 840 | include features/latencytop/latencytop.scc |
| 841 | include features/profiling/profiling.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 842 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 843 | # 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 852 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 853 | <para> |
| 854 | Now consider the "minnow" description for the "tiny" kernel |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 855 | type (i.e. <filename>minnow-tiny.scc</filename>): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 856 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 857 | define KMACHINE minnow |
| 858 | define KTYPE tiny |
| 859 | define KARCH i386 |
| 860 | |
| 861 | include ktypes/tiny |
| 862 | |
| 863 | include minnow.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 864 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 876 | <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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 882 | </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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 936 | </para> |
| 937 | |
| 938 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 939 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 988 | a "type=kmeta" repository through the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 989 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 992 | statement from the <filename>linux-yocto_4.12.bb</filename> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 993 | kernel recipe: |
| 994 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 995 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 997 | </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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1015 | <para> |
| 1016 | If you modify the Metadata, you must not forget to update the |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1017 | <filename>SRCREV</filename> statements in the kernel's recipe. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1018 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1024 | </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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1137 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1140 | <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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1169 | <note> |
| 1170 | The "base" branches are an artifact of the way Git manages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1171 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1217 | <listitem><para> |
| 1218 | <filename>branch [ref]</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1219 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1223 | <listitem><para> |
| 1224 | <filename>define</filename>: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1225 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1232 | <listitem><para> |
| 1233 | <filename>include SCC_FILE</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1234 | Includes an SCC file in the current file. |
| 1235 | The file is parsed as if you had inserted it inline. |
| 1236 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1237 | <listitem><para> |
| 1238 | <filename>kconf [hardware|non-hardware] CFG_FILE</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1239 | Queues a configuration fragment for merging into the final |
| 1240 | Linux <filename>.config</filename> file.</para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1241 | <listitem><para> |
| 1242 | <filename>git merge GIT_BRANCH</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1243 | Merges the feature branch into the current branch. |
| 1244 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1245 | <listitem><para> |
| 1246 | <filename>patch PATCH_FILE</filename>: |
| 1247 | Applies the patch to the current Git branch. |
| 1248 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1249 | </itemizedlist> |
| 1250 | </para> |
| 1251 | </section> |
| 1252 | |
| 1253 | </chapter> |
| 1254 | <!-- |
| 1255 | vim: expandtab tw=80 ts=4 |
| 1256 | --> |