[Original post : ]
October 9, 2013
This post will walk through building and deploying Android 4.3 (Jelly Bean MR2) for a Nexus 4 device, from upstream sources.
Overview
A useful source tree, in practical terms, requires these components:
Proprietary binaries for hardware support
Proprietary Google Apps applications (e.g. Play store)
The AOSP system image, recovery image, modem firmware, etc.
A kernel
These four components are not bundled together, and need to be assembled into the Android build system.
Obtain the AOSP source
First, obtain the AOSP tree:
repo init -u -b android-4.3_r1.1
repo sync -c -d -j10
Get the proprietary hardware support files
Now, get the proprietary hardware support files, and install them to the source tree:
cd $ANDROID_BUILD_TOP
wget
wget
wget
for item in *.tgz; do
tar xzvf $item
done
for item in *.sh; do
bash $item
done
# Manually accept all agreements to expand files into ./vendor tree.
rm *.sh *.tgz
Note: probably a good idea to stash these in a/some git repository/ies.
Setup the kernel
Now, get the kernel. Note that the version in the android-msm-mako-3.4-jb-mr2 branch actually has a display driver bug, and “tears” during scroll, out of box. The solution is to use the same revision as is in the stock kernel image.
git clone kernel
git checkout f43c3d9dd98e351a98bbcccff5933061493f30a4
Alright — but it turns out that the AndroidKernel.mk, the main Makefile for the Android kernel, has some issues. The kernel config has modules disabled, but the makefile tries to build modules. You can comment out the offending lines with this sed command:
sed -i '/\t\+\$(.*module/s/^/#/' kernel/AndroidKernel.mk
Get the proprietary Google Apps
There are a couple ways to go about this, but an easy way is to download the proprietary files in a bundle fromRootzWiki:
wget
That package is intended to be use as an update.zip through a recovery session, once the phone is all loaded with an image. An alternative is to create Makefiles so that the files get included in the build. The key files aredevice-partial.mk, and Android.mk.
You can also cheat and just checkout that project, into your tree:
cd $ANDROID_BUILD_TOP
mkdir -p vendor/google
git clone vendor/google/mako
Modify the device/lge/mako Project to include the added files
We now have all of the basic components we need to build, but still have to make a few tweaks to the build system. Firstly, we want to use the files we downloaded to ./vendor, so have to remove the RODUCT_RESTRICT_VENDOR_FILES directive:
sed -i '/PRODUCT_RESTRICT_VENDOR_FILES/s/^/#/' device/lge/mako/full_mako.mk
Similarly, we want to use the kernel source we added to the tree — not the prebuilt kernel image that comes with AOSP. The changes to support this can be viewed in this commit.
Build the Thing
Alright. Assuming all of the above was followed carefully, we should be ready to build:
cd $ANDROID_BUILD_TOP
. build/envsetup.sh
lunch full_mako-eng
make clean
make updatepackage
The update package ends up at $OUT/$TARGET_PRODUCT-img-$TARGET_BUILD_VARIANT.$USER.zip.
Deploy the Thing
Plug in your Nexus 4, ensure that you are able to do USB Debugging, and run:
adb reboot-bootloader
fastboot oem unlock
fastboot -w update $OUT/$TARGET_PRODUCT-img-$TARGET_BUILD_VARIANT.$USER.zip
At that point, the phone will reboot, and you’ll be running Android 4.3 on your Nexus 4.
阅读(2531) | 评论(0) | 转发(0) |