aosp的android 5.0编译源码-asus 编译代号

aosp的android 5.0编译源码:
1.安装openJDK-7

sudo apt-get install openjdk-7-jdk
2.source build/env
3.lunch nexus-7 2012 grouper
4.make otapackage -j16 2>&1 | tee build.log

http://source.android.com/source/building-devices.html#flashing-a-device

https://developers.google.com/android/nexus/drivers#grouperktu84p

Obtaining proprietary binaries


The Android Open-Source Project can’t be used from pure source code only, and requires additional hardware-related proprietary libraries to run, specifically for hardware graphics acceleration.

Official binaries for the supported devices running tagged AOSP release branches can be downloaded fromGoogle’s Nexus driver page. These add access to additional hardware capabilities with non-open-source code. To instead build the AOSP master branch, use the Binaries Preview for Nexus Devices.

When building the master branch for a device, the binaries for the most recent numbered release or with the most recent date are the ones that should be used.

Extracting the proprietary binaries

Each set of binaries comes as a self-extracting script in a compressed archive. After uncompressing each archive, run the included self-extracting script from the root of the source tree, confirm that you agree to the terms of the enclosed license agreement, and the binaries and their matching makefiles will get installed in thevendor/ hierarchy of the source tree.

Cleaning up when adding proprietary binaries

In order to make sure that the newly installed binaries are properly taken into account after being extracted, the existing output of any previous build needs to be deleted with

$ make clobber

Picking and building the configuration that matches a device


The steps to configure and build the Android Open Source Project are described in the Building page.

The recommended builds for the various devices are available through the lunch menu, accessed when running the lunch command with no arguments. Factory images and binaries for Nexus devices can be downloaded from:

https://developers.google.com/android/nexus/images

https://developers.google.com/android/nexus/drivers

Device Code name Build configuration
Nexus 5 (GSM/LTE) hammerhead aosp_hammerhead-userdebug
Nexus 7 (Wi-Fi) razor (flo) aosp_flo-userdebug
Nexus 7 (Mobile) razorg (deb) aosp_deb-userdebug
Nexus 10 mantaray (manta) full_manta-userdebug
Nexus 4 occam (mako) full_mako-userdebug
Nexus 7 (Wi-Fi) nakasi (grouper) full_grouper-userdebug
Nexus 7 (Mobile) nakasig (tilapia) full_tilapia-userdebug
Galaxy Nexus (GSM/HSPA+) yakju (maguro) full_maguro-userdebug
Galaxy Nexus (Verizon) mysid (toro) aosp_toro-userdebug
Galaxy Nexus (Experimental) mysidspr (toroplus) aosp_toroplus-userdebug
PandaBoard (Archived) panda aosp_panda-userdebug
Motorola Xoom (U.S. Wi-Fi) wingray full_wingray-userdebug
Nexus S soju (crespo) full_crespo-userdebug
Nexus S 4G sojus (crespo4g) full_crespo4g-userdebug

Do not use 4.1.1 on a Nexus 7 that was originally sold with 4.1.2 or newer.

Flashing a device


Set the device in fastboot mode if necessary (see above).

An entire Android system can be flashed in a single command: this writes the boot, recovery and system partitions together after verifying that the system being flashed is compatible with the installed bootloader and radio, and reboots the system. This also erases all the user data, similarly to fastboot oem unlock mentioned earlier.

$ fastboot -w flashall

Note that filesystems created via fastboot on Motorola Xoom aren’t working optimally, and it is strongly recommended to re-create them through recovery

$ adb reboot recovery

Once in recovery, open the menu (press Power + Volume Up), wipe the cache partition, then wipe data.

 

Booting into fastboot mode


During a cold boot, the following key combinations can be used to boot into fastboot mode, which is a mode in the bootloader that can be used to flash the devices:

Device Keys
hammerhead Press and hold both Volume Up and Volume Down, then press and hold Power
flo Press and hold Volume Down, then press and hold Power
deb Press and hold Volume Down, then press and hold Power
manta Press and hold both Volume Up and Volume Down, then press and hold Power
mako Press and hold Volume Down, then press and hold Power
grouper Press and hold Volume Down, then press and hold Power
tilapia Press and hold Volume Down, then press and hold Power
phantasm Power the device, cover it with one hand after the LEDs light up and until they turn red
maguro Press and hold both Volume Up and Volume Down, then press and hold Power
toro Press and hold both Volume Up and Volume Down, then press and hold Power
toroplus Press and hold both Volume Up and Volume Down, then press and hold Power
panda Press and hold Input, then press Power
wingray Press and hold Volume Down, then press and hold Power
crespo Press and hold Volume Up, then press and hold Power
crespo4g Press and hold Volume Up, then press and hold Power

