Build Android

来自Firefly wiki
跳转至: 导航搜索


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 are met.

To initialize compiling environment, please reference .

  • 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

Download Android SDK

The size of SDK is huge. Please download fireprime_android5.1_git_20150612.tar from one of the following cloud storage:

Please check the md5 checksum before proceeding:

$ md5sum /path/to/fireprime_android5.1_git_20150612.tar
b896848a3068b50be4c6780e8bd73a2c  fireprime_android5.1_git_20150612.tar

If it is correct, uncompress it:

mkdir -p ~/proj/fireprime
cd ~/proj/fireprime
tar xf /path/to/fireprime_android5.1_git_20150612.tar
git reset --hard
git remote add bitbucket

From now on, you can pull from bitbucket:

git pull bitbucket fireprime:fireprime

You can also browse the source codes online at .

Compiling Kernel

To compile Linux kernel, run:

cd ~/proj/fireprime/kernel
make fireprime_defconfig
make -j8 rk3128-fireprime.img

Compiling Android

Compiling Android:

cd ~/proj/fireprime
make -j8

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, 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, 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, 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-rk312x-user
make -j8 PRODUCT-rk312x-userdebug
make -j8 PRODUCT-rk312x-eng

Flashing partition images

./ at previous step will repack boot.img and system.img, and copy other related image files to the rockdev/Image-rk312x/ 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.

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.