diff options
Diffstat (limited to 'documentation/kernel-dev/kernel-dev-concepts-appx.rst')
-rw-r--r-- | documentation/kernel-dev/kernel-dev-concepts-appx.rst | 409 |
1 files changed, 409 insertions, 0 deletions
diff --git a/documentation/kernel-dev/kernel-dev-concepts-appx.rst b/documentation/kernel-dev/kernel-dev-concepts-appx.rst new file mode 100644 index 0000000000..e8addbd307 --- /dev/null +++ b/documentation/kernel-dev/kernel-dev-concepts-appx.rst | |||
@@ -0,0 +1,409 @@ | |||
1 | ************************ | ||
2 | Advanced Kernel Concepts | ||
3 | ************************ | ||
4 | |||
5 | .. _kernel-big-picture: | ||
6 | |||
7 | Yocto Project Kernel Development and Maintenance | ||
8 | ================================================ | ||
9 | |||
10 | Kernels available through the Yocto Project (Yocto Linux kernels), like | ||
11 | other kernels, are based off the Linux kernel releases from | ||
12 | ` <http://www.kernel.org>`__. At the beginning of a major Linux kernel | ||
13 | development cycle, the Yocto Project team chooses a Linux kernel based | ||
14 | on factors such as release timing, the anticipated release timing of | ||
15 | final upstream ``kernel.org`` versions, and Yocto Project feature | ||
16 | requirements. Typically, the Linux kernel chosen is in the final stages | ||
17 | of development by the Linux community. In other words, the Linux kernel | ||
18 | is in the release candidate or "rc" phase and has yet to reach final | ||
19 | release. But, by being in the final stages of external development, the | ||
20 | team knows that the ``kernel.org`` final release will clearly be within | ||
21 | the early stages of the Yocto Project development window. | ||
22 | |||
23 | This balance allows the Yocto Project team to deliver the most | ||
24 | up-to-date Yocto Linux kernel possible, while still ensuring that the | ||
25 | team has a stable official release for the baseline Linux kernel | ||
26 | version. | ||
27 | |||
28 | As implied earlier, the ultimate source for Yocto Linux kernels are | ||
29 | released kernels from ``kernel.org``. In addition to a foundational | ||
30 | kernel from ``kernel.org``, the available Yocto Linux kernels contain a | ||
31 | mix of important new mainline developments, non-mainline developments | ||
32 | (when no alternative exists), Board Support Package (BSP) developments, | ||
33 | and custom features. These additions result in a commercially released | ||
34 | Yocto Project Linux kernel that caters to specific embedded designer | ||
35 | needs for targeted hardware. | ||
36 | |||
37 | You can find a web interface to the Yocto Linux kernels in the `Source | ||
38 | Repositories <&YOCTO_DOCS_OM_URL;#source-repositories>`__ at | ||
39 | ` <&YOCTO_GIT_URL;>`__. If you look at the interface, you will see to | ||
40 | the left a grouping of Git repositories titled "Yocto Linux Kernel". | ||
41 | Within this group, you will find several Linux Yocto kernels developed | ||
42 | and included with Yocto Project releases: | ||
43 | |||
44 | - *``linux-yocto-4.1``:* The stable Yocto Project kernel to use with | ||
45 | the Yocto Project Release 2.0. This kernel is based on the Linux 4.1 | ||
46 | released kernel. | ||
47 | |||
48 | - *``linux-yocto-4.4``:* The stable Yocto Project kernel to use with | ||
49 | the Yocto Project Release 2.1. This kernel is based on the Linux 4.4 | ||
50 | released kernel. | ||
51 | |||
52 | - *``linux-yocto-4.6``:* A temporary kernel that is not tied to any | ||
53 | Yocto Project release. | ||
54 | |||
55 | - *``linux-yocto-4.8``:* The stable yocto Project kernel to use with | ||
56 | the Yocto Project Release 2.2. | ||
57 | |||
58 | - *``linux-yocto-4.9``:* The stable Yocto Project kernel to use with | ||
59 | the Yocto Project Release 2.3. This kernel is based on the Linux 4.9 | ||
60 | released kernel. | ||
61 | |||
62 | - *``linux-yocto-4.10``:* The default stable Yocto Project kernel to | ||
63 | use with the Yocto Project Release 2.3. This kernel is based on the | ||
64 | Linux 4.10 released kernel. | ||
65 | |||
66 | - *``linux-yocto-4.12``:* The default stable Yocto Project kernel to | ||
67 | use with the Yocto Project Release 2.4. This kernel is based on the | ||
68 | Linux 4.12 released kernel. | ||
69 | |||
70 | - *``yocto-kernel-cache``:* The ``linux-yocto-cache`` contains patches | ||
71 | and configurations for the linux-yocto kernel tree. This repository | ||
72 | is useful when working on the linux-yocto kernel. For more | ||
73 | information on this "Advanced Kernel Metadata", see the "`Working | ||
74 | With Advanced Metadata | ||
75 | (``yocto-kernel-cache``) <#kernel-dev-advanced>`__" Chapter. | ||
76 | |||
77 | - *``linux-yocto-dev``:* A development kernel based on the latest | ||
78 | upstream release candidate available. | ||
79 | |||
80 | .. note:: | ||
81 | |||
82 | Long Term Support Initiative (LTSI) for Yocto Linux kernels is as | ||
83 | follows: | ||
84 | |||
85 | - For Yocto Project releases 1.7, 1.8, and 2.0, the LTSI kernel is | ||
86 | ``linux-yocto-3.14``. | ||
87 | |||
88 | - For Yocto Project releases 2.1, 2.2, and 2.3, the LTSI kernel is | ||
89 | ``linux-yocto-4.1``. | ||
90 | |||
91 | - For Yocto Project release 2.4, the LTSI kernel is | ||
92 | ``linux-yocto-4.9`` | ||
93 | |||
94 | - ``linux-yocto-4.4`` is an LTS kernel. | ||
95 | |||
96 | Once a Yocto Linux kernel is officially released, the Yocto Project team | ||
97 | goes into their next development cycle, or upward revision (uprev) | ||
98 | cycle, while still continuing maintenance on the released kernel. It is | ||
99 | important to note that the most sustainable and stable way to include | ||
100 | feature development upstream is through a kernel uprev process. | ||
101 | Back-porting hundreds of individual fixes and minor features from | ||
102 | various kernel versions is not sustainable and can easily compromise | ||
103 | quality. | ||
104 | |||
105 | During the uprev cycle, the Yocto Project team uses an ongoing analysis | ||
106 | of Linux kernel development, BSP support, and release timing to select | ||
107 | the best possible ``kernel.org`` Linux kernel version on which to base | ||
108 | subsequent Yocto Linux kernel development. The team continually monitors | ||
109 | Linux community kernel development to look for significant features of | ||
110 | interest. The team does consider back-porting large features if they | ||
111 | have a significant advantage. User or community demand can also trigger | ||
112 | a back-port or creation of new functionality in the Yocto Project | ||
113 | baseline kernel during the uprev cycle. | ||
114 | |||
115 | Generally speaking, every new Linux kernel both adds features and | ||
116 | introduces new bugs. These consequences are the basic properties of | ||
117 | upstream Linux kernel development and are managed by the Yocto Project | ||
118 | team's Yocto Linux kernel development strategy. It is the Yocto Project | ||
119 | team's policy to not back-port minor features to the released Yocto | ||
120 | Linux kernel. They only consider back-porting significant technological | ||
121 | jumps DASH and, that is done after a complete gap analysis. The reason | ||
122 | for this policy is that back-porting any small to medium sized change | ||
123 | from an evolving Linux kernel can easily create mismatches, | ||
124 | incompatibilities and very subtle errors. | ||
125 | |||
126 | The policies described in this section result in both a stable and a | ||
127 | cutting edge Yocto Linux kernel that mixes forward ports of existing | ||
128 | Linux kernel features and significant and critical new functionality. | ||
129 | Forward porting Linux kernel functionality into the Yocto Linux kernels | ||
130 | available through the Yocto Project can be thought of as a "micro | ||
131 | uprev." The many “micro uprevs” produce a Yocto Linux kernel version | ||
132 | with a mix of important new mainline, non-mainline, BSP developments and | ||
133 | feature integrations. This Yocto Linux kernel gives insight into new | ||
134 | features and allows focused amounts of testing to be done on the kernel, | ||
135 | which prevents surprises when selecting the next major uprev. The | ||
136 | quality of these cutting edge Yocto Linux kernels is evolving and the | ||
137 | kernels are used in leading edge feature and BSP development. | ||
138 | |||
139 | Yocto Linux Kernel Architecture and Branching Strategies | ||
140 | ======================================================== | ||
141 | |||
142 | As mentioned earlier, a key goal of the Yocto Project is to present the | ||
143 | developer with a kernel that has a clear and continuous history that is | ||
144 | visible to the user. The architecture and mechanisms, in particular the | ||
145 | branching strategies, used achieve that goal in a manner similar to | ||
146 | upstream Linux kernel development in ``kernel.org``. | ||
147 | |||
148 | You can think of a Yocto Linux kernel as consisting of a baseline Linux | ||
149 | kernel with added features logically structured on top of the baseline. | ||
150 | The features are tagged and organized by way of a branching strategy | ||
151 | implemented by the Yocto Project team using the Source Code Manager | ||
152 | (SCM) Git. | ||
153 | |||
154 | .. note:: | ||
155 | |||
156 | - Git is the obvious SCM for meeting the Yocto Linux kernel | ||
157 | organizational and structural goals described in this section. Not | ||
158 | only is Git the SCM for Linux kernel development in ``kernel.org`` | ||
159 | but, Git continues to grow in popularity and supports many | ||
160 | different work flows, front-ends and management techniques. | ||
161 | |||
162 | - You can find documentation on Git at | ||
163 | ` <http://git-scm.com/documentation>`__. You can also get an | ||
164 | introduction to Git as it applies to the Yocto Project in the | ||
165 | "`Git <&YOCTO_DOCS_OM_URL;#git>`__" section in the Yocto Project | ||
166 | Overview and Concepts Manual. The latter reference provides an | ||
167 | overview of Git and presents a minimal set of Git commands that | ||
168 | allows you to be functional using Git. You can use as much, or as | ||
169 | little, of what Git has to offer to accomplish what you need for | ||
170 | your project. You do not have to be a "Git Expert" in order to use | ||
171 | it with the Yocto Project. | ||
172 | |||
173 | Using Git's tagging and branching features, the Yocto Project team | ||
174 | creates kernel branches at points where functionality is no longer | ||
175 | shared and thus, needs to be isolated. For example, board-specific | ||
176 | incompatibilities would require different functionality and would | ||
177 | require a branch to separate the features. Likewise, for specific kernel | ||
178 | features, the same branching strategy is used. | ||
179 | |||
180 | This "tree-like" architecture results in a structure that has features | ||
181 | organized to be specific for particular functionality, single kernel | ||
182 | types, or a subset of kernel types. Thus, the user has the ability to | ||
183 | see the added features and the commits that make up those features. In | ||
184 | addition to being able to see added features, the user can also view the | ||
185 | history of what made up the baseline Linux kernel. | ||
186 | |||
187 | Another consequence of this strategy results in not having to store the | ||
188 | same feature twice internally in the tree. Rather, the kernel team | ||
189 | stores the unique differences required to apply the feature onto the | ||
190 | kernel type in question. | ||
191 | |||
192 | .. note:: | ||
193 | |||
194 | The Yocto Project team strives to place features in the tree such | ||
195 | that features can be shared by all boards and kernel types where | ||
196 | possible. However, during development cycles or when large features | ||
197 | are merged, the team cannot always follow this practice. In those | ||
198 | cases, the team uses isolated branches to merge features. | ||
199 | |||
200 | BSP-specific code additions are handled in a similar manner to | ||
201 | kernel-specific additions. Some BSPs only make sense given certain | ||
202 | kernel types. So, for these types, the team creates branches off the end | ||
203 | of that kernel type for all of the BSPs that are supported on that | ||
204 | kernel type. From the perspective of the tools that create the BSP | ||
205 | branch, the BSP is really no different than a feature. Consequently, the | ||
206 | same branching strategy applies to BSPs as it does to kernel features. | ||
207 | So again, rather than store the BSP twice, the team only stores the | ||
208 | unique differences for the BSP across the supported multiple kernels. | ||
209 | |||
210 | While this strategy can result in a tree with a significant number of | ||
211 | branches, it is important to realize that from the developer's point of | ||
212 | view, there is a linear path that travels from the baseline | ||
213 | ``kernel.org``, through a select group of features and ends with their | ||
214 | BSP-specific commits. In other words, the divisions of the kernel are | ||
215 | transparent and are not relevant to the developer on a day-to-day basis. | ||
216 | From the developer's perspective, this path is the "master" branch in | ||
217 | Git terms. The developer does not need to be aware of the existence of | ||
218 | any other branches at all. Of course, value exists in the having these | ||
219 | branches in the tree, should a person decide to explore them. For | ||
220 | example, a comparison between two BSPs at either the commit level or at | ||
221 | the line-by-line code ``diff`` level is now a trivial operation. | ||
222 | |||
223 | The following illustration shows the conceptual Yocto Linux kernel. | ||
224 | |||
225 | In the illustration, the "Kernel.org Branch Point" marks the specific | ||
226 | spot (or Linux kernel release) from which the Yocto Linux kernel is | ||
227 | created. From this point forward in the tree, features and differences | ||
228 | are organized and tagged. | ||
229 | |||
230 | The "Yocto Project Baseline Kernel" contains functionality that is | ||
231 | common to every kernel type and BSP that is organized further along in | ||
232 | the tree. Placing these common features in the tree this way means | ||
233 | features do not have to be duplicated along individual branches of the | ||
234 | tree structure. | ||
235 | |||
236 | From the "Yocto Project Baseline Kernel", branch points represent | ||
237 | specific functionality for individual Board Support Packages (BSPs) as | ||
238 | well as real-time kernels. The illustration represents this through | ||
239 | three BSP-specific branches and a real-time kernel branch. Each branch | ||
240 | represents some unique functionality for the BSP or for a real-time | ||
241 | Yocto Linux kernel. | ||
242 | |||
243 | In this example structure, the "Real-time (rt) Kernel" branch has common | ||
244 | features for all real-time Yocto Linux kernels and contains more | ||
245 | branches for individual BSP-specific real-time kernels. The illustration | ||
246 | shows three branches as an example. Each branch points the way to | ||
247 | specific, unique features for a respective real-time kernel as they | ||
248 | apply to a given BSP. | ||
249 | |||
250 | The resulting tree structure presents a clear path of markers (or | ||
251 | branches) to the developer that, for all practical purposes, is the | ||
252 | Yocto Linux kernel needed for any given set of requirements. | ||
253 | |||
254 | .. note:: | ||
255 | |||
256 | Keep in mind the figure does not take into account all the supported | ||
257 | Yocto Linux kernels, but rather shows a single generic kernel just | ||
258 | for conceptual purposes. Also keep in mind that this structure | ||
259 | represents the Yocto Project | ||
260 | Source Repositories | ||
261 | that are either pulled from during the build or established on the | ||
262 | host development system prior to the build by either cloning a | ||
263 | particular kernel's Git repository or by downloading and unpacking a | ||
264 | tarball. | ||
265 | |||
266 | Working with the kernel as a structured tree follows recognized | ||
267 | community best practices. In particular, the kernel as shipped with the | ||
268 | product, should be considered an "upstream source" and viewed as a | ||
269 | series of historical and documented modifications (commits). These | ||
270 | modifications represent the development and stabilization done by the | ||
271 | Yocto Project kernel development team. | ||
272 | |||
273 | Because commits only change at significant release points in the product | ||
274 | life cycle, developers can work on a branch created from the last | ||
275 | relevant commit in the shipped Yocto Project Linux kernel. As mentioned | ||
276 | previously, the structure is transparent to the developer because the | ||
277 | kernel tree is left in this state after cloning and building the kernel. | ||
278 | |||
279 | Kernel Build File Hierarchy | ||
280 | =========================== | ||
281 | |||
282 | Upstream storage of all the available kernel source code is one thing, | ||
283 | while representing and using the code on your host development system is | ||
284 | another. Conceptually, you can think of the kernel source repositories | ||
285 | as all the source files necessary for all the supported Yocto Linux | ||
286 | kernels. As a developer, you are just interested in the source files for | ||
287 | the kernel on which you are working. And, furthermore, you need them | ||
288 | available on your host system. | ||
289 | |||
290 | Kernel source code is available on your host system several different | ||
291 | ways: | ||
292 | |||
293 | - *Files Accessed While using ``devtool``:* ``devtool``, which is | ||
294 | available with the Yocto Project, is the preferred method by which to | ||
295 | modify the kernel. See the "`Kernel Modification | ||
296 | Workflow <#kernel-modification-workflow>`__" section. | ||
297 | |||
298 | - *Cloned Repository:* If you are working in the kernel all the time, | ||
299 | you probably would want to set up your own local Git repository of | ||
300 | the Yocto Linux kernel tree. For information on how to clone a Yocto | ||
301 | Linux kernel Git repository, see the "`Preparing the Build Host to | ||
302 | Work on the | ||
303 | Kernel <#preparing-the-build-host-to-work-on-the-kernel>`__" section. | ||
304 | |||
305 | - *Temporary Source Files from a Build:* If you just need to make some | ||
306 | patches to the kernel using a traditional BitBake workflow (i.e. not | ||
307 | using the ``devtool``), you can access temporary kernel source files | ||
308 | that were extracted and used during a kernel build. | ||
309 | |||
310 | The temporary kernel source files resulting from a build using BitBake | ||
311 | have a particular hierarchy. When you build the kernel on your | ||
312 | development system, all files needed for the build are taken from the | ||
313 | source repositories pointed to by the | ||
314 | ```SRC_URI`` <&YOCTO_DOCS_REF_URL;#var-SRC_URI>`__ variable and gathered | ||
315 | in a temporary work area where they are subsequently used to create the | ||
316 | unique kernel. Thus, in a sense, the process constructs a local source | ||
317 | tree specific to your kernel from which to generate the new kernel | ||
318 | image. | ||
319 | |||
320 | The following figure shows the temporary file structure created on your | ||
321 | host system when you build the kernel using Bitbake. This `Build | ||
322 | Directory <&YOCTO_DOCS_REF_URL;#build-directory>`__ contains all the | ||
323 | source files used during the build. | ||
324 | |||
325 | Again, for additional information on the Yocto Project kernel's | ||
326 | architecture and its branching strategy, see the "`Yocto Linux Kernel | ||
327 | Architecture and Branching | ||
328 | Strategies <#yocto-linux-kernel-architecture-and-branching-strategies>`__" | ||
329 | section. You can also reference the "`Using ``devtool`` to Patch the | ||
330 | Kernel <#using-devtool-to-patch-the-kernel>`__" and "`Using Traditional | ||
331 | Kernel Development to Patch the | ||
332 | Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__" | ||
333 | sections for detailed example that modifies the kernel. | ||
334 | |||
335 | Determining Hardware and Non-Hardware Features for the Kernel Configuration Audit Phase | ||
336 | ======================================================================================= | ||
337 | |||
338 | This section describes part of the kernel configuration audit phase that | ||
339 | most developers can ignore. For general information on kernel | ||
340 | configuration including ``menuconfig``, ``defconfig`` files, and | ||
341 | configuration fragments, see the "`Configuring the | ||
342 | Kernel <#configuring-the-kernel>`__" section. | ||
343 | |||
344 | During this part of the audit phase, the contents of the final | ||
345 | ``.config`` file are compared against the fragments specified by the | ||
346 | system. These fragments can be system fragments, distro fragments, or | ||
347 | user-specified configuration elements. Regardless of their origin, the | ||
348 | OpenEmbedded build system warns the user if a specific option is not | ||
349 | included in the final kernel configuration. | ||
350 | |||
351 | By default, in order to not overwhelm the user with configuration | ||
352 | warnings, the system only reports missing "hardware" options as they | ||
353 | could result in a boot failure or indicate that important hardware is | ||
354 | not available. | ||
355 | |||
356 | To determine whether or not a given option is "hardware" or | ||
357 | "non-hardware", the kernel Metadata in ``yocto-kernel-cache`` contains | ||
358 | files that classify individual or groups of options as either hardware | ||
359 | or non-hardware. To better show this, consider a situation where the | ||
360 | ``yocto-kernel-cache`` contains the following files: | ||
361 | yocto-kernel-cache/features/drm-psb/hardware.cfg | ||
362 | yocto-kernel-cache/features/kgdb/hardware.cfg | ||
363 | yocto-kernel-cache/ktypes/base/hardware.cfg | ||
364 | yocto-kernel-cache/bsp/mti-malta32/hardware.cfg | ||
365 | yocto-kernel-cache/bsp/qemu-ppc32/hardware.cfg | ||
366 | yocto-kernel-cache/bsp/qemuarma9/hardware.cfg | ||
367 | yocto-kernel-cache/bsp/mti-malta64/hardware.cfg | ||
368 | yocto-kernel-cache/bsp/arm-versatile-926ejs/hardware.cfg | ||
369 | yocto-kernel-cache/bsp/common-pc/hardware.cfg | ||
370 | yocto-kernel-cache/bsp/common-pc-64/hardware.cfg | ||
371 | yocto-kernel-cache/features/rfkill/non-hardware.cfg | ||
372 | yocto-kernel-cache/ktypes/base/non-hardware.cfg | ||
373 | yocto-kernel-cache/features/aufs/non-hardware.kcf | ||
374 | yocto-kernel-cache/features/ocf/non-hardware.kcf | ||
375 | yocto-kernel-cache/ktypes/base/non-hardware.kcf | ||
376 | yocto-kernel-cache/ktypes/base/hardware.kcf | ||
377 | yocto-kernel-cache/bsp/qemu-ppc32/hardware.kcf The following list | ||
378 | provides explanations for the various files: | ||
379 | |||
380 | - ``hardware.kcf``: Specifies a list of kernel Kconfig files that | ||
381 | contain hardware options only. | ||
382 | |||
383 | - ``non-hardware.kcf``: Specifies a list of kernel Kconfig files that | ||
384 | contain non-hardware options only. | ||
385 | |||
386 | - ``hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options that | ||
387 | are hardware, regardless of whether or not they are within a Kconfig | ||
388 | file specified by a hardware or non-hardware Kconfig file (i.e. | ||
389 | ``hardware.kcf`` or ``non-hardware.kcf``). | ||
390 | |||
391 | - ``non-hardware.cfg``: Specifies a list of kernel ``CONFIG_`` options | ||
392 | that are not hardware, regardless of whether or not they are within a | ||
393 | Kconfig file specified by a hardware or non-hardware Kconfig file | ||
394 | (i.e. ``hardware.kcf`` or ``non-hardware.kcf``). | ||
395 | |||
396 | Here is a specific example using the | ||
397 | ``kernel-cache/bsp/mti-malta32/hardware.cfg``: CONFIG_SERIAL_8250 | ||
398 | CONFIG_SERIAL_8250_CONSOLE CONFIG_SERIAL_8250_NR_UARTS | ||
399 | CONFIG_SERIAL_8250_PCI CONFIG_SERIAL_CORE CONFIG_SERIAL_CORE_CONSOLE | ||
400 | CONFIG_VGA_ARB The kernel configuration audit automatically detects | ||
401 | these files (hence the names must be exactly the ones discussed here), | ||
402 | and uses them as inputs when generating warnings about the final | ||
403 | ``.config`` file. | ||
404 | |||
405 | A user-specified kernel Metadata repository, or recipe space feature, | ||
406 | can use these same files to classify options that are found within its | ||
407 | ``.cfg`` files as hardware or non-hardware, to prevent the OpenEmbedded | ||
408 | build system from producing an error or warning when an option is not in | ||
409 | the final ``.config`` file. | ||