Also, the command adb reboot bootloader can be used to reboot from Android directly into the bootloader with no key combinations.

fastboot oem unlock
fastboot erase boot
fastboot erase cache
fastboot erase recovery
fastboot erase system
fastboot erase userdata
fastboot flash bootloader bootloader-grouper-4.23.img
fastboot reboot-bootloader
sleep 10
fastboot -w update image-nakasi-grouper.zip

 

Nexus 7 (Wi-Fi) binaries for Android 4.4.4 (KTU84P)

Hardware Component Company Download MD5 Checksum SHA-1 Checksum
Camera, Sensors, DRM ASUS Link 7ffa1f81555ed43a7c3087f433259664 23762b0aed3cd3120e0c3fc3dadc6d5a69ab9772
Wi-Fi, Bluetooth, GPS Broadcom Link c92d63852e3ba158e4c0a0766b2418e0 d8c1d01d17092b89cf62fb49e239c1373f27b9bd
Touch Panel ELAN Link 008d914344e5946fad5b9b6d89c6b58d 9f56304c2b5228117155dbd0091258bf2a6b2c05
Orientation Sensor Invensense Link 7684cae88024bc5cfa7f11f5d6ace212 5549e1b7ec243dd315763cfaba2a06a00078fb2c
Graphics NVIDIA Link d1e9ef9b67cf3a1b5055597625a5d857 f7363843ac56c125f8d2d869b94d5700d0e53a2a
NFC NXP Link b92526920471de241aa1b474c2197f29 ccc3753614ce36df907519bc225d4ba1bcdcc8cd
DRM Widevine/Google Link 066906b0170176e9533cc5a9c254a3cf 249b05ae3792325a41e6f4789e793c9f164489f1

支持设备为Nexus系列亲儿子,最近的几款设备全部在列,但是较老的Google Nexus、Nexus S并不在列。

Nexus 7 Wi-Fi 2013:
https://android.googlesource.com/device/asus/flo/+/l-preview

Nexus 7 LTE 2013:
https://android.googlesource.com/device/asus/deb/+/l-preview

Nexus 7 Wi-Fi 2012:
https://android.googlesource.com/device/asus/grouper/+/l-preview

Nexus 7 LTE 2012:
https://android.googlesource.com/device/asus/tilapia/+/l-preview

Nexus 10:
https://android.googlesource.com/device/samsung/manta/+/l-preview

Nexus 5:
https://android.googlesource.com/device/lge/hammerhead/+/l-preview

Nexus 4:
https://android.googlesource.com/device/lge/mako/+/l-preview

 

http://source.android.com/source/building-kernels.html

Building Kernels

If you are only interested in the kernel, you may use this guide to download and build the appropriate kernel.

The following instructions assume that you have not downloaded all of AOSP. If you have downloaded all of AOSP, you may skip the git clone steps other than the step to download the actual kernel sources.

We will use the Pandaboard kernel in all the following examples.

Figuring out which kernel to build


This table lists the name and locations of the kernel sources and binaries:

Device Binary location Source location Build configuration
hammerhead device/lge/hammerhead-kernel kernel/msm hammerhead_defconfig
flo device/asus/flo-kernel/kernel kernel/msm flo_defconfig
deb device/asus/flo-kernel/kernel kernel/msm flo_defconfig
manta device/samsung/manta/kernel kernel/exynos manta_defconfig
mako device/lge/mako-kernel/kernel kernel/msm mako_defconfig
grouper device/asus/grouper/kernel kernel/tegra tegra3_android_defconfig
tilapia device/asus/grouper/kernel kernel/tegra tegra3_android_defconfig
maguro device/samsung/tuna/kernel kernel/omap tuna_defconfig
toro device/samsung/tuna/kernel kernel/omap tuna_defconfig
panda device/ti/panda/kernel kernel/omap panda_defconfig
stingray device/moto/wingray/kernel kernel/tegra stingray_defconfig
wingray device/moto/wingray/kernel kernel/tegra stingray_defconfig
crespo device/samsung/crespo/kernel kernel/samsung herring_defconfig
crespo4g device/samsung/crespo/kernel kernel/samsung herring_defconfig

You will want to look at the git log for the kernel binary in the device project that you are interested in.

Device projects are of the form device/<vendor>/<name>.

$ git clone https://android.googlesource.com/device/ti/panda
$ cd panda
$ git log --max-count=1 kernel

The commit message for the kernel binary contains a partial git log of the kernel sources that were used to build the binary in question. The first entry in the log is the most recent, i.e. the one used to build that kernel. You will need it at a later step.

Identifying kernel version


To determine the kernel version used in a particular system image, run the following command against the kernel file:


$ dd if=kernel bs=1 skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' kernel | cut -d ':' -f 1) | zgrep -a 'Linux version'

For Nexus 5 (hammerhead), this can be accomplished with:


$ bzgrep -a 'Linux version' vmlinux.bz2

Downloading sources


Depending on which kernel you want,

$ git clone https://android.googlesource.com/kernel/common.git
$ git clone https://android.googlesource.com/kernel/exynos.git
$ git clone https://android.googlesource.com/kernel/goldfish.git
$ git clone https://android.googlesource.com/kernel/msm.git
$ git clone https://android.googlesource.com/kernel/omap.git
$ git clone https://android.googlesource.com/kernel/samsung.git
$ git clone https://android.googlesource.com/kernel/tegra.git
  • The goldfish project contains the kernel sources for the emulated platforms.
  • The msm project has the sources for ADP1, ADP2, Nexus One, Nexus 4, and can be used as a starting point for work on Qualcomm MSM chipsets.
  • The omap project is used for PandaBoard and Galaxy Nexus, and can be used as a starting point for work on TI OMAP chipsets.
  • The samsung project is used for Nexus S, and can be used as a starting point for work on Samsung Hummingbird chipsets.
  • The tegra project is for Xoom and Nexus 7, and can be used as a starting point for work on NVIDIA Tegra chipsets.
  • The exynos project has the kernel sources for Nexus 10, and can be used as a starting point for work on Samsung Exynos chipsets.

Downloading a prebuilt gcc


Ensure that the prebuilt toolchain is in your path.

$ export PATH=$(pwd)/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH

or

$ export PATH=$(pwd)/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin:$PATH

On a linux host, if you don’t have an Android source tree, you can download the prebuilt toolchain from:

$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6

Building


As an example, we would build the panda kernel using the following commands:

$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ cd omap
$ git checkout <commit_from_first_step>
$ make panda_defconfig
$ make

To build the tuna kernel, you may run the previous commands replacing all instances of “panda” with “tuna”.

The kernel binary is output as: `arch/arm/boot/zImage` It can be copied into the Android source tree in order to build the matching boot image.

Or you can include the TARGET_PREBUILT_KERNEL variable while using make bootimage or any other make command line that builds a boot image.


$ export TARGET_PREBUILT_KERNEL=$your_kernel_path/arch/arm/boot/zImage

That variable is supported by all devices as it is set up via device/common/populate-new-device.sh

http://www.2cto.com/kf/201109/103802.html

以TCC88XX为例,当在Android顶层源码目录使用make编译完成后,会生成这样一个目录:

out/target/product/tcc8800,该目录内部有我们需要的boot.img和system.img,boot.mg

使用kernel和out/target/product/tcc8800/root目录打包而成(广义的ramdisk),也就是说,

boot.img是由kernel和ramdisk.img生成得到,在本文中主要分析root目录和ramdisk.img的生成,

Android编译框架中,把许多固定的、反复用到的目录路径定义为宏变量,而上述生成的目录

out/target/product/tcc8800的宏即为:PRODUCT_OUT

out/target/product/tcc8800/system的宏即为:TARGET_OUT

而out/target/product/tcc8800/root的宏即为:TARGET_ROOT_OUT,

out/target/product/tcc8800/root主要是由system/core/rootdir目录拷贝得到的,

为此我分析了system/core/rootdir目录中的Android.mk文件,具体情况是这样的:

copy_from := etc/dbus.conf   etc/hosts

copy_from += etc/vold.fstab

以上内容将需要拷贝的文件添加到copy_from变量中,以便后续处理。

拷贝到那里呢? 在看看copy_to的定义:

copy_to := $(addprefix $(TARGET_OUT)/,$(coby_from))

该语句即为copy_from中每个字符串片段添加一个TARGET_OUT前缀(即system),这样copy_to的

内容就很明了:

copy_to :=out/target/product/tcc8800/system/etc/dbus.conf …之类,在此略掉。

之后,给copy_from添加路径前缀:

copy_from := $(addprefix $(LOCAL_PATH)/, $(copy_from)

之所以要添加前缀的原因是接下来马上要设置的拷贝语句:

$(copy_to) : $(TARGET_OUT)/% : $(LOCAL_PATH)/% | $(ACP)

$(stransform-prebuilt-to-target)
上述语句会让Android在构建img前,自动完成拷贝工作,其中使用到符号%进行匹配,这也是为什么要

给copy_from添加前缀的原因。

随后,脚本将copy_to变量添加进 ALL_PREBUILT全局宏中:

ALL_PREBUILT += $(copy_to)

最后,在build/core/Makefile中看到copy_to的内容被提取到了另外一个全局宏 ,具体如下:

#build/core/Makefile

INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%,$(ALL_PREBUILT) ……

由于上述4行内容设计到system.img的生成,在此不深究。

看来system/core/rootdir中的部分内容是拷贝到了out/target/product/tcc8800/system中的,并不是

完完全全拷贝到out/target/product/tcc8800/root目录中去的。

我们回头继续查看system/core/rootdir/Android.mk文件,该文件中剩下的内容才是与root密切相关的。

file := $(TARGET_ROOT_OUT)/init.rc

然后也是经典的拷贝设置:
$(file) : $(LOCAL_PATH)/% | $(ACP)

$(stransform-prebuilt-to-target)

接下来的脚本的内容是为生成boot.img而写的。
ALL_PREBUILT +=$(file)

$(INSTALLED_RAMDISK_TARGET):$(file)

看来原理也和上述system的拷贝相同,在build/core/Makefile中是由INTERNAL_RAMDISK_FILE提取的,

具体如下:INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, $(ALL_PREBUILT) …

随后有一段很关键的句子直接道破了ramdisk.img的生成:

INSTALLED_RAMDISK_TARGET=$(BUILT_RAMDISK_TARGET)

$(INSTALLED_RAMDISK_TARGET):$(MKBOOTFS $(INTERNAL_RAMDISK_FILES | $(MINIGZIP)

$(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@
如此多的宏,让我们一一列出它们的值:

BUILT_RAMDISK_TARGET = $(PRODUCT_OUT/ramdisk.img 这是我们的目标

INSTALLED_RAMDISK_TARGET = BUILT_RAMDISK_TARGET 目标伪装了一下。

MKBOOTFS = mkbootfs 就是位于out/host/linux-x86/bin目录下的mkbootfs,这东西自然也有后话。

INTERNAL_RAMDISK_FILES = 所有TARGET_ROOT_OUT中的文件

由此可以看出root目录先被打包生成了ramdisk.img,然后才合并进boot.img的。

上文已经对boot.img其中组成部分之一ramdisk.img做了分析,boot.img另外一个重要的组成部分就是kernel了,

这里所说的kernel,可以只理解为位于out/target/product/tcc8800/中的kernel文件,本文主要分析kernel的拷贝

过程以及如何被打包到boot.img中。经过分析得知位于out/target/product/tcc8800/中的kernel文件其实就是内核

编译后的Image文件,位于kernel/arch/arm/boot目录下,线索就是这个Image文件,经过搜索发现一处定义:

LOCAL_KERNEL :=  kernel/arch/arm/boot/Image

该定义位于devices/telechips/tcc88xx-common/BoardConfigCommon.mk中,紧接着,在同目录的Android.mk中

有以下一段定义:

PRODUCT_COPY_FILES += \

$(LOCAL_KERNEL):kernel

意在将Image文件拷贝且重命名为kernel,随后的拷贝设置是在build/core/Makefile中完成的,在此略掉。

那么,拷贝完成后,kernel文件如何被打包到boot.img中呢?同样在build/core/Makefile中有以下一段内容:

INTERNAL_BOOTIMAGE_ARGS := … –kernel $(INSTALLED_KERNEL_TARGET)

现在的问题就是查看 INSTALLED_KERNEL_TARGET的定义,该宏位于build/target/board/Android.mk中:

INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel

内容很明显了,至此,内核Image算是到位了。

另外INSTALL_KERNEL_TARGET定义在build/target/board/Android.mk中有点怪怪的,

build/target/board/Android.mk在main.mk中通过subdir_makefiles抽取得到,并包含进main.mk中