[Sticky] Build the Android Source  

  RSS

Koncn Tseng
Active MemberAdmin
Joined:1 year  ago
Posts: 18
October 2, 2016 5:49 pm  

1. Requirements

Please refer to AOSP website and follow all the instruction mentioned there. Read and prepare carefully through the link, http://source.android.com/source/requirements.html .

Pay attention to the following key points:

  • GUN/Linux distribution selecting: We strongly recommend you install Ubuntu 14.04 (Trusty) to  build the environment;
  • Java Development Kit (JDK): OpenJDK 7 for Android 6.0 (Marshmallow) on Ubuntu;
  • Device binaries: MediaTek X20 SLA source part including the device binaries;

2. Establishing a Build Environment

Refer to AOSP website ( http://source.android.com/source/initializing.html ) and follow the below key points:

  • The Android build is routinely tested in house on recent versions of Ubuntu LTS (14.04)
  • Installing the JDK 7
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk
  • Installing required packages
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
  libgl1-mesa-dev libxml2-utils xsltproc unzip
  • Using a separate output directory
$ export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>

3. Downloading the Source

Refer to AOSP website ( http://source.android.com/source/downloading.html ) and follow the below key points:

  • Installing Repo
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
  • Downloading the AOSP
$ mkdir ~/develop/x20
$ cd ~/develop/x20
$ repo init -u  https://android.googlesource.com/platform/manifest  -b android-6.0.0_r1
$ epo sync –j8
  • Downloading Linux Kernel
$ cd ~/develop
$ git clone https://github.com/helio-x20/linux.git
  • Downloading MediaTek SLA
$ cd ~/develop
$ curl https://builds.96boards.org/releases/helio-x20/mediatek/aosp/16.07/sla.tar.gz

4. Merge the Source

$ cd ~/develop
$ mv linux ~/develop/x20/kernel-3.18
$ tar vxfz sla.tar.gz
$ cp –rf sla/* ~/develop/x20/

5. Build the Android Source

Refer to AOSP website ( http://source.android.com/source/building.html ) and follow the below key points:

  • Clean up
$ make clobber
  • Set up environment
$ source build/envsetup.sh
  • Choose a target
$ lunch full_amt6796_64_open-eng
  • Build the code

Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. For example, on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.

$ make -j8

or make one by one manually

$ make pl -j8
$ make lk -j8
$ make kernel -j8
$ make bootimage -j8
$ make systemimage -j8

Note that, the Android OS for x20 96Boards is open source, but excluding HAL part, and the preloader part.

So, there is no need to execute "$ make pl -j8".

6. Images in the out directory

boot.img
cache.img
lk.bin
logo.bin
MT6797_Android_scatter.txt
PGPT
preloader_amt6797_64_open.bin
recovery.img
system.img
tinysys-scp.bin
trustzone.bin
userdata.img

 

Edited: 12 months  ago

ReplyQuote
Koncn Tseng
Active MemberAdmin
Joined:1 year  ago
Posts: 18
October 2, 2016 6:10 pm  

The directory structure of android source root tree:

Here is short version of what you will find when you download the Android source. I will leave out some minor directories and dig deeper into a couple of the important ones. Basically what you will get (based on the current Marshmallow release), in alphabetical order:

  • Bionic - the C-runtime for Android. Note that Android is not using glibc like most Linux distributions. Instead the c-library is called bionic and is based mostly on BSD-derived sources. In this folder you will find the source for the c-library, math and other core runtime libraries.
  • Bootable - boot and startup related code. Some of it is legacy, the fastboot protocol info could be interesting since it is implemented by boot loaders in a number of devices such as the Nexus ones.
  • Build - the build system implementation including all the core make file templates. An important file here is the envsetup.sh script that will help you a lot when working with the platform source. Running this script in a shell will enable commands to setup environment variables, build specific modules and grep in source code files.
  • Cts - the compatability tests. The test suite to ensure that a build complies with the Android specification.
  • Dalvik - the source code for the implementation of the Dalvik Virtual Machine
  • Development - projects related to development such as the source code for the sdk and ndk tools. Normally not a folder you touch when working with the platform for a target.
  • Device - product specific code for different devices. This is the place to find hardware modules for the different Nexus devices, build configurations and more.
  • External - contains source code for all external open source projects such as SQLite, Freetype and webkit.
  • Frameworks - this folder is essential to Android since it contains the sources for the framework. Here you will find the implementation of key services such as the System Server with the Package- and Activity managers. A lot of the mapping between the java application APIs and the native libraries is also done here.
  • Hardware - hardware related source code such as the Android hardware abstraction layer specification and implementation. This folder also contains the reference radio interface layer (to communicate with the modem side) implementation.
  • libcore - Apache Harmony.
  • libnativehelper - Helper functions for use with JNI.
  • (Kernel) - not part of the default source download but you can get access to this code either by downloading it manually or by adding the repository to the repo tool. Contains the sources for the Android version of the Linux kernel.
  • Out - the build output will be placed here after you run make. The folder structure is out/target/product/. In the default build for the emulator the output will be placed in out/target/product/generic. This is where you will find the images used by the emulator to start (or to be downloaded and flashed to a device if you are building for a hardware target).
  • Packages - contains the source code for the default applications such as contacts, calendar, browser.
  • Prebuilt - contains files that are distributed in binary form for convenience. Examples include the cross compilations toolchains for different development machines.
  • System - source code files for the core Android system. That is the minimal Linux system that is started before the Dalvik VM and any java based services are enabled. This includes the source code for the init process and the default init.rc script that provide the dynamic configuration of the platform
  • tools - Various IDE tools.

Beyond the above you also have the hidden .repo directory that contains the source for the repo utility. It also holds the manifest specifying what git repositories you want to track for this Android source project. If you have your own additions you could automatically track them by adding a local manifest here.

For modifications of the platform framework there are some instructions available in the device/sample folder of the source code tree. That will show you how to add APIs to Android without having to modify the core framework.


ReplyQuote
  
Working

Please Login or Register