blob: b825ae7ea536aeb02aabe5ae81553e27bce51dbb [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
2"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
3[<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
4
5<appendix id='kernel-dev-maint-appx'>
6<title>Kernel Maintenance</title>
7
8 <section id='tree-construction'>
9 <title>Tree Construction</title>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 This section describes construction of the Yocto Project kernel
13 source repositories as accomplished by the Yocto Project team to
14 create Yocto Linux kernel repositories.
15 These kernel repositories are found under the heading "Yocto Linux
16 Kernel" at
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 <ulink url='&YOCTO_GIT_URL;'>&YOCTO_GIT_URL;</ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 and are shipped as part of a Yocto Project release.
19 The team creates these repositories by compiling and executing the
20 set of feature descriptions for every BSP and feature in the
21 product.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 Those feature descriptions list all necessary patches,
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023 configurations, branches, tags, and feature divisions found in a
24 Yocto Linux kernel.
25 Thus, the Yocto Project Linux kernel repository (or tree) and
26 accompanying Metadata in the
27 <filename>yocto-kernel-cache</filename> are built.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050029
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031 The existence of these repositories allow you to access and clone a
32 particular Yocto Project Linux kernel repository and use it to
33 build images based on their configurations and features.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037 You can find the files used to describe all the valid features and
38 BSPs in the Yocto Project Linux kernel in any clone of the Yocto
39 Project Linux kernel source repository and
40 <filename>yocto-kernel-cache</filename> Git trees.
41 For example, the following commands clone the Yocto Project
42 baseline Linux kernel that branches off
43 <filename>linux.org</filename> version 4.12 and the
44 <filename>yocto-kernel-cache</filename>, which contains stores of
45 kernel Metadata:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047 $ git clone git://git.yoctoproject.org/linux-yocto-4.12
48 $ git clone git://git.yoctoproject.org/linux-kernel-cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050050 For more information on how to set up a local Git repository of
51 the Yocto Project Linux kernel files, see the
52 "<link linkend='preparing-the-build-host-to-work-on-the-kernel'>Preparing the Build Host to Work on the Kernel</link>"
53 section.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050055
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050057 Once you have cloned the kernel Git repository and the
58 cache of Metadata on your local machine, you can discover the
59 branches that are available in the repository using the following
60 Git command:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050062 $ git branch -a
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 </literallayout>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050064 Checking out a branch allows you to work with a particular
65 Yocto Linux kernel.
66 For example, the following commands check out the
67 "standard/beagleboard" branch of the Yocto Linux kernel repository
68 and the "yocto-4.12" branch of the
69 <filename>yocto-kernel-cache</filename> repository:
70 <literallayout class='monospaced'>
71 $ cd ~/linux-yocto-4.12
72 $ git checkout -b my-kernel-4.12 remotes/origin/standard/beagleboard
73 $ cd ~/linux-kernel-cache
74 $ git checkout -b my-4.12-metadata remotes/origin/yocto-4.12
75 </literallayout>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 <note>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050077 Branches in the <filename>yocto-kernel-cache</filename>
78 repository correspond to Yocto Linux kernel versions
79 (e.g. "yocto-4.12", "yocto-4.10", "yocto-4.9", and so forth).
80 </note>
81 Once you have checked out and switched to appropriate branches,
82 you can see a snapshot of all the kernel source files used to
83 used to build that particular Yocto Linux kernel for a
84 particular board.
85 </para>
86
87 <para>
88 To see the features and configurations for a particular Yocto
89 Linux kernel, you need to examine the
90 <filename>yocto-kernel-cache</filename> Git repository.
91 As mentioned, branches in the
92 <filename>yocto-kernel-cache</filename> repository correspond to
93 Yocto Linux kernel versions (e.g. <filename>yocto-4.12</filename>).
94 Branches contain descriptions in the form of
95 <filename>.scc</filename> and <filename>.cfg</filename> files.
96 </para>
97
98 <para>
99 You should realize, however, that browsing your local
100 <filename>yocto-kernel-cache</filename> repository for feature
101 descriptions and patches is not an effective way to determine what
102 is in a particular kernel branch.
103 Instead, you should use Git directly to discover the changes in
104 a branch.
105 Using Git is an efficient and flexible way to inspect changes to
106 the kernel.
107 <note>
108 Ground up reconstruction of the complete kernel tree is an
109 action only taken by the Yocto Project team during an active
110 development cycle.
111 When you create a clone of the kernel Git repository, you are
112 simply making it efficiently available for building and
113 development.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 </note>
115 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500118 The following steps describe what happens when the Yocto Project
119 Team constructs the Yocto Project kernel source Git repository
120 (or tree) found at
Brad Bishop316dfdd2018-06-25 12:45:53 -0400121 <ulink url='&YOCTO_GIT_URL;'></ulink> given the
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122 introduction of a new top-level kernel feature or BSP.
Brad Bishop316dfdd2018-06-25 12:45:53 -0400123 The following actions effectively provide the Metadata
124 and create the tree that includes the new feature, patch, or BSP:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125 <orderedlist>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500126 <listitem><para>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400127 <emphasis>Pass Feature to the OpenEmbedded Build System:</emphasis>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500128 A top-level kernel feature is passed to the kernel build
129 subsystem.
130 Normally, this feature is a BSP for a particular kernel
131 type.
132 </para></listitem>
133 <listitem><para>
134 <emphasis>Locate Feature:</emphasis>
135 The file that describes the top-level feature is located
136 by searching these system directories:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137 <itemizedlist>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500138 <listitem><para>
139 The in-tree kernel-cache directories, which are
140 located in the
Brad Bishop316dfdd2018-06-25 12:45:53 -0400141 <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi/yocto-kernel-cache/tree/bsp'><filename>yocto-kernel-cache</filename></ulink>
142 repository organized under the "Yocto Linux Kernel"
143 heading in the
144 <ulink url='http://git.yoctoproject.org/cgit/cgit.cgi'>Yocto Project Source Repositories</ulink>.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500145 </para></listitem>
146 <listitem><para>
147 Areas pointed to by <filename>SRC_URI</filename>
148 statements found in kernel recipes
149 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 </itemizedlist>
151 For a typical build, the target of the search is a
152 feature description in an <filename>.scc</filename> file
Brad Bishop316dfdd2018-06-25 12:45:53 -0400153 whose name follows this format (e.g.
154 <filename>beaglebone-standard.scc</filename> and
155 <filename>beaglebone-preempt-rt.scc</filename>):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156 <literallayout class='monospaced'>
Brad Bishop316dfdd2018-06-25 12:45:53 -0400157 <replaceable>bsp_root_name</replaceable>-<replaceable>kernel_type</replaceable>.scc
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 </literallayout>
159 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500160 <listitem><para>
161 <emphasis>Expand Feature:</emphasis>
162 Once located, the feature description is either expanded
163 into a simple script of actions, or into an existing
164 equivalent script that is already part of the shipped
165 kernel.
166 </para></listitem>
167 <listitem><para>
168 <emphasis>Append Extra Features:</emphasis>
169 Extra features are appended to the top-level feature
170 description.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 These features can come from the
172 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500173 variable in recipes.
174 </para></listitem>
175 <listitem><para>
176 <emphasis>Locate, Expand, and Append Each Feature:</emphasis>
177 Each extra feature is located, expanded and appended to
178 the script as described in step three.
179 </para></listitem>
180 <listitem><para>
181 <emphasis>Execute the Script:</emphasis>
182 The script is executed to produce files
183 <filename>.scc</filename> and <filename>.cfg</filename>
184 files in appropriate directories of the
185 <filename>yocto-kernel-cache</filename> repository.
186 These files are descriptions of all the branches, tags,
187 patches and configurations that need to be applied to the
188 base Git repository to completely create the
189 source (build) branch for the new BSP or feature.
190 </para></listitem>
191 <listitem><para>
192 <emphasis>Clone Base Repository:</emphasis>
193 The base repository is cloned, and the actions
194 listed in the <filename>yocto-kernel-cache</filename>
195 directories are applied to the tree.
196 </para></listitem>
197 <listitem><para>
198 <emphasis>Perform Cleanup:</emphasis>
199 The Git repositories are left with the desired branches
200 checked out and any required branching, patching and
201 tagging has been performed.
202 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500203 </orderedlist>
204 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500205
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500207 The kernel tree and cache are ready for developer consumption to
208 be locally cloned, configured, and built into a Yocto Project
209 kernel specific to some target hardware.
210 <note><title>Notes</title>
211 <itemizedlist>
212 <listitem><para>
213 The generated <filename>yocto-kernel-cache</filename>
214 repository adds to the kernel as shipped with the Yocto
215 Project release.
216 Any add-ons and configuration data are applied to the
217 end of an existing branch.
218 The full repository generation that is found in the
219 official Yocto Project kernel repositories at
Brad Bishop316dfdd2018-06-25 12:45:53 -0400220 <ulink url='&YOCTO_GIT_URL;'>http://git.yoctoproject.org</ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500221 is the combination of all supported boards and
222 configurations.
223 </para></listitem>
224 <listitem><para>
225 The technique the Yocto Project team uses is flexible
226 and allows for seamless blending of an immutable
227 history with additional patches specific to a
228 deployment.
229 Any additions to the kernel become an integrated part
230 of the branches.
231 </para></listitem>
232 <listitem><para>
233 The full kernel tree that you see on
Brad Bishop316dfdd2018-06-25 12:45:53 -0400234 <ulink url='&YOCTO_GIT_URL;'></ulink> is
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500235 generated through repeating the above steps for all
236 valid BSPs.
237 The end result is a branched, clean history tree that
238 makes up the kernel for a given release.
239 You can see the script (<filename>kgit-scc</filename>)
240 responsible for this in the
241 <ulink url='&YOCTO_GIT_URL;/cgit.cgi/yocto-kernel-tools/tree/tools'><filename>yocto-kernel-tools</filename></ulink>
242 repository.
243 </para></listitem>
244 <listitem><para>
245 The steps used to construct the full kernel tree are
246 the same steps that BitBake uses when it builds a
247 kernel image.
248 </para></listitem>
249 </itemizedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500250 </note>
251 </para>
252 </section>
253
254 <section id='build-strategy'>
255 <title>Build Strategy</title>
256
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500257 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500258 Once you have cloned a Yocto Linux kernel repository and the
259 cache repository (<filename>yocto-kernel-cache</filename>) onto
260 your development system, you can consider the compilation phase
261 of kernel development, which is building a kernel image.
262 Some prerequisites exist that are validated by the build process
263 before compilation starts:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500264 </para>
265
266 <itemizedlist>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500267 <listitem><para>
268 The
269 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
270 points to the kernel Git repository.
271 </para></listitem>
272 <listitem><para>
273 A BSP build branch with Metadata exists in the
274 <filename>yocto-kernel-cache</filename> repository.
275 The branch is based on the Yocto Linux kernel version and
276 has configurations and features grouped under the
277 <filename>yocto-kernel-cache/bsp</filename> directory.
278 For example, features and configurations for the
279 BeagleBone Board assuming a
280 <filename>linux-yocto_4.12</filename> kernel reside in the
281 following area of the <filename>yocto-kernel-cache</filename>
282 repository:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500283 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500284 yocto-kernel-cache/bsp/beaglebone
285 </literallayout>
286 <note>
287 In the previous example, the "yocto-4.12" branch is
288 checked out in the <filename>yocto-kernel-cache</filename>
289 repository.
290 </note>
291 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292 </itemizedlist>
293
294 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500295 The OpenEmbedded build system makes sure these conditions exist
296 before attempting compilation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 Other means, however, do exist, such as as bootstrapping a BSP.
298 </para>
299
300 <para>
301 Before building a kernel, the build process verifies the tree
302 and configures the kernel by processing all of the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500303 configuration "fragments" specified by feature descriptions
304 in the <filename>.scc</filename> files.
305 As the features are compiled, associated kernel configuration
306 fragments are noted and recorded in the series of directories
307 in their compilation order.
308 The fragments are migrated, pre-processed and passed to the
309 Linux Kernel Configuration subsystem (<filename>lkc</filename>) as
310 raw input in the form of a <filename>.config</filename> file.
311 The <filename>lkc</filename> uses its own internal dependency
312 constraints to do the final processing of that information and
313 generates the final <filename>.config</filename> file that is used
314 during compilation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500315 </para>
316
317 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500318 Using the board's architecture and other relevant values from
319 the board's template, kernel compilation is started and a kernel
320 image is produced.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500321 </para>
322
323 <para>
324 The other thing that you notice once you configure a kernel is that
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500325 the build process generates a build tree that is separate from
326 your kernel's local Git source repository tree.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500327 This build tree has a name that uses the following form, where
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500328 <filename>${MACHINE}</filename> is the metadata name of the
329 machine (BSP) and "kernel_type" is one of the Yocto Project
330 supported kernel types (e.g. "standard"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500331 <literallayout class='monospaced'>
332 linux-${MACHINE}-<replaceable>kernel_type</replaceable>-build
333 </literallayout>
334 </para>
335
336 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500337 The existing support in the <filename>kernel.org</filename> tree
338 achieves this default functionality.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500339 </para>
340
341 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500342 This behavior means that all the generated files for a particular
343 machine or BSP are now in the build tree directory.
344 The files include the final <filename>.config</filename> file,
345 all the <filename>.o</filename> files, the <filename>.a</filename>
346 files, and so forth.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500347 Since each machine or BSP has its own separate
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500348 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
349 in its own separate branch of the Git repository, you can easily
350 switch between different builds.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500351 </para>
352 </section>
353</appendix>
354<!--
355vim: expandtab tw=80 ts=4
356-->