forked from nathanchance/android-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuilding_Flash.txt
255 lines (176 loc) · 7.66 KB
/
Building_Flash.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#####################################
## ##
## 1. Configure your environment ##
## ##
#####################################
In order to compile this kernel, you will need a Linux environment.
If you can't dual boot, use Virtual Box to create a virtual machine
(I did it with Mint 18, images below). To get the environment configured, e
ither use Google's own guide (https://source.android.com/source/initializing.html)
or my guide (https://raw.githubusercontent.com/nathanchance/Android-Tools/master/Building_AOSP.txt)
##########################
## ##
## 2. Grab the source ##
## ##
##########################
1. Grab my Flash source
Format:
$ mkdir ~/Android
$ cd ~/Android
$ git clone https://github.com/nathanchance/angler.git Flash
Explanation:
-- First command makes a directory named Android in your home folder
(mkdir = make directory). You can change the location if you want
but keep it consistent throughout the guide.
-- Second command moves into that directory (change directory)
-- Third command pulls the source from my Github into a directory named
Flash (git clone <url> <folder_to_clone_in_to> is the format of the command)
2. Grab my AnyKernel2 source
Format:
$ mkdir ~/Android
$ cd ~/Android
$ git clone https://github.com/nathanchance/AnyKernel2.git Flash-AK2
Explanation:
-- First command makes a directory named Android in your home folder
(mkdir = make directory). You can change the location if you want
but keep it consistent throughout the guide.
-- Second command moves into that directory (change directory)
-- Third command pulls the AnyKernel repo from my Github into a directory named
Flash-AK2 (git clone <url> <folder_to_clone_in_to> is the format of the command)
3. Grab the toolchain you want to use to compile the kernel
Format:
$ cd ~/Android
$ git clone -b personal-linaro-7.x https://github.com/nathanchance/gcc-prebuilts aarch64-linaro-linux-gnu
Explanation:
- In order to compile the kernel, we need to grab a toolchain (bunch of
compilation tools). I currently use my own toolchain, based on Uber. This will
download and checkout the toolchain like above.
##########################
## ##
## 3. Setup the build ##
## ##
##########################
1. Make sure everything looks right
-- After following the above steps, type:
$ ls
-- You should see something like this:
aarch64-linaro-linux-gnu Flash Flash-AK2
2. Select the correct AnyKernel branch
Format:
$ cd ~/Android/Flash-AK
$ git checkout <branch>
Example:
$ cd ~/Android/Flash-AK
$ git checkout angler-flash-public-7.1.2
Explanation:
-- First command will move you into the AnyKernel2 source directory we cloned above.
-- Second command will checkout the branch you want to use. You can see the list
of branches by typing git branch -av.
##########################
## ##
## 4. Make the kernel ##
## ##
##########################
1. Tell the makefile what toolchain and architecture you are building for
1. Figure out the full path of your toolchain folder
Assuming you have done this whole process correctly, you can move
into your toolchain directory and type:
$ cd ~/Android/aarch64-linaro-linux-gnu
$ pwd
You should get something like this: /home/nathan/Android/aarch64-linaro-linux-gnu
2. Tell the compiler where that toolchain is
Copy and paste that file location above into this command:
$ export CROSS_COMPILE=<toolchain_dir>/bin/aarch64-linaro-linux-gnu-
Example:
$ export CROSS_COMPILE=/home/nathan/Android/aarch64-linaro-linux-gnu/bin/aarch64-linaro-linux-gnu-
3. Set the architecture
Angler is a 64-bit device so we need arm64
$ export ARCH=arm64 && export SUBARCH=arm64
2. Clean up from a previous compilation and update the source
$ cd ~/Android/Flash
$ git clean -f -d -x > /dev/null 2>&1
$ git fetch origin
$ git reset --hard origin/7.1.2-flash
-- The first command moves you into the Flash source directory.
-- The second command will clean any untracked or compiled files (this is send
to /dev/null so you do not see it happen).
-- The third and fourth command will pull any new kernel changes from me into the source.
3. Set up the defconfig
A defconfig tells the compiler which features you want in the kernel.
This is already set up by me. To set up the defconfig, type the following:
$ cd ~/Android/Flash
$ mkdir out
$ make O=out flash_defconfig
4. Make the kernel!
Format:
$ make O=out -j$( nproc --all )
###############################
## ##
## 5. Zip it up and flash! ##
## ##
###############################
1. Clean the AnyKernel directory
Format:
$ cd ~/Android/Flash-AK2
$ git clean -f -d -x > /dev/null 2>&1
$ git fetch origin
$ git reset --hard origin/<anykernel_branch>
Example:
$ cd ~/Android/Flash-AK2
$ git clean -f -d -x > /dev/null 2>&1
$ git fetch origin
$ git reset --hard origin/angler-flash-public-7.1.2
-- The first command moves you into the AnyKernel source directory.
-- The second command will clean any untracked or compiled files (this is send
to /dev/null so you do not see it happen).
-- The third and fourth command will pull any new repo changes from me into the source.
2. Copy the zImage to the AnyKernel directory
Format:
$ cp -v ~/Android/Flash/out/arch/arm64/boot/Image.gz-dtb ~/Android/Flash-AK2
Explanation:
-- We need to copy the newly compiled kernel (which resides in the
arch/arm64/boot folder) to the AnyKernel directory, while changing its
name to zImage-dtb.
-- cp = copy
-- -v = verbose (prints the copying)
-- ~/Android/Flash/out/arch/arm64/boot/Image.gz-dtb = file to be copied
-- ~/Android/Flash-AK2 = destination
2. Zip it up!
Format:
$ cd ~/Android/Flash-AK2
$ zip -r9 flash-kernel.zip * -x README flash-kernel.zip
Explanation:
-- Using the above commands, your newly completed kernel will be
located at ~/Android/Flash-AK2/flash-kernel.zip
##################
## ##
## CONCLUSION ##
## ##
##################
If you followed all of the above steps successfully, congratulations, you built
the kernel!! Once you have done all five steps, you will just need to follow
steps 4 and 5 to update in the future. Below, I have linked a script that will
do all of this for you (with some variable edits at the top); however, please do
it manually first so you know exactly what you are doing :) enjoy!
https://raw.githubusercontent.com/nathanchance/Android-Tools/master/Scripts/build-flash.sh
Below are screenshots of me doing this process in a virtual machine (Arch Linux)
with 2 cores, 4GB of RAM, and 60GB of storage on my MacBook with a 2.5 GHz Intel
Core i5 and 8GB of RAM (fairly average in the world of PC specs I think).
It's totally possible to do this on your own.
http://i.imgur.com/CwDH96j.png
If you have any questions, feel free to mention me on XDA (@The Flash)
or contact me on Hangouts ([email protected]) or Telegram (@nathanchance)
# Copyright (C) 2016-2017 Nathan Chancellor
#
# This guide is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This guide is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>