Difference between revisions of "Template:RK3399-BuildFromSource"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 1: Line 1:
===Compile Android10 Source Code===
+
===Build u-boot and kernel===
====Download Android10 Source Code====
+
====Kernel and u-boot versions====
 +
{| class="wikitable"
 +
|-
 +
! Operating System
 +
! Kernel Version
 +
! U-boot version
 +
! Cross-compiler
 +
! Partition type
 +
! Packaging Tool
 +
! Kernel branch
 +
! Kernel configuration
 +
! U-boot branch
 +
! U-boot configuration
 +
|-
 +
| lubuntu
 +
| rowspan="4" | linux v4.4.y
 +
| rowspan="4" | u-boot v2014.10
 +
| rowspan="4" | 6.4-aarch64<br />
 +
| rowspan="4" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/master/prebuilt/parameter.template MBR]
 +
| rowspan="4" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/master sd-fuse]
 +
| rowspan="4" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-linux-v4.4.y nanopi4-linux-v4.4.y]
 +
| rowspan="4" | nanopi4_linux_defconfig
 +
| rowspan="4" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2014.10_oreo nanopi4-v2014.10_oreo]
 +
| rowspan="4" | rk3399_defconfig
 +
|-
 +
| friendlycore-arm64
 +
|-
 +
| friendlydesktop-arm64
 +
|-
 +
| eflasher
 +
|-
 +
| buildroot
 +
| rowspan="8" | linux v4.19.y
 +
| rowspan="8" | u-boot <br />v2017.09
 +
| rowspan="8" | 11.3-aarch64
 +
| rowspan="8" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-4.19/prebuilt/parameter.template GPT]
 +
| rowspan="8" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-4.19 sd-fuse]
 +
| rowspan="8" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi4-v4.19.y nanopi4-v4.19.y]
 +
| rowspan="7" | nanopi4_linux_defconfig
 +
| rowspan="8" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2017.09 nanopi4-v2017.09]
 +
| rowspan="8" | rk3399_defconfig
 +
|-
 +
| debian-buster-desktop-arm64
 +
|-
 +
| debian-bullseye-core-arm64
 +
|-
 +
| debian-bullseye-desktop-arm64
 +
|-
 +
| debian-bullseye-minimal-arm64
 +
|-
 +
| friendlycore-focal-arm64
 +
|-
 +
| friendlycore-lite-focal-kernel4-arm64
 +
|-
 +
| friendlywrt21-kernel4
 +
| nanopi4_linux_defconfig<br /> friendlywrt.config
 +
|-
 +
| friendlycore-lite-focal-kernel5-arm64
 +
| rowspan="5" | linux v5.15.y
 +
| rowspan="5" | u-boot <br />v2017.09
 +
| rowspan="5" | 11.3-aarch64
 +
| rowspan="5" | [https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-5.15.y/prebuilt/parameter.template GPT]
 +
| rowspan="5" | [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-5.15.y<br /> sd-fuse]
 +
| rowspan="5" | [https://github.com/friendlyarm/kernel-rockchip/tree/nanopi-r2-v5.15.y nanopi-r2-v5.15.y]
 +
| nanopi4_linux_defconfig
 +
| rowspan="5" | [https://github.com/friendlyarm/uboot-rockchip/tree/nanopi4-v2017.09<br /> nanopi4-v2017.09]
 +
| rowspan="5" | rk3399_defconfig
 +
|-
 +
| friendlywrt21
 +
| rowspan="4" | nanopi4_linux_defconfig<br /> friendlywrt.config
 +
|-
 +
| friendlywrt21-docker
 +
|-
 +
| friendlywrt22
 +
|-
 +
| friendlywrt22-docker
 +
|}
 +
* Kernel git repo:https://github.com/friendlyarm/kernel-rockchip
 +
* U-boot git repo:https://github.com/friendlyarm/uboot-rockchip
 +
* The cross-compile toolchain is located in the path: /opt/FriendlyARM/toolchain/
 +
* The SD-Fuse is a  helper script to make bootable SD card image.
 +
* Click on MBR and GPT in the table to view the partition layout (configuration file) for each system.
 +
 
 +
====Build kernel linux-v4.4.y====
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| lubuntu
 +
| eflasher
 +
| friendlydesktop-arm64
 +
| friendlycore-arm64
 +
|}
 +
Clone the repository to your local drive then build:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
 +
cd kernel-rockchip
 +
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 +
touch .scmversion
 +
# Load configuration
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
 +
# Optionally, if you want to change the default kernel config
 +
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig 
 +
# Start building kernel
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
 +
# Start building kernel modules
 +
mkdir -p out-modules
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
 +
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
 +
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
 +
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
 +
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
 +
</syntaxhighlight>
 +
After the compilation, the following files will be generated:
 +
{| class="wikitable"
 +
|-
 +
| kernel.img
 +
| resource.img
 +
| The kernel modules are located in the out-modules directory
 +
|}
 +
Run your build: <br>
 +
Please refre to [[#Running the build]]<br>
 +
 
 +
====Build u-boot v2014.10====
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| lubuntu
 +
| eflasher
 +
| friendlydesktop-arm64
 +
| friendlycore-arm64
 +
|}
 +
Clone the repository to your local drive then build:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2014.10_oreo
 +
cd uboot-rockchip
 +
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 +
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
 +
make CROSS_COMPILE=aarch64-linux-
 +
</syntaxhighlight>
 +
After the compilation, the following files will be generated:
 +
{| class="wikitable"
 +
|-
 +
| uboot.img
 +
| trust.img
 +
| rk3399_loader_v1.22.119.bin (aka MiniLoaderAll.bin)
 +
|}
 +
Installing the u-boot: <br>
 +
Please refre to [[#Running the build]]<br>
 +
 
 +
====Build kernel linux-v4.19.y====
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| debian-buster-desktop-arm64
 +
| debian-bullseye-core-arm64
 +
| debian-bullseye-desktop-arm64
 +
| debian-bullseye-minimal-arm64
 +
|-
 +
| friendlycore-focal-arm64
 +
| friendlycore-lite-focal-kernel4-arm64
 +
| friendlywrt21-kernel4
 +
| buildroot
 +
|}
 +
Clone the repository to your local drive then build:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-v4.19.y kernel-rockchip
 +
cd kernel-rockchip
 +
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
 +
touch .scmversion
 +
# Configuring the Kernel
 +
# Load default configuration
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
 +
# Optionally, load configuration for FriendlyWrt
 +
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig friendlywrt.config
 +
# Launching menuconfig
 +
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig
 +
# Start building kernel
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
 +
# Start building kernel modules
 +
mkdir -p out-modules
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
 +
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
 +
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
 +
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
 +
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
 +
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
 +
</syntaxhighlight>
 +
After the compilation, the following files will be generated:
 +
{| class="wikitable"
 +
|-
 +
| kernel.img
 +
| resource.img
 +
| The kernel modules are located in the out-modules directory
 +
|}
 +
Run your build: <br>
 +
Please refre to [[#Running the build]]<br>
 +
====Build kernel linux-v5.15.y====
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| friendlywrt21
 +
| friendlywrt21-docker
 +
| friendlywrt22
 +
| friendlywrt22-docker
 +
| friendlycore-lite-focal-kernel5-arm64
 +
|}
 +
Clone the repository to your local drive then build:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi-r2-v5.15.y kernel-rockchip
 +
cd kernel-rockchip
 +
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
 +
touch .scmversion
 +
# Configuring the Kernel
 +
# Load default configuration
 +
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig
 +
# Optionally, load configuration for FriendlyWrt
 +
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig friendlywrt.config
 +
# Optionally, if you want to change the default kernel config
 +
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig
 +
# Start building kernel
 +
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j$(nproc)
 +
# Start building kernel modules
 +
mkdir -p out-modules && rm -rf out-modules/*
 +
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
 +
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules_install
 +
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
 +
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
 +
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
 +
</syntaxhighlight>
 +
Pack the kernel.img and resource.img:
 +
<syntaxhighlight lang="bash">
 +
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/mkkrnlimg && chmod 755 mkkrnlimg
 +
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/resource_tool && chmod 755 resource_tool
 +
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo.bmp
 +
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo_kernel.bmp
 +
./mkkrnlimg arch/arm64/boot/Image kernel.img
 +
mkdir kernel-dtbs
 +
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev09.dtb
 +
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev0a.dtb
 +
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4se.dtb kernel-dtbs/rk3399-nanopi4-rev0b.dtb
 +
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb kernel-dtbs/rk3399-nanopi4-rev00.dtb
 +
./resource_tool --dtbname kernel-dtbs/*.dtb logo.bmp logo_kernel.bmp
 +
</syntaxhighlight>
 +
After the compilation, the following files will be generated:
 +
{| class="wikitable"
 +
|-
 +
| kernel.img
 +
| resource.img
 +
| The kernel modules are located in the out-modules directory
 +
|}
 +
Run your build: <br>
 +
Please refre to [[#Running the build]]<br>
 +
====Build u-boot v2017.09====
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| debian-buster-desktop-arm64
 +
| debian-bullseye-core-arm64
 +
| debian-bullseye-desktop-arm64
 +
| debian-bullseye-minimal-arm64
 +
|-
 +
| friendlycore-focal-arm64
 +
| friendlycore-lite-focal-kernel4-arm64
 +
| friendlywrt21-kernel4
 +
| buildroot
 +
|}
 +
Clone the repository to your local drive then build:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b friendlyelec
 +
git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2017.09
 +
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
 +
cd uboot-rockchip/
 +
./make.sh nanopi4
 +
</syntaxhighlight>
 +
After the compilation, the following files will be generated:
 +
{| class="wikitable"
 +
|-
 +
| uboot.img
 +
| trust.img
 +
| rk3399_loader_v1.24.126.bin (aka MiniLoaderAll.bin)
 +
|}
 +
Installing the u-boot: <br>
 +
Please refre to [[#Running the build]]<br>
 +
 
 +
====Running the build====
 +
=====Install to target board=====
 +
======MBR partition======
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| lubuntu
 +
| eflasher
 +
| friendlydesktop-arm64
 +
| friendlycore-arm64
 +
|}
 +
The MBR partitioning is only used by the Linux v4.4 kernel. You can check the partition layout by clicking on this link: [https://github.com/friendlyarm/sd-fuse_rk3399/blob/master/prebuilt/parameter.template partmap]. To write an image file, you can use the dd command. For example, in the parameter.template file, "0x00014000@0x00014000(kernel)" specifies that the kernel partition starts at 0x00014000, which is equivalent to 81920 in decimal. Therefore, the dd command should be as follows:
 +
<syntaxhighlight lang="bash">
 +
dd if=kernel.img of=/dev/mmcblk0 seek=81920
 +
</syntaxhighlight>
 +
 
 +
======GPT partition======
 +
This section applies to the following operating systems:
 +
{| class="wikitable"
 +
|-
 +
| debian-buster-desktop-arm64
 +
| debian-bullseye-core-arm64
 +
| debian-bullseye-desktop-arm64
 +
| debian-bullseye-minimal-arm64
 +
|-
 +
| friendlycore-focal-arm64
 +
| friendlycore-lite-focal-kernel4-arm64
 +
| friendlywrt21-kernel4
 +
| buildroot
 +
|-
 +
| friendlywrt21
 +
| friendlywrt21-docker
 +
| friendlywrt22
 +
| friendlywrt22-docker
 +
|}
 +
Systems using the Linux v4.19 and Linux v5.15 kernels use GPT partitioning by default. You can use the dd command to write the image file to the partition. The device nodes for SD card and eMMC are shown below:
 +
* The SD/TF Card device node: /dev/mmcblk0 <br />
 +
* The eMMC device node: /dev/mmcblk2 <br />
 +
<br />
 +
Use the 'parted' command to view the partition layout:
 +
<syntaxhighlight lang="bash">
 +
parted /dev/mmcblk2 print
 +
</syntaxhighlight>
 +
Sample outputs:
 +
<syntaxhighlight lang="bash">
 +
Model: MMC BJTD4R (sd/mmc)
 +
Disk /dev/mmcblk2: 31.3GB
 +
Sector size (logical/physical): 512B/512B
 +
Partition Table: gpt
 +
Disk Flags:
 +
 
 +
Number  Start  End    Size    File system  Name      Flags
 +
1      8389kB  12.6MB  4194kB              uboot
 +
2      12.6MB  16.8MB  4194kB              trust
 +
3      16.8MB  21.0MB  4194kB              misc
 +
4      21.0MB  25.2MB  4194kB              dtbo
 +
5      25.2MB  41.9MB  16.8MB              resource
 +
6      41.9MB  83.9MB  41.9MB              kernel
 +
7      83.9MB  134MB  50.3MB              boot
 +
8      134MB  2500MB  2366MB  ext4        rootfs
 +
9      2500MB  31.3GB  28.8GB  ext4        userdata
 +
</syntaxhighlight>
 +
as shown above, the resource partition is located at 5 and the kernel partition is located at 6. Use the dd command to write the resource.img and kernel.img files to these partitions, the commands are as follows:
 +
<syntaxhighlight lang="bash">
 +
dd if=resource.img of=/dev/mmcblk2p5 bs=1M
 +
dd if=kernel.img of=/dev/mmcblk2p6 bs=1M
 +
</syntaxhighlight>
 +
If you want to update u-boot:
 +
<syntaxhighlight lang="bash">
 +
dd if=boot.img of=/dev/mmcblk2p1 bs=1M
 +
</syntaxhighlight>
 +
To update new driver modules, copy the newly compiled driver modules to the appropriate directory under /lib/modules.
 +
 
 +
=====Packaging and creating an SD image=====
 +
To create a new OS image file, you need to use the "sd-fuse" packaging tool.<br />
 +
<br />
 +
"sd-fuse" is a collection of scripts that can be used to create bootable SD card images for FriendlyElec boards. Its main features include:<br />
 +
* Creation of root filesystem images from a directory <br />
 +
* Building of bootable SD card images<br />
 +
* Simple compilation of kernel, U-Boot, and third-party drivers<br />
 +
Please click on the following link to find out more:
 +
{| class="wikitable"
 +
|-
 +
! Kernel version
 +
! Packaging Tool
 +
|-
 +
| linux v4.4.y
 +
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/master sd-fuse]
 +
|-
 +
| linux v4.19.y
 +
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-4.19<br /> sd-fuse]
 +
|-
 +
| linux v5.15.y
 +
| [https://github.com/friendlyarm/sd-fuse_rk3399/tree/kernel-5.15.y<br /> sd-fuse]
 +
|}
 +
=====USB flashing=====
 +
======Linux======
 +
To flash U-Boot and kernel using the "upgrade_tool" tool, please use the following command:
 +
<syntaxhighlight lang="bash">
 +
sudo upgrade_tool ul MiniLoaderAll.bin
 +
sudo upgrade_tool di -p parameter.txt
 +
sudo upgrade_tool di uboot uboot.img
 +
sudo upgrade_tool di trust trust.img
 +
sudo upgrade_tool di resource resource.img
 +
sudo upgrade_tool di kernel kernel.img
 +
sudo upgrade_tool RD
 +
</syntaxhighlight>
 +
Note: "upgrade_tool" is a command-line tool provided by Rockchip for Linux operating systems (Linux_Upgrade_Tool).
 +
===Building AOSP from source===
 +
====Compile Android10====
 +
=====Download Android10 Source Code=====
 
There are two ways to download the source code:
 
There are two ways to download the source code:
 
* '''repo archive file on netdisk'''
 
* '''repo archive file on netdisk'''
 
Netdisk URL: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} Click here]<br />
 
Netdisk URL: [http://download.friendlyelec.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} Click here]<br />
File location on netdisk:rk3399-android-10.git-YYYYMMDD.tar.xz (YYYYMMDD means the date of packaging)<br />
+
File location on netdisk:"07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz" (YYYYMMDD means the date of packaging)<br />
 
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
 
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
tar xf /path/to/netdisk/sources/rk3399-android-10.git-YYYYMMDD.tar.xz
+
tar xf "/path/to/netdisk/07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz"
 
cd rk3399-android-10
 
cd rk3399-android-10
 
./sync.sh
 
./sync.sh
Line 17: Line 412:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Note: If the following error "error: unknown option `recurse-submodules'" appears, please upgrade git to v2.0.0 or above.
 
Note: If the following error "error: unknown option `recurse-submodules'" appears, please upgrade git to v2.0.0 or above.
====Generate Image File====
+
=====Generate Image File=====
 
You can compile an Android source code and generate an image file (non-root user is recommended):
 
You can compile an Android source code and generate an image file (non-root user is recommended):
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 30: Line 425:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Make OTA Packages====
+
=====Make OTA Packages=====
 
If you need the support of A/B (Seamless) System Updates, you need to do the following:<br />
 
If you need the support of A/B (Seamless) System Updates, you need to do the following:<br />
 
a) Build your own update server for http download of update files;<br />
 
a) Build your own update server for http download of update files;<br />
Line 48: Line 443:
 
<br />
 
<br />
  
====Update System with New Image====
+
=====Update System with New Image=====
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 10's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 10's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
Line 55: Line 450:
 
When flashing Android 10, EFlasher requires v1.3 or above. When flashing with Type-C, please use the tool AndroidTool v2.71 or Linux_Upgrade_Tool v1.49 provided by Rockchip.
 
When flashing Android 10, EFlasher requires v1.3 or above. When flashing with Type-C, please use the tool AndroidTool v2.71 or Linux_Upgrade_Tool v1.49 provided by Rockchip.
  
===Compile Android8.1 Source Code===
+
====Compile Android8.1====
====Download Android8.1 Source Code====
+
=====Download Android8.1 Source Code=====
 
There are two ways to download the source code:  
 
There are two ways to download the source code:  
 
* '''repo archive file on netdisk'''
 
* '''repo archive file on netdisk'''
Line 73: Line 468:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Generate Image File====
+
=====Generate Image File=====
 
You can compile an Android source code and generate an image file:
 
You can compile an Android source code and generate an image file:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 80: Line 475:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Update System with New Image====
+
=====Update System with New Image=====
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 8.1's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 8.1's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
Line 87: Line 482:
 
Here is an alternative guide to update OS: [https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 
Here is an alternative guide to update OS: [https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
  
===Compile Android7 Source Code===
+
====Compile Android7====
====Download Android7 Source Code====
+
=====Download Android7 Source Code=====
 
There are two ways to download the source code:  
 
There are two ways to download the source code:  
 
* '''repo archive file on netdisk'''
 
* '''repo archive file on netdisk'''
Line 105: Line 500:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Generate Image File====
+
=====Generate Image File=====
 
You can compile an Android7 source code and generate an image file:
 
You can compile an Android7 source code and generate an image file:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 112: Line 507:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
====Update System with New Image====
+
=====Update System with New Image=====
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android7's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android7's source code directory. You can follow the steps below to update the OS in {{{1}}}:<br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
 
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted; <br />
Line 118: Line 513:
 
3) Insert this SD card to {{{1}}} and reflash Android<br />
 
3) Insert this SD card to {{{1}}} and reflash Android<br />
 
Here is an alternative guide to update OS: [https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 
Here is an alternative guide to update OS: [https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 
===Compile FriendlyCore/FriendlyDesktop/Lubuntu/EFlasher Kernel Source Code===
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
 
cd kernel-rockchip
 
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images
 
</syntaxhighlight>
 
 
After compilation is done a kernel.img and a resource.img will be generated. You can simply copy them to replace the existing files in your eflasher SD card. We assume your SD card's FRIENDLYARM partition is mounted at the FRIENDLYARM directory and you can run the following commands to update system:
 
<syntaxhighlight lang="bash">
 
# for Lubuntu
 
cp kernel.img resource.img /media/FRIENDLYARM/lubuntu/
 
 
# for FriendlyCore
 
cp kernel.img resource.img /media/FRIENDLYARM/friendlycore-arm64/
 
 
# for FriendlyDesktop
 
cp kernel.img resource.img /media/FRIENDLYARM/friendlydesktop-arm64/
 
</syntaxhighlight>
 
Or you can use a USB Type-C cable and the Linux_Upgrade_Tool utility to update system.
 
 
===Compile  U-boot v2014.10 for FriendlyCore/FriendlyDesktop/Lubuntu/EFlasher===
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi4-v2014.10_oreo
 
cd uboot-rockchip
 
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
 
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
 
make CROSS_COMPILE=aarch64-linux-
 
</syntaxhighlight>
 
 
After compilation is done a uboot.img, a trust.img and a rk3399_loader_v1.22.119.bin will be generated. You need to rename the rk3399_loader_v1.22.119.bin to "MiniLoaderAll.bin" and copy it to replace the existing file in your eflasher SD card. We assume your SD card's FRIENDLYARM partition is mounted at the FRIENDLYARM directory. You can run the following commands to update system:
 
<syntaxhighlight lang="bash">
 
# for Lubuntu
 
cp uboot.img trust.img /media/FRIENDLYARM/lubuntu
 
cp rk3399_loader_v1.22.119.bin /media/FRIENDLYARM/lubuntu/MiniLoaderAll.bin
 
 
# for FriendlyCore
 
cp uboot.img trust.img /media/FRIENDLYARM/friendlycore-arm64
 
cp rk3399_loader_v1.22.119.bin /media/FRIENDLYARM/friendlycore-arm64/MiniLoaderAll.bin
 
 
# for FriendlyDesktop
 
cp uboot.img trust.img /media/FRIENDLYARM/friendlydesktop-arm64
 
cp rk3399_loader_v1.22.119.bin /media/FRIENDLYARM/friendlydesktop-arm64/MiniLoaderAll.bin
 
</syntaxhighlight>
 
Or you can use a USB Type-C cable and the Linux_Upgrade_Tool utility to update system.
 
 
===Compile U-boot v2017.09 for FriendlyCore-focal===
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/rkbin -b friendlyelec
 
git clone https://github.com/friendlyarm/uboot-rockchip -b nanopi4-v2017.09
 
cd uboot-rockchip/
 
./make.sh nanopi4
 
</syntaxhighlight>
 
3 files will be generated after compilation: uboot.img, trust.img and rk3399_loader_v1.24.126.bin, rk3399_loader_v1.24.126.bin needs to be renamed to MiniLoaderAll.bin, then copy it to the SD card of the eflasher system and replace the old file . <br />
 
 
===Make Bootable SD Card for Mass Production===
 
If you need to make a bootable SD card for mass production you can refer to this github link:[https://github.com/friendlyarm/sd-fuse_rk3399 sd-fuse_rk3399]<br />
 

Revision as of 07:09, 10 April 2023

1 Build u-boot and kernel

1.1 Kernel and u-boot versions

Operating System Kernel Version U-boot version Cross-compiler Partition type Packaging Tool Kernel branch Kernel configuration U-boot branch U-boot configuration
lubuntu linux v4.4.y u-boot v2014.10 6.4-aarch64
MBR sd-fuse nanopi4-linux-v4.4.y nanopi4_linux_defconfig nanopi4-v2014.10_oreo rk3399_defconfig
friendlycore-arm64
friendlydesktop-arm64
eflasher
buildroot linux v4.19.y u-boot
v2017.09
11.3-aarch64 GPT sd-fuse nanopi4-v4.19.y nanopi4_linux_defconfig nanopi4-v2017.09 rk3399_defconfig
debian-buster-desktop-arm64
debian-bullseye-core-arm64
debian-bullseye-desktop-arm64
debian-bullseye-minimal-arm64
friendlycore-focal-arm64
friendlycore-lite-focal-kernel4-arm64
friendlywrt21-kernel4 nanopi4_linux_defconfig
friendlywrt.config
friendlycore-lite-focal-kernel5-arm64 linux v5.15.y u-boot
v2017.09
11.3-aarch64 GPT
sd-fuse
nanopi-r2-v5.15.y nanopi4_linux_defconfig
nanopi4-v2017.09
rk3399_defconfig
friendlywrt21 nanopi4_linux_defconfig
friendlywrt.config
friendlywrt21-docker
friendlywrt22
friendlywrt22-docker

1.2 Build kernel linux-v4.4.y

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
cd kernel-rockchip
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
touch .scmversion
# Load configuration
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
# Optionally, if you want to change the default kernel config
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig  
# Start building kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
# Start building kernel modules
mkdir -p out-modules
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)

After the compilation, the following files will be generated:

kernel.img resource.img The kernel modules are located in the out-modules directory

Run your build:
Please refre to #Running the build

1.3 Build u-boot v2014.10

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2014.10_oreo
cd uboot-rockchip
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
make CROSS_COMPILE=aarch64-linux-

After the compilation, the following files will be generated:

uboot.img trust.img rk3399_loader_v1.22.119.bin (aka MiniLoaderAll.bin)

Installing the u-boot:
Please refre to #Running the build

1.4 Build kernel linux-v4.19.y

This section applies to the following operating systems:

debian-buster-desktop-arm64 debian-bullseye-core-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64
friendlycore-focal-arm64 friendlycore-lite-focal-kernel4-arm64 friendlywrt21-kernel4 buildroot

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-v4.19.y kernel-rockchip
cd kernel-rockchip
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
touch .scmversion
# Configuring the Kernel
# Load default configuration
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
# Optionally, load configuration for FriendlyWrt
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig friendlywrt.config
# Launching menuconfig
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig
# Start building kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
# Start building kernel modules
mkdir -p out-modules
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)

After the compilation, the following files will be generated:

kernel.img resource.img The kernel modules are located in the out-modules directory

Run your build:
Please refre to #Running the build

1.5 Build kernel linux-v5.15.y

This section applies to the following operating systems:

friendlywrt21 friendlywrt21-docker friendlywrt22 friendlywrt22-docker friendlycore-lite-focal-kernel5-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi-r2-v5.15.y kernel-rockchip
cd kernel-rockchip
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
touch .scmversion
# Configuring the Kernel
# Load default configuration
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig
# Optionally, load configuration for FriendlyWrt
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_linux_defconfig friendlywrt.config
# Optionally, if you want to change the default kernel config
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig
# Start building kernel
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j$(nproc)
# Start building kernel modules
mkdir -p out-modules && rm -rf out-modules/*
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules_install
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
[ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER}
(cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)

Pack the kernel.img and resource.img:

wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/mkkrnlimg && chmod 755 mkkrnlimg
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/tools/resource_tool && chmod 755 resource_tool
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo.bmp
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-5.15.y/prebuilt/boot/logo_kernel.bmp
./mkkrnlimg arch/arm64/boot/Image kernel.img
mkdir kernel-dtbs
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev09.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev0a.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4se.dtb kernel-dtbs/rk3399-nanopi4-rev0b.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb kernel-dtbs/rk3399-nanopi4-rev00.dtb
./resource_tool --dtbname kernel-dtbs/*.dtb logo.bmp logo_kernel.bmp

After the compilation, the following files will be generated:

kernel.img resource.img The kernel modules are located in the out-modules directory

Run your build:
Please refre to #Running the build

1.6 Build u-boot v2017.09

This section applies to the following operating systems:

debian-buster-desktop-arm64 debian-bullseye-core-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64
friendlycore-focal-arm64 friendlycore-lite-focal-kernel4-arm64 friendlywrt21-kernel4 buildroot

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b friendlyelec
git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2017.09
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
cd uboot-rockchip/
./make.sh nanopi4

After the compilation, the following files will be generated:

uboot.img trust.img rk3399_loader_v1.24.126.bin (aka MiniLoaderAll.bin)

Installing the u-boot:
Please refre to #Running the build

1.7 Running the build

1.7.1 Install to target board
1.7.1.1 MBR partition

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

The MBR partitioning is only used by the Linux v4.4 kernel. You can check the partition layout by clicking on this link: partmap. To write an image file, you can use the dd command. For example, in the parameter.template file, "0x00014000@0x00014000(kernel)" specifies that the kernel partition starts at 0x00014000, which is equivalent to 81920 in decimal. Therefore, the dd command should be as follows:

dd if=kernel.img of=/dev/mmcblk0 seek=81920
1.7.1.2 GPT partition

This section applies to the following operating systems:

debian-buster-desktop-arm64 debian-bullseye-core-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64
friendlycore-focal-arm64 friendlycore-lite-focal-kernel4-arm64 friendlywrt21-kernel4 buildroot
friendlywrt21 friendlywrt21-docker friendlywrt22 friendlywrt22-docker

Systems using the Linux v4.19 and Linux v5.15 kernels use GPT partitioning by default. You can use the dd command to write the image file to the partition. The device nodes for SD card and eMMC are shown below:

  • The SD/TF Card device node: /dev/mmcblk0
  • The eMMC device node: /dev/mmcblk2


Use the 'parted' command to view the partition layout:

parted /dev/mmcblk2 print

Sample outputs:

Model: MMC BJTD4R (sd/mmc)
Disk /dev/mmcblk2: 31.3GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
 
Number  Start   End     Size    File system  Name      Flags
 1      8389kB  12.6MB  4194kB               uboot
 2      12.6MB  16.8MB  4194kB               trust
 3      16.8MB  21.0MB  4194kB               misc
 4      21.0MB  25.2MB  4194kB               dtbo
 5      25.2MB  41.9MB  16.8MB               resource
 6      41.9MB  83.9MB  41.9MB               kernel
 7      83.9MB  134MB   50.3MB               boot
 8      134MB   2500MB  2366MB  ext4         rootfs
 9      2500MB  31.3GB  28.8GB  ext4         userdata

as shown above, the resource partition is located at 5 and the kernel partition is located at 6. Use the dd command to write the resource.img and kernel.img files to these partitions, the commands are as follows:

dd if=resource.img of=/dev/mmcblk2p5 bs=1M
dd if=kernel.img of=/dev/mmcblk2p6 bs=1M

If you want to update u-boot:

dd if=boot.img of=/dev/mmcblk2p1 bs=1M

To update new driver modules, copy the newly compiled driver modules to the appropriate directory under /lib/modules.

1.7.2 Packaging and creating an SD image

To create a new OS image file, you need to use the "sd-fuse" packaging tool.

"sd-fuse" is a collection of scripts that can be used to create bootable SD card images for FriendlyElec boards. Its main features include:

  • Creation of root filesystem images from a directory
  • Building of bootable SD card images
  • Simple compilation of kernel, U-Boot, and third-party drivers

Please click on the following link to find out more:

Kernel version Packaging Tool
linux v4.4.y sd-fuse
linux v4.19.y
sd-fuse
linux v5.15.y
sd-fuse
1.7.3 USB flashing
1.7.3.1 Linux

To flash U-Boot and kernel using the "upgrade_tool" tool, please use the following command:

sudo upgrade_tool ul MiniLoaderAll.bin
sudo upgrade_tool di -p parameter.txt
sudo upgrade_tool di uboot uboot.img
sudo upgrade_tool di trust trust.img
sudo upgrade_tool di resource resource.img
sudo upgrade_tool di kernel kernel.img
sudo upgrade_tool RD

Note: "upgrade_tool" is a command-line tool provided by Rockchip for Linux operating systems (Linux_Upgrade_Tool).

2 Building AOSP from source

2.1 Compile Android10

2.1.1 Download Android10 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:"07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz" (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xf "/path/to/netdisk/07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz"
cd rk3399-android-10
./sync.sh
  • git clone from gitlab

{{{1}}} source code is maintained in gitlab, You can download it by running the following command:

git clone --recursive https://gitlab.com/friendlyelec/rk3399-android-10.git -b main

Note: If the following error "error: unknown option `recurse-submodules'" appears, please upgrade git to v2.0.0 or above.

2.1.2 Generate Image File

You can compile an Android source code and generate an image file (non-root user is recommended):

cd rk3399-android-10
./build-nanopc-t4.sh -F -M

If you need to include google apps, you need to set an environment variable and then compile, as shown below:

cd rk3399-android-10
export INSTALL_GAPPS_FOR_TESTING=yes
./build-nanopc-t4.sh -F -M
2.1.3 Make OTA Packages

If you need the support of A/B (Seamless) System Updates, you need to do the following:
a) Build your own update server for http download of update files;
b) Customize the Updater application, the code is located in packages/apps/Updater, let it connect and download file from your server;
c) Use the quick compilation script parameter -O or --ota to compile OTA Packages, as shown below:

cd rk3399-android-10
./build-nanopc-t4.sh -F -O -M

After the compilation is successfully completed, the OTA update related packages are located in the directory: rockdev/otapackage/ ,Please do not delete this directory.
After you have made some changes, compiling again with the parameter -O will generate ota-update-XXXXXXXX.zip, which is an incremental update package.
OTA Packages decides whether to generate incremental update package according to BUILD_NUMBER, for details, please refer to build-nanopc-t4.sh.
To disable the A/B feature, you can refer to the following to modify device/rockchip/rk3399/nanopc-t4/BoardConfig.mk, and then recompile uboot and android:

BOARD_USES_AB_IMAGE := false


2.1.4 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 10's source code directory. You can follow the steps below to update the OS in {{{1}}}:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android10 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to {{{1}}} and reflash Android
When flashing Android 10, EFlasher requires v1.3 or above. When flashing with Type-C, please use the tool AndroidTool v2.71 or Linux_Upgrade_Tool v1.49 provided by Rockchip.

2.2 Compile Android8.1

2.2.1 Download Android8.1 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-8.1.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xvzf /path/to/netdisk/sources/rk3399-android-8.1.git-YYYYMMDD.tgz
cd rk3399-android-8.1
./sync.sh
  • git clone from gitlab

{{{1}}} source code is maintained in gitlab, You can download it by running the following command:

git clone https://gitlab.com/friendlyelec/rk3399-android-8.1 --depth 1 -b master
2.2.2 Generate Image File

You can compile an Android source code and generate an image file:

cd rk3399-android-8.1
./build-nanopc-t4.sh -F -M
2.2.3 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 8.1's source code directory. You can follow the steps below to update the OS in {{{1}}}:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to {{{1}}} and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399

2.3 Compile Android7

2.3.1 Download Android7 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-7.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xvzf /path/to/netdisk/sources/rk3399-android-7.git-YYYYMMDD.tgz
cd rk3399-nougat
./sync.sh
  • git clone from gitlab

{{{1}}} source code is maintained in gitlab, You can download it by running the following command:

git clone https://gitlab.com/friendlyelec/rk3399-nougat --depth 1 -b nanopc-t4-nougat
2.3.2 Generate Image File

You can compile an Android7 source code and generate an image file:

cd rk3399-nougat
./build-nanopc-t4.sh -F -M
2.3.3 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android7's source code directory. You can follow the steps below to update the OS in {{{1}}}:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to {{{1}}} and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399