kernel-dev-advanced.xml 55 KB

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