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