Build Android 5.1
Update time:2018-07-02 Views:9970
1 Preparation
To compile Android, requirement of PC is:
64 bit CPU
16GB physical memory + swap memory
30GB free disk space to build. The source code tree take another 25GB space.
Ubuntu 14.04 is officially recommended. However, Ubuntu 12.04 is confirmed to be supported, providing the requirements of software and hardware in http://source.android.com/source/building.html are met.
To initialize compiling environment, please reference http://source.android.com/source/initializing.html .
Install OpenJDK 7:
sudo apt-get install openjdk-7-jdk
Tips: After installing openjdk-7-jdk, you might need to fix JDK's default link:
$ sudo update-alternatives --config java $ sudo update-alternatives --config javac
to switch JDK version. SDK will switch to internal JDK path once the default one cannot be found. Therefore, in order to compile Android 5.1 and before, removing the JDK7 link is more preferable:
$ sudo /var/lib/dpkg/info/openjdk-7-jdk:amd64.prerm remove
Ubuntu 12.04 packages install:
sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ g++-multilib mingw32 tofrodos gcc-multilib ia32-libs \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \ lzop libssl1.0.0 libssl-dev
Ubuntu 14.04 packages install:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev \ libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl \ libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils \ xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev \ lib32readline-gplv2-dev gcc-multilib libswitch-perl \ libssl1.0.0 libssl-dev
2 Download Android SDK
The size of SDK is huge. Please download firefly-rk3288_android5.1_git_20180126.tar.gz
Please check the md5 checksum before proceeding:
$ md5sum /path/to/firefly-rk3288_android5.1_git_20180126.tar.gz dad080373115053de3367c21289562d2 firefly-rk3288_android5.1_git_20180126.tar.gz
If it is correct, uncompress it:
mkdir -p ~/proj/firefly-rk3288-lollipop cd ~/proj/firefly-rk3288-lollipop tar xzf /path/to/firefly-rk3288_android5.1_git_20180126.tar.gz git reset --hard # git remote add bitbucket https://bitbucket.org/T-Firefly/firenow-lollipop.git
From now on, you can pull from bitbucket:
git pull bitbucket Firefly-RK3288:Firefly-RK3288
You can also browse the source codes online at https://bitbucket.org/T-Firefly/firenow-lollipop/commits/branch/Firefly-RK3288 .
3 Compiling Kernel
To compile Firefly-RK3288 Linux kernel, run:
cd ~/proj/firefly-rk3288-lollipop/kernel make firefly_defconfig make -j8 firefly-rk3288.img
To compile Firefly-RK3288-Reload Linux kernel, run:
cd ~/proj/firefly-rk3288-lollipop/kernel make firefly_defconfig make -j8 firefly-rk3288-reload.img
4 Compiling Android
Firefly-RK3288/Firefly-RK3288-Reload Compiling Android:
cd ~/proj/firefly-rk3288-lollipop source build.sh lunch rk3288_box-userdebug make -j8 ./mkimage.sh
TARGET_BUILD_VARIANT defaults to userdebug. There are three variants: user, userdebug and eng. The main differences are:
user
Only install modules with user tag
Set property ro.secure=1, to turn on security check.
Set property ro.debuggable=0, to close application debugging function.
Turn off adb by default.
Enable Proguard.
Enable DEXPREOPT to optimize applcation.
userdebug
Only install modules with userdebug tag
Set property ro.secure=1, to turn on security check.
Set property ro.debuggable=1, to turn on application debugging function.
Turn on adb by default.
Enable Proguard.
Enable DEXPREOPT to optimize applcation.
eng
Install modules with user, debug or eng tag.
Set property ro.secure=0, to turn off security check.
Set property ro.debuggable=1, to turn on application debugging fucntion.
Turn on adb by default.
Disable Proguard.
Disable DEXPREOPT, not optimizing applcation.
If TARGET_BUILD_VARIANT is user, adb can not gain root permission.
To switch target build variant, add parameter to the make command line:
make -j8 PRODUCT-rk3288_box-user make -j8 PRODUCT-rk3288_box-userdebug make -j8 PRODUCT-rk3288_box-eng
5 Flashing partition images
./mkimage.sh
at previous step will repack boot.img and system.img, and copy other related image files to the rockdev/Image-rk3288_box/
directory. The common image files are listed below:
boot.img : Android's initramfs, to initialize and mount system partition.
kernel.img : Kernel image.
misc.img : Misc partition image, to switch boot mode and pass parameter in recovery mode.
recovery.img : Recovery mode image.
resource.img : Resource image, containing boot logo and kernel's device tree info.
system.img : System partition image with ext4 filesystem format.
Please flash the image according to Flash image.
If you are using Windows system to flash the images, please copy the image files mentioned above to rockdev\Image
directory in AndroidTool (Image flash tool in Windows). Then follow instructions in the flash image guide. This is the easy way, using default configuration, no need to modify image file's path.
6 Create update.img
Create update.img in Windows is simple. Just copy the files to AndroidTool's rockdev\Image
directory as previous step. Then run the batch file mkupdate.bat
in rockdev
directory, which will create update.img under rockdev\Image
.
update.img is convenient to distribute to end users to upgrade the system, while partition images are more frequently used during development.