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