Download, compile, and test Android Source code
1. Configure the Android Source code Download Environment
Create a directory to hold the download script file (repo): "mkdir ~/bin
Path=~/bin: $PATH";
Download repo script file: "Curl
Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo";
Create a directory to hold the Android Source code: "mkdir android_source
CD Android_source";
Initialize: "repo init-u
Https://android.googlesource.com/platform/manifest";
Start downloading Android Source code: "repo sync".
2.Android Source code directory structure
Abi (Abi:applicationbinary Interface, Application Binary interface )
Bionic(bionic C Library)
bootable(boot boot related code)
Build(Storage System compilation rules and Basic Development configuration packages such as generic)
CTS(Compatibility test suite standard)
Dalvik(dalvik Java virtual machine)
Development(Application development related)
Device (equipment-related code)
Docs ( Introduction to open source documentation )
External( Some open-source modules used by Android)
Frameworks(Core framework, source code for Android SDK )
Hardware(mainly hardware adaptation layer HAL code)
Libcore(Core library related)
NDK (NDK related code. androidndk(Android nativedevelopment Kit)
is a series of development tools that allow program developers to embed in Android Applications
Unmanaged code that is written into the C + + language. )
Out(the output of the code after compilation is complete with this directory)
Packages(Application package)
prebuilt( Pre-compiled resources in x86 and arm architectures)
SDK(SDK and emulator)
System(file system, applications and Components-C language)
Makefile
3. Download Part of the Android source code
Method One: Use the repo sync command (Generate a hidden directory in the current directory .) Repo)
Method Two: Use the git clone command
4. Compiling Android Source code
Initialize the compilation environment: "source build/envsetup.sh" or
". build/envsetup.sh";
Select target: Use the lunch command;
Compiling Android Source code: "make";
5.out directory Structure
Host: The libraries and tools needed during the compilation process;
Target:common and product
6. Publish your APK as an Android built-in program
Copy the apk file directly to the system/app directory and generate it from the system directory system.img file.
7. Test the system.img file with the simulator
Download and compile the Linux kernel source code
1. Download the Linux kernel source code
"git clone https://android.googlesource.com/kernel/common.git" To download the latest Linux kernel source code; git branch-a"See what remote repositories are currently available,"git checkout--b Export "To export the content you want.
2.Linux Kernel Source code directory structure
Arch: source code and configuration files related to CPU architecture
Block: Partial block device driver.
Crypto: Commonly used encryption and hashing algorithms, there are some compression and CRC check algorithms.
Documentation: General explanations and annotations on each part of the kernel.
Drivers: A device driver that consumes a subdirectory for each different driver.
Firmware: Some drivers need to use the implementation code of the device firmware.
FS: Various supported file systems, such as ext,fat,NTFS , and so on.
Include: Header file. Which, and system-related header files are placed in the Linux subdirectory
Recorded.
Init: Kernel initialization code (note not system boot code).
IPC: Code for interprocess communication.
Kernel: The core part of the kernel, including process scheduling, timers, etc., and the platform phase
Part of the code is placed in the arch/*/kernel directory.
LIB: library file code.
MM: Memory management code, and platform-related part of the code placed in the arch/*/mm mesh
Recorded.
NET: Network-related code, the realization of a variety of common network protocols.
Samples: Some examples of kernel programming.
Scripts: The script file used to configure the kernel files.
Security: Mainly a SELinux module.
Sound: Drivers for commonly used audio devices.
Tools: Implementation code for a Linux-brought tool.
usr: A cpio has been implemented .
Virt: Implementation code for the kernel virtual machine.
3. Install the Android Kernel's build environment
Configure the Linux kernel source code root directory under the Makefile file, open the Makefile file, locate the ARCH and cross_compile: "ARCH =arm cross_compile?= arm-none-linux-gnueabi- ".
Step one: Prepare for the second step: Unzip the compiler step three: Verify that the Cross compiler is installed successfully fourth step: Install libncurses5
4. Configuring and compiling the Linux kernel
Makeclean: Clears most of the files generated by the compilation, but retains the configuration file.
Make Mrproper: clears all files generated by the compilation and clears the configuration file.
Make Distclean:make mrproper+ Delete the backup files and patches left by the editor
File.
linux source code root execution Configuration command: " make config " (text) " make menuconfig " (character interface) make oldconfig "(character interface)" Span style= "FONT-FAMILY:CALIBRI;" >make xconfig "(graphical interface).
After the Linux kernel is successfully compiled, a <linux kernel source root directory >/arch/arm/boot directory is generated Zimage file, the file is Linux Binary version of the kernel.
Download and compile the source code