Template:RK3399-BuildFromSource
Contents
1 Make Your Own OS Image
1.1 Setup Development Environment
If you want to compile an Android image we suggest you use a PC running a 64-bit Ubuntu 16.04.
sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zip sudo apt-get install flex curl libncurses5-dev libssl-dev zlib1g-dev gawk minicom sudo apt-get install openjdk-8-jdk sudo apt-get install exfat-fuse exfat-utils device-tree-compiler liblz4-tool
For more details refer to https://source.android.com/source/initializing.html 。
1.2 Install Cross Compiler
1.2.1 Install aarch64-linux-gcc 6.4
Download and extract compiler:
git clone https://github.com/friendlyarm/prebuilts.git sudo mkdir -p /opt/FriendlyARM/toolchain sudo tar xf prebuilts/gcc-x64/aarch64-cortexa53-linux-gnu-6.4.tar.xz -C /opt/FriendlyARM/toolchain/
Add the compiler's path to the PATH variable by appending the following lines to the "~/.bashrc" file:
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin:$PATH export GCC_COLORS=auto
Run the "~/.bashrc" script to make the compiler setting effective in the current shell. Note:there is a space after ".":
. ~/.bashrc
This is a 64-bit compiler and cannot be run on a 32-bit Linux. After installation is done you can verify it by running the following commands:
aarch64-linux-gcc -v Using built-in specs. COLLECT_GCC=aarch64-linux-gcc COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/6.4-aarch64/libexec/gcc/aarch64-cortexa53-linux-gnu/6.4.0/lto-wrapper Target: aarch64-cortexa53-linux-gnu Configured with: /work/toolchain/build/aarch64-cortexa53-linux-gnu/build/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=aarch64-cortexa53-linux-gnu --prefix=/opt/FriendlyARM/toolchain/6.4-aarch64 --with-sysroot=/opt/FriendlyARM/toolchain/6.4-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-languages=c,c++ --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-cpu=cortex-a53 ... Thread model: posix gcc version 6.4.0 (ctng-1.23.0-150g-FA)
1.3 Compile Android7 Source Code
1.3.1 Download Android7 Source Code
All the NanoPC-T4's source code is hosted at gitlab, you can download it by running the following commands:
git clone https://gitlab.com/friendlyelec/rk3399-nougat.git
1.3.2 Compile & Make Image File
Compile Android7 by running the following commands:
cd rk3399-nougat ./build-nanopc-t4.sh -F -M
1.3.3 Update Image File
After compilation is done an image file will be generated under Android7's "rockdev/Image-nanopc_t4/" directory. Update the image file on T4 by running the following commands:
1) Insert a bootable SD card with EFLASHER to a card adapter and insert this adapter to a host PC and the SD card's sections will be automatically mounted;
2) Copy all the files under "rockdev/Image-nanopc_t4/" to the "nougat" directory of this SD card's FRIENDLYARM section;
3) Insert this SD card to your NanoPC-T4 and reinstall Android;
1.4 Compile Lubuntu Kernel
1.4.1 compile Linux kernel
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-linux-v4.4.y cd kernel-rockchip make ARCH=arm64 nanopi4_linux_defconfig make ARCH=arm64 nanopi4-images
1.4.2 Update Lubuntu Kernel
To update the kernel you need to use the Linux_Upgrade_Tool_1.27.rar utility. Refer to the aforementioned sections on how to use this utility.