yocto-project-kernel-manual.xml 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <chapter id='kernel'>
  4. <title>Yocto Project Kernel Architecture and Use Manual</title>
  5. <section id='introduction'>
  6. <title>Introduction</title>
  7. <para>
  8. Yocto Project presents the kernel as a fully patched, history-clean git
  9. repository.
  10. The git tree represents the selected features, board support,
  11. and configurations extensively tested by Yocto Project.
  12. The Yocto Project kernel allows the end user to leverage community
  13. best practices to seamlessly manage the development, build and debug cycles.
  14. </para>
  15. <para>
  16. This manual describes the Yocto Project kernel by providing information
  17. on its history, organization, benefits, and use.
  18. The manual consists of two sections:
  19. <itemizedlist>
  20. <listitem><para>Concepts - Describes concepts behind the kernel.
  21. You will understand how the kernel is organized and why it is organized in
  22. the way it is. You will understand the benefits of the kernel's organization
  23. and the mechanisms used to work with the kernel and how to apply it in your
  24. design process.</para></listitem>
  25. <listitem><para>Using the Kernel - Describes best practices and "how-to" information
  26. that lets you put the kernel to practical use. Some examples are "How to Build a
  27. Project Specific Tree", "How to Examine Changes in a Branch", and "Saving Kernel
  28. Modifications."</para></listitem>
  29. </itemizedlist>
  30. </para>
  31. <para>
  32. For more information on the kernel, see the following links:
  33. <itemizedlist>
  34. <listitem><para><ulink url='http://ldn.linuxfoundation.org/book/1-a-guide-kernel-development-process'></ulink></para></listitem>
  35. <listitem><para><ulink url='http://userweb.kernel.org/~akpm/stuff/tpp.txt'></ulink></para></listitem>
  36. <listitem><para><ulink url='http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/HOWTO;hb=HEAD'></ulink></para></listitem>
  37. </itemizedlist>
  38. <para>
  39. You can find more information on Yocto Project by visiting the website at
  40. <ulink url='http://www.yoctoproject.org'></ulink>.
  41. </para>
  42. </para>
  43. </section>
  44. <section id='concepts'>
  45. <title>Concepts</title>
  46. <para>
  47. This section provides conceptual information about the Yocto Project kernel:
  48. <itemizedlist>
  49. <listitem><para>Kernel Goals</para></listitem>
  50. <listitem><para>Yocto Project Kernel Development and Maintenance Overview</para></listitem>
  51. <listitem><para>Kernel Architecture</para></listitem>
  52. <listitem><para>Kernel Tools</para></listitem>
  53. </itemizedlist>
  54. </para>
  55. <section id='kernel-goals'>
  56. <title>Kernel Goals</title>
  57. <para>
  58. The complexity of embedded kernel design has increased dramatically.
  59. Whether it is managing multiple implementations of a particular feature or tuning and
  60. optimizing board specific features, flexibility and maintainability are key concerns.
  61. The Yocto Project Linux kernel is presented with the embedded
  62. developer's needs in mind and has evolved to assist in these key concerns.
  63. For example, prior methods such as applying hundreds of patches to an extracted
  64. tarball have been replaced with proven techniques that allow easy inspection,
  65. bisection and analysis of changes.
  66. Application of these techniques also creates a platform for performing integration and
  67. collaboration with the thousands of upstream development projects.
  68. </para>
  69. <para>
  70. With all these considerations in mind, the Yocto Project kernel and development team
  71. strives to attain these goals:
  72. <itemizedlist>
  73. <listitem><para>Allow the end user to leverage community best practices to seamlessly
  74. manage the development, build and debug cycles.</para></listitem>
  75. <listitem><para>Create a platform for performing integration and collaboration with the
  76. thousands of upstream development projects that exist.</para></listitem>
  77. <listitem><para>Provide mechanisms that support many different work flows, front-ends and
  78. management techniques.</para></listitem>
  79. <listitem><para>Deliver the most up-to-date kernel possible while still ensuring that
  80. the baseline kernel is the the most stable official release.</para></listitem>
  81. <listitem><para>Include major technological features as part of Yocto Project's up-rev
  82. strategy.</para></listitem>
  83. <listitem><para>Present a git tree, that just like the upstream kernel.org tree, has a
  84. clear and continuous history.</para></listitem>
  85. <listitem><para>Deliver a key set of supported kernel types, where each type is tailored
  86. to a specific use case (i.g. networking, consumer, devices, and so forth).</para></listitem>
  87. <listitem><para>Employ a git branching strategy that from a customer's point of view
  88. results in a linear path from the baseline kernel.org, through a select group of features and
  89. ends with their BSP-specific commits.</para></listitem>
  90. </itemizedlist>
  91. </para>
  92. </section>
  93. <section id='kernel-big-picture'>
  94. <title>Yocto Project Kernel Development and Maintenance Overview</title>
  95. <para>
  96. Yocto Project kernel, like other kernels, is based off the Linux kernel release
  97. from <ulink url='http://www.kernel.org'></ulink>.
  98. At the beginning of our major development cycle, we choose our Yocto Project kernel
  99. based on factors like release timing, the anticipated release timing of "final" (i.e. non "rc")
  100. upstream kernel.org versions, and Yocto Project feature requirements.
  101. Typically this will be a kernel that is in the
  102. final stages of development by the community (i.e. still in the release
  103. candidate or "rc" phase) and not yet a final release.
  104. But by being in the final stages of external development, we know that the
  105. kernel.org final release will clearly land within the early stages of
  106. the Yocto Project development window.
  107. </para>
  108. <para>
  109. This balance allows us to deliver the most up-to-date kernel
  110. as possible, while still ensuring that we have a stable official release as
  111. our baseline kernel version.
  112. </para>
  113. <para>
  114. The following figure represents the overall place the Yocto Project kernel fills.
  115. </para>
  116. <para>
  117. <imagedata fileref="figures/kernel-big-picture.png" width="6in" depth="6in" align="center" scale="100" />
  118. </para>
  119. <para>
  120. In the figure the ultimate source for the Yocto Project kernel is a released kernel
  121. from kernel.org.
  122. In addition to a foundational kernel from kernel.org the commercially released
  123. Yocto Project kernel contains a mix of important new mainline
  124. developments, non-mainline developments, Board Support Package (BSP) developments,
  125. and custom features.
  126. These additions result in a commercially released Yocto Project kernel that caters
  127. to specific embedded designer needs for targeted hardware.
  128. </para>
  129. <para>
  130. Once a Yocto Project kernel is officially released the Yocto Project team goes into
  131. their next development cycle, or "uprev" cycle.
  132. It is important to note that the most sustainable and stable way
  133. to include feature development upstream is through a kernel uprev process.
  134. Back-porting of hundreds of individual fixes and minor features from various
  135. kernel versions is not sustainable and can easily compromise quality.
  136. During the uprev cycle, the Yocto Project team uses an ongoing analysis of
  137. kernel development, BSP support, and release timing to select the best
  138. possible kernel.org version.
  139. The team continually monitors community kernel
  140. development to look for significant features of interest.
  141. The illustration depicts this by showing the team looking back to kernel.org for new features,
  142. BSP features, and significant bug fixes.
  143. The team does consider back-porting large features if they have a significant advantage.
  144. User or community demand can also trigger a back-port or creation of new
  145. functionality in the Yocto Project baseline kernel during the uprev cycle.
  146. </para>
  147. <para>
  148. Generally speaking, every new kernel both adds features and introduces new bugs.
  149. These consequences are the basic properties of upstream kernel development and are
  150. managed by the Yocto Project team's kernel strategy.
  151. It is the Yocto Project team's policy to not back-port minor features to the released kernel.
  152. They only consider back-porting significant technological jumps - and, that is done
  153. after a complete gap analysis.
  154. The reason for this policy is that simply back-porting any small to medium sized change
  155. from an evolving kernel can easily create mismatches, incompatibilities and very
  156. subtle errors.
  157. </para>
  158. <para>
  159. These policies result in both a stable and a cutting
  160. edge kernel that mixes forward ports of existing features and significant and critical
  161. new functionality.
  162. Forward porting functionality in the Yocto Project kernel can be thought of as a
  163. "micro uprev."
  164. The many “micro uprevs” produce a kernel version with a mix of
  165. important new mainline, non-mainline, BSP developments and feature integrations.
  166. This kernel gives insight into new features and allows focused
  167. amounts of testing to be done on the kernel, which prevents
  168. surprises when selecting the next major uprev.
  169. The quality of these cutting edge kernels is evolving and the kernels are used in very special
  170. cases for BSP and feature development.
  171. </para>
  172. </section>
  173. <section id='kernel-architecture'>
  174. <title>Kernel Architecture</title>
  175. <para>
  176. This section describes the architecture of the Yocto Project kernel and provides information
  177. on the mechanisms used to achieve that architecture.
  178. </para>
  179. <section id='architecture-overview'>
  180. <title>Overview</title>
  181. <para>
  182. As mentioned earlier, a key goal of Yocto Project is to present the developer with
  183. a kernel that has a clear and continuous history that is visible to the user.
  184. The architecture and mechanisms used achieve that goal in a manner similar to the
  185. upstream kernel.org.
  186. </para>
  187. <para>
  188. You can think of the Yocto Project kernel as consisting of a baseline kernel with
  189. added features logically structured on top of the baseline.
  190. The features are tagged and organized by way of a branching strategy implemented by the
  191. source code manager (SCM) git.
  192. The result is that the user has the ability to see the added features and
  193. the commits that make up those features.
  194. In addition to being able to see added features, the user can also view the history of what
  195. made up the baseline kernel as well.
  196. </para>
  197. <para>
  198. The following illustration shows the conceptual Yocto Project kernel.
  199. </para>
  200. <para>
  201. <imagedata fileref="figures/kernel-architecture-overview.png" width="6in" depth="7in" align="center" scale="100" />
  202. </para>
  203. <para>
  204. In the illustration, the "kernel.org Branch Point" marks the specific spot (or release) from
  205. which the Yocto Project kernel is created. From this point "up" in the tree features and
  206. differences are organized and tagged.
  207. </para>
  208. <para>
  209. The "Yocto Project Baseline Kernel" contains functionality that is common to every kernel
  210. type and BSP that is organized further up the tree. Placing these common features in the
  211. tree this way means features don't have to be duplicated along individual branches of the
  212. structure.
  213. </para>
  214. <para>
  215. From the Yocto Project Baseline Kernel branch points represent specific functionality
  216. for individual BSPs as well as real-time kernels.
  217. The illustration represents this through three BSP-specific branches and a real-time
  218. kernel branch.
  219. Each branch represents some unique functionality for the BSP or a real-time kernel.
  220. </para>
  221. <para>
  222. The real-time kernel branch has common features for all real-time kernels and contains
  223. more branches for individual BSP-specific real-time kernels.
  224. The illustration shows three branches as an example.
  225. Each branch points the way to specific, unique features for a respective real-time
  226. kernel as they apply to a given BSP.
  227. </para>
  228. <para>
  229. The resulting tree structure presents a clear path of markers (or branches) to the user
  230. that for all practical purposes is the kernel needed for any given set of requirements.
  231. </para>
  232. </section>
  233. <section id='branching-and-workflow'>
  234. <title>Branching Strategy and Workflow</title>
  235. <para>
  236. The Yocto Project team creates kernel branches at points where functionality is
  237. no longer shared and thus, needs to be isolated.
  238. For example, board-specific incompatibilities would require different functionality
  239. and would require a branch to separate the features.
  240. Likewise, for specific kernel features the same branching strategy is used.
  241. This branching strategy results in a tree that has features organized to be specific
  242. for particular functionality, single kernel types, or a subset of kernel types.
  243. This strategy results in not having to store the same feature twice internally in the
  244. tree.
  245. Rather we store the unique differences required to apply the feature onto the kernel type
  246. in question.
  247. </para>
  248. <para>
  249. BSP-specific code additions are handled in a similar manner to kernel-specific additions.
  250. Some BSPs only make sense given certain kernel types.
  251. So, for these types, we create branches off the end of that kernel type for all
  252. of the BSPs that are supported on that kernel type.
  253. From the perspective of the tools that create the BSP branch, the BSP is really no
  254. different than a feature.
  255. Consequently, the same branching strategy applies to BSPs as it does to features.
  256. So again, rather than store the BSP twice, only the unique differences for the BSP across
  257. the supported multiple kernels are uniquely stored.
  258. </para>
  259. <para>
  260. While this strategy results in a tree with a significant number of branches, it is
  261. important to realize that from the customer's point of view, there is a linear
  262. path that travels from the baseline kernel.org, through a select group of features and
  263. ends with their BSP-specific commits.
  264. In other words, the divisions of the kernel are transparent and are not relevant
  265. to the developer on a day-to-day basis.
  266. From the customer's perspective, this is the "master" branch.
  267. They do not need not be aware of the existence of any other branches at all.
  268. Of course there is value in the existence of these branches
  269. in the tree, should a person decide to explore them.
  270. For example, a comparison between two BSPs at either the commit level or at the line-by-line
  271. code diff level is now a trivial operation.
  272. </para>
  273. <para>
  274. Working with the kernel as a structured tree follows recognized community best practices.
  275. In particular, the kernel as shipped with the product should be
  276. considered an 'upstream source' and viewed as a series of
  277. historical and documented modifications (commits).
  278. These modifications represent the development and stabilization done
  279. by the Yocto Project kernel development team.
  280. </para>
  281. <para>
  282. Because commits only change at significant release points in the product life cycle,
  283. developers can work on a branch created
  284. from the last relevant commit in the shipped Yocto Project kernel.
  285. As mentioned previously, the structure is transparent to the user
  286. because the kernel tree is left in this state after cloning and building the kernel.
  287. </para>
  288. </section>
  289. <section id='source-code-manager-git'>
  290. <title>Source Code Manager - git</title>
  291. <para>
  292. The Source Code Manager (SCM) is git and it is the obvious mechanism for meeting the
  293. previously mentioned goals.
  294. Not only is it the SCM for kernel.org but git continues to grow in popularity and
  295. supports many different work flows, front-ends and management techniques.
  296. </para>
  297. <note><para>
  298. It should be noted that you can use as much, or as little, of what git has to offer
  299. as is appropriate to your project.
  300. </para></note>
  301. </section>
  302. </section>
  303. <section id='kernel-tools'>
  304. <title>Kernel Tools</title>
  305. <para>
  306. Since most standard workflows involve moving forward with an existing tree by
  307. continuing to add and alter the underlying baseline, the tools that manage
  308. Yocto Project's kernel construction are largely hidden from the developer to
  309. present a simplified view of the kernel for ease of use.
  310. </para>
  311. <para>
  312. The fundamental properties of the tools that manage and construct the
  313. kernel are:
  314. <itemizedlist>
  315. <listitem><para>the ability to group patches into named, reusable features</para></listitem>
  316. <listitem><para>to allow top down control of included features</para></listitem>
  317. <listitem><para>the binding of kernel configuration to kernel patches/features</para></listitem>
  318. <listitem><para>the presentation of a seamless git repository that blends Yocto Project value with the kernel.org history and development</para></listitem>
  319. </itemizedlist>
  320. </para>
  321. <!--<para>
  322. The tools that construct a kernel tree will be discussed later in this
  323. document. The following tools form the foundation of the Yocto Project
  324. kernel toolkit:
  325. <itemizedlist>
  326. <listitem><para>git : distributed revision control system created by Linus Torvalds</para></listitem>
  327. <listitem><para>guilt: quilt on top of git</para></listitem>
  328. <listitem><para>*cfg : kernel configuration management and classification</para></listitem>
  329. <listitem><para>kgit*: Yocto Project kernel tree creation and management tools</para></listitem>
  330. <listitem><para>scc : series &amp; configuration compiler</para></listitem>
  331. </itemizedlist>
  332. </para> -->
  333. </section>
  334. </section>
  335. <!-- <section id='concepts2'>
  336. <title>Kernel Concepts</title>
  337. <itemizedlist>
  338. <listitem><para>What tools and commands are used with the kernel.</para></listitem>
  339. <listitem><para>Source Control Manager (SCM).</para></listitem>
  340. <listitem><para>What are some workflows that you can apply using the kernel.</para></listitem>
  341. </itemizedlist>
  342. </section> -->
  343. <section id='actions'>
  344. <title>How to Get Things Accomplished with the Kernel</title>
  345. <para>
  346. This section describes how to accomplish tasks involving the kernel's tree structure.
  347. The information covers the following:
  348. <itemizedlist>
  349. <listitem><para>Tree construction</para></listitem>
  350. <listitem><para>Build strategies</para></listitem>
  351. <!-- <listitem><para>Series &amp; Configuration Compiler</para></listitem>
  352. <listitem><para>kgit</para></listitem> -->
  353. <listitem><para>Workflow examples</para></listitem>
  354. <listitem><para>Source Code Manager (SCM)</para></listitem>
  355. <!-- <listitem><para>Board Support Package (BSP) template migration</para></listitem> -->
  356. <listitem><para>BSP creation</para></listitem>
  357. <listitem><para>Patching</para></listitem>
  358. <listitem><para>Updating BSP patches and configuration</para></listitem>
  359. <!-- <listitem><para>guilt</para></listitem>
  360. <listitem><para>scc file example</para></listitem> -->
  361. <listitem><para>"dirty" string</para></listitem>
  362. <!-- <listitem><para>Transition kernel layer</para></listitem> -->
  363. </itemizedlist>
  364. </para>
  365. <section id='tree-construction'>
  366. <title>Tree Construction</title>
  367. <para>
  368. The Yocto Project kernel repository, as shipped with the product, is created by
  369. compiling and executing the set of feature descriptions for every BSP/feature
  370. in the product. Those feature descriptions list all necessary patches,
  371. configuration, branching, tagging and feature divisions found in the kernel.
  372. </para>
  373. <para>
  374. The files used to describe all the valid features and BSPs in the Yocto Project
  375. kernel can be found in any clone of the kernel git tree. The directory
  376. wrs/cfg/kernel-cache/ is a snapshot of all the kernel configuration and
  377. feature descriptions (.scc) that were used to build the kernel repository.
  378. It should however be noted, that browsing the snapshot of feature
  379. descriptions and patches is not an effective way to determine what is in a
  380. particular kernel branch. Using git directly to get insight into the changes
  381. in a branch is more efficient and a more flexible way to inspect changes to
  382. the kernel. Examples of using git to inspect kernel commits are in the
  383. following sections.
  384. </para>
  385. <para>
  386. As a reminder, it is envisioned that a ground up reconstruction of the
  387. complete kernel tree is an action only taken by Yocto Project team during an
  388. active development cycle. When an end user creates a project, it takes
  389. advantage of this complete tree in order to efficiently place a git tree
  390. within their project.
  391. </para>
  392. <para>
  393. The general flow of the project specific kernel tree construction is as follows:
  394. <orderedlist>
  395. <listitem><para>a top level kernel feature is passed to the kernel build subsystem,
  396. normally this is a BSP for a particular kernel type.</para></listitem>
  397. <listitem><para>the file that describes the top level feature is located by searching
  398. system directories:</para>
  399. <itemizedlist>
  400. <listitem><para>the kernel-cache under linux/wrs/cfg/kernel-cache</para></listitem>
  401. <!-- <listitem><para>kernel-*-cache directories in layers</para></listitem> -->
  402. <listitem><para>recipe SRC_URIs</para></listitem>
  403. <!-- <listitem><para>configured and default templates</para></listitem> -->
  404. </itemizedlist>
  405. <para>In a typical build a feature description of the format:
  406. &lt;bsp name&gt;-&lt;kernel type&gt;.scc is the target of the search.
  407. </para></listitem>
  408. <listitem><para>once located, the feature description is compiled into a simple script
  409. of actions, or an existing equivalent script which was part of the
  410. shipped kernel is located.</para></listitem>
  411. <listitem><para>extra features are appended to the top level feature description. Extra
  412. features can come from the KERNEL_FEATURES variable in recipes.</para></listitem>
  413. <listitem><para>each extra feature is located, compiled and appended to the script from
  414. step #3</para></listitem>
  415. <listitem><para>the script is executed, and a meta-series is produced. The meta-series
  416. is a description of all the branches, tags, patches and configuration that
  417. need to be applied to the base git repository to completely create the
  418. "bsp_name-kernel_type".</para></listitem>
  419. <listitem><para>the base repository is cloned, and the actions
  420. listed in the meta-series are applied to the tree.</para></listitem>
  421. <listitem><para>the git repository is left with the desired branch checked out and any
  422. required branching, patching and tagging has been performed.</para></listitem>
  423. </orderedlist>
  424. </para>
  425. <para>
  426. The tree is now ready for configuration and compilation. Those two topics will
  427. be covered below.
  428. </para>
  429. <note><para>The end user generated meta-series adds to the kernel as shipped with
  430. the Yocto Project release. Any add-ons and configuration data are applied
  431. to the end of an existing branch. The full repository generation that
  432. is found in the linux-2.6-windriver.git is the combination of all
  433. supported boards and configurations.
  434. </para></note>
  435. <para>
  436. This technique is flexible and allows the seamless blending of an immutable
  437. history with additional deployment specific patches. Any additions to the
  438. kernel become an integrated part of the branches.
  439. </para>
  440. <!-- <note><para>It is key that feature descriptions indicate if any branches are
  441. required, since the build system cannot automatically decide where a
  442. BSP should branch or if that branch point needs a name with
  443. significance. There is a single restriction enforced by the compilation
  444. phase:
  445. </para>
  446. <para>A BSP must create a branch of the format &lt;bsp name&gt;-&lt;kernel type&gt;.</para>
  447. <para>This means that all merged/support BSPs must indicate where to start
  448. its branch from, with the right name, in its .scc files. The scc
  449. section describes the available branching commands in more detail.
  450. </para>
  451. </note> -->
  452. <para>
  453. A summary of end user tree construction activities follow:
  454. <itemizedlist>
  455. <listitem><para>compile and link a full top-down kernel description from feature descriptions</para></listitem>
  456. <listitem><para>execute the complete description to generate a meta-series</para></listitem>
  457. <listitem><para>interpret the meta-series to create a customized git repository for the
  458. board</para></listitem>
  459. <listitem><para>migrate configuration fragments and configure the kernel</para></listitem>
  460. <listitem><para>checkout the BSP branch and build</para></listitem>
  461. </itemizedlist>
  462. </para>
  463. </section>
  464. <section id='build-strategy'>
  465. <title>Build Strategy</title>
  466. <para>
  467. There are some prerequisites that must be met before starting the compilation
  468. phase of the kernel build system:
  469. </para>
  470. <itemizedlist>
  471. <listitem><para>There must be a kernel git repository indicated in the SRC_URI.</para></listitem>
  472. <listitem><para>There must be a branch &lt;bsp name&gt;-&lt;kernel type&gt;.</para></listitem>
  473. </itemizedlist>
  474. <para>
  475. These are typically met by running tree construction/patching phase of the
  476. build system, but can be achieved by other means. Examples of alternate work
  477. flows such as bootstrapping a BSP are provided below.
  478. </para>
  479. <para>
  480. Before building a kernel it is configured by processing all of the
  481. configuration "fragments" specified by the scc feature descriptions. As the
  482. features are compiled, associated kernel configuration fragments are noted
  483. and recorded in the meta-series in their compilation order. The
  484. fragments are migrated, pre-processed and passed to the Linux Kernel
  485. Configuration subsystem (lkc) as raw input in the form of a .config file.
  486. The lkc uses its own internal dependency constraints to do the final
  487. processing of that information and generates the final .config that will
  488. be used during compilation.
  489. </para>
  490. <para>
  491. Kernel compilation is started, using the board's architecture and other
  492. relevant values from the board template, and a kernel image is produced.
  493. </para>
  494. <para>
  495. The other thing that you will first see once you configure a kernel is that
  496. it will generate a build tree that is separate from your git source tree.
  497. This build dir will be called "linux-&lt;BSPname&gt;-&lt;kerntype&gt;-build" where
  498. kerntype is one of standard kernel types. This functionality is done by making
  499. use of the existing support that is within the kernel.org tree by default.
  500. </para>
  501. <para>
  502. What this means, is that all the generated files (that includes the final
  503. ".config" itself, all ".o" and ".a" etc) are now in this directory. Since
  504. the git source tree can contain any number of BSPs, all on their own branch,
  505. you now can easily switch between builds of BSPs as well, since each one also
  506. has their own separate build directory.
  507. </para>
  508. </section>
  509. <!-- <section id='scc'>
  510. <title>Series &amp; Configuration Compiler (SCC)</title>
  511. <para>
  512. In early versions of the product, kernel patches were simply listed in a flat
  513. file called "patches.list", and then quilt was added as a tool to help
  514. traverse this list, which in quilt terms was called a "series" file.
  515. </para>
  516. <para>
  517. Before the 2.0 release, it was already apparent that a static series file was
  518. too inflexible, and that the series file had to become more dynamic and rely
  519. on certain state (like kernel type) in order to determine whether a patch was
  520. to be used or not. The 2.0 release already made use of some stateful
  521. construction of series files, but since the delivery mechanism was unchanged
  522. (tar + patches + series files), most people were not aware of anything really
  523. different. The 3.0 release continues with this stateful construction of
  524. series files, but since the delivery mechanism is changed (git + branches) it
  525. now is more apparent to people.
  526. </para>
  527. <para>
  528. As was previously mentioned, scc is a "series and configuration
  529. compiler". Its role is to combine feature descriptions into a format that can
  530. be used to generate a meta-series. A meta series contains all the required
  531. information to construct a complete set of branches that are required to
  532. build a desired board and feature set. The meta series is interpreted by the
  533. kgit tools to create a git repository that could be built.
  534. </para>
  535. <para>
  536. To illustrate how scc works, a feature description must first be understood.
  537. A feature description is simply a small bash shell script that is executed by
  538. scc in a controlled environment. Each feature description describes a set of
  539. operations that add patches, modify existing patches or configure the
  540. kernel. It is key that feature descriptions can include other features, and
  541. hence allow the division of patches and configuration into named, reusable
  542. containers.
  543. </para>
  544. <para>
  545. Each feature description can use any of the following valid scc commands:
  546. <itemizedlist>
  547. <listitem><para>shell constructs: bash conditionals and other utilities can be used in a feature
  548. description. During compilation, the working directory is the feature
  549. description itself, so any command that is "raw shell" and not from the
  550. list of supported commands, can not directly modify a git repository.</para></listitem>
  551. <listitem><para>patch &lt;relative path&gt;/&lt;patch name&gt;: outputs a patch to be included in a feature's patch set. Only the name of
  552. the patch is supplied, the path is calculated from the currently set
  553. patch directory, which is normally the feature directory itself.</para></listitem>
  554. <listitem><para>patch_trigger &gt;condition&lt; &gt;action&lt; &lt;tgt&gt;: indicate that a trigger should be set to perform an action on a
  555. patch.</para>
  556. <para>The conditions can be:
  557. <itemizedlist>
  558. <listitem><para>arch:&lt;comma separated arch list or "all"&gt;</para></listitem>
  559. <listitem><para>plat:&lt;comma separated platform list or "all"&gt;</para></listitem>
  560. </itemizedlist></para>
  561. <para>The action can be:
  562. <itemizedlist>
  563. <listitem><para>exclude: This is used in exceptional situations where a patch
  564. cannot be applied for certain reasons (arch or platform).
  565. When the trigger is satisfied the patch will be removed from
  566. the patch list.</para></listitem>
  567. <listitem><para>include: This is used to include a patch only for a specific trigger.
  568. Like exclude, this should only be used when necessary.
  569. It takes 1 argument, the patch to include.</para></listitem>
  570. </itemizedlist></para></listitem>
  571. <listitem><para>include &lt;feature name&gt; [after &lt;feature&gt;]: includes a feature for processing. The feature is "expanded" at the
  572. position of the include directive. This means that any patches,
  573. configuration or sub-includes of the feature will appear in the final
  574. series before the commands that follow the include.</para>
  575. <para>
  576. include searches the include directories for a matching feature name,
  577. include directories are passed to scc by the caller using -I &lt;path&gt; and
  578. is transparent to the feature script. This means that &lt;feature name&gt; must
  579. be relative to one of the search paths. For example, if
  580. /opt/kernel-cache/feat/sched.scc is to be included and scc is invoked
  581. with -I /opt/kernel-cache, then a feature would issue "include
  582. feat/sched.scc" to include the feature.
  583. </para>
  584. <para>
  585. The optional "after" directive allows a feature to modify the existing
  586. order of includes and insert a feature after the named feature is
  587. processed. Note: the "include foo after bar" must be issued before "bar"
  588. is processed, so is normally only used by a new top level feature to
  589. modify the order of features in something it is including.</para></listitem>
  590. <listitem><para>exclude &lt;feature name&gt;: Indicates that a particular feature should *not* be included even if an
  591. 'include' directive is found. The exclude must be issued before the
  592. include is processed, so is normally only used by a new top level feature
  593. to modify the order of features in something it is including.</para></listitem>
  594. <listitem><para>git &lt;command&gt;: Issues any git command during tree construction. Note: this command is
  595. not validated/sanitized so care must be taken to not damage the
  596. tree. This can be used to script branching, tagging, pulls or other git
  597. operations.</para></listitem>
  598. <listitem><para>dir &lt;directory&gt;: changes the working directory for "patch" directives. This can be used to
  599. shorten a long sequence of patches by not requiring a common relative
  600. directory to be issued each time.</para></listitem>
  601. <listitem><para>kconf &lt;type&gt; &lt;fragment name&gt;: associates a kernel config frag with the feature.
  602. &lt;type&gt; can be
  603. "hardware" or "non-hardware" and is used by the kernel configuration
  604. subsystem to audit configuration. &lt;fragment name&gt; is the name of a file
  605. in the current feature directory that contains a series of kernel
  606. configuration options. There is no restriction on the chosen fragment
  607. name, although a suffix of ".cfg" is recommended. Multiple fragment
  608. specifications are supported.</para></listitem>
  609. <listitem><para>branch &lt;branch name&gt;: creates a branch in the tree. All subsequent patch commands will be
  610. applied to the new branch and changes isolated from the rest of the
  611. repository.</para></listitem>
  612. <listitem><para>scc_leaf &lt;base feature&gt; &lt;branch name&gt;: Performs a combination feature include and branch. This is mainly a
  613. convenience directive, but has significance to some build system bindings
  614. as a sentinel to indicate that this intends to create a branch that is
  615. valid for kernel compilation.</para></listitem>
  616. <listitem><para>tag &lt;tag name&gt;: Tags the tree. The tag will be applied in processing order, so will
  617. be after already applied patches and precede patches yet to be applied.</para></listitem>
  618. <listitem><para>define &lt;var&gt; &lt;value&gt;: Creates a variable with a particular value that can be used in subsequent
  619. feature descriptions.</para></listitem>
  620. </itemizedlist>
  621. </para>
  622. </section> -->
  623. <!-- <section id='kgit-tools'>
  624. <title>kgit Tools</title>
  625. <para>
  626. The kgit tools are responsible for constructing and maintaining the Wind
  627. River kernel repository. These activities include importing, exporting, and
  628. applying patches as well as sanity checking and branch management. From the
  629. developers perspective, the kgit tools are hidden and rarely require
  630. interactive use. But one tool in particular that warrants further description
  631. is "kgit-meta".
  632. </para>
  633. <para>
  634. kgit-meta is the actual application of feature description(s) to a kernel repo.
  635. In other words, it is responsible for interpreting the meta series generated
  636. from a scc compiled script. As a result, kgit-meta is coupled to the set of
  637. commands permitted in a .scc feature description (listed in the scc section).
  638. kgit-meta understands both the meta series format and how to use git and
  639. guilt to modify a base git repository. It processes a meta-series line by
  640. line, branching, tagging, patching and tracking changes that are made to the
  641. base git repository.
  642. </para>
  643. <para>
  644. Once kgit-meta has processed a meta-series, it leaves the repository with the
  645. last branch checked out, and creates the necessary guilt infrastructure to
  646. inspect the tree, or add to it via using guilt. As was previously mentioned,
  647. guilt is not required, but is provided as a convenience. Other utilities such
  648. as quilt, stgit, git or others can also be used to manipulate the git
  649. repository.
  650. </para>
  651. </section> -->
  652. <section id='workflow-examples'>
  653. <title>Workflow Examples</title>
  654. <para>
  655. As previously noted, the Yocto Project kernel has built in git/guilt
  656. integration, but these utilities are not the only way to work with the kernel
  657. repository. Yocto Project has not made changes to git, or other tools that
  658. invalidate alternate workflows. Additionally, the way the kernel repository
  659. is constructed uses only core git functionality allowing any number of tools
  660. or front ends to use the resulting tree.</para>
  661. <para>
  662. This section contains several workflow examples.
  663. </para>
  664. <section id='change-inspection-kernel-changes-commits'>
  665. <title>Change Inspection: Kernel Changes/Commits</title>
  666. <para>
  667. A common question when working with a BSP/kernel is: "What changes have been applied to this tree?"
  668. </para>
  669. <para>
  670. In some projects, where a collection of directories that
  671. contained patches to the kernel, those patches could be inspected, grep'd or
  672. otherwise used to get a general feeling for changes. This sort of patch
  673. inspection is not an efficient way to determine what has been done to the
  674. kernel, since there are many optional patches that are selected based on the
  675. kernel type and feature description, not to mention patches that are actually
  676. in directories that are not being searched.
  677. </para>
  678. <para>
  679. A more effective way to determine what has changed in the kernel is to use
  680. git and inspect / search the kernel tree. This is a full view of not only the
  681. source code modifications, but the reasoning behind the changes.
  682. </para>
  683. <section id='what-changed-in-a-bsp'>
  684. <title>What Changed in a BSP?</title>
  685. <para>
  686. These examples could continue for some time, since the Yocto Project git
  687. repository doesn't break existing git functionality and there are nearly
  688. endless permutations of those commands. Also note that unless a commit range
  689. is given (&lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;), kernel.org history is blended
  690. with Yocto Project changes
  691. </para>
  692. <literallayout class='monospaced'>
  693. # full description of the changes
  694. &gt; git whatchanged &lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;
  695. &gt; eg: git whatchanged standard..common_pc-standard
  696. # summary of the changes
  697. &gt; git log &dash;&dash;pretty=oneline &dash;&dash;abbrev-commit &lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;
  698. # source code changes (one combined diff)
  699. &gt; git diff &lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;
  700. &gt; git show &lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;
  701. # dump individual patches per commit
  702. &gt; git format-patch -o &lt;dir&gt; &lt;kernel type&gt;..&lt;bsp&gt;-&lt;kernel type&gt;
  703. # determine the change history of a particular file
  704. &gt; git whatchanged &lt;path to file&gt;
  705. # determine the commits which touch each line in a file
  706. &gt; git blame &lt;path to file&gt;
  707. </literallayout>
  708. </section>
  709. <section id='show-a-particular-feature-or-branch-change'>
  710. <title>Show a Particular Feature or Branch Change</title>
  711. <para>
  712. Significant features or branches are tagged in the Yocto Project tree to divide
  713. changes. Remember to first determine (or add) the tag of interest. Note:
  714. there will be many tags, since each BSP branch is tagged, kernel.org tags and
  715. feature tags are all present.
  716. </para>
  717. <literallayout class='monospaced'>
  718. # show the changes tagged by a feature
  719. &gt; git show &lt;tag&gt;
  720. &gt; eg: git show yaffs2
  721. # determine which branches contain a feature
  722. &gt; git branch &dash;&dash;contains &lt;tag&gt;
  723. # show the changes in a kernel type
  724. &gt; git whatchanged wrs_base..&lt;kernel type&gt;
  725. &gt; eg: git whatchanged wrs_base..standard
  726. </literallayout>
  727. <para>
  728. Many other comparisons can be done to isolate BSP changes, such as comparing
  729. to kernel.org tags (v2.6.27.18, etc), per subsystem comparisons (git
  730. whatchanged mm) or many other types of checks.
  731. </para>
  732. </section>
  733. </section>
  734. <section id='development-saving-kernel-modifications'>
  735. <title>Development: Saving Kernel Modifications</title>
  736. <para>
  737. Another common operation is to build a Yocto Project supplied BSP, make some
  738. changes, rebuild and test. Those local changes often need to be exported,
  739. shared or otherwise maintained.
  740. </para>
  741. <para>
  742. Since the Yocto Project kernel source tree is backed by git, this activity is
  743. greatly simplified and is much easier than in previous releases. git tracks
  744. file modifications, additions and deletions, which allows the developer to
  745. modify the code and later realize that the changes should be saved, and
  746. easily determine what was changed. It also provides many tools to commit,
  747. undo and export those modifications.
  748. </para>
  749. <para>
  750. There are many ways to perform this action, and the technique employed
  751. depends on the destination for the patches, which could be any of:
  752. <itemizedlist>
  753. <listitem><para>bulk storage</para></listitem>
  754. <listitem><para>internal sharing either through patches or using git</para></listitem>
  755. <listitem><para>external submission</para></listitem>
  756. <listitem><para>export for integration into another SCM</para></listitem>
  757. </itemizedlist>
  758. </para>
  759. <para>
  760. The destination of the patches also incluences the method of gathering them
  761. due to issues such as:
  762. <itemizedlist>
  763. <listitem><para>bisectability</para></listitem>
  764. <listitem><para>commit headers</para></listitem>
  765. <listitem><para>division of subsystems for separate submission / review</para></listitem>
  766. </itemizedlist>
  767. </para>
  768. <section id='bulk-export'>
  769. <title>Bulk Export</title>
  770. <para>
  771. If patches are simply being stored outside of the kernel source repository,
  772. either permanently or temporarily, then there are several methods that can be
  773. used.
  774. </para>
  775. <para>
  776. Note the "bulk" in this discussion, these techniques are not appropriate for
  777. full integration of upstream submission, since they do not properly divide
  778. changes or provide an avenue for per-change commit messages. This example
  779. assumes that changes have not been committed incrementally during development
  780. and simply must be gathered and exported.
  781. <literallayout class='monospaced'>
  782. # bulk export of ALL modifications without separation or division
  783. # of the changes
  784. &gt; git add .
  785. &gt; git commit -s -a -m &gt;commit message&lt;
  786. or
  787. &gt; git commit -s -a # and interact with $EDITOR
  788. </literallayout>
  789. </para>
  790. <para>
  791. These operations have captured all the local changes in the project source
  792. tree in a single git commit, and that commit is also stored in the project's
  793. source tree.
  794. </para>
  795. <para>
  796. Once exported, those changes can then be restored manually, via a template or
  797. through integration with the default_kernel. Those topics are covered in
  798. future sections.
  799. </para>
  800. </section>
  801. <section id='incremental-planned-sharing'>
  802. <title>Incremental/Planned Sharing</title>
  803. <para>
  804. Note: unlike the previous "bulk" section, the following examples assume that
  805. changes have been incrementally committed to the tree during development and
  806. now are being exported.
  807. </para>
  808. <para>
  809. During development the following commands will be of interest, but for full
  810. git documentation refer to the git man pages or an online resource such as
  811. http://github.com
  812. <literallayout class='monospaced'>
  813. # edit a file
  814. &gt; vi &gt;path&lt;/file
  815. # stage the change
  816. &gt; git add &gt;path&lt;/file
  817. # commit the change
  818. &gt; git commit -s
  819. # remove a file
  820. &gt; git rm &gt;path&lt;/file
  821. # commit the change
  822. &gt; git commit -s
  823. ... etc.
  824. </literallayout>
  825. </para>
  826. <para>
  827. Distributed development with git is possible by having a universally agreed
  828. upon unique commit identifier (set by the creator of the commit) mapping to a
  829. specific changeset with a specific parent. This ID is created for you when
  830. you create a commit, and will be re-created when you amend/alter or re-apply
  831. a commit. As an individual in isolation, this is of no interest, but if you
  832. intend to share your tree with normal git push/pull operations for
  833. distributed development, you should consider the ramifications of changing a
  834. commit that you've already shared with others.
  835. </para>
  836. <para>
  837. Assuming that the changes have *not* been pushed upstream, or pulled into
  838. another repository, both the commit content and commit messages associated
  839. with development can be update via:
  840. <literallayout class='monospaced'>
  841. &gt; git add &gt;path&lt;/file
  842. &gt; git commit &dash;&dash;amend
  843. &gt; git rebase or git rebase -i
  844. </literallayout>
  845. </para>
  846. <para>
  847. Again, assuming that the changes have *not* been pushed upstream, and that
  848. there are no pending works in progress (use "git status" to check) then
  849. commits can be reverted (undone) via:
  850. <literallayout class='monospaced'>
  851. # remove the commit, update working tree and remove all
  852. # traces of the change
  853. &gt; git reset &dash;&dash;hard HEAD^
  854. # remove the commit, but leave the files changed and staged for re-commit
  855. &gt; git reset &dash;&dash;soft HEAD^
  856. # remove the commit, leave file change, but not staged for commit
  857. &gt; git reset &dash;&dash;mixed HEAD^
  858. </literallayout>
  859. </para>
  860. <para>
  861. Branches can be created, changes cherry-picked or any number of git
  862. operations performed until the commits are in good order for pushing upstream
  863. or pull requests. After a push or pull, commits are normally considered
  864. 'permanent' and should not be modified, only incrementally changed in new
  865. commits. This is standard "git" workflow and Yocto Project recommends the
  866. kernel.org best practices.
  867. </para>
  868. <note><para>It is recommend to tag or branch before adding changes to a Yocto Project
  869. BSP (or creating a new one), since the branch or tag provides a
  870. reference point to facilitate locating and exporting local changes.
  871. </para></note>
  872. <section id='export-internally-via-patches'>
  873. <title>Export Internally Via Patches</title>
  874. <para>
  875. Committed changes can be extracted from a working directory by exporting them
  876. as patches. Those patches can be used for upstream submission, placed in a
  877. Yocto Project template for automatic kernel patching or many other common uses.
  878. <literallayout class='monospaced'>
  879. # &gt;first commit&gt; can be a tag if one was created before development
  880. # began. It can also be the parent branch if a branch was created
  881. # before development began.
  882. &gt; git format-patch -o &lt;dir&gt; &lt;first commit&gt;..&lt;last commit&gt;
  883. </literallayout>
  884. </para>
  885. <para>
  886. In other words:
  887. <literallayout class='monospaced'>
  888. # identify commits of interest.
  889. # if the tree was tagged before development
  890. &gt; git format-patch -o &lt;save dir&gt; &lt;tag&gt;
  891. # if no tags are available
  892. &gt; git format-patch -o &lt;save dir&gt; HEAD^ # last commit
  893. &gt; git format-patch -o &lt;save dir&gt; HEAD^^ # last 2 commits
  894. &gt; git whatchanged # identify last commit
  895. &gt; git format-patch -o &lt;save dir&gt; &lt;commit id&gt;
  896. &gt; git format-patch -o &lt;save dir&gt; &lt;rev-list&gt;
  897. </literallayout>
  898. </para>
  899. <para>
  900. The result is a directory with sequentially numbered patches, that when
  901. applied to a repository using "git am", will reproduce the original commit
  902. and all related information (author, date, commit log, etc) will be
  903. preserved. Note that new commit IDs will be generated upon reapplication,
  904. reflecting that the commit is now applied to an underlying commit with a
  905. different ID.
  906. </para>
  907. <!--<para>
  908. See the "template patching" example for how to use the patches to
  909. automatically apply to a new kernel build.
  910. </para> -->
  911. </section>
  912. <section id='export-internally-via-git'>
  913. <title>Export Internally Via git</title>
  914. <para>
  915. Committed changes can also be exported from a working directory by pushing
  916. (or by making a pull request) the changes into a master repository. Those
  917. same change can then be pulled into a new kernel build at a later time using this command form:
  918. <literallayout class='monospaced'>
  919. git push ssh://&lt;master server&gt;/&lt;path to repo&gt; &lt;local branch&gt;:&lt;remote branch&gt;
  920. </literallayout>
  921. For example:
  922. <literallayout class='monospaced'>
  923. &gt; push ssh://git.mycompany.com/pub/git/kernel-2.6.27 common_pc-standard:common_pc-standard
  924. </literallayout>
  925. A pull request entails using "git request-pull" to compose an email to the
  926. maintainer requesting that a branch be pulled into the master repository, see
  927. http://github.com/guides/pull-requests for an example.
  928. </para>
  929. <para>
  930. Other commands such as 'git stash' or branching can also be used to save
  931. changes, but are not covered in this document.
  932. </para>
  933. <para>
  934. See the section "importing from another SCM" for how a git push to the
  935. default_kernel, can be used to automatically update the builds of all users
  936. of a central git repository.
  937. </para>
  938. </section>
  939. </section>
  940. <section id='export-for-external-upstream-submission'>
  941. <title>Export for External (Upstream) Submission</title>
  942. <para>
  943. If patches are to be sent for external submission, they can be done via a
  944. pull request if the patch series is large or the maintainer prefers to pull
  945. changes. But commonly, patches are sent as email series for easy review and
  946. integration.
  947. </para>
  948. <note><para>
  949. Before sending patches for review ensure that you understand the
  950. standard of the community in question and follow their best practices. For
  951. example, kernel patches should follow standards such as:
  952. <itemizedlist>
  953. <listitem><para><ulink url='http://userweb.kernel.org/~akpm/stuff/tpp.txt'></ulink></para></listitem>
  954. <listitem><para><ulink url='http://linux.yyz.us/patch-format.html'></ulink></para></listitem>
  955. <listitem><para>Documentation/SubmittingPatches (in any linux kernel source tree)</para></listitem>
  956. </itemizedlist>
  957. </para></note>
  958. <para>
  959. The messages used to commit changes are a large part of these standards, so
  960. ensure that the headers for each commit have the required information. If the
  961. initial commits were not properly documented or don't meet those standards
  962. rebasing via git rebase -i offer an opportunity to manipulate the commits and
  963. get them into the required format. Other techniques such as branching and
  964. cherry picking commits are also viable options.
  965. </para>
  966. <para>
  967. Once complete, patches are sent via email to the maintainer(s) or lists that
  968. review and integrate changes. "git send-email" is commonly used to ensure
  969. that patches are properly formatted for easy application and avoid mailer
  970. induced patch damage.
  971. </para>
  972. <para>
  973. An example of dumping patches for external submission follows:
  974. <literallayout class='monospaced'>
  975. # dump the last 4 commits
  976. &gt; git format-patch &dash;&dash;thread -n -o ~/rr/ HEAD^^^^
  977. &gt; git send-email &dash;&dash;compose &dash;&dash;subject '[RFC 0/N] &lt;patch series summary&gt;' \
  978. &dash;&dash;to foo@yoctoproject.org &dash;&dash;to bar@yoctoproject.org \
  979. &dash;&dash;cc list@yoctoproject.org ~/rr
  980. # the editor is invoked for the 0/N patch, and when complete the entire
  981. # series is sent via email for review
  982. </literallayout>
  983. </para>
  984. </section>
  985. <section id='export-for-import-into-other-scm'>
  986. <title>Export for Import into Other SCM</title>
  987. <para>
  988. Using any one of the previously discussed techniques, commits can be exported
  989. as patches for import into another SCM. Note however, that if those patches
  990. are manually applied to a secondary tree and then that secondary tree is
  991. checked into the SCM, then it often results in lost information (like commit
  992. logs) and so it is not recommended.
  993. </para>
  994. <para>
  995. Many SCMs can directly import git commits, or can translate git patches to
  996. not lose information. Those facilities are SCM dependent and should be used
  997. whenever possible.
  998. </para>
  999. </section>
  1000. </section>
  1001. <section id='scm-working-with-the-yocto-project-kernel-in-another-scm'>
  1002. <title>SCM: Working with the Yocto Project Kernel in Another SCM</title>
  1003. <para>
  1004. This is not the same as the exporting of patches to another SCM, but instead
  1005. is concerned with kernel development that is done completely in another
  1006. environment, but built with the Yocto Project build system. In this scenario two
  1007. things must happen:
  1008. <itemizedlist>
  1009. <listitem><para>The delivered Yocto Project kernel must be exported into the second
  1010. SCM.</para></listitem>
  1011. <listitem><para>Development must be exported from that secondary SCM into a
  1012. format that can be used by the Yocto Project build system.</para></listitem>
  1013. </itemizedlist>
  1014. </para>
  1015. <section id='exporting-delivered-kernel-to-scm'>
  1016. <title>Exporting Delivered Kernel to SCM</title>
  1017. <para>
  1018. Depending on the SCM it may be possible to export the entire Yocto Project
  1019. kernel git repository, branches and all, into a new environment. This is the
  1020. preferred method, since it has the most flexibility and potential to maintain
  1021. the meta data associated with each commit.
  1022. </para>
  1023. <para>
  1024. When a direct import mechanism is not available, it is still possible to
  1025. export a branch (or series of branches) and check them into a new
  1026. repository.
  1027. </para>
  1028. <para>
  1029. The following commands illustrate some of the steps that could be used to
  1030. import the common_pc-standard kernel into a secondary SCM
  1031. <literallayout class='monospaced'>
  1032. &gt; git checkout common_pc-standard
  1033. &gt; cd .. ; echo linux/.git &gt; .cvsignore
  1034. &gt; cvs import -m "initial import" linux MY_COMPANY start
  1035. </literallayout>
  1036. The CVS repo could now be relocated and used in a centralized manner.
  1037. </para>
  1038. <para>
  1039. The following commands illustrate how two BSPs could be condensed and merged
  1040. into a second SCM:
  1041. <literallayout class='monospaced'>
  1042. &gt; git checkout common_pc-standard
  1043. &gt; git merge cav_ebt5800-standard
  1044. # resolve any conflicts and commit them
  1045. &gt; cd .. ; echo linux/.git &gt; .cvsignore
  1046. &gt; cvs import -m "initial import" linux MY_COMPANY start
  1047. </literallayout>
  1048. </para>
  1049. </section>
  1050. <section id='importing-changes-for-build'>
  1051. <title>Importing Changes for Build</title>
  1052. <para>
  1053. Once development has reached a suitable point in the second development
  1054. environment, changes can either be exported as patches or imported into git
  1055. directly (if a conversion/import mechanism is available for the SCM).
  1056. </para>
  1057. <para>
  1058. If changes are exported as patches, they can be placed in a recipe and
  1059. automatically applied to the kernel during patching.
  1060. </para>
  1061. <!--<para>
  1062. If changes are imported directly into git, they must be propagated to the
  1063. wrll-linux-2.6.27/git/default_kernel bare clone of each individual build
  1064. to be present when the kernel is checked out.
  1065. </para>
  1066. <para>
  1067. The following example illustrates one variant of this workflow:
  1068. <literallayout class='monospaced'>
  1069. # on master git repository
  1070. &gt; cd linux-2.6.27
  1071. &gt; git tag -d common_pc-standard-mark
  1072. &gt; git pull ssh://&lt;foo&gt;@&lt;bar&gt;/pub/git/kernel-2.6.27 common_pc-standard:common_pc-standard
  1073. &gt; git tag common_pc-standard-mark
  1074. # on each build machine (or NFS share, etc)
  1075. &gt; cd wrll-linux-2.6.27/git/default_kernel
  1076. &gt; git fetch ssh://&lt;foo&gt;@&lt;master server&gt;/pub/git/kernel-2.6.27
  1077. # in the build, perform a from-scratch build of Linux and the new changes
  1078. # will be checked out and built.
  1079. &gt; make linux
  1080. </literallayout>
  1081. </para> -->
  1082. </section>
  1083. </section>
  1084. <!-- <section id='bsp-template-migration-from-2'>
  1085. <title>BSP: Template Migration from 2.0</title>
  1086. <para>
  1087. The move to a git-backed kernel build system in 3.0 introduced a small new
  1088. requirement for any BSP that is not integrated into the GA release of the
  1089. product: branching information.
  1090. </para>
  1091. <para>
  1092. As was previously mentioned in the background sections, branching information
  1093. is always required, since the kernel build system cannot make intelligent
  1094. branching decisions and must rely on the developer. This branching
  1095. information is provided via a .scc file.
  1096. </para>
  1097. <para>
  1098. A BSP template in 2.0 contained build system information (config.sh, etc) and
  1099. kernel patching information in the 'linux' subdirectory. The same holds true
  1100. in 3.0, with only minor changes in the kernel patching directory.
  1101. The ".smudge" files are now ".scc" files and now contain a full description
  1102. of the kernel branching, patching and configuration for the BSP. Where in
  1103. 2.0, they only contained kernel patching information.
  1104. </para>
  1105. <para>
  1106. The following illustrates the migration of a simple 2.0 BSP template to the
  1107. new 3.0 kernel build system.
  1108. </para>
  1109. <note><para>
  1110. Note: all operations are from the root of a customer layer.
  1111. </para></note>
  1112. <literallayout class='monospaced'>
  1113. templates/
  1114. `&dash;&dash; board
  1115. `&dash;&dash; my_board
  1116. |&dash;&dash; config.sh
  1117. |&dash;&dash; include
  1118. `&dash;&dash; linux
  1119. `&dash;&dash; 2.6.x
  1120. |&dash;&dash; knl-base.cfg
  1121. |&dash;&dash; bsp.patch
  1122. `&dash;&dash; my_bsp.smudge
  1123. &gt; mv templates/board/my_board/linux/2.6.x/* templates/board/my_board/linux
  1124. &gt; rm -rf templates/board/my_board/linux/2.6.x/
  1125. &gt; mv templates/board/my_board/linux/my_bsp.smudge \
  1126. templates/board/my_board/linux/my_bsp-standard.scc
  1127. &gt; echo "kconf hardware knl-base.cfg" &gt;&gt; \
  1128. templates/board/my_board/linux/my_bsp-standard.scc
  1129. &gt; vi templates/board/my_board/linux/my_bsp-standard.scc
  1130. # add the following at the top of the file
  1131. scc_leaf ktypes/standard my_bsp-standard
  1132. templates/
  1133. `&dash;&dash; board
  1134. `&dash;&dash; my_board
  1135. |&dash;&dash; config.sh
  1136. |&dash;&dash; include
  1137. `&dash;&dash; linux
  1138. |&dash;&dash; knl-base.cfg
  1139. |&dash;&dash; bsp.patch
  1140. `&dash;&dash; my_bsp-standard.scc
  1141. </literallayout>
  1142. <para>
  1143. That's it. Configure and build.
  1144. </para>
  1145. <note><para>There is a naming convention for the .scc file, which allows the build
  1146. system to locate suitable feature descriptions for a board:
  1147. </para></note>
  1148. <literallayout class='monospaced'>
  1149. &lt;bsp name&gt;-&lt;kernel type&gt;.scc
  1150. </literallayout>
  1151. <para>
  1152. if this naming convention isn't followed your feature description will
  1153. not be located and a build error thrown.
  1154. </para>
  1155. </section> -->
  1156. <section id='bsp-creating'>
  1157. <title>BSP: Creating</title>
  1158. <para>
  1159. This section provides an example for creating a BSP based on an existing, and hopefully,
  1160. similar one.
  1161. Follow these steps and keep in mind your particular situation and differences:
  1162. <orderedlist>
  1163. <listitem><para>Get a machine configuration file that matches your machine.</para>
  1164. <para>You can start with something in <filename>meta/conf/machine</filename>.
  1165. Or, <filename>meta-emenlow/conf/machine</filename> has an example in its own layer.</para>
  1166. <para>The most up-to-date machines that are probably most similar to yours and that you might want
  1167. to look at are <filename>meta/conf/machine/atom-pc.conf</filename> and
  1168. <filename>meta-emenlow/conf/machine/emenlow.conf</filename>.
  1169. Both of these were either just added or upgraded to use the Yocto Project kernel
  1170. at <ulink url='http://git.pokylinux.org/cgit/cgit.cgi/linux-2.6-windriver/'></ulink>.
  1171. The main difference between them is that "emenlow" is in its own layer.
  1172. It is in its own layer because it needs extra machine-specific packages such as its
  1173. own video driver and other supporting packages.
  1174. The "atom-pc" is simpler and does not need any special packages - everything it needs can
  1175. be specified in the configuration file.
  1176. The "atom-pc" machine also supports all of Asus eee901, Acer Aspire One, Toshiba NB305,
  1177. and the Intel&reg; Embedded Development Board 1-N450 with no changes.</para>
  1178. <para>If you want to make minor changes to support a slightly different machine, you can
  1179. create a new configuration file for it and add it alongside the others.
  1180. You might consider keeping the common stuff separate and including it.</para>
  1181. <para>Similarly, you can also use multiple configuration files for different machines even
  1182. if you do it as a separate layer like meta-emenlow.</para>
  1183. <para>As an example consider this:
  1184. <itemizedlist>
  1185. <listitem><para>Copy meta-emenlow</para></listitem>
  1186. <listitem><para>Fix or remove anything you do not need.
  1187. For this example the only thing left was the kernel directory with a linux-yocto_git.bbappend
  1188. file (linux-yocto is the kernel listed in
  1189. <filename>meta-crownbay/conf/machine/crownbay.conf</filename>.
  1190. Finally, a new entry to the <filename>build/donf/bblayers.conf</filename> was added so the
  1191. new layer could be found by Bitbake.</para></listitem>
  1192. </itemizedlist>
  1193. </para></listitem>
  1194. <listitem><para>Get an image with a working kernel built.</para>
  1195. <para>For the kernel to compile successfully, you need to create a branch in the git repository
  1196. specifically named for your machine.
  1197. So first create a bare clone of the Yocto Project git repository, and then create a
  1198. local clone of that:
  1199. <literallayout class='monospaced'>
  1200. $ git clone &dash;&dash;bare git://git.pokylinux.org/linux-2.6-windriver.git
  1201. linux-2.6-windriver.git
  1202. $ git clone linux-2.6-windriver.git linux-2.6-windriver
  1203. </literallayout>
  1204. </para>
  1205. <para>Now create a branch in the local clone and push it to the bare clone:
  1206. <literallayout class='monospaced'>
  1207. $ git checkout -b crownbay-standard origin/standard $ git push origin crownbay-standard:crownbay-standard
  1208. </literallayout>
  1209. </para>
  1210. <para>At this point, your git tree should be set up well enough to compile.</para></listitem>
  1211. <listitem><para>Point the build at the new kernel git tree.</para>
  1212. <para>You can do this by commenting out the SRC_URI variable in
  1213. <filename>meta/recipes-kernel/linux/linux-yocto_git.bb</filename> and using a SRC_URI
  1214. that points to your new bare git tree.
  1215. You should also be able to do this in <filename>linux-yocto_git.bbappend</filename> in the layer:
  1216. <literallayout class='monospaced'>
  1217. # To use a staged, on-disk bare clone of a Wind River Kernel, use a variant of the
  1218. # below SRC_URI = "git://///path/to/kernel/default_kernel.git;fullclone=1"
  1219. #
  1220. SRC_URI = "git://git.pokylinux.org/linux-2.6-windriver.git;protocol=git;fullclone=1;branch=${KBRANCH};name=machine
  1221. \
  1222. git://git.pokylinux.org/linux-2.6-windriver.git;protocol=git;noclone=1;branch=wrs_meta;name=meta"
  1223. </literallayout>
  1224. </para>
  1225. <para>After doing that, select the machine in <filename>build/conf/local.conf</filename>:
  1226. <literallayout class='monospaced'>
  1227. #
  1228. MACHINE ?= "crownbay"
  1229. #
  1230. </literallayout>
  1231. </para>
  1232. <para>You should now be able to build and boot an image with the new kernel:
  1233. <literallayout class='monospaced'>
  1234. $ bitbake poky-image-sato-live
  1235. </literallayout>
  1236. </para>
  1237. <para>Of course, that will give you a kernel with the default config, which is probably
  1238. not what you want.
  1239. If you just want to set some kernel config options, you can do that by putting them in a files.
  1240. For example inserting the following into some <filename>.cfg</filename> file:
  1241. <literallayout class='monospaced'>
  1242. CONFIG_NETDEV_1000=y
  1243. CONFIG_E1000E=y
  1244. </literallayout>
  1245. </para>
  1246. <para>And, another <filename>.cfg</filename> file would contain:
  1247. <literallayout class='monospaced'>
  1248. CONFIG_LOG_BUF_SHIFT=18
  1249. http://git.pokylinux.org/cgit/cgit.cgi/linux-2.6-windriver/
  1250. SRC_URI_append_crownbay = " file://some.cfg \
  1251. file://other.cfg \
  1252. "
  1253. </literallayout>
  1254. </para>
  1255. <para>You could also add these directly to the git repo's wrs_meta branch as well.
  1256. However, the former method is probably easier.</para></listitem>
  1257. <listitem><para>If you're also adding patches to the kernel, you can do the same thing.
  1258. Put your patches in the SRC_URI as well (plus .cfg for their kernel config options if needed).</para>
  1259. <para>Practically speaking, to generate the patches, you'd go to the source in the build tree:
  1260. <literallayout class='monospaced'>
  1261. build/tmp/work/crownbay-poky-linux/linux-yocto-2.6.34+git0+d1cd5c80ee97e81e130be8c3de3965b770f320d6_0+
  1262. 0431115c9d720fee5bb105f6a7411efb4f851d26-r13/linux
  1263. </literallayout>
  1264. </para>
  1265. <para>Then, modify the code there, using quilt to save the changes, and recompile
  1266. (bitbake -c compile -f)
  1267. until it works.</para></listitem>
  1268. <listitem><para>Once you have the final patch from quilt, copy it to the
  1269. SRC_URI location, and it should be
  1270. applied the next time you do a clean build.
  1271. Of course, since you have a branch for the BSP in git, it would be better to put it there instead.
  1272. For example, in this case, commit the patch to the crownbay-standard branch, and during the
  1273. next build it will be applied from there.</para></listitem>
  1274. </orderedlist>
  1275. </para>
  1276. </section>
  1277. <!-- <section id='bsp-creating-a-new-bsp'>
  1278. <title>BSP: Creating a New BSP</title>
  1279. <para>
  1280. Although it is obvious that the structure of a new BSP uses the migrated
  1281. directory structure from the previous example,the first question is whether
  1282. or not the BSP is started from scratch.
  1283. </para>
  1284. <para>
  1285. If Yocto Project has a similar BSP, it is often easier to clone and update,
  1286. rather than start from scratch. If the mainline kernel has support, it is
  1287. easier to branch from the -standard kernel and begin development (and not be
  1288. concerned with undoing existing changes). This section covers both options.
  1289. </para>
  1290. <para>
  1291. In almost every scenario, the LDAT build system bindings must be completed
  1292. before either cloning or starting a new BSP from scratch. This is simply
  1293. because the board template files are required to configure a project/build
  1294. and create the necessary environment to begin working directly with the
  1295. kernel. If it is desired to start immediately with kernel development and
  1296. then add LDAT bindings, see the "bootstrapping a BSP" section.
  1297. </para>
  1298. <section id='creating-from-scratch'>
  1299. <title>Creating the BSP from Scratch</title>
  1300. <para>
  1301. To create the BSP from scratch you need to do the following:
  1302. <orderedlist>
  1303. <listitem><para>Create a board template for the new BSP in a layer.</para></listitem>
  1304. <listitem><para>Configure a build with the board.</para></listitem>
  1305. <listitem><para>Configure a kernel.</para></listitem>
  1306. </orderedlist>
  1307. </para>
  1308. <para>
  1309. Following is an example showing all three steps. You start by creating a board template for the new BSP in a layer.
  1310. <literallayout class='monospaced'>
  1311. templates/
  1312. `&dash;&dash; board
  1313. `&dash;&dash; my_bsp
  1314. |&dash;&dash; include
  1315. |&dash;&dash; config.sh
  1316. `&dash;&dash; linux
  1317. |&dash;&dash; my_bsp.cfg
  1318. `&dash;&dash; my_bsp-standard.scc
  1319. &gt; cat config.sh
  1320. TARGET_BOARD="my_bsp"
  1321. TARGET_LINUX_LINKS="bzImage"
  1322. TARGET_SUPPORTED_KERNEL="standard"
  1323. TARGET_SUPPORTED_ROOTFS="glibc_std"
  1324. BANNER="This BSP is *NOT* supported"
  1325. TARGET_PROCFAM="pentium4"
  1326. TARGET_PLATFORMS="GPP"
  1327. &gt; cat include
  1328. cpu/x86_32_i686
  1329. karch/i386
  1330. &gt; cat linux/my_bsp-standard.scc
  1331. scc_leaf ktypes/standard/standard.scc my_bsp-standard
  1332. &gt; cat linux/my_bsp.cfg
  1333. CONFIG_X86=y
  1334. CONFIG_SMP=y
  1335. CONFIG_VT=y
  1336. # etc, etc, etc
  1337. </literallayout>
  1338. </para>
  1339. <para>
  1340. Something like the following can now be added to a board build, and
  1341. a project can be started:
  1342. <literallayout class='monospaced'>
  1343. &dash;&dash;enable-board=my_bsp \
  1344. &dash;&dash;with-layer=custom_bsp
  1345. </literallayout>
  1346. </para>
  1347. <para>
  1348. Now you can configure a kernel:
  1349. <literallayout class='monospaced'>
  1350. &gt; make -C build linux.config
  1351. </literallayout>
  1352. </para>
  1353. <para>
  1354. You now have a kernel tree, which is branched and has no patches, ready for
  1355. development.
  1356. </para>
  1357. </section> -->
  1358. <!-- <section id='cloning-an-existing-bsp'>
  1359. <title>Cloning an Existing BSP</title>
  1360. <para>
  1361. Cloning an existing BSP from the shipped product is similar to the "from
  1362. scratch" option and there are two distinct ways to achieve this goal:
  1363. <itemizedlist>
  1364. <listitem><para>Create a board template for the new BSP in a layer.</para></listitem>
  1365. <listitem><para>Clone the .scc and board config.</para></listitem>
  1366. </itemizedlist>
  1367. </para>
  1368. <para>
  1369. The first method is similar to the from scratch BSP where you create a board template for the new
  1370. BSP. Although in this case, copying an existing board template from
  1371. wrll-wrlinux/templates/board would be appropriate, since we are cloning an
  1372. existing BSP. Edit the config.sh, include and other board options for the new
  1373. BSP.
  1374. </para>
  1375. <para>
  1376. The second method is to clone the .scc and board config.
  1377. To do this, in the newly created board template, create a linux subdirectory and export
  1378. the .scc and configuration from the source BSP in the published Yocto Project
  1379. kernel. During construction, all of the configuration and patches were
  1380. captured, so it is simply a matter of extracting them.
  1381. </para>
  1382. <para>
  1383. Extraction can be accomplished using four different techniques:
  1384. <itemizedlist>
  1385. <listitem><para>Config and patches from the bare default_kernel.</para></listitem>
  1386. <listitem><para>Clone default_kernel and checkout wrs_base.</para></listitem>
  1387. <listitem><para>Clone default_kernel and checkout BSP branch.</para></listitem>
  1388. <listitem><para>Branch from the Yocto Project BSP.</para></listitem>
  1389. </itemizedlist>
  1390. </para>
  1391. <para>
  1392. Technique 1: config and patches from the bare default_kernel
  1393. <literallayout class='monospaced'>
  1394. &gt; cd layers/wrll-linux-2.6.27/git/default_kernel
  1395. &gt; git show checkpoint_end | filterdiff -i '*common_pc*' | patch -s -p2 -d /tmp
  1396. # This will create two directories: cfg and patches.
  1397. &gt; cd /tmp/cfg/kernel-cache/bsp/common_pc/
  1398. # This directory contains all the patches and .scc files used to construct
  1399. # the BSP in the shipped tree. Copy the patches to the new BSP template,
  1400. # and add them to the .scc file created above. See "template patching" if
  1401. # more details are required.
  1402. </literallayout>
  1403. </para>
  1404. <para>
  1405. Technique 2: clone default_kernel and checkout wrs_base
  1406. <literallayout class='monospaced'>
  1407. &gt; git clone layers/wrll-linux-2.6.27/git/default_kernel windriver-2.6.27
  1408. &gt; cd windriver-2.6.27
  1409. &gt; git checkout wrs_base
  1410. &gt; cd wrs/cfg/kernel-cache/bsp/common_pc
  1411. # again, this directory has all the patches and .scc files used to construct
  1412. # the BSP
  1413. </literallayout>
  1414. </para>
  1415. <para>
  1416. Technique 3: clone default_kernel and checkout BSP branch
  1417. <literallayout class='monospaced'>
  1418. &gt; git clone layers/wrll-linux-2.6.27/git/default_kernel windriver-2.6.27
  1419. &gt; cd windriver-2.6.27
  1420. &gt; git checkout common_pc-standard
  1421. &gt; git whatchanged
  1422. # browse patches and determine which ones are of interest, say there are
  1423. # 3 patches of interest
  1424. &gt; git format-patch -o &lt;path to BSP template&gt;/linux HEAD^^^
  1425. # update the .scc file to add the patches, see "template patches" if
  1426. # more details are required
  1427. </literallayout>
  1428. </para>
  1429. <para>
  1430. Technique #4: branch from the Yocto Project BSP
  1431. <note><para>This is potentially the most "different" technique, but is actually
  1432. the easiest to support and leverages the infrastructure. rtcore BSPs
  1433. are created in a similar manner to this.
  1434. </para></note>
  1435. </para>
  1436. <para>
  1437. In this technique the .scc file in the board template is slightly different
  1438. and indicates that the BSP should branch after the base Yocto Project BSP
  1439. of the correct kernel type, so to start a new BSP that inherits the
  1440. kernel patches of the common_pc-standard, the following would be done:
  1441. <literallayout class='monospaced'>
  1442. &gt; cat linux/my_bsp-standard.scc
  1443. scc_leaf bsp/common_pc/common_pc-standard.scc my_bsp-standard
  1444. </literallayout>
  1445. </para>
  1446. <para>
  1447. And only kernel configuration (not patches) need be contained in the
  1448. board template.
  1449. </para>
  1450. <para>
  1451. This has the advantage of automatically picking up updates to the BSP
  1452. and not duplicating any patches for a similar board.
  1453. </para>
  1454. </section> -->
  1455. <!-- <section id='bsp-bootstrapping'>
  1456. <title>BSP: Bootstrapping</title>
  1457. <para>
  1458. The previous examples created the board templates and configured a build
  1459. before beginning work on a new BSP. It is also possible for advanced users to
  1460. simply treat the Yocto Project git repository as an upstream source and begin
  1461. BSP development directly on the repository. This is the closest match to how
  1462. the kernel community at large would operate.
  1463. </para>
  1464. <para>
  1465. Two techniques exist to accomplish this:
  1466. </para>
  1467. <para>
  1468. Technique 1: upstream workflow
  1469. <literallayout class='monospaced'>
  1470. &gt; git clone layers/wrll-linux-2.6.27/git/default_kernel windriver-2.6.27
  1471. &gt; cd windriver-2.6.27
  1472. &gt; git checkout -b my_bsp-standard common_pc-standard
  1473. # edit files, import patches, generally do BSP development
  1474. # at this point we can create the BSP template, and export the kernel
  1475. # changes using one of the techniques discussed in that section. For
  1476. # example, It is possible to push these changes, directly into the
  1477. # default_kernel and never directly manipulate or export patch files
  1478. </literallayout>
  1479. </para>
  1480. <para>
  1481. Technique 2: Yocto Project kernel build workflow
  1482. </para>
  1483. <para>
  1484. Create the BSP branch from the appropriate kernel type
  1485. <literallayout class='monospaced'>
  1486. &gt; cd linux
  1487. # the naming convention for auto-build is &lt;bsp&gt;-&lt;kernel type&gt;
  1488. &gt; git checkout -b my_bsp-standard standard
  1489. </literallayout>
  1490. </para>
  1491. <para>
  1492. Make changes, import patches, etc.
  1493. <literallayout class='monospaced'>
  1494. &gt; ../../host-cross/bin/guilt init
  1495. # 'wrs/patches/my_bsp-standard' has now been created to
  1496. # manage the branches patches
  1497. # option 1: edit files, guilt import
  1498. &gt; ../../host-cross/bin/guilt new extra-version.patch
  1499. &gt; vi Makefile
  1500. &gt; ../../host-cross/bin/guilt refresh
  1501. # add a header
  1502. &gt; ../../host-cross/bin/guilt header -e
  1503. # describe the patch using best practices, like the example below:
  1504. &dash;&dash;&dash;&gt;&dash;&dash;&dash;&gt;&dash;&dash;&dash;&gt; cut here
  1505. From: Bruce Ashfield &lt;bruce.ashfield@windriver.com&gt;
  1506. Adds an extra version to the kernel
  1507. Modify the main EXTRAVERSION to show our bsp name
  1508. Signed-off-by: Bruce Ashfield &lt;bruce.ashfield@windriver.com&gt;
  1509. &dash;&dash;&dash;&gt;&dash;&dash;&dash;&gt;&dash;&dash;&dash;&gt; cut here
  1510. # option 2: import patches
  1511. &gt; git am &lt;patch&gt;
  1512. or
  1513. &gt; git apply &lt;patch&gt;
  1514. &gt; git add &lt;files&gt;
  1515. &gt; git commit -s
  1516. # configure the board, save relevant options
  1517. &gt; make ARCH=&lt;arch&gt; menuconfig
  1518. # save the cfg changes for reconfiguration
  1519. &gt; mkdir wrs/cfg/&lt;cache&gt;/my_bsp
  1520. &gt; vi wrs/cfg/&lt;cache&gt;/my_bsp/my_bsp.cfg
  1521. # classify the patches
  1522. &gt; ../../host-cross/bin/kgit classify create &lt;kernel-foo-cache&gt;/my_bsp/my_bsp
  1523. # test build
  1524. &gt; cd ..
  1525. &gt; make linux TARGET_BOARD=my_bsp kprofile=my_bsp use_current_branch=1
  1526. </literallayout>
  1527. </para>
  1528. <para>
  1529. Assuming the patches have been exported to the correct location, Future
  1530. builds will now find the board, apply the patches to the base tree and make
  1531. the relevant branches and structures and the special build options are no
  1532. longer required.
  1533. </para>
  1534. </section>
  1535. </section> -->
  1536. <!-- <section id='patching'>
  1537. <title>Patching</title>
  1538. <para>
  1539. The most common way to apply patches to the kernel is via a template.
  1540. However, for more advanced applications (such as the sharing of patches between
  1541. multiple sub-features) it is possible to patch the kernel-cache.
  1542. This section covers both scenarios.
  1543. </para>
  1544. <section id='patching-template'>
  1545. <title>Patching: Template</title>
  1546. <para>
  1547. kernel
  1548. templates follow the same rules as any LDAT template. A directory should be
  1549. created in a recognized template location, with a 'linux' subdirectory. The
  1550. 'linux' directory triggers LDAT to pass the dir as a potential patch location
  1551. to the kernel build system. Any .scc files found in that directory, will be
  1552. automatically appended to the end of the BSP branch (for the configured
  1553. board).
  1554. </para>
  1555. <para>
  1556. This behavior is essentially the same since previous product
  1557. releases. The only exception is the use of ".scc", which allows kernel
  1558. configuration AND patches to be applied in a template.
  1559. </para>
  1560. <note><para>
  1561. If creating a full template is not required, a .scc file can be placed at
  1562. the top of the build, along with configuration and patches. The build
  1563. system will pickup the .scc and add it onto the patch list automatically
  1564. </para></note>
  1565. <para>
  1566. As an example, consider a simple template to update a BP:
  1567. <literallayout class='monospaced'>
  1568. &gt; cat templates/feature/extra_version/linux/extra_version.scc
  1569. patch 0001-extraversion-add-Wind-River-identifier.patch
  1570. </literallayout>
  1571. </para>
  1572. <para>
  1573. To illustrate how the previous template patch was created, the following
  1574. steps were performed:
  1575. <literallayout class='monospaced'>
  1576. &gt; cd &lt;board build&gt;/build/linux
  1577. &gt; vi Makefile
  1578. # modify EXTRAVERSION to have a unique string
  1579. &gt; git commit -s -m "extraversion: add Yocto Project identifier" Makefile
  1580. &gt; git format-patch -o &lt;path to layer&gt;/templates/feature/extra_version/linux/
  1581. &gt; echo "patch 0001-extraversion-add-Wind-River-identifier.patch" &gt; \
  1582. &lt;path to layer&gt;/templates/feature/extra_version/linux/extra_version.scc
  1583. </literallayout>
  1584. </para>
  1585. <para>
  1586. This next example creates a template with a linux subdirectory, just as we
  1587. always have for previous releases.
  1588. <literallayout class='monospaced'>
  1589. &gt; mkdir templates/features/my_feature/linux
  1590. </literallayout>
  1591. </para>
  1592. <para>
  1593. In that directory place your feature description, your
  1594. patch and configuration (if required).
  1595. <literallayout class='monospaced'>
  1596. &gt; ls templates/features/my_feature/linux
  1597. version.patch
  1598. my_feature.scc
  1599. my_feature.cfg
  1600. </literallayout>
  1601. </para>
  1602. <para>
  1603. The .scc file describes the patches, configuration and
  1604. where in the patch order the feature should be inserted.
  1605. <literallayout class='monospaced'>
  1606. patch version.patch
  1607. kconf non-hardware my_feature.cfg
  1608. </literallayout>
  1609. </para>
  1610. <para>
  1611. Configure your build with the new template
  1612. <literallayout class='monospaced'>
  1613. &dash;&dash;with-template=features/my_feature
  1614. </literallayout>
  1615. </para>
  1616. <para>
  1617. Build the kernel
  1618. <literallayout class='monospaced'>
  1619. &gt; make linux
  1620. </literallayout>
  1621. </para>
  1622. </section>
  1623. <section id='patching-kernel-cache'>
  1624. <title>Patching: Kernel Cache</title>
  1625. <para>
  1626. As previously mentioned, this example is included for completeness, and is for more advanced
  1627. applications (such as the sharing of patches between multiple sub-features).
  1628. Most patching should be done via templates, since that interface is
  1629. guaranteed not to change and the kernel-cache interface carries no such
  1630. guarantee.
  1631. </para>
  1632. <para>
  1633. At the top of a layer, create a kernel cache. The build system will recognize
  1634. any directory of the name 'kernel-*-cache' as a kernel cache.
  1635. <literallayout class='monospaced'>
  1636. &gt; cd &lt;my layer&gt;
  1637. &gt;mkdir kernel-temp-cache
  1638. </literallayout>
  1639. </para>
  1640. <para>
  1641. Make a directory with the BSP
  1642. <literallayout class='monospaced'>
  1643. &gt; mkdir kernel-temp-cache
  1644. &gt; mkdir kernel-temp-cache/my_feat
  1645. </literallayout>
  1646. </para>
  1647. <para>
  1648. Create the feature files as they were in technique #1
  1649. <literallayout class='monospaced'>
  1650. &gt; echo "patch my_patch.path" &gt; kernel-temp-cache/my_feat/my_feature.scc
  1651. </literallayout>
  1652. </para>
  1653. <para>
  1654. Configure the build with the feature added to the kernel type
  1655. <literallayout class='monospaced'>
  1656. &dash;&dash;with-kernel=standard+my_feat/my_feature.scc
  1657. </literallayout>
  1658. </para>
  1659. <para>
  1660. Build the kernel
  1661. <literallayout class='monospaced'>
  1662. &gt; make linux
  1663. </literallayout>
  1664. </para>
  1665. </section>
  1666. </section>
  1667. <section id='bsp-updating-patches-and-configuration'>
  1668. <title>BSP: Updating Patches and Configuration</title>
  1669. <para>
  1670. As was described in the "template patching" example, it is simple
  1671. to add patches to a BSP via a template, but often, it is desirable
  1672. to experiment and test patches before committing them to a template.
  1673. You can do this by modifying the BSP source.
  1674. </para>
  1675. <para>
  1676. Start as follows:
  1677. <literallayout class='monospaced'>
  1678. &gt; cd linux
  1679. &gt; git checkout &lt;bspname&gt;-&lt;kernel name&gt;
  1680. &gt; git am &lt;patch&gt;
  1681. </literallayout>
  1682. </para>
  1683. <para>
  1684. Or you can do this:
  1685. <literallayout class='monospaced'>
  1686. &gt; kgit-import -t patch &lt;patch&gt;
  1687. &gt; cd ..
  1688. &gt; make linux
  1689. </literallayout>
  1690. </para>
  1691. <para>
  1692. For details on conflict resolution and patch application, see the
  1693. git manual, or other suitable online references.
  1694. <literallayout class='monospaced'>
  1695. &gt; git am &lt;mbox&gt;
  1696. # conflict
  1697. &gt; git apply &dash;&dash;reject .git/rebase-apply/0001
  1698. # resolve conflict
  1699. &gt; git am &dash;&dash;resolved (or git am &dash;&dash;skip, git am &dash;&dash;abort)
  1700. # continue until complete
  1701. </literallayout>
  1702. </para>
  1703. <para>
  1704. Here is another example:
  1705. <literallayout class='monospaced'>
  1706. # merge the patches
  1707. # 1) single patch
  1708. &gt; git am &lt;mbox&gt;
  1709. &gt; git apply &lt;patch&lt;
  1710. &gt; kgit import -t patch &lt;patch&gt;
  1711. # 2) multiple patches
  1712. &gt; git am &lt;mbox&gt;
  1713. &gt; kgit import -t dir &lt;dir&gt;
  1714. # if kgit -t dir is used, a patch resolution cycle such
  1715. # as this can be used:
  1716. &gt; kgit import -t dir &lt;dir&gt;
  1717. # locate rejects and resolve
  1718. # options:
  1719. &gt; wiggle &dash;&dash;replace &lt;path to file&gt; &lt;path to reject&gt;
  1720. &gt; guilt refresh
  1721. or
  1722. &gt; # manual resolution
  1723. &gt; git add &lt;files&gt;
  1724. &gt; git commit -s
  1725. or
  1726. &gt; git apply &dash;&dash;reject .git/rebase-apply/0001
  1727. &gt; git add &lt;files&gt;
  1728. &gt; git am &dash;&dash;resolved
  1729. or
  1730. &gt; # merge tool of choice
  1731. # continue series:
  1732. &gt; kgit import -t dir &lt;dir&gt;
  1733. or
  1734. &gt; git am &dash;&dash;continue
  1735. </literallayout>
  1736. </para>
  1737. <para>
  1738. Once all the patches have been tested and are satisfactory, they
  1739. should be exported via the techniques described in "saving kernel
  1740. modifications."
  1741. </para>
  1742. <para>
  1743. Once the kernel has been patched and configured for a BSP, it's
  1744. configuration commonly needs to be modified. This can be done by
  1745. running [menu|x]config on the kernel tree, or working with
  1746. configuration fragments.
  1747. </para>
  1748. <para>
  1749. Using menuconfig, the operation is as follows:
  1750. <literallayout class='monospaced'>
  1751. &gt; make linux.menuconfig
  1752. &gt; make linux.rebuild
  1753. </literallayout>
  1754. </para>
  1755. <para>
  1756. Once complete, the changes are in linux-&lt;bsp&gt;-&lt;kernel type&gt;-build/.config.
  1757. To permanently save these changes, compare the .config before and after the
  1758. menuconfig, and place those changes in a configuration fragment in the
  1759. template of your choice.
  1760. </para>
  1761. <para>
  1762. Using configuration fragments, the operation is as follows (using the
  1763. si_is8620 as an example BSP):
  1764. <literallayout class='monospaced'>
  1765. &gt; vi linux/wrs/cfg/kernel-cache/bsp/si_is8620/si_is8620.cfg
  1766. &gt; make linux.reconfig
  1767. &gt; make linux.rebuild
  1768. </literallayout>
  1769. </para>
  1770. <para>
  1771. The modified configuration fragment can simply be copied out of the
  1772. linux/wrs/.. directory and placed in the appropriate template for future
  1773. application.
  1774. </para>
  1775. </section>
  1776. <section id='tools-guilt'>
  1777. <title>Tools: guilt</title>
  1778. <para>
  1779. Yocto Project has guilt integrated as a kernel tool; therefore users that are
  1780. familiar with quilt may wish to use this tool to pop, push and refresh
  1781. their patches. Note: guilt should only be used for local operations, once
  1782. a set of changes has been pushed or pulled, they should no longer be popped
  1783. or refresh by guilt, since popping, refreshing and re-pushing patches
  1784. changes their commit IDs and creating non-fast forward branches.
  1785. </para>
  1786. <para>
  1787. The following example illustrates how to add patches a Yocto Project
  1788. BSP branch via guilt:
  1789. <literallayout class='monospaced'>
  1790. &gt; cd build/linux
  1791. &gt; git checkout common_pc-standard
  1792. &gt; guilt new extra.patch
  1793. # edit files, make changes, etc
  1794. &gt; guilt refresh
  1795. &gt; guilt top
  1796. extra.patch
  1797. # export that patch to an external location
  1798. &gt; kgit export -p top /tmp
  1799. </literallayout>
  1800. </para>
  1801. <para>
  1802. Other guilt operations of interest are:
  1803. <literallayout class='monospaced'>
  1804. > guilt push, guilt push -a
  1805. > guilt pop
  1806. > guilt applied, guilt unapplied
  1807. > guilt top
  1808. > guilt refresh
  1809. > guilt header -e
  1810. > guilt next
  1811. </literallayout>
  1812. </para>
  1813. <note><para>
  1814. Guilt only uses git commands and git plumbing to perform its operations,
  1815. anything that guilt does can also be done using git directly. It is provided
  1816. as a convenience utility, but is not required and the developer can use whatever
  1817. tools or workflow they wish.
  1818. </para></note>
  1819. <para>
  1820. The following builds from the above instructions to show how guilt can be
  1821. used to assist in getting your BSP kernel patches ready. You should follow
  1822. the above instructions up to and including 'make linux.config'. In this
  1823. example I will create a new commit (patch) from scratch and import another
  1824. fictitious patch from some external public git tree (ie, a commit with full
  1825. message, signoff etc.). Please ensure you have host-cross/bin in your path.
  1826. <literallayout class='monospaced'>
  1827. %> cd linux
  1828. %> guilt-init
  1829. %> guilt-new -m fill_me_in_please first_one.patch
  1830. %> touch somefile.txt
  1831. %> guilt-add somefile.txt
  1832. %> guilt-header -e
  1833. %> guilt-refresh
  1834. %> guilt-import path_to_some_patch/patch_filename
  1835. %> guilt-push
  1836. </literallayout>
  1837. </para>
  1838. <para>
  1839. Here are a few notes about the above:
  1840. <itemizedlist>
  1841. <listitem><para>guilt-header -e &dash;&dash; this will open editing of the patch header in
  1842. EDITOR. As with a git commit the first line is the short log and
  1843. should be just that short and concise message about the commit. Follow
  1844. the short log with lines of text that will be the long description but
  1845. note Do not put a blank line after the short log. As usual you will
  1846. want to follow this with a blank line and then a signoff line.</para></listitem>
  1847. <listitem><para>The last line in the example above has 2 dots on the end. If you
  1848. don't add the 2 periods on the end guilt will think you are sending
  1849. just one patch. The wrong one!</para></listitem>
  1850. <listitem><para>The advantage to using guilt over not using guilt is that if you have a
  1851. review comment in the first patch (first_one.patch in the case of this
  1852. example) it is very easy to use guilt to pop the other patches off
  1853. allowing you to make the necessary changes without having to use more
  1854. inventive git type strategies.</para></listitem>
  1855. </itemizedlist>
  1856. </para>
  1857. </section>
  1858. <section id='tools-scc-file-example'>
  1859. <title>Tools: scc File Example</title>
  1860. <para>
  1861. This section provides some scc file examples: leaf node, 'normal' mode, and transforms.
  1862. </para>
  1863. <section id='leaf-node'>
  1864. <title>Leaf Node</title>
  1865. <para>
  1866. The following example is a BSP branch with no child branches - a leaf on the tree.
  1867. <literallayout class='monospaced'>
  1868. # these are optional, but allow standalone tree construction
  1869. define WRS_BOARD &lt;name&gt;
  1870. define WRS_KERNEL &lt;kern type&gt;
  1871. define WRS_ARCH &lt;arch&gt;
  1872. scc_leaf ktypes/standard common_pc-standard
  1873. # ^ ^
  1874. # +&dash;&dash; parent + branch name
  1875. include common_pc.scc
  1876. # ^
  1877. # +&dash;&dash;&dash; include another feature
  1878. </literallayout>
  1879. </para>
  1880. </section>
  1881. <section id='normal-mode'>
  1882. <title>'Normal' Mode</title>
  1883. <para>
  1884. Here is an example of 'normal' mode:
  1885. <literallayout class='monospaced'>
  1886. # +&dash;&dash;&dash;&dash; name of file to read
  1887. # v
  1888. kconf hardware common_pc.cfg
  1889. # ^ ^
  1890. # | +&dash;&dash; 'type: hardware or non-hardware
  1891. # |
  1892. # +&dash;&dash;&dash; kernel config
  1893. # patches
  1894. patch 0002-atl2-add-atl2-driver.patch
  1895. patch 0003-net-remove-LLTX-in-atl2-driver.patch
  1896. patch 0004-net-add-net-poll-support-for-atl2-driver.patch
  1897. </literallayout>
  1898. </para>
  1899. </section>
  1900. <section id='transforms'>
  1901. <title>Transforms</title>
  1902. <para>
  1903. This section shows an example of transforms:
  1904. <literallayout class='monospaced'>
  1905. # either of the next two options will trigger an 'auto'
  1906. # branch from existing ones, since they change the commit
  1907. # order and hence must construct their own branch
  1908. # this changes the order of future includes, if the
  1909. # passed feature is detected, the first feature is
  1910. # included AFTER it
  1911. include features/rt/rt.scc after features/kgdb/kgdb
  1912. # this also changes the order of existing branches
  1913. # this prevents the named feature from ever being
  1914. # included
  1915. exclude features/dynamic_ftrace/dynamic_ftrace.scc
  1916. # inherit the standard kernel
  1917. include ktypes/standard/standard
  1918. # LTT supplies this, so we don't want the sub-chunk from RT.
  1919. patch_trigger arch:all exclude ftrace-upstream-tracepoints.patch
  1920. # ...but we still want the one unique tracepoint it added.
  1921. patch tracepoint-add-for-sched_resched_task.patch
  1922. # these will change the named patches in the series into
  1923. # &lt;patch name&gt;.patch.&lt;feature name&gt;
  1924. # where the substituted patch is in this directory
  1925. patch_trigger arch:all ctx_mod dynamic_printk.patch
  1926. patch_trigger arch:all ctx_mod 0001-Implement-futex-macros-for-ARM.patch
  1927. # unconditionally exclude a patch
  1928. patch_trigger arch:all exclude ftrace-fix-ARM-crash.patch
  1929. </literallayout>
  1930. </para>
  1931. </section>
  1932. </section> -->
  1933. <section id='tip-dirty-string'>
  1934. <title>"-dirty" String</title>
  1935. <para>
  1936. If kernel images are being built with -dirty on the end of the version
  1937. string, this simply means that there are modification in the source
  1938. directory that haven't been committed.
  1939. <literallayout class='monospaced'>
  1940. &gt; git status
  1941. </literallayout>
  1942. </para>
  1943. <para>
  1944. The above git command will indicate modified, removed or added files. Those changes should
  1945. be committed to the tree (even if they will never be saved, or exported
  1946. for future use) and the kernel rebuilt.
  1947. </para>
  1948. <para>
  1949. To brute force pickup and commit all such pending changes enter the following:
  1950. <literallayout class='monospaced'>
  1951. &gt; git add .
  1952. &gt; git commit -s -a -m "getting rid of -dirty"
  1953. </literallayout>
  1954. </para>
  1955. <para>
  1956. And then rebuild the kernel
  1957. </para>
  1958. </section>
  1959. <section id='kernel-transition-kernel-layer'>
  1960. <title>Kernel: Transition Kernel Layer</title>
  1961. <para>
  1962. In order to temporarily use a different base kernel in Yocto Project
  1963. Linux 3.0 you need to do the following:
  1964. <orderedlist>
  1965. <listitem><para>Create a custom kernel layer.</para></listitem>
  1966. <listitem><para>Create a git repository of the transition kernel.</para></listitem>
  1967. </orderedlist>
  1968. </para>
  1969. <para>
  1970. Once those requirements are met multiple boards and kernels can
  1971. be built. The cost of setup is only paid once and then additional
  1972. BSPs and options can be added.
  1973. </para>
  1974. <para>
  1975. This creates a transition kernel layer to evaluate functionality
  1976. of some other kernel with the goal of easing transition to an
  1977. integrated and validated Yocto Project kernel.
  1978. </para>
  1979. <!--<para>
  1980. The next few sections describe the process:
  1981. </para> -->
  1982. <!-- <section id='creating-a-custom-kernel-layer'>
  1983. <title>Creating a Custom Kernel Layer</title>
  1984. <para>
  1985. The custom kernel layer must have the following minimum
  1986. elements:
  1987. <itemizedlist>
  1988. <listitem><para>An include of the shipped Yocto Project kernel layer.</para></listitem>
  1989. <listitem><para>A kernel-cache with an override of the standard kernel type.</para></listitem>
  1990. </itemizedlist>
  1991. </para>
  1992. <para>
  1993. This allows the inheritance of the kernel build infrastructure,
  1994. while overriding the list of patches that should be applied to
  1995. the base kernel.
  1996. </para>
  1997. <para>
  1998. The kernel layer can optionally include an override to the base
  1999. Yocto Project Linux BSP to inhibit the application of BSP specific
  2000. patches. If a custom BSP is being used, this is not required.
  2001. </para>
  2002. </section> -->
  2003. <!-- <section id='git-repo-of-the-transition-kernel'>
  2004. <title>git Repo of the Transition Kernel</title>
  2005. <para>
  2006. The kernel build system requires a base kernel repository to
  2007. seed the build process. This repository must be found in the
  2008. same layer as the build infrastructure (i.e wrll-linux-2.6.27)
  2009. in the 'git' subdir, with the name 'default_kernel'
  2010. </para>
  2011. <para>Since Yocto Project Linux ships with a default_kernel
  2012. (the validated Yocto Project kernel) in the wrll-linux-2.6.27
  2013. kernel layer, that must be removed and replaced with the
  2014. transition kernel.
  2015. </para>
  2016. <para>If the Yocto Project install cannot be directly modified
  2017. with the new default kernel, then the path to the transition
  2018. kernel layer's 'git' subdir must be passed to the build
  2019. process via:
  2020. <programlisting>
  2021. linux_GIT_BASE=&lt;absolute path to layer&gt;/git
  2022. </programlisting>
  2023. </para>
  2024. <para>
  2025. If the transition kernel has not been delivered via git,
  2026. then a git repo should be created, and bare cloned into
  2027. place. Creating this repository is as simple as:
  2028. <literallayout class='monospaced'>
  2029. &gt; tar zxvf temp_kernel.tgz
  2030. &gt; cd temp_kernel
  2031. &gt; git init
  2032. &gt; git add .
  2033. &gt; git commit -a -m "Transition kernel baseline"
  2034. 'temp_kernel' can now be cloned into place via:
  2035. &gt; cd &lt;path to git base&gt;/git
  2036. &gt; git clone &dash;&dash;bare &lt;path to temp_kernel/temp_kernel default_kernel
  2037. </literallayout>
  2038. </para>
  2039. </section> -->
  2040. <!-- <section id='building-the-kernel'>
  2041. <title>Building the Kernel</title>
  2042. <para>
  2043. Once these prerequisites have been met, the kernel can be
  2044. built with:
  2045. <literallayout class='monospaced'>
  2046. &gt; make linux
  2047. </literallayout>
  2048. </para>
  2049. <para>
  2050. The new base kernel will be cloned into place and have any patches
  2051. indicated in the transition kernel's cache (or templates) applied.
  2052. The kernel build will detect the non-Yocto Project base repo and
  2053. use the HEAD of the tree for the build.
  2054. </para>
  2055. </section> -->
  2056. <!-- <section id='example'>
  2057. <title>Example</title>
  2058. <para>
  2059. This example creates a kernel layer to build the latest
  2060. kernel.org tree as the 'common_pc' BSP.
  2061. <literallayout class='monospaced'>
  2062. &gt; cd &lt;path to layers&gt;
  2063. &gt; mkdir wrll-linux-my_version
  2064. &gt; cd wrll-linux-my_version
  2065. &gt; echo "wrll-linux-2.6.27" &gt; include
  2066. &gt; mkdir -p kernel-cache/ktypes/standard
  2067. &gt; mkdir -p kernel-cache/bsp/common_pc
  2068. &gt; echo "v2.6.29" &gt; kernel-cache/kver
  2069. &gt; echo "branch common_pc-standard" &gt; kernel-cache/bsp/common_pc/common_pc.scc
  2070. &gt; echo "kconf hardware common_pc.cfg" &gt;&gt; kernel-cache/bsp/common_pc/common_pc.scc
  2071. &gt; echo "CONFIG_FOO=y" &gt; kernel-cache/bsp/common_pc/common_pc.cfg
  2072. &gt; mkdir git
  2073. &gt; cd git
  2074. &gt; git clone &dash;&dash;bare git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git default_kernel
  2075. </literallayout>
  2076. </para>
  2077. <para>
  2078. Configure a build to use the new layer. This means that:
  2079. <literallayout class='monospaced'>
  2080. &dash;&dash;enable-kernel-version=my_version
  2081. </literallayout>
  2082. </para>
  2083. <para>
  2084. Should be used to override the shipped default.
  2085. </para>
  2086. <para>
  2087. To build the kernel:
  2088. <literallayout class='monospaced'>
  2089. &gt; cd build
  2090. &gt; make linux_GIT_BASE=&lt;layer path&gt;/wrll-linux-my_version/git linux
  2091. </literallayout>
  2092. </para>
  2093. <para>
  2094. If this is to build without some user intervention (passing of the
  2095. GIT_BASE), you must do the clone into the wrll-linux-2.6.27/git directory.
  2096. </para>
  2097. <note><para>Unless you define valid "hardware.kcf" and "non-hardware.kcf" some
  2098. non fatal warnings will be seen. They can be fixed by populating these
  2099. files in the kernel-cache with valid hardware and non hardware config
  2100. options.
  2101. </para></note>
  2102. </section> -->
  2103. </section>
  2104. </section>
  2105. <!-- <itemizedlist>
  2106. <listitem><para>Introduction to this section.</para></listitem>
  2107. <listitem><para>Constructing a project-specific kernel tree.</para></listitem>
  2108. <listitem><para>Building the kernel.</para></listitem>
  2109. <listitem><para>Seeing what has changed.</para></listitem>
  2110. <listitem><para>Seeing what has changed in a particular branch.</para></listitem>
  2111. <listitem><para>Modifying the kernel.</para></listitem>
  2112. <listitem><para>Saving modifications.</para></listitem>
  2113. <listitem><para>Storing patches outside of the kernel source repository (bulk export).</para></listitem>
  2114. <listitem><para>Working with incremental changes.</para></listitem>
  2115. <listitem><para>Extracting commited changes from a working directory (exporting internally through
  2116. patches.</para></listitem>
  2117. <listitem><para>Pushing commited changes.</para></listitem>
  2118. <listitem><para>Exporting for external (upstream) submission.</para></listitem>
  2119. <listitem><para>Exporting for import into another Source Control Manager (SCM).</para></listitem>
  2120. <listitem><para>Working with the Yocto Project kernel in another SCM.</para>
  2121. <itemizedlist>
  2122. <listitem><para>Exporting the delivered kernel to an SCM.</para></listitem>
  2123. <listitem><para>Importing changed for the build.</para></listitem>
  2124. </itemizedlist></listitem>
  2125. <listitem><para>Migrating templates from version 2.0.</para></listitem>
  2126. <listitem><para>Creating a new Board Support Package (BSP).</para>
  2127. <itemizedlist>
  2128. <listitem><para>Creating from scratch.</para></listitem>
  2129. <listitem><para>Cloning.</para></listitem>
  2130. </itemizedlist></listitem>
  2131. <listitem><para>BSP bootstrapping.</para></listitem>
  2132. <listitem><para>Applying patches to the kernel through a template.</para></listitem>
  2133. <listitem><para>Applying patches to the kernel without using a template.</para></listitem>
  2134. <listitem><para>Updating patches and configurations for a BSP.</para></listitem>
  2135. <listitem><para>Using guilt to add and export patches.</para></listitem>
  2136. <listitem><para>Using scc.</para></listitem>
  2137. <listitem><para>Building a 'dirty' image.</para></listitem>
  2138. <listitem><para>Temporarily using a different base kernel.</para></listitem>
  2139. <listitem><para>Creating a custom kernel layer.</para></listitem>
  2140. <listitem><para>Creating the git repository of the transition kernel.</para></listitem>
  2141. </itemizedlist> -->
  2142. </section>
  2143. </chapter>
  2144. <!--
  2145. vim: expandtab tw=80 ts=4
  2146. -->