Android Deep Explore ( vol. 1) HAL with Driver Development Learning notes (4)
The fourth chapter of the source code download and compilation
First, source code configuration Android Source code Download Environment
1. Create a directory to hold the download script file (repo)
# mkdir ~/bin
# path=~,bin: $PATH
2. Download the repo script file
# Curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
#chmod a+x ~/bin/repo
3. Create a directory to hold the Android Source code
# mkdir Android_reource
# CD Android_source
4. Initialization
# repo Init-u https://android.googlesource.com/platform/manifest
download Master Branch
#repo init-u https://android.googlesource.com/platform/manifest -B android-4.0.1_rl
Download Other branches
5. Start downloading Android Source code
# Repo Sync
Download part of Android Source code
Method 1 using the repo sync command
# Repo Sync platform/bootable/recovery
Method 2 using the git clone command
# git clone http://android.googlesourse.com/<project name>
Second, Android source code directory structure analysis
In addition to the Makefile file, the rest is directory
|--Makefile
|--Abi ( application Binary Interface )
|--Bionic (bionic C Library)
|--bootable (boot boot related code)
|--build (storage System compilation rules and Basic Development package configuration such as generic)
|--CTS (Android Compatibility test suite standard)
|--Dalvik (Dalvik java Virtual machine)
|--Development (Application development related)
|--external ( Some open-source modules used by Android)
|--Frameworks (Core framework --java and C + + language)
|--Hardware (main protection hard Zhei layer HAL code)
|--Libcore (JAVA Core Library)
|--ndk (ndk related source code)
|--Device (equipment-related code)
|-- out (the output of the code after compilation is complete with this directory)
|--Packages (application package)
|--prebuilt (Some resources precompiled underx86 and arm architectures)
|--SDK (SDK and emulator)
|--system (file system library, applications and Components --c language)
|--Vendor (manufacturer custom code)
Third, compile the Android Source code
1. Initializing the compilation environment
# source Build/envsetup.sh
Or
# . build/envsetup.sh// used primarily to initialize some of the compile commands
2. Select a target
# lunch Full-eng// for all mobile devices,Android emulator is active and all debug options are turned on
3. Compiling Android Source code
# make// compile
analysis of the structure of the Out directory
The Out directory holds the default directory for compiling the target files generated by the Android source code
--Target(indicates the target machine, if the compiler defines target_strip_module=false , this directory is debug/target) The main two directories are host and Target, which represents the tools generatedon the host (x86), which represents the target machine (the default is ARMv5 ) to run the content.
V. Download and compile the Linux kernel source code
# git clone https://android.googlesourse.com/kernel/common.git // Download the latest version of the kernel source code
# git branch-a// see which remote repository
# git check out-b android-3.0 remotes/origin/android-3.0// export Linux3.0 kernel
# git clone http://android,googlesourse.com/kernel/goldfish.git
# git checkout-b android-goldfish-2.6.29 remotes/origin/android-goldfish-2.6.29// export goldfish
Six, the Linux kernel source directory
Arch: contains code related to hardware architecture, each of which occupies a corresponding directory.
Block: partial block device drive
Crypto: commonly used encryption and hashing algorithms (such as AES,SHA , etc.), as well as some compression and CRC check algorithms.
Documentation
Drivers: device drivers, each of which consumes a subdirectory, such as char,block,net, MTD , I²c and so on.
FS: supports various file systems, such as EXT,FAT,NTFS, JFFS2 , etc.
Include: header files, system-related header files are placed under the include/linux subdirectory.
Init: kernel initialization code.
IPC: code for interprocess communication
Kernel: The core of the kernel, including the scheduling of the process, timers, and so on, and some of the peace platform related to the code in the arch/*/kernel directory.
LIB: library file code.
MM: memory management Code, and part of the platform-related code is placed in the arch/*/mm directory.
NET: network-related code, the realization of a variety of common network protocols.
Scripts: The script file used to configure the kernel.
Security: mainly a SELinux module.
Drive core code and common device drivers for Sound:alsa,OSS Audio Devices
USR: Cipo for packaging and compression are implemented .
Vii. Install the Android Kernel's compilation environment
1. Add the arm-linux-gcc-4.3.2.tgz file and the arm-none-linux-gnueabi-arm-2008q3-72-for-linux.tar,bz2 files copied to the working directory
2. Unzip the two files above
3. Verify that the cross compiler is successfully installed
# ls/user/local/arm-1
- Installing libncurses5
# Apt-get Install Libncurses5-dev
Viii. Configuring and compiling the Linux kernel
# Export Path=/root/compilers/arm-none-linux-gnueabi/bin: $PATH
#cd ~/linux_kernel
#make Clean
#make
execute the following four configuration commands in the Linux source code Directory
Make Config
Make Manuconfig
Make Oldconfig
Make Xconfig
Nine, after the successful compilation of the Linux kernel, the <linux kernel source directory >/arch/arm/boot directory to generate a Zlmage file, the file is Linux Binary version of the kernel, which can be used directly Zlmage installed on the development version, you can also use the command to Android test in the simulator.
# EMULATOR-AVD Myavd-kernel/root/kernel/goldfish/arch/arm/boot/zlmage
Android Deep Exploration (Volume 1) HAL and Driver Development Study notes (4)