Lucinth wrote:
What do you bros know about android?
I wanna learn to build my own kernels and roms for my phone. I don't like relying on others so much

Sent from my SPH-D700 using Tapatalk
Install either a linux distribution or run one inside of a VM (IMO ubuntu/debian (or mint) are way easier to get the environment up and running, in part because that's what the manuals are written for and the AOSP devs probably all use either one of those). If you don't understand a thing in here then a quick google shall provide an answer -- especially if you're using ubuntu.
It needs to be x86_64, even though android is x86, it has to be built on a 64bit machine.
Get familiar with apt-get/aptitude, now you must make an environment. You'll need: python 2.4-2.7 (and not higher unless that changed recently), sun JDK 6 (if you want to build 2.3+), or the open-jdk equivalent. Enable the 'partner' repositories, update and grab the JDK first.
EDIT2: you'll need about 12gb of free space on the partition you're building for android.
Grab a bunch of dependencies:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev
This also wouldn't hurt:
Code:
sudo apt-get build-dep linux-meta
Or do it the Joklem way:
Code:
sudo apt-get install lib*dev
Grab the repo binary, imo it's less cruel than git:
Code:
sudo curl http://android.git.kernel.org/repo > /usr/bin/repo
sudo chmod +x /usr/bin/repo
Now make your working directory, for the record ~ in unix always refers to "/home/username", so ~/blah points to /home/username/blah, cd changes directories.
Code:
mkdir ~/src/android
cd ~/src/android
Initialize the repo:
Code:
repo init -u git://android.git.kernel.org/platform/manifest.git
You can also specify -b gingerbread to only get that branch, or get a specific branch that you want.
Download the sourcecode:
Code:
repo sync
This might take an hour or three. Once it's done, and don't skip this step, import the android GNUPG key so that you can be sure that what you got is exactly the same shit as how it is on the repository, type:
Code:
gpg --import
You'll be on an empty line, paste this: (verify it there too
http://source.android.com/source/downloading.html)
Code:
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7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wUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
then, CTRL+D to signify EOF (end-of-file)
You now have an environment and the entire android sourcecode, but more importantly you have the toolchain required to build it and the kernel. That's the GNU compiler collection, to build android obviously the x86_64 to ARM cross-compiler is used. Look around on the xda-developers forums for ROMs and kernels that interest you, read a few on general build howtos and get used to the Unix environment by experimenting and fixing whatever errors pop up.
When building you'll need the toolchain in your PATH:
export PATH=$PATH:~/src/android/prebuilt/linux-x86/toolchain/arm-eabi-<version>/bin
this sets a variable the environment to look into that directory for the compiler binaries, otherwise you will get a command not found error.
to specify that you want to cross compile for ARM:
export ARCH=arm
this is "architecture = ARM"
export CROSS_COMPILE:arm-eabi-
where 'arm-eabi-' is the 'prefix' of the binaries in the above folder, i.e. they would be named arm-eabi-c or something. That's the default though.
Some other influential variables, especially when building the kernel, are CFLAGS and CXXFLAGS, those are the GCC optimization arguments.
For practice, build stock Android 2.3.3
prepare:
Code:
cd ~/src/android
. build/envsetup.sh
## only for the nexus one and nexus S, don't install any of those on other phones
lunch
## choose your target, probably full-engineering
If all went well so far:
Code:
make -j##
where ## is the number of cores (and threads) in your machine or number of cores+1, so if you're on a core i7, make -j9 to max out your cpu
That'll take a while and it will likely heat up your room and the adjacent room(edit3: if you have overheating issues, then run less threads, seriously, a thermal shutdown in the middle of a build sucks and 100% usage for nearly an hour will push it there if you've had overheating issues before, here's my global warming:
http://i.imgur.com/vIBQS.jpg). When you're done, you can run it in an emulator - I forgot about that so google it mmkay?
As for building the kernel, you need to download an android kernel source code (the GNU GPL ensures that any dev that you see on xda-developers has to publish his full source code, so it won't be hard to find one), do the same but read up on kernel configuration and building instead of android. Use the same toolchain (all the export shit we did)
I wish many errors upon you because that's how terminal-fu is developed.
EDIT:
Once you're more comfortable from building other people's shit, you could start experimenting step by step. First with the kernel configuration/CFLAGS optimizations, then start merging interesting patches into kernel source trees, then maybe add a few lines of C code to the source. Fuck around, read some source files, try to understand some shit and piece it all together in a mental map, etc.
If you flash a kernel on your phone that panics or is a total dickwad, don't panic and just boot into recovery then restore your NAND, or better yet have a .zip package of the original kernel on your SDCard and just flash that then reboot. You can wipe your ROM/kernel partitions clean if you wished and as long as the bootloader and recovery partitions are intact, you can install from the SDCard or restore a backup, if you happened to forget then pop the SDCard in a PC and transfer the zips over. Easy as that.