Recently in the exploration of Android source code and ROM, was fortunate to buy a book with online to see some of the tutorial, first do some notes, in case of a rainy days ...
1. Learn about Git and repo
2. Environment configuration
The first is definitely the JDK and SDK installation, online tutorials A lot, you can also refer to Google's official offer: https://source.android.com/source/initializing.html
(a) Installing Git and curl:
Apt-get Install Git-core Curl
(b) Installation of Repo:
Create a directory to store repo
# mkdir ~/bin
# Export Path=~/bin: $PATH
# Curl Http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo (can also be downloaded on-line)
# chmod A+x ~/bin/repo
3. Download Android source code
Download Android Source code:
# mkdir ~/source
# CD Source
# Repo Init-u https://android.googlesource.com/platform/manifest-b android-4.2.2_r1 (Sync specified branch, git branch-a view)
# Repo Sync
Compile Android Source code:
# source Build/envsetup.sh
# Lunch Full-eng (compile build can be run on Android emulator or only lunch display all currently supported devices, for example: Full_x86-eng for computers running on X86 architecture)
# MAKE-J4 (4 threads compiled)
The resulting file includes the image file under: ~/source/out/target/product/generic (ramdisk.img, system.img, userdata.img)
Google official source code compilation details can be learned in https://source.android.com/source/building.html
4, download the Android official Linux kernel source code
git commands
# git clone http://android.googlesource.com/kernel/common.git
# git clone http://android.googlesource.com/kernel/exynos.git
# git clone http://android.googlesource.com/kernel/goldfish.git
# git clone http://android.googlesource.com/kernel/msm.git
# git clone http://android.googlesource.com/kernel/omap.git
# git clone http://android.googlesource.com/kernel/samsung.git
# git clone http://android.googlesource.com/kernel/tegra.git
which
Common: Universal Linux kernel, the following 6 sets are based on the source code;
Exynos: Android device for use with the Samsung Exynos chip, typically represented by the Nexus 10;
Goldfish: Kernel source for Android simulator;
MSM: Android device for use with high-pass MSM chips, typically represented by ADP1 (G1), ADP2 (G2), Nexus One and Nexus 4;
OMAP: For use with Texas Instruments (TI) OMAP chip Android devices, typical representative is the PandaBoard and Galaxy Nexus;
Samsung: For Android devices using the Samsung Hummingbird Chip, the typical representative is the Nexus S;
Tefra: For use with the NVIDIA (TEFRA) chip Android device, the typical representative is Xoom and Nexus 7.
HTC phone, you can also download the Linux kernel source of the specified device at the following address:
Http://www.htcdev.com/devcenter/downloads
To view the kernel branch:
# CD Common
# git Branch-a
To switch branches:
# git checkout remotes/origin/xxxxxxxxx
5, compile the kernel source code
To compile a kernel source that is suitable for running on an Android device, you must install a cross compiler that supports the ARM architecture, but the version used by the official compilation of each device is different and must be considered.
The Nexus 7 device uses the cross compiler 4.4.3, which can refer to the following command:
# git clone https://android.googlesource.com/platform/prebuilt
# export path=$ (PWD)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin: $PATH
# Export Arch=arm
# Export cross_compile=arm-eabi-
# make
Finally, a zimage file is generated in the <linux source root directory >/arch/arm/boot directory, which is a binary version of the Linux kernel that can be run (Nexus 7).
(also refer to http://android.git.kernel.org/)
Get Android source code with the official Linux kernel source code