blob: 8e9fed1e28db6f2435e38718ed5c8c6f3d6a95ff [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Building Kernels
2@jd:body
3
4<!--
Clay Murphy768b82a2013-11-12 11:32:41 -08005 Copyright 2013 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
19<div id="qv-wrapper">
20 <div id="qv">
21 <h2>In this document</h2>
22 <ol id="auto-toc">
23 </ol>
24 </div>
25</div>
26
27<p>If you are only interested in the kernel, you may use this guide
28to download and build the appropriate kernel.</p>
29<p>The following instructions assume that you have not downloaded all
30of AOSP. If you have downloaded all of AOSP, you may skip the git
31clone steps other than the step to download the actual kernel sources.</p>
32<p>We will use the Pandaboard kernel in all the following examples.</p>
33<h2 id="figuring-out-which-kernel-to-build">Figuring out which kernel to build</h2>
Robert Ly40e3b6d2013-04-17 18:12:10 -070034<p>This table lists the name and locations of the kernel sources and binaries:
35<table>
36 <tr>
37 <th>Device</th>
38 <th>Binary location</th>
39 <th>Source location</th>
40 <th>Build configuration</th>
41 </tr>
42 <tr>
Jean-Baptiste Queru3b418432013-07-11 15:44:44 -070043 <td>flo</td>
44 <td>device/asus/flo-kernel/kernel</td>
45 <td>kernel/msm</td>
46 <td>flo_defconfig</td>
47 </tr>
48 <tr>
49 <td>deb</td>
50 <td>device/asus/flo-kernel/kernel</td>
51 <td>kernel/msm</td>
52 <td>flo_defconfig</td>
53 </tr>
54 <tr>
Robert Ly40e3b6d2013-04-17 18:12:10 -070055 <td>manta</td>
56 <td>device/samsung/manta/kernel</td>
57 <td>kernel/exynos</td>
58 <td>manta_defconfig</td>
59 </tr>
60 <tr>
61 <td>mako</td>
62 <td>device/lge/mako-kernel/kernel</td>
63 <td>kernel/msm</td>
64 <td>mako_defconfig</td>
65 </tr>
66 <tr>
67 <td>grouper</td>
68 <td>device/asus/grouper/kernel</td>
69 <td>kernel/tegra</td>
70 <td>tegra3_android_defconfig</td>
71 </tr>
72 <tr>
73 <td>tilapia</td>
74 <td>device/asus/grouper/kernel</td>
75 <td>kernel/tegra</td>
76 <td>tegra3_android_defconfig</td>
77 </tr>
78 <tr>
79 <td>maguro</td>
80 <td>device/samsung/tuna/kernel</td>
81 <td>kernel/omap</td>
82 <td>tuna_defconfig</td>
83 </tr>
84 <tr>
85 <td>toro</td>
86 <td>device/samsung/tuna/kernel</td>
87 <td>kernel/omap</td>
88 <td>tuna_defconfig</td>
89 </tr>
90 <tr>
91 <td>panda</td>
92 <td>device/ti/panda/kernel</td>
93 <td>kernel/omap</td>
94 <td>panda_defconfig</td>
95 </tr>
96 <tr>
97 <td>stingray</td>
98 <td>device/moto/wingray/kernel</td>
99 <td>kernel/tegra</td>
100 <td>stingray_defconfig</td>
101 </tr>
102 <tr>
103 <td>wingray</td>
104 <td>device/moto/wingray/kernel </td>
105 <td>kernel/tegra</td>
106 <td>stingray_defconfig</td>
107 </tr>
108 <tr>
109 <td>crespo</td>
110 <td>device/samsung/crespo/kernel</td>
111 <td>kernel/samsung</td>
112 <td>herring_defconfig</td>
113 </tr>
114 <tr>
115 <td>crespo4g</td>
116 <td>device/samsung/crespo/kernel</td>
117 <td>kernel/samsung</td>
118 <td>herring_defconfig</td>
119 </tr>
120</table>
121
122<p>You will want to look at the git log for the kernel binary in the device
123project that you are interested in.</p>
124
Clay Murphy4d366102013-11-19 14:37:52 -0800125<p>Device projects are of the form device/&lt;vendor&gt;/&lt;name&gt;.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -0800126<pre><code>$ git clone https://android.googlesource.com/device/ti/panda
127$ cd panda
Robert Ly40e3b6d2013-04-17 18:12:10 -0700128$ git log --max-count=1 kernel
Robert Ly35f2fda2013-01-29 16:27:05 -0800129</code></pre>
Robert Ly40e3b6d2013-04-17 18:12:10 -0700130
131<p>The commit message for the kernel binary contains a partial git log
132of the kernel sources that were used to build the binary in question.
133The first entry in the log is the most recent, i.e. the one used to
134build that kernel. You will need it at a later step.</p>
135
Clay Murphy4d366102013-11-19 14:37:52 -0800136
137<h2 id="id-version">Identifying kernel version</h2>
138<p>To determine the kernel version used in a particular system image, run the
139following command against the kernel file:</p>
140<pre><code>
141$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'
142</code></pre>
143<p>For Nexus 5 (hammerhead), this can be accomplished with:</p>
144<pre><code>
145$ bzgrep -a 'Linux version' vmlinux.bz2
146</code></pre>
147
148
Robert Ly35f2fda2013-01-29 16:27:05 -0800149<h2 id="downloading-sources">Downloading sources</h2>
150<p>Depending on which kernel you want,</p>
151<pre><code>$ git clone https://android.googlesource.com/kernel/common.git
152$ git clone https://android.googlesource.com/kernel/exynos.git
153$ git clone https://android.googlesource.com/kernel/goldfish.git
154$ git clone https://android.googlesource.com/kernel/msm.git
155$ git clone https://android.googlesource.com/kernel/omap.git
156$ git clone https://android.googlesource.com/kernel/samsung.git
157$ git clone https://android.googlesource.com/kernel/tegra.git
158</code></pre>
159<ul>
160<li>The <code>goldfish</code> project contains the kernel sources for the emulated
161platforms.</li>
162<li>The <code>msm</code> project has the sources for ADP1, ADP2, Nexus One, Nexus 4,
163and can be used as a starting point for work on Qualcomm MSM chipsets.</li>
164<li>The <code>omap</code> project is used for PandaBoard and Galaxy Nexus,
165and can be used as a starting point for work on TI OMAP chipsets.</li>
166<li>The <code>samsung</code> project is used for Nexus S,
167and can be used as a starting point for work on Samsung Hummingbird chipsets.</li>
168<li>The <code>tegra</code> project is for Xoom and Nexus 7,
169and can be used as a starting point for work on NVIDIA Tegra chipsets.</li>
170<li>The <code>exynos</code> project has the kernel sources for Nexus 10,
171and can be used as a starting point for work on Samsung Exynos chipsets.</li>
172</ul>
173<h2 id="downloading-a-prebuilt-gcc">Downloading a prebuilt gcc</h2>
174<p>Ensure that the prebuilt toolchain is in your path.</p>
Robert Ly40e3b6d2013-04-17 18:12:10 -0700175<pre>$ export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH</pre>
176
177or
178<pre>$ export PATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH</pre>
179
180<p>On a linux host, if you don't have an Android source tree, you can download
181the prebuilt toolchain from:
182<pre>$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6</pre>
183
Robert Ly35f2fda2013-01-29 16:27:05 -0800184<h2 id="building">Building</h2>
185<p>As an example, we would build the panda kernel using the following commands:</p>
186<pre><code>$ export ARCH=arm
187$ export SUBARCH=arm
188$ export CROSS_COMPILE=arm-eabi-
189$ cd omap
190$ git checkout &lt;commit_from_first_step&gt;
191$ make panda_defconfig
192$ make
193</code></pre>
194<p>To build the tuna kernel, you may run the previous commands replacing all
195instances of "panda" with "tuna".</p>
Robert Ly40e3b6d2013-04-17 18:12:10 -0700196<p>
Clay Murphy4d366102013-11-19 14:37:52 -0800197The kernel binary is output as: `arch/arm/boot/zImage` It can be copied
Robert Ly40e3b6d2013-04-17 18:12:10 -0700198into the Android source tree in order to build the matching boot image.
Jean-Baptiste Queru3b418432013-07-11 15:44:44 -0700199</p>
Clay Murphy4d366102013-11-19 14:37:52 -0800200<p>Or you can include the <code>TARGET_PREBUILT_KERNEL</code> variable while
201using <code>make bootimage</code> or any other make command line that builds a
202boot image.</p>
203<pre><code>
204$ export TARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage
205</code></pre>
206<p>That variable is supported by all devices as it is set up via
207device/common/populate-new-device.sh</p>