Compile Android7.1 industry firmware(Major maintenance)

Download compilation instructions:

The Android7.1 industry version (Major maintenance) is more widely used in industrial tablets, boxes and other fields, and its stable performance has been verified in mass production. This version is also our main maintenance version, applicable to all models of our RK3399 system.

The preparatory work

Compiling Android requires higher configuration requirements for the machine:

  • 64 bits CPU

  • 16GB physical memory + swap memory

  • 30GB the free disk space is used for the build, and the source tree takes up an additional approximately 25GB

The official recommendation of Ubuntu 14.04 operating system, after testing, Ubuntu 12.04 can also compile and run successfully, just need to meet the hardware and software configuration following of the compilation environment is referred to

  • Install OpenJDK 8:

sudo apt-get install openjdk-8-jdk  

Tip: Install openjdk-8-jdk would changed the default link to the JDK .We can:

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

To switch JDK versions. SDK will use the JDK path set internally when the default JDK of the operating system cannot be found. Therefore, to enable the same machine to compile Android 5.1 and previous versions, it is more convenient to remove the link:

$ sudo /var/lib/dpkg/info/openjdk-8-jdk:amd64.prerm remove   
  • Ubuntu 12.04 package installation:

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 package installation:

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 rk3399-firefly-industry-71-20190926.7z.* from the following cloud storage: [Download Android7.1 SDK]

Verify MD5 code after downloading:

$ md5sum /path/to/rk3399-firefly-industry-71-20190926.7z.001

afb279a7d2966908bcf53ce2c2c05edc  rk3399-firefly-industry-71-20190926.7z.001

$md5sum /path/to/rk3399-firefly-industry-71-20190926.7z.002

2bc5a41fd1056f1d1ab1f7e84f666bee  rk3399-firefly-industry-71-20190926.7z.002

After confirmation, you can decompress:

mkdir -p ~/proj/firefly-rk3399-Industry
cd ~/proj/firefly-rk3399-Industry
7z x /path/to/rk3399-firefly-industry-71-20190926.7z.001 -r -o.
git reset --hard
  • Update

The following method is updated from gitlab:

1. Enter SDK root directory
cd ~/proj/firefly-rk3399-Industry  

2. First, clone bundle from gitlab
git clone .bundle

3. If clone fail, try to download package bundle from GoogleDriver below and decompress
7z x rk3399-nougat-bundle-20190612.7z -r -o. && mv rk3399-nougat-bundle/ .bundle/

4. After that, run command below to update SDK

5. Download the code for your own branch
git rebase FETCH_HEAD

The bundle in the SDK,GoogleDriver Download [bundle package]

Default Compilation and Packing: HDMI+DP

The Overall Compilation:

./FFTools/ -j8 -d rk3399-firefly -l rk3399_firefly-userdebug

Pack The Firmware:

./FFTools/mkupdate/ -l rk3399_firefly-userdebug

The packaged firmware is generated in  rockdev/image-rk3399_firefly/  when packaged.

Manually Compile the Packaged Firmware

Step by step compilation

Before compiling, execute the following command:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 
export PATH=$JAVA_HOME/bin:$PATH 
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
  • Compile Kernel:

cd ~/proj/firefly-rk3399-Industry/kernel/
make ARCH=arm64 firefly_defconfig
make -j8 ARCH=arm64 rk3399-firefly.img
  • Compile Uboot:

cd ~/proj/firefly-rk3399-Industry/u-boot/
make rk3399_defconfig
make ARCHV=aarch64 -j8
  • Compile Android:

cd ~/proj/firefly-rk3399-Industry/
source build/
lunch rk3399_firefly-userdebug
make -j8

Package into unified firmware - update.img

After compiling, you can package the unified firmware with the official script of Firefly, and execute the following command:

./FFTools/mkupdate/ update

When the packaging is complete, the unified firmware (update.img) will be generated under rockdev/ image-rk3399_firefly_xxx/

Update. Img is also easy to package under Windows, copy the compiled files to rockdev\Image directory of AndroidTool, and then run mkupdate.bat batch file under rockdev directory to create update.img and store it in rockdev\Image directory.

Upgrade partition images

At compile time./ repackage boot.img and system.img and copy other related image files into the directory (rockdev/Image-rk3399_firefly_xxx/).

The following is a list of image files used by common firmware:

  • boot.img :Android’s initial file image, which initializes and loads the system partition.

  • kernel.img :The kernel image

  • misc.img :misc partition image, responsible for initiating mode switching and parameter passing of first-aid mode.

  • parameter.txt :Partition information for emmc.

  • recovery.img :Image of first aid mode.

  • resource.img :resource image, which contains boot image and kernel device tree information.

  • system.img :Android system partition image, ext4 file system format.

  • trust.img :sleep to wake up relevant files.

  • rk3399_loader_v1.08.106.bin :Loader file.

  • uboot.img :uboot file.

Refer to How to upgrade firmware to burn the partition image file.

If you are using a Windows system, copy the above Image file to rockdev\Image directory of AndroidTool (firmware upgrade tool under Windows), and then upgrade the partition Image according to the upgrade document. The advantage is that you can use the default configuration without changing the path of the file. Update. Img is convenient for firmware release, for end users to upgrade the system. It is generally convenient to use partition images during development.

When using the upgrade tool to upgrade the firmware of industry version, if the original firmware burned was tvbox version, short-circuit emmc or flash erase is required first. Also, use the appropriate upgrade tool
Please refer to Upgrade instructions