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 |
| 24 | <ulink url='&YOCTO_DOCS_REF_URL;#source-repositories'>Source Repositories</ulink> |
| 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 |
| 67 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 68 | variable, which is used by |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 69 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | However, in some cases, the variable might instead refer to the |
| 71 | underlying platform of the <filename>MACHINE</filename>. |
| 72 | </para> |
| 73 | |
| 74 | <para> |
| 75 | Multiple BSPs can reuse the same <filename>KMACHINE</filename> |
| 76 | name if they are built using the same BSP description. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 77 | Multiple Corei7-based BSPs could share the same "intel-corei7-64" |
| 78 | value for <filename>KMACHINE</filename>. |
| 79 | It is important to realize that <filename>KMACHINE</filename> is |
| 80 | just for kernel mapping, while |
| 81 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> |
| 82 | is the machine type within a BSP Layer. |
| 83 | Even with this distinction, however, these two variables can hold |
| 84 | the same value. |
| 85 | See the <link linkend='bsp-descriptions'>BSP Descriptions</link> |
| 86 | section for more information. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | </para> |
| 88 | |
| 89 | <para> |
| 90 | Every linux-yocto style recipe must also indicate the Linux kernel |
| 91 | source repository branch used to build the Linux kernel. |
| 92 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> |
| 93 | variable must be set to indicate the branch. |
| 94 | <note> |
| 95 | You can use the <filename>KBRANCH</filename> value to define an |
| 96 | alternate branch typically with a machine override as shown here |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 97 | from the <filename>meta-yocto-bsp</filename> layer: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 98 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 99 | KBRANCH_edgerouter = "standard/edgerouter" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | </literallayout> |
| 101 | </note> |
| 102 | </para> |
| 103 | |
| 104 | <para> |
| 105 | The linux-yocto style recipes can optionally define the following |
| 106 | variables: |
| 107 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 108 | KERNEL_FEATURES |
| 109 | LINUX_KERNEL_TYPE |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | </literallayout> |
| 111 | </para> |
| 112 | |
| 113 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink> |
| 115 | defines the kernel type to be |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | used in assembling the configuration. |
| 117 | If you do not specify a <filename>LINUX_KERNEL_TYPE</filename>, |
| 118 | it defaults to "standard". |
| 119 | Together with |
| 120 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>, |
| 121 | <filename>LINUX_KERNEL_TYPE</filename> defines the search |
| 122 | arguments used by the kernel tools to find the |
| 123 | appropriate description within the kernel Metadata with which to |
| 124 | build out the sources and configuration. |
| 125 | The linux-yocto recipes define "standard", "tiny", and "preempt-rt" |
| 126 | kernel types. |
| 127 | See the "<link linkend='kernel-types'>Kernel Types</link>" section |
| 128 | for more information on kernel types. |
| 129 | </para> |
| 130 | |
| 131 | <para> |
| 132 | During the build, the kern-tools search for the BSP description |
| 133 | file that most closely matches the <filename>KMACHINE</filename> |
| 134 | and <filename>LINUX_KERNEL_TYPE</filename> variables passed in from the |
| 135 | recipe. |
| 136 | The tools use the first BSP description it finds that match |
| 137 | both variables. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 138 | If the tools cannot find a match, they issue a warning. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | </para> |
| 140 | |
| 141 | <para> |
| 142 | The tools first search for the <filename>KMACHINE</filename> and |
| 143 | then for the <filename>LINUX_KERNEL_TYPE</filename>. |
| 144 | If the tools cannot find a partial match, they will use the |
| 145 | sources from the <filename>KBRANCH</filename> and any configuration |
| 146 | specified in the |
| 147 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 148 | </para> |
| 149 | |
| 150 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 151 | You can use the |
| 152 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink> |
| 153 | variable |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | to include features (configuration fragments, patches, or both) that |
| 155 | are not already included by the <filename>KMACHINE</filename> and |
| 156 | <filename>LINUX_KERNEL_TYPE</filename> variable combination. |
| 157 | For example, to include a feature specified as |
| 158 | "features/netfilter/netfilter.scc", |
| 159 | specify: |
| 160 | <literallayout class='monospaced'> |
| 161 | KERNEL_FEATURES += "features/netfilter/netfilter.scc" |
| 162 | </literallayout> |
| 163 | To include a feature called "cfg/sound.scc" just for the |
| 164 | <filename>qemux86</filename> machine, specify: |
| 165 | <literallayout class='monospaced'> |
| 166 | KERNEL_FEATURES_append_qemux86 = " cfg/sound.scc" |
| 167 | </literallayout> |
| 168 | The value of the entries in <filename>KERNEL_FEATURES</filename> |
| 169 | are dependent on their location within the kernel Metadata itself. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 170 | The examples here are taken from the |
| 171 | <filename>yocto-kernel-cache</filename> repository. |
| 172 | Each branch of this repository contains "features" and "cfg" |
| 173 | subdirectories at the top-level. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | For more information, see the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 175 | "<link linkend='kernel-metadata-syntax'>Kernel Metadata Syntax</link>" |
| 176 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | </para> |
| 178 | </section> |
| 179 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | <section id='kernel-metadata-syntax'> |
| 181 | <title>Kernel Metadata Syntax</title> |
| 182 | |
| 183 | <para> |
| 184 | The kernel Metadata consists of three primary types of files: |
| 185 | <filename>scc</filename> |
| 186 | <footnote> |
| 187 | <para> |
| 188 | <filename>scc</filename> stands for Series Configuration |
| 189 | Control, but the naming has less significance in the |
| 190 | current implementation of the tooling than it had in the |
| 191 | past. |
| 192 | Consider <filename>scc</filename> files to be description files. |
| 193 | </para> |
| 194 | </footnote> |
| 195 | description files, configuration fragments, and patches. |
| 196 | The <filename>scc</filename> files define variables and include or |
| 197 | otherwise reference any of the three file types. |
| 198 | The description files are used to aggregate all types of kernel |
| 199 | Metadata into |
| 200 | what ultimately describes the sources and the configuration required |
| 201 | to build a Linux kernel tailored to a specific machine. |
| 202 | </para> |
| 203 | |
| 204 | <para> |
| 205 | The <filename>scc</filename> description files are used to define two |
| 206 | fundamental types of kernel Metadata: |
| 207 | <itemizedlist> |
| 208 | <listitem><para>Features</para></listitem> |
| 209 | <listitem><para>Board Support Packages (BSPs)</para></listitem> |
| 210 | </itemizedlist> |
| 211 | </para> |
| 212 | |
| 213 | <para> |
| 214 | Features aggregate sources in the form of patches and configuration |
| 215 | fragments into a modular reusable unit. |
| 216 | You can use features to implement conceptually separate kernel |
| 217 | Metadata descriptions such as pure configuration fragments, |
| 218 | simple patches, complex features, and kernel types. |
| 219 | <link linkend='kernel-types'>Kernel types</link> define general |
| 220 | kernel features and policy to be reused in the BSPs. |
| 221 | </para> |
| 222 | |
| 223 | <para> |
| 224 | BSPs define hardware-specific features and aggregate them with kernel |
| 225 | types to form the final description of what will be assembled and built. |
| 226 | </para> |
| 227 | |
| 228 | <para> |
| 229 | While the kernel Metadata syntax does not enforce any logical |
| 230 | separation of configuration fragments, patches, features or kernel |
| 231 | types, best practices dictate a logical separation of these types |
| 232 | of Metadata. |
| 233 | The following Metadata file hierarchy is recommended: |
| 234 | <literallayout class='monospaced'> |
| 235 | <replaceable>base</replaceable>/ |
| 236 | bsp/ |
| 237 | cfg/ |
| 238 | features/ |
| 239 | ktypes/ |
| 240 | patches/ |
| 241 | </literallayout> |
| 242 | </para> |
| 243 | |
| 244 | <para> |
| 245 | The <filename>bsp</filename> directory contains the |
| 246 | <link linkend='bsp-descriptions'>BSP descriptions</link>. |
| 247 | The remaining directories all contain "features". |
| 248 | Separating <filename>bsp</filename> from the rest of the structure |
| 249 | aids conceptualizing intended usage. |
| 250 | </para> |
| 251 | |
| 252 | <para> |
| 253 | Use these guidelines to help place your <filename>scc</filename> |
| 254 | description files within the structure: |
| 255 | <itemizedlist> |
| 256 | <listitem><para>If your file contains |
| 257 | only configuration fragments, place the file in the |
| 258 | <filename>cfg</filename> directory.</para></listitem> |
| 259 | <listitem><para>If your file contains |
| 260 | only source-code fixes, place the file in the |
| 261 | <filename>patches</filename> directory.</para></listitem> |
| 262 | <listitem><para>If your file encapsulates |
| 263 | a major feature, often combining sources and configurations, |
| 264 | place the file in <filename>features</filename> directory. |
| 265 | </para></listitem> |
| 266 | <listitem><para>If your file aggregates |
| 267 | non-hardware configuration and patches in order to define a |
| 268 | base kernel policy or major kernel type to be reused across |
| 269 | multiple BSPs, place the file in <filename>ktypes</filename> |
| 270 | directory. |
| 271 | </para></listitem> |
| 272 | </itemizedlist> |
| 273 | </para> |
| 274 | |
| 275 | <para> |
| 276 | These distinctions can easily become blurred - especially as |
| 277 | out-of-tree features slowly merge upstream over time. |
| 278 | Also, remember that how the description files are placed is |
| 279 | a purely logical organization and has no impact on the functionality |
| 280 | of the kernel Metadata. |
| 281 | There is no impact because all of <filename>cfg</filename>, |
| 282 | <filename>features</filename>, <filename>patches</filename>, and |
| 283 | <filename>ktypes</filename>, contain "features" as far as the kernel |
| 284 | tools are concerned. |
| 285 | </para> |
| 286 | |
| 287 | <para> |
| 288 | Paths used in kernel Metadata files are relative to |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 289 | <replaceable>base</replaceable>, which is either |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 290 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink> |
| 291 | if you are creating Metadata in |
| 292 | <link linkend='recipe-space-metadata'>recipe-space</link>, |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 293 | or the top level of |
| 294 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/yocto-kernel-cache/tree/'><filename>yocto-kernel-cache</filename></ulink> |
| 295 | if you are creating |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 296 | <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] | 297 | </para> |
| 298 | |
| 299 | <section id='configuration'> |
| 300 | <title>Configuration</title> |
| 301 | |
| 302 | <para> |
| 303 | The simplest unit of kernel Metadata is the configuration-only |
| 304 | feature. |
| 305 | This feature consists of one or more Linux kernel configuration |
| 306 | parameters in a configuration fragment file |
| 307 | (<filename>.cfg</filename>) and a <filename>.scc</filename> file |
| 308 | that describes the fragment. |
| 309 | </para> |
| 310 | |
| 311 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 312 | As an example, consider the Symmetric Multi-Processing (SMP) |
| 313 | fragment used with the <filename>linux-yocto-4.12</filename> |
| 314 | kernel as defined outside of the recipe space (i.e. |
| 315 | <filename>yocto-kernel-cache</filename>). |
| 316 | This Metadata consists of two files: <filename>smp.scc</filename> |
| 317 | and <filename>smp.cfg</filename>. |
| 318 | You can find these files in the <filename>cfg</filename> directory |
| 319 | of the <filename>yocto-4.12</filename> branch in the |
| 320 | <filename>yocto-kernel-cache</filename> Git repository: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 321 | <literallayout class='monospaced'> |
| 322 | cfg/smp.scc: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 323 | define KFEATURE_DESCRIPTION "Enable SMP for 32 bit builds" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 324 | define KFEATURE_COMPATIBILITY all |
| 325 | |
| 326 | kconf hardware smp.cfg |
| 327 | |
| 328 | cfg/smp.cfg: |
| 329 | CONFIG_SMP=y |
| 330 | CONFIG_SCHED_SMT=y |
| 331 | # Increase default NR_CPUS from 8 to 64 so that platform with |
| 332 | # more than 8 processors can be all activated at boot time |
| 333 | CONFIG_NR_CPUS=64 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 334 | # The following is needed when setting NR_CPUS to something |
| 335 | # greater than 8 on x86 architectures, it should be automatically |
| 336 | # disregarded by Kconfig when using a different arch |
| 337 | CONFIG_X86_BIGSMP=y |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 338 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 339 | You can find general information on configuration fragment files in |
| 340 | the |
| 341 | "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
| 342 | section. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 343 | </para> |
| 344 | |
| 345 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 346 | Within the <filename>smp.scc</filename> file, the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 347 | <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] | 348 | statement provides a short description of the fragment. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 349 | Higher level kernel tools use this description. |
| 350 | </para> |
| 351 | |
| 352 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 353 | Also within the <filename>smp.scc</filename> file, the |
| 354 | <filename>kconf</filename> command includes the |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 355 | actual configuration fragment in an <filename>.scc</filename> |
| 356 | file, and the "hardware" keyword identifies the fragment as |
| 357 | being hardware enabling, as opposed to general policy, |
| 358 | which would use the "non-hardware" keyword. |
| 359 | The distinction is made for the benefit of the configuration |
| 360 | validation tools, which warn you if a hardware fragment |
| 361 | overrides a policy set by a non-hardware fragment. |
| 362 | <note> |
| 363 | The description file can include multiple |
| 364 | <filename>kconf</filename> statements, one per fragment. |
| 365 | </note> |
| 366 | </para> |
| 367 | |
| 368 | <para> |
| 369 | As described in the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 370 | "<link linkend='validating-configuration'>Validating Configuration</link>" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 371 | section, you can use the following BitBake command to audit your |
| 372 | configuration: |
| 373 | <literallayout class='monospaced'> |
| 374 | $ bitbake linux-yocto -c kernel_configcheck -f |
| 375 | </literallayout> |
| 376 | </para> |
| 377 | </section> |
| 378 | |
| 379 | <section id='patches'> |
| 380 | <title>Patches</title> |
| 381 | |
| 382 | <para> |
| 383 | Patch descriptions are very similar to configuration fragment |
| 384 | descriptions, which are described in the previous section. |
| 385 | However, instead of a <filename>.cfg</filename> file, these |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 386 | descriptions work with source patches (i.e. |
| 387 | <filename>.patch</filename> files). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 388 | </para> |
| 389 | |
| 390 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 391 | A typical patch includes a description file and the patch itself. |
| 392 | As an example, consider the build patches used with the |
| 393 | <filename>linux-yocto-4.12</filename> kernel as defined outside of |
| 394 | the recipe space (i.e. <filename>yocto-kernel-cache</filename>). |
| 395 | This Metadata consists of several files: |
| 396 | <filename>build.scc</filename> and a set of |
| 397 | <filename>*.patch</filename> files. |
| 398 | You can find these files in the <filename>patches/build</filename> |
| 399 | directory of the <filename>yocto-4.12</filename> branch in the |
| 400 | <filename>yocto-kernel-cache</filename> Git repository. |
| 401 | </para> |
| 402 | |
| 403 | <para> |
| 404 | The following listings show the <filename>build.scc</filename> |
| 405 | file and part of the |
| 406 | <filename>modpost-mask-trivial-warnings.patch</filename> file: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 407 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 408 | patches/build/build.scc: |
| 409 | patch arm-serialize-build-targets.patch |
| 410 | patch powerpc-serialize-image-targets.patch |
| 411 | patch kbuild-exclude-meta-directory-from-distclean-processi.patch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 412 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 413 | # applied by kgit |
| 414 | # patch kbuild-add-meta-files-to-the-ignore-li.patch |
| 415 | |
| 416 | patch modpost-mask-trivial-warnings.patch |
| 417 | patch menuconfig-check-lxdiaglog.sh-Allow-specification-of.patch |
| 418 | |
| 419 | patches/build/modpost-mask-trivial-warnings.patch: |
| 420 | From bd48931bc142bdd104668f3a062a1f22600aae61 Mon Sep 17 00:00:00 2001 |
| 421 | From: Paul Gortmaker <paul.gortmaker@windriver.com> |
| 422 | Date: Sun, 25 Jan 2009 17:58:09 -0500 |
| 423 | Subject: [PATCH] modpost: mask trivial warnings |
| 424 | |
| 425 | Newer HOSTCC will complain about various stdio fcns because |
| 426 | . |
| 427 | . |
| 428 | . |
| 429 | char *dump_write = NULL, *files_source = NULL; |
| 430 | int opt; |
| 431 | -- |
| 432 | 2.10.1 |
| 433 | |
| 434 | 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] | 435 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 436 | The description file can include multiple patch statements where |
| 437 | each statement handles a single patch. |
| 438 | In the example <filename>build.scc</filename> file, five patch |
| 439 | statements exist for the five patches in the directory. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 440 | </para> |
| 441 | |
| 442 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 443 | You can create a typical <filename>.patch</filename> file using |
| 444 | <filename>diff -Nurp</filename> or |
| 445 | <filename>git format-patch</filename> commands. |
| 446 | For information on how to create patches, see the |
| 447 | "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>" |
| 448 | and |
| 449 | "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>" |
| 450 | sections. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 451 | </para> |
| 452 | </section> |
| 453 | |
| 454 | <section id='features'> |
| 455 | <title>Features</title> |
| 456 | |
| 457 | <para> |
| 458 | Features are complex kernel Metadata types that consist |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 459 | of configuration fragments, patches, and possibly other feature |
| 460 | description files. |
| 461 | As an example, consider the following generic listing: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 462 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 463 | features/<replaceable>myfeature</replaceable>.scc |
| 464 | define KFEATURE_DESCRIPTION "Enable <replaceable>myfeature</replaceable>" |
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 | patch 0001-<replaceable>myfeature</replaceable>-core.patch |
| 467 | patch 0002-<replaceable>myfeature</replaceable>-interface.patch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 468 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 469 | include cfg/<replaceable>myfeature</replaceable>_dependency.scc |
| 470 | kconf non-hardware <replaceable>myfeature</replaceable>.cfg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 471 | </literallayout> |
| 472 | This example shows how the <filename>patch</filename> and |
| 473 | <filename>kconf</filename> commands are used as well as |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 474 | how an additional feature description file is included with |
| 475 | the <filename>include</filename> command. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 476 | </para> |
| 477 | |
| 478 | <para> |
| 479 | Typically, features are less granular than configuration |
| 480 | fragments and are more likely than configuration fragments |
| 481 | and patches to be the types of things you want to specify |
| 482 | in the <filename>KERNEL_FEATURES</filename> variable of the |
| 483 | Linux kernel recipe. |
| 484 | See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>" |
| 485 | section earlier in the manual. |
| 486 | </para> |
| 487 | </section> |
| 488 | |
| 489 | <section id='kernel-types'> |
| 490 | <title>Kernel Types</title> |
| 491 | |
| 492 | <para> |
| 493 | A kernel type defines a high-level kernel policy by |
| 494 | aggregating non-hardware configuration fragments with |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 495 | patches you want to use when building a Linux kernel of a |
| 496 | specific type (e.g. a real-time kernel). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 497 | Syntactically, kernel types are no different than features |
| 498 | as described in the "<link linkend='features'>Features</link>" |
| 499 | section. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 500 | The |
| 501 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_KERNEL_TYPE'><filename>LINUX_KERNEL_TYPE</filename></ulink> |
| 502 | variable in the kernel recipe selects the kernel type. |
| 503 | For example, in the <filename>linux-yocto_4.12.bb</filename> |
| 504 | kernel recipe found in |
| 505 | <filename>poky/meta/recipes-kernel/linux</filename>, a |
| 506 | <ulink url='&YOCTO_DOCS_BB_URL;#require-inclusion'><filename>require</filename></ulink> |
| 507 | directive includes the |
| 508 | <filename>poky/meta/recipes-kernel/linux/linux-yocto.inc</filename> |
| 509 | file, which has the following statement that defines the default |
| 510 | kernel type: |
| 511 | <literallayout class='monospaced'> |
| 512 | LINUX_KERNEL_TYPE ??= "standard" |
| 513 | </literallayout> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 514 | </para> |
| 515 | |
| 516 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 517 | Another example would be the real-time kernel (i.e. |
| 518 | <filename>linux-yocto-rt_4.12.bb</filename>). |
| 519 | This kernel recipe directly sets the kernel type as follows: |
| 520 | <literallayout class='monospaced'> |
| 521 | LINUX_KERNEL_TYPE = "preempt-rt" |
| 522 | </literallayout> |
| 523 | <note> |
| 524 | You can find kernel recipes in the |
| 525 | <filename>meta/recipes-kernel/linux</filename> directory of the |
| 526 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> |
| 527 | (e.g. <filename>poky/meta/recipes-kernel/linux/linux-yocto_4.12.bb</filename>). |
| 528 | See the "<link linkend='using-kernel-metadata-in-a-recipe'>Using Kernel Metadata in a Recipe</link>" |
| 529 | section for more information. |
| 530 | </note> |
| 531 | </para> |
| 532 | |
| 533 | <para> |
| 534 | Three kernel types ("standard", "tiny", and "preempt-rt") are |
| 535 | supported for Linux Yocto kernels: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 536 | <itemizedlist> |
| 537 | <listitem><para>"standard": |
| 538 | Includes the generic Linux kernel policy of the Yocto |
| 539 | Project linux-yocto kernel recipes. |
| 540 | This policy includes, among other things, which file |
| 541 | systems, networking options, core kernel features, and |
| 542 | debugging and tracing options are supported. |
| 543 | </para></listitem> |
| 544 | <listitem><para>"preempt-rt": |
| 545 | Applies the <filename>PREEMPT_RT</filename> |
| 546 | patches and the configuration options required to |
| 547 | build a real-time Linux kernel. |
| 548 | This kernel type inherits from the "standard" kernel type. |
| 549 | </para></listitem> |
| 550 | <listitem><para>"tiny": |
| 551 | Defines a bare minimum configuration meant to serve as a |
| 552 | base for very small Linux kernels. |
| 553 | The "tiny" kernel type is independent from the "standard" |
| 554 | configuration. |
| 555 | Although the "tiny" kernel type does not currently include |
| 556 | any source changes, it might in the future. |
| 557 | </para></listitem> |
| 558 | </itemizedlist> |
| 559 | </para> |
| 560 | |
| 561 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 562 | For any given kernel type, the Metadata is defined by the |
| 563 | <filename>.scc</filename> (e.g. <filename>standard.scc</filename>). |
| 564 | Here is a partial listing for the <filename>standard.scc</filename> |
| 565 | file, which is found in the <filename>ktypes/standard</filename> |
| 566 | directory of the <filename>yocto-kernel-cache</filename> Git |
| 567 | repository: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 568 | <literallayout class='monospaced'> |
| 569 | # Include this kernel type fragment to get the standard features and |
| 570 | # configuration values. |
| 571 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 572 | # Note: if only the features are desired, but not the configuration |
| 573 | # then this should be included as: |
| 574 | # include ktypes/standard/standard.scc nocfg |
| 575 | # if no chained configuration is desired, include it as: |
| 576 | # include ktypes/standard/standard.scc nocfg inherit |
| 577 | |
| 578 | |
| 579 | |
| 580 | include ktypes/base/base.scc |
| 581 | branch standard |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 582 | |
| 583 | kconf non-hardware standard.cfg |
| 584 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 585 | include features/kgdb/kgdb.scc |
| 586 | . |
| 587 | . |
| 588 | . |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 589 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 590 | include cfg/net/ip6_nf.scc |
| 591 | include cfg/net/bridge.scc |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 592 | |
| 593 | include cfg/systemd.scc |
| 594 | |
| 595 | include features/rfkill/rfkill.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 596 | </literallayout> |
| 597 | </para> |
| 598 | |
| 599 | <para> |
| 600 | As with any <filename>.scc</filename> file, a |
| 601 | kernel type definition can aggregate other |
| 602 | <filename>.scc</filename> files with |
| 603 | <filename>include</filename> commands. |
| 604 | These definitions can also directly pull in |
| 605 | configuration fragments and patches with the |
| 606 | <filename>kconf</filename> and <filename>patch</filename> |
| 607 | commands, respectively. |
| 608 | </para> |
| 609 | |
| 610 | <note> |
| 611 | It is not strictly necessary to create a kernel type |
| 612 | <filename>.scc</filename> file. |
| 613 | The Board Support Package (BSP) file can implicitly define |
| 614 | the kernel type using a <filename>define |
| 615 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'>KTYPE</ulink> myktype</filename> |
| 616 | line. |
| 617 | See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>" |
| 618 | section for more information. |
| 619 | </note> |
| 620 | </section> |
| 621 | |
| 622 | <section id='bsp-descriptions'> |
| 623 | <title>BSP Descriptions</title> |
| 624 | |
| 625 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 626 | BSP descriptions (i.e. <filename>*.scc</filename> files) |
| 627 | combine kernel types with hardware-specific features. |
| 628 | The hardware-specific Metadata is typically defined |
| 629 | independently in the BSP layer, and then aggregated with each |
| 630 | supported kernel type. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 631 | <note> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 632 | For BSPs supported by the Yocto Project, the BSP description |
| 633 | files are located in the <filename>bsp</filename> directory |
| 634 | of the <filename>yocto-kernel-cache</filename> repository |
| 635 | organized under the "Yocto Linux Kernel" heading in the |
| 636 | <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] | 637 | </note> |
| 638 | </para> |
| 639 | |
| 640 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 641 | This section overviews the BSP description structure, the |
| 642 | aggregation concepts, and presents a detailed example using |
| 643 | a BSP supported by the Yocto Project (i.e. BeagleBone Board). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 644 | </para> |
| 645 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 646 | <section id='bsp-description-file-overview'> |
| 647 | <title>Overview</title> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 648 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 649 | <para> |
| 650 | For simplicity, consider the following top-level BSP |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 651 | description files for the BeagleBone board. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 652 | Top-level BSP descriptions files employ both a structure |
| 653 | and naming convention for consistency. |
| 654 | The naming convention for the file is as follows: |
| 655 | <literallayout class='monospaced'> |
| 656 | <replaceable>bsp_name</replaceable>-<replaceable>kernel_type</replaceable>.scc |
| 657 | </literallayout> |
| 658 | Here are some example top-level BSP filenames for the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 659 | BeagleBone Board BSP, which is supported by the Yocto Project: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 660 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 661 | beaglebone-standard.scc |
| 662 | beaglebone-preempt-rt.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 663 | </literallayout> |
| 664 | Each file uses the BSP name followed by the kernel type. |
| 665 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 666 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 667 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 668 | Examine the <filename>beaglebone-standard.scc</filename> |
| 669 | file: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 670 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 671 | define KMACHINE beaglebone |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 672 | define KTYPE standard |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 673 | define KARCH arm |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 674 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 675 | include ktypes/standard/standard.scc |
| 676 | branch beaglebone |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 677 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 678 | include beaglebone.scc |
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 | # default policy for standard kernels |
| 681 | include features/latencytop/latencytop.scc |
| 682 | include features/profiling/profiling.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 683 | </literallayout> |
| 684 | Every top-level BSP description file should define the |
| 685 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>, |
| 686 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>, |
| 687 | and <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink> |
| 688 | variables. |
| 689 | These variables allow the OpenEmbedded build system to identify |
| 690 | the description as meeting the criteria set by the recipe being |
| 691 | built. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 692 | This example supports the "beaglebone" machine for the |
| 693 | "standard" kernel and the "arm" architecture. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 694 | </para> |
| 695 | |
| 696 | <para> |
| 697 | Be aware that a hard link between the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 698 | <filename>KTYPE</filename> variable and a kernel type |
| 699 | description file does not exist. |
| 700 | Thus, if you do not have the kernel type defined in your kernel |
| 701 | Metadata as it is here, you only need to ensure that the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 702 | <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] | 703 | variable in the kernel recipe and the |
| 704 | <filename>KTYPE</filename> variable in the BSP description |
| 705 | file match. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 706 | </para> |
| 707 | |
| 708 | <para> |
| 709 | To separate your kernel policy from your hardware configuration, |
| 710 | you include a kernel type (<filename>ktype</filename>), such as |
| 711 | "standard". |
| 712 | In the previous example, this is done using the following: |
| 713 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 714 | include ktypes/standard/standard.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 715 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 716 | This file aggregates all the configuration fragments, patches, |
| 717 | and features that make up your standard kernel policy. |
| 718 | See the "<link linkend='kernel-types'>Kernel Types</link>" |
| 719 | section for more information. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 720 | </para> |
| 721 | |
| 722 | <para> |
| 723 | To aggregate common configurations and features specific to the |
| 724 | kernel for <replaceable>mybsp</replaceable>, use the following: |
| 725 | <literallayout class='monospaced'> |
| 726 | include <replaceable>mybsp</replaceable>.scc |
| 727 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 728 | You can see that in the BeagleBone example with the following: |
| 729 | <literallayout class='monospaced'> |
| 730 | include beaglebone.scc |
| 731 | </literallayout> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 732 | For information on how to break a complete |
| 733 | <filename>.config</filename> file into the various |
| 734 | configuration fragments, see the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 735 | "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 736 | section. |
| 737 | </para> |
| 738 | |
| 739 | <para> |
| 740 | Finally, if you have any configurations specific to the |
| 741 | hardware that are not in a <filename>*.scc</filename> file, |
| 742 | you can include them as follows: |
| 743 | <literallayout class='monospaced'> |
| 744 | kconf hardware <replaceable>mybsp</replaceable>-<replaceable>extra</replaceable>.cfg |
| 745 | </literallayout> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 746 | The BeagleBone example does not include these types of |
| 747 | configurations. |
| 748 | However, the Malta 32-bit board does ("mti-malta32"). |
| 749 | Here is the <filename>mti-malta32-le-standard.scc</filename> |
| 750 | file: |
| 751 | <literallayout class='monospaced'> |
| 752 | define KMACHINE mti-malta32-le |
| 753 | define KMACHINE qemumipsel |
| 754 | define KTYPE standard |
| 755 | define KARCH mips |
| 756 | |
| 757 | include ktypes/standard/standard.scc |
| 758 | branch mti-malta32 |
| 759 | |
| 760 | include mti-malta32.scc |
| 761 | kconf hardware mti-malta32-le.cfg |
| 762 | </literallayout> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 763 | </para> |
| 764 | </section> |
| 765 | |
| 766 | <section id='bsp-description-file-example-minnow'> |
| 767 | <title>Example</title> |
| 768 | |
| 769 | <para> |
| 770 | Many real-world examples are more complex. |
| 771 | Like any other <filename>.scc</filename> file, BSP |
| 772 | descriptions can aggregate features. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 773 | Consider the Minnow BSP definition given the |
| 774 | <filename>linux-yocto-4.4</filename> branch of the |
| 775 | <filename>yocto-kernel-cache</filename> (i.e. |
| 776 | <filename>yocto-kernel-cache/bsp/minnow/minnow.scc</filename>): |
| 777 | <note> |
| 778 | Although the Minnow Board BSP is unused, the Metadata |
| 779 | remains and is being used here just as an example. |
| 780 | </note> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 781 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 782 | include cfg/x86.scc |
| 783 | include features/eg20t/eg20t.scc |
| 784 | include cfg/dmaengine.scc |
| 785 | include features/power/intel.scc |
| 786 | include cfg/efi.scc |
| 787 | include features/usb/ehci-hcd.scc |
| 788 | include features/usb/ohci-hcd.scc |
| 789 | include features/usb/usb-gadgets.scc |
| 790 | include features/usb/touchscreen-composite.scc |
| 791 | include cfg/timer/hpet.scc |
| 792 | include features/leds/leds.scc |
| 793 | include features/spi/spidev.scc |
| 794 | include features/i2c/i2cdev.scc |
| 795 | include features/mei/mei-txe.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 796 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 797 | # Earlyprintk and port debug requires 8250 |
| 798 | kconf hardware cfg/8250.cfg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 799 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 800 | kconf hardware minnow.cfg |
| 801 | kconf hardware minnow-dev.cfg |
| 802 | </literallayout> |
| 803 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 804 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 805 | <para> |
| 806 | The <filename>minnow.scc</filename> description file includes |
| 807 | a hardware configuration fragment |
| 808 | (<filename>minnow.cfg</filename>) specific to the Minnow |
| 809 | BSP as well as several more general configuration |
| 810 | fragments and features enabling hardware found on the |
| 811 | machine. |
| 812 | This <filename>minnow.scc</filename> description file is then |
| 813 | included in each of the three |
| 814 | "minnow" description files for the supported kernel types |
| 815 | (i.e. "standard", "preempt-rt", and "tiny"). |
| 816 | Consider the "minnow" description for the "standard" kernel |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 817 | type (i.e. <filename>minnow-standard.scc</filename>: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 818 | <literallayout class='monospaced'> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 819 | define KMACHINE minnow |
| 820 | define KTYPE standard |
| 821 | define KARCH i386 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 822 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 823 | include ktypes/standard |
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 minnow.scc |
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 | # Extra minnow configs above the minimal defined in minnow.scc |
| 828 | include cfg/efi-ext.scc |
| 829 | include features/media/media-all.scc |
| 830 | include features/sound/snd_hda_intel.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 831 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 832 | # The following should really be in standard.scc |
| 833 | # USB live-image support |
| 834 | include cfg/usb-mass-storage.scc |
| 835 | include cfg/boot-live.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 836 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 837 | # Basic profiling |
| 838 | include features/latencytop/latencytop.scc |
| 839 | include features/profiling/profiling.scc |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 840 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 841 | # Requested drivers that don't have an existing scc |
| 842 | kconf hardware minnow-drivers-extra.cfg |
| 843 | </literallayout> |
| 844 | The <filename>include</filename> command midway through the file |
| 845 | includes the <filename>minnow.scc</filename> description that |
| 846 | defines all enabled hardware for the BSP that is common to |
| 847 | all kernel types. |
| 848 | Using this command significantly reduces duplication. |
| 849 | </para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 850 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 851 | <para> |
| 852 | Now consider the "minnow" description for the "tiny" kernel |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 853 | type (i.e. <filename>minnow-tiny.scc</filename>: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 854 | <literallayout class='monospaced'> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 855 | define KMACHINE minnow |
| 856 | define KTYPE tiny |
| 857 | define KARCH i386 |
| 858 | |
| 859 | include ktypes/tiny |
| 860 | |
| 861 | include minnow.scc |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 862 | </literallayout> |
| 863 | As you might expect, the "tiny" description includes quite a |
| 864 | bit less. |
| 865 | In fact, it includes only the minimal policy defined by the |
| 866 | "tiny" kernel type and the hardware-specific configuration |
| 867 | required for booting the machine along with the most basic |
| 868 | functionality of the system as defined in the base "minnow" |
| 869 | description file. |
| 870 | </para> |
| 871 | |
| 872 | <para> |
| 873 | Notice again the three critical variables: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 874 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>, |
| 875 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KTYPE'><filename>KTYPE</filename></ulink>, |
| 876 | and |
| 877 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KARCH'><filename>KARCH</filename></ulink>. |
| 878 | Of these variables, only <filename>KTYPE</filename> |
| 879 | has changed to specify the "tiny" kernel type. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 880 | </para> |
| 881 | </section> |
| 882 | </section> |
| 883 | </section> |
| 884 | |
| 885 | <section id='kernel-metadata-location'> |
| 886 | <title>Kernel Metadata Location</title> |
| 887 | |
| 888 | <para> |
| 889 | Kernel Metadata always exists outside of the kernel tree either |
| 890 | defined in a kernel recipe (recipe-space) or outside of the recipe. |
| 891 | Where you choose to define the Metadata depends on what you want |
| 892 | to do and how you intend to work. |
| 893 | Regardless of where you define the kernel Metadata, the syntax used |
| 894 | applies equally. |
| 895 | </para> |
| 896 | |
| 897 | <para> |
| 898 | If you are unfamiliar with the Linux kernel and only wish |
| 899 | to apply a configuration and possibly a couple of patches provided to |
| 900 | you by others, the recipe-space method is recommended. |
| 901 | This method is also a good approach if you are working with Linux kernel |
| 902 | sources you do not control or if you just do not want to maintain a |
| 903 | Linux kernel Git repository on your own. |
| 904 | For partial information on how you can define kernel Metadata in |
| 905 | the recipe-space, see the |
| 906 | "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>" |
| 907 | section. |
| 908 | </para> |
| 909 | |
| 910 | <para> |
| 911 | Conversely, if you are actively developing a kernel and are already |
| 912 | maintaining a Linux kernel Git repository of your own, you might find |
| 913 | it more convenient to work with kernel Metadata kept outside the |
| 914 | recipe-space. |
| 915 | Working with Metadata in this area can make iterative development of |
| 916 | the Linux kernel more efficient outside of the BitBake environment. |
| 917 | </para> |
| 918 | |
| 919 | <section id='recipe-space-metadata'> |
| 920 | <title>Recipe-Space Metadata</title> |
| 921 | |
| 922 | <para> |
| 923 | When stored in recipe-space, the kernel Metadata files reside in a |
| 924 | directory hierarchy below |
| 925 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>. |
| 926 | For a linux-yocto recipe or for a Linux kernel recipe derived |
| 927 | by copying and modifying |
| 928 | <filename>oe-core/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb</filename> |
| 929 | to a recipe in your layer, <filename>FILESEXTRAPATHS</filename> |
| 930 | is typically set to |
| 931 | <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>. |
| 932 | See the "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>" |
| 933 | section for more information. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 934 | </para> |
| 935 | |
| 936 | <para> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 937 | Here is an example that shows a trivial tree of kernel Metadata |
| 938 | stored in recipe-space within a BSP layer: |
| 939 | <literallayout class='monospaced'> |
| 940 | meta-<replaceable>my_bsp_layer</replaceable>/ |
| 941 | `-- recipes-kernel |
| 942 | `-- linux |
| 943 | `-- linux-yocto |
| 944 | |-- bsp-standard.scc |
| 945 | |-- bsp.cfg |
| 946 | `-- standard.cfg |
| 947 | </literallayout> |
| 948 | </para> |
| 949 | |
| 950 | <para> |
| 951 | When the Metadata is stored in recipe-space, you must take |
| 952 | steps to ensure BitBake has the necessary information to decide |
| 953 | what files to fetch and when they need to be fetched again. |
| 954 | It is only necessary to specify the <filename>.scc</filename> |
| 955 | files on the |
| 956 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>. |
| 957 | BitBake parses them and fetches any files referenced in the |
| 958 | <filename>.scc</filename> files by the <filename>include</filename>, |
| 959 | <filename>patch</filename>, or <filename>kconf</filename> commands. |
| 960 | Because of this, it is necessary to bump the recipe |
| 961 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> |
| 962 | value when changing the content of files not explicitly listed |
| 963 | in the <filename>SRC_URI</filename>. |
| 964 | </para> |
| 965 | |
| 966 | <para> |
| 967 | If the BSP description is in recipe space, you cannot simply list |
| 968 | the <filename>*.scc</filename> in the <filename>SRC_URI</filename> |
| 969 | statement. |
| 970 | You need to use the following form from your kernel append file: |
| 971 | <literallayout class='monospaced'> |
| 972 | SRC_URI_append_<replaceable>myplatform</replaceable> = " \ |
| 973 | file://<replaceable>myplatform</replaceable>;type=kmeta;destsuffix=<replaceable>myplatform</replaceable> \ |
| 974 | " |
| 975 | </literallayout> |
| 976 | </para> |
| 977 | </section> |
| 978 | |
| 979 | <section id='metadata-outside-the-recipe-space'> |
| 980 | <title>Metadata Outside the Recipe-Space</title> |
| 981 | |
| 982 | <para> |
| 983 | When stored outside of the recipe-space, the kernel Metadata |
| 984 | files reside in a separate repository. |
| 985 | The OpenEmbedded build system adds the Metadata to the build as |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 986 | a "type=kmeta" repository through the |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 987 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 988 | variable. |
| 989 | As an example, consider the following <filename>SRC_URI</filename> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 990 | statement from the <filename>linux-yocto_4.12.bb</filename> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 991 | kernel recipe: |
| 992 | <literallayout class='monospaced'> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 993 | SRC_URI = "git://git.yoctoproject.org/linux-yocto-4.12.git;name=machine;branch=${KBRANCH}; \ |
| 994 | 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] | 995 | </literallayout> |
| 996 | <filename>${KMETA}</filename>, in this context, is simply used to |
| 997 | name the directory into which the Git fetcher places the Metadata. |
| 998 | This behavior is no different than any multi-repository |
| 999 | <filename>SRC_URI</filename> statement used in a recipe (e.g. |
| 1000 | see the previous section). |
| 1001 | </para> |
| 1002 | |
| 1003 | <para> |
| 1004 | You can keep kernel Metadata in a "kernel-cache", which is a |
| 1005 | directory containing configuration fragments. |
| 1006 | As with any Metadata kept outside the recipe-space, you simply |
| 1007 | need to use the <filename>SRC_URI</filename> statement with the |
| 1008 | "type=kmeta" attribute. |
| 1009 | Doing so makes the kernel Metadata available during the |
| 1010 | configuration phase. |
| 1011 | </para> |
| 1012 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1013 | <para> |
| 1014 | If you modify the Metadata, you must not forget to update the |
| 1015 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> |
| 1016 | statements in the kernel's recipe. |
| 1017 | In particular, you need to update the |
| 1018 | <filename>SRCREV_meta</filename> variable to match the commit in |
| 1019 | the <filename>KMETA</filename> branch you wish to use. |
| 1020 | Changing the data in these branches and not updating the |
| 1021 | <filename>SRCREV</filename> statements to match will cause the |
| 1022 | build to fetch an older commit. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1023 | </para> |
| 1024 | </section> |
| 1025 | </section> |
| 1026 | |
| 1027 | <section id='organizing-your-source'> |
| 1028 | <title>Organizing Your Source</title> |
| 1029 | |
| 1030 | <para> |
| 1031 | Many recipes based on the <filename>linux-yocto-custom.bb</filename> |
| 1032 | recipe use Linux kernel sources that have only a single |
| 1033 | branch - "master". |
| 1034 | This type of repository structure is fine for linear development |
| 1035 | supporting a single machine and architecture. |
| 1036 | However, if you work with multiple boards and architectures, |
| 1037 | a kernel source repository with multiple branches is more |
| 1038 | efficient. |
| 1039 | For example, suppose you need a series of patches for one board to boot. |
| 1040 | Sometimes, these patches are works-in-progress or fundamentally wrong, |
| 1041 | yet they are still necessary for specific boards. |
| 1042 | In these situations, you most likely do not want to include these |
| 1043 | patches in every kernel you build (i.e. have the patches as part of |
| 1044 | the lone "master" branch). |
| 1045 | It is situations like these that give rise to multiple branches used |
| 1046 | within a Linux kernel sources Git repository. |
| 1047 | </para> |
| 1048 | |
| 1049 | <para> |
| 1050 | Repository organization strategies exist that maximize source reuse, |
| 1051 | remove redundancy, and logically order your changes. |
| 1052 | This section presents strategies for the following cases: |
| 1053 | <itemizedlist> |
| 1054 | <listitem><para>Encapsulating patches in a feature description |
| 1055 | and only including the patches in the BSP descriptions of |
| 1056 | the applicable boards.</para></listitem> |
| 1057 | <listitem><para>Creating a machine branch in your |
| 1058 | kernel source repository and applying the patches on that |
| 1059 | branch only.</para></listitem> |
| 1060 | <listitem><para>Creating a feature branch in your |
| 1061 | kernel source repository and merging that branch into your |
| 1062 | BSP when needed.</para></listitem> |
| 1063 | </itemizedlist> |
| 1064 | </para> |
| 1065 | |
| 1066 | <para> |
| 1067 | The approach you take is entirely up to you |
| 1068 | and depends on what works best for your development model. |
| 1069 | </para> |
| 1070 | |
| 1071 | <section id='encapsulating-patches'> |
| 1072 | <title>Encapsulating Patches</title> |
| 1073 | |
| 1074 | <para> |
| 1075 | if you are reusing patches from an external tree and are not |
| 1076 | working on the patches, you might find the encapsulated feature |
| 1077 | to be appropriate. |
| 1078 | Given this scenario, you do not need to create any branches in the |
| 1079 | source repository. |
| 1080 | Rather, you just take the static patches you need and encapsulate |
| 1081 | them within a feature description. |
| 1082 | Once you have the feature description, you simply include that into |
| 1083 | the BSP description as described in the |
| 1084 | "<link linkend='bsp-descriptions'>BSP Descriptions</link>" |
| 1085 | section. |
| 1086 | </para> |
| 1087 | |
| 1088 | <para> |
| 1089 | You can find information on how to create patches and BSP |
| 1090 | descriptions in the "<link linkend='patches'>Patches</link>" and |
| 1091 | "<link linkend='bsp-descriptions'>BSP Descriptions</link>" |
| 1092 | sections. |
| 1093 | </para> |
| 1094 | </section> |
| 1095 | |
| 1096 | <section id='machine-branches'> |
| 1097 | <title>Machine Branches</title> |
| 1098 | |
| 1099 | <para> |
| 1100 | When you have multiple machines and architectures to support, |
| 1101 | or you are actively working on board support, it is more |
| 1102 | efficient to create branches in the repository based on |
| 1103 | individual machines. |
| 1104 | Having machine branches allows common source to remain in the |
| 1105 | "master" branch with any features specific to a machine stored |
| 1106 | in the appropriate machine branch. |
| 1107 | This organization method frees you from continually reintegrating |
| 1108 | your patches into a feature. |
| 1109 | </para> |
| 1110 | |
| 1111 | <para> |
| 1112 | Once you have a new branch, you can set up your kernel Metadata |
| 1113 | to use the branch a couple different ways. |
| 1114 | In the recipe, you can specify the new branch as the |
| 1115 | <filename>KBRANCH</filename> to use for the board as |
| 1116 | follows: |
| 1117 | <literallayout class='monospaced'> |
| 1118 | KBRANCH = "mynewbranch" |
| 1119 | </literallayout> |
| 1120 | Another method is to use the <filename>branch</filename> command |
| 1121 | in the BSP description: |
| 1122 | <literallayout class='monospaced'> |
| 1123 | mybsp.scc: |
| 1124 | define KMACHINE mybsp |
| 1125 | define KTYPE standard |
| 1126 | define KARCH i386 |
| 1127 | include standard.scc |
| 1128 | |
| 1129 | branch mynewbranch |
| 1130 | |
| 1131 | include mybsp-hw.scc |
| 1132 | </literallayout> |
| 1133 | </para> |
| 1134 | |
| 1135 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1136 | If you find yourself with numerous branches, you might consider |
| 1137 | using a hierarchical branching system similar to what the |
| 1138 | Yocto Linux Kernel Git repositories use: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1139 | <literallayout class='monospaced'> |
| 1140 | <replaceable>common</replaceable>/<replaceable>kernel_type</replaceable>/<replaceable>machine</replaceable> |
| 1141 | </literallayout> |
| 1142 | </para> |
| 1143 | |
| 1144 | <para> |
| 1145 | If you had two kernel types, "standard" and "small" for |
| 1146 | instance, three machines, and <replaceable>common</replaceable> |
| 1147 | as <filename>mydir</filename>, the branches in your |
| 1148 | Git repository might look like this: |
| 1149 | <literallayout class='monospaced'> |
| 1150 | mydir/base |
| 1151 | mydir/standard/base |
| 1152 | mydir/standard/machine_a |
| 1153 | mydir/standard/machine_b |
| 1154 | mydir/standard/machine_c |
| 1155 | mydir/small/base |
| 1156 | mydir/small/machine_a |
| 1157 | </literallayout> |
| 1158 | </para> |
| 1159 | |
| 1160 | <para> |
| 1161 | This organization can help clarify the branch relationships. |
| 1162 | In this case, <filename>mydir/standard/machine_a</filename> |
| 1163 | includes everything in <filename>mydir/base</filename> and |
| 1164 | <filename>mydir/standard/base</filename>. |
| 1165 | The "standard" and "small" branches add sources specific to those |
| 1166 | kernel types that for whatever reason are not appropriate for the |
| 1167 | other branches. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1168 | <note> |
| 1169 | The "base" branches are an artifact of the way Git manages |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1170 | its data internally on the filesystem: Git will not allow you |
| 1171 | to use <filename>mydir/standard</filename> and |
| 1172 | <filename>mydir/standard/machine_a</filename> because it |
| 1173 | would have to create a file and a directory named "standard". |
| 1174 | </note> |
| 1175 | </para> |
| 1176 | </section> |
| 1177 | |
| 1178 | <section id='feature-branches'> |
| 1179 | <title>Feature Branches</title> |
| 1180 | |
| 1181 | <para> |
| 1182 | When you are actively developing new features, it can be more |
| 1183 | efficient to work with that feature as a branch, rather than |
| 1184 | as a set of patches that have to be regularly updated. |
| 1185 | The Yocto Project Linux kernel tools provide for this with |
| 1186 | the <filename>git merge</filename> command. |
| 1187 | </para> |
| 1188 | |
| 1189 | <para> |
| 1190 | To merge a feature branch into a BSP, insert the |
| 1191 | <filename>git merge</filename> command after any |
| 1192 | <filename>branch</filename> commands: |
| 1193 | <literallayout class='monospaced'> |
| 1194 | mybsp.scc: |
| 1195 | define KMACHINE mybsp |
| 1196 | define KTYPE standard |
| 1197 | define KARCH i386 |
| 1198 | include standard.scc |
| 1199 | |
| 1200 | branch mynewbranch |
| 1201 | git merge myfeature |
| 1202 | |
| 1203 | include mybsp-hw.scc |
| 1204 | </literallayout> |
| 1205 | </para> |
| 1206 | </section> |
| 1207 | </section> |
| 1208 | |
| 1209 | <section id='scc-reference'> |
| 1210 | <title>SCC Description File Reference</title> |
| 1211 | |
| 1212 | <para> |
| 1213 | This section provides a brief reference for the commands you can use |
| 1214 | within an SCC description file (<filename>.scc</filename>): |
| 1215 | <itemizedlist> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1216 | <listitem><para> |
| 1217 | <filename>branch [ref]</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1218 | Creates a new branch relative to the current branch |
| 1219 | (typically <filename>${KTYPE}</filename>) using |
| 1220 | the currently checked-out branch, or "ref" if specified. |
| 1221 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1222 | <listitem><para> |
| 1223 | <filename>define</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1224 | Defines variables, such as <filename>KMACHINE</filename>, |
| 1225 | <filename>KTYPE</filename>, <filename>KARCH</filename>, |
| 1226 | and <filename>KFEATURE_DESCRIPTION</filename>.</para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1227 | <listitem><para> |
| 1228 | <filename>include SCC_FILE</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1229 | Includes an SCC file in the current file. |
| 1230 | The file is parsed as if you had inserted it inline. |
| 1231 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1232 | <listitem><para> |
| 1233 | <filename>kconf [hardware|non-hardware] CFG_FILE</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1234 | Queues a configuration fragment for merging into the final |
| 1235 | Linux <filename>.config</filename> file.</para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1236 | <listitem><para> |
| 1237 | <filename>git merge GIT_BRANCH</filename>: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1238 | Merges the feature branch into the current branch. |
| 1239 | </para></listitem> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1240 | <listitem><para> |
| 1241 | <filename>patch PATCH_FILE</filename>: |
| 1242 | Applies the patch to the current Git branch. |
| 1243 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1244 | </itemizedlist> |
| 1245 | </para> |
| 1246 | </section> |
| 1247 | |
| 1248 | </chapter> |
| 1249 | <!-- |
| 1250 | vim: expandtab tw=80 ts=4 |
| 1251 | --> |