kernel-dev-advanced.xml 55 KB

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