Android Exploration and drive development and thinking (4)

Source: Internet
Author: User

Related to the source code, and the previous chapter learned git download two sets of source code, a set of Android source code, all download will be nearly 4GB in size, its gold content imaginable. The other is the core Linux kernel source code, hundreds of MB after decompression.
First we learn to download, compile, and test the Android source code.
1. Configure the Android source code download environment
(1) Create a directory to hold the download script file (repo)
(2) Download repo script file
(3) Create a directory to hold the Android source code
(4) initialization
(5) Start downloading Android source code
Android Source code directory structure analysis
Download part of the Android source code
There are two ways to download an item in the Android source code: Method One, using the Repo Sync command method Two, using the git clone command
Compiling Android source code
First step: Initializing the compilation Environment Step two: Select Target step three: compiling Android source code
Out Directory structure analysis
Publish your apk as an Android built-in program
Test system.img file with simulator
The second part we learn to download and compile the Linux kernel source code
Download Linux kernel source code
Directory structure of the Linux kernel source code
Install the Android kernel's build environment
Step one: Prepare for the second step: Unzip the compiler step three: Verify that the Cross compiler is installed successfully fourth step: Install LIBNCURSES5
Configuring and compiling the Linux kernel
Download and compile the Linux kernel source code
Prior to this, we have been exposed to the Linux kernel: especially kernel compilation, so this is easy to understand here.
Kernel compilation: 1. Download the Linux kernel source code: Git clone;2. Enter the common directory in the current directory: Git branch-a " See which remote repositories are currently available "; 3. Export the latest Linux kernel: Git checkout-b android-3.0 remotes/origin/android-3.0;4. Download the appropriate kernel: Git clone http ://;5. Go to Goldfish directory, export goldfish:git checkout-b android-goldfish-2.6.29 Remotes/origin/android-goldfish-2.6.29.
2. Understand the directory structure of the Linux kernel source code: see "Embedded Linux Application Development" or "Android Deep Exploration Volume 1", "Where: Arch directory: Source code and configuration files related to CPU architecture." Init: Initializes the implementation code of the kernel program. Samples: Some examples of kernel programming and so on.
3. Install the kernel compilation environment: cross-compiling environment, the first teacher personally took us to install cross-compilation environment, but I still failed, the main reason is that many of the knowledge or code application is not very skilled. Earlier, the second chapter has described how to install a cross-compilation environment, where we need to understand that before compiling the Linux kernel, you need to configure the Linux makefile file: ARCH =arm[for easy operation on the arm structure] and cross_compile " Cross compiler prefix "? =arm-none-linux-guneabi-.
4. Configure and compile the Linux kernel: assuming the Linux kernel directory:/root/linux_kernel, then we use the following command:
Export Path=/root/complilers/arm-none-linx-guneabi/bin: $PATH
CD ~/linux_kernel
Make clean "clears most of the files generated by the compilation. Ko, etc., but keep the profile"
In addition to making clean, there are two clear commands: Make Mrproper "Clear all files generated by the compilation + configuration file", making Distclean "making mrporper+ delete the backup files left by the editor + patch files".
In addition, the following four commands must be executed in the root directory: Make config "text form configuration", "Make menuconfig" character Interface style menu form ", do oldconfig" character interface requires user Configuration one by one, but Menuconfig ", make Xconfig" in graphical interface Configuration ".
Finally, after a successful Linux compilation, a Zimage file is generated in the < kernel source root >/arch/arm/boot directory.

The content of this chapter is basically how to build these two development environments, in which the Linux kernel development environment is the focus.

Android Exploration and drive development and thinking (4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.