blob: f5fd183fd093c9f6be5379524999d3aacc7602e7 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'>&YOCTO_GIT_URL;/cgit.cgi</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
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink> given the
122 introduction of a new top-level kernel feature or BSP.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500123 These are the actions that 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>
127 <emphasis>Pass Feature to Build Subsystem:</emphasis>
128 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
141 <filename>yocto-kernel-cache</filename>
142 repository
143 </para></listitem>
144 <listitem><para>
145 Areas pointed to by <filename>SRC_URI</filename>
146 statements found in kernel recipes
147 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 </itemizedlist>
149 For a typical build, the target of the search is a
150 feature description in an <filename>.scc</filename> file
151 whose name follows this format:
152 <literallayout class='monospaced'>
153 <replaceable>bsp_name</replaceable>-<replaceable>kernel_type</replaceable>.scc
154 </literallayout>
155 </para></listitem>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500156 <listitem><para>
157 <emphasis>Expand Feature:</emphasis>
158 Once located, the feature description is either expanded
159 into a simple script of actions, or into an existing
160 equivalent script that is already part of the shipped
161 kernel.
162 </para></listitem>
163 <listitem><para>
164 <emphasis>Append Extra Features:</emphasis>
165 Extra features are appended to the top-level feature
166 description.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 These features can come from the
168 <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500169 variable in recipes.
170 </para></listitem>
171 <listitem><para>
172 <emphasis>Locate, Expand, and Append Each Feature:</emphasis>
173 Each extra feature is located, expanded and appended to
174 the script as described in step three.
175 </para></listitem>
176 <listitem><para>
177 <emphasis>Execute the Script:</emphasis>
178 The script is executed to produce files
179 <filename>.scc</filename> and <filename>.cfg</filename>
180 files in appropriate directories of the
181 <filename>yocto-kernel-cache</filename> repository.
182 These files are descriptions of all the branches, tags,
183 patches and configurations that need to be applied to the
184 base Git repository to completely create the
185 source (build) branch for the new BSP or feature.
186 </para></listitem>
187 <listitem><para>
188 <emphasis>Clone Base Repository:</emphasis>
189 The base repository is cloned, and the actions
190 listed in the <filename>yocto-kernel-cache</filename>
191 directories are applied to the tree.
192 </para></listitem>
193 <listitem><para>
194 <emphasis>Perform Cleanup:</emphasis>
195 The Git repositories are left with the desired branches
196 checked out and any required branching, patching and
197 tagging has been performed.
198 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199 </orderedlist>
200 </para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500201
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500203 The kernel tree and cache are ready for developer consumption to
204 be locally cloned, configured, and built into a Yocto Project
205 kernel specific to some target hardware.
206 <note><title>Notes</title>
207 <itemizedlist>
208 <listitem><para>
209 The generated <filename>yocto-kernel-cache</filename>
210 repository adds to the kernel as shipped with the Yocto
211 Project release.
212 Any add-ons and configuration data are applied to the
213 end of an existing branch.
214 The full repository generation that is found in the
215 official Yocto Project kernel repositories at
216 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'>http://git.yoctoproject.org/cgit.cgi</ulink>
217 is the combination of all supported boards and
218 configurations.
219 </para></listitem>
220 <listitem><para>
221 The technique the Yocto Project team uses is flexible
222 and allows for seamless blending of an immutable
223 history with additional patches specific to a
224 deployment.
225 Any additions to the kernel become an integrated part
226 of the branches.
227 </para></listitem>
228 <listitem><para>
229 The full kernel tree that you see on
230 <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink> is
231 generated through repeating the above steps for all
232 valid BSPs.
233 The end result is a branched, clean history tree that
234 makes up the kernel for a given release.
235 You can see the script (<filename>kgit-scc</filename>)
236 responsible for this in the
237 <ulink url='&YOCTO_GIT_URL;/cgit.cgi/yocto-kernel-tools/tree/tools'><filename>yocto-kernel-tools</filename></ulink>
238 repository.
239 </para></listitem>
240 <listitem><para>
241 The steps used to construct the full kernel tree are
242 the same steps that BitBake uses when it builds a
243 kernel image.
244 </para></listitem>
245 </itemizedlist>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246 </note>
247 </para>
248 </section>
249
250 <section id='build-strategy'>
251 <title>Build Strategy</title>
252
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500253 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500254 Once you have cloned a Yocto Linux kernel repository and the
255 cache repository (<filename>yocto-kernel-cache</filename>) onto
256 your development system, you can consider the compilation phase
257 of kernel development, which is building a kernel image.
258 Some prerequisites exist that are validated by the build process
259 before compilation starts:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500260 </para>
261
262 <itemizedlist>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500263 <listitem><para>
264 The
265 <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
266 points to the kernel Git repository.
267 </para></listitem>
268 <listitem><para>
269 A BSP build branch with Metadata exists in the
270 <filename>yocto-kernel-cache</filename> repository.
271 The branch is based on the Yocto Linux kernel version and
272 has configurations and features grouped under the
273 <filename>yocto-kernel-cache/bsp</filename> directory.
274 For example, features and configurations for the
275 BeagleBone Board assuming a
276 <filename>linux-yocto_4.12</filename> kernel reside in the
277 following area of the <filename>yocto-kernel-cache</filename>
278 repository:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500279 <literallayout class='monospaced'>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500280 yocto-kernel-cache/bsp/beaglebone
281 </literallayout>
282 <note>
283 In the previous example, the "yocto-4.12" branch is
284 checked out in the <filename>yocto-kernel-cache</filename>
285 repository.
286 </note>
287 </para></listitem>
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288 </itemizedlist>
289
290 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500291 The OpenEmbedded build system makes sure these conditions exist
292 before attempting compilation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500293 Other means, however, do exist, such as as bootstrapping a BSP.
294 </para>
295
296 <para>
297 Before building a kernel, the build process verifies the tree
298 and configures the kernel by processing all of the
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500299 configuration "fragments" specified by feature descriptions
300 in the <filename>.scc</filename> files.
301 As the features are compiled, associated kernel configuration
302 fragments are noted and recorded in the series of directories
303 in their compilation order.
304 The fragments are migrated, pre-processed and passed to the
305 Linux Kernel Configuration subsystem (<filename>lkc</filename>) as
306 raw input in the form of a <filename>.config</filename> file.
307 The <filename>lkc</filename> uses its own internal dependency
308 constraints to do the final processing of that information and
309 generates the final <filename>.config</filename> file that is used
310 during compilation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500311 </para>
312
313 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500314 Using the board's architecture and other relevant values from
315 the board's template, kernel compilation is started and a kernel
316 image is produced.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500317 </para>
318
319 <para>
320 The other thing that you notice once you configure a kernel is that
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500321 the build process generates a build tree that is separate from
322 your kernel's local Git source repository tree.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500323 This build tree has a name that uses the following form, where
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500324 <filename>${MACHINE}</filename> is the metadata name of the
325 machine (BSP) and "kernel_type" is one of the Yocto Project
326 supported kernel types (e.g. "standard"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500327 <literallayout class='monospaced'>
328 linux-${MACHINE}-<replaceable>kernel_type</replaceable>-build
329 </literallayout>
330 </para>
331
332 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500333 The existing support in the <filename>kernel.org</filename> tree
334 achieves this default functionality.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500335 </para>
336
337 <para>
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500338 This behavior means that all the generated files for a particular
339 machine or BSP are now in the build tree directory.
340 The files include the final <filename>.config</filename> file,
341 all the <filename>.o</filename> files, the <filename>.a</filename>
342 files, and so forth.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500343 Since each machine or BSP has its own separate
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500344 <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
345 in its own separate branch of the Git repository, you can easily
346 switch between different builds.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500347 </para>
348 </section>
349</appendix>
350<!--
351vim: expandtab tw=80 ts=4
352-->