Manual Version
Disclaimer
While every effort has been made to ensure accuracy in this document, errors or omissions may still exist. Users should carefully assess its applicability; we reserve the right to make revisions at any time and do not guarantee the validity of content from previous versions. For the latest product information, please regularly visit the official website of LCSC Dev Boards for updated materials. The copyright and final interpretation of this document belong to Shenzhen JLC Technology Group Co.,Ltd. Please take note of this disclaimer and assess the risks independently when making decisions. We are not responsible for any issues arising from the use of this document. Thank you for your understanding and support.
Introduction
Here, we will introduce the Android system SDK and compilation method for the Taishan-RK3566 development board. Once you are familiar with the SDK package and the compilation process, you will be able to perform secondary development and create a customized image that is exclusively yours.
WARNING
📌 If you are a beginner, we highly recommend following the tutorial from the training camp for more detailed instructions:
Preparation
Computer Requirements: Compiling the Android system requires a high-performance computer, especially with regard to memory. If your memory is too small, you won't be able to compile at all. Below are the specifications of my computer. It is recommended that your system has better specs than mine. If your CPU is not as powerful, make sure your memory is larger. CPU will affect the compilation speed, and insufficient memory will result in errors.
Virtual Machine Configuration:
Ubuntu Version Information:NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
2
3
4
5
6
7
8
9
10
11
12
Download SDK
The development board materials are provided through a cloud drive, and the SDK directory is as follows for you to download:
Download
📌 Download Center (Click to Jump)
📌 In Download Center
->Baidu Netdisk Resource Content
->Chapter 05.System SDK
->tspi_android_sdk_xxxxxxxx.tar.gz
- The xxxxxxxx in the directory represents the date.
- The SDK in the directory will be updated periodically, so the version you download will always be the latest.
- The Android system is quite large, so the provided SDK may contain bugs. If you find any, please contact us in a timely manner.
Upload the tspi_android_sdk_xxxxxxxx.tar.gz file to the Ubuntu virtual machine. You can choose the directory path freely, but it must not contain Chinese characters, and there must be at least 250GB of free space. After compilation, the SDK will be approximately 160GB in size.
Extract SDK
Run the following extraction command in the directory where the tspi_android_sdk_20230909.tar.gz file is located:
tar -zxvf tspi_android_sdk_20230909.tar.gz
Command Explanation:
tar: extraction command.
-z: use gzip compression algorithm to extract or compress.
-x: extract files.
-v: show detailed operation information, i.e., display the file list during extraction.
-f: specify the file to operate on.
tspi_android_sdk_20230909.tar.gz: the file to be extracted.
2
3
4
5
6
7
8
9
After extraction, you will get tspi_android_sdk_20230909:
root@lckfb:/home/lckfb_tspi/android11/Release# ls
tspi_android_sdk_20230909 tspi_android_sdk_20230909.tar.gz
2
Enter the just-extracted tspi_android_sdk_20230909 directory:
root@lckfb:/home/lckfb_tspi/android11/Release# cd tspi_android_sdk_20230909
View the contents of the SDK directory as follows:
Android.bp
: Blueprint build file for Android development, used to define and configure modules.art
: Contains code related to the Android Runtime (ART).bionic
: Contains implementations of C libraries for Android systems.bootable
: Contains boot-related code such as bootloader and boot images.bootstrap.bash
: Script for starting the Android development environment.build
: Contains code and scripts related to the build system.build.sh
: Script for building the Android system.compatibility
: Contains code related to Android Compatibility Test Suite (CTS).cts
: Code and configuration for Android Compatibility Test Suite (CTS).development
: Contains development tools and libraries like SDK Manager and emulator.device
: Contains manufacturer or platform-specific code and configuration files.external
: Contains third-party libraries and tools from external sources.frameworks
: Contains code for the Android system framework.hardware
: Contains hardware-related code such as drivers and Hardware Abstraction Layer (HAL).javaenv.sh
: Script to set up the Java runtime environment.kernel
: Contains Linux kernel code used by the Android system.libcore
: Contains implementations of Java core libraries.libnativehelper
: Contains libraries for implementing interaction between native code and Java code.makefile
: Makefile used for building the Android system.mkcombinedroot
: Script for creating a combined root filesystem.mkimage_ab.sh
: Script for creating Android system boot images.mkimage.sh
: Script for creating RK3566 upgrade images.out
: Directory for output files generated during the build process.packages
: Contains code for pre-installed applications and services.pdk
: Contains files related to the Android Platform Development Kit (PDK).platform_testing
: Contains test code running on the device.prebuilts
: Contains precompiled third-party tools and libraries.rkbin
: Contains the binary files required for RK3566 system development.RKDocs
: Contains documentation for RK3566 hardware development.rkst
: Contains files related to RK development toolchain.sdk
: Contains files for the Android Software Development Kit (SDK).system
: Contains core functionality and services of the Android system.test
: Contains various test code and testing frameworks.tools
: Contains various utilities for Android development.toolchain
: Contains files related to the cross-compilation toolchain.u-boot
: Contains U-Boot bootloader code and configuration files.vendor
: Contains manufacturer-specific code and configuration files.rockdev
: Stores compiled output firmware.
Among these directories, we often modify the u-boot, kernel, vendor, system, device, frameworks, and packages directories.
Compilation Environment Setup
Here, we demonstrate how to compile directly on Ubuntu 18.04. Since your compilation environments may vary, unexpected errors might occur. If your environment cannot compile successfully, you can use a Docker environment for compilation. For reference, check the [Docker] compilation environment setup. If you're using Docker, you can skip this chapter and compile the SDK yourself. To compile the Android SDK, the following libraries need to be installed:
apt-get update && apt-get install -y git python make openjdk-8-jdk git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libgl1-mesa-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libxml2-utils xsltproc unzip python bc imagemagick ccache schedtool libssl-dev libncursesw5-dbg libncursesw5-dev libncurses5 libncursesw5 libncursesada5-dev libncurses5-dbg libncurses5-dev libncursesada-doc libncursesada5 libncurses-dev libncurses-gst libncurses5-dev clang
Note: The command above should not have line breaks. If manually adding line breaks, make sure to use the continuation symbol
Explanation of commands:
apt-get update # Update the package list for upgrades and new package installations
apt-get install git # :Install git
apt-get install python # Install python
apt-get install make # Install make
apt-get install -y openjdk-8-jdk # Install the Java Development Kit
apt-get install -y git-core # Install the core git library
apt-get install -y gnupg # Install GNU Privacy Guard (GPG)
apt-get install -y flex # Install flex (a lexical analyzer generator)
apt-get install -y bison # Install bison (a parser generator)
apt-get install -y gperf # Install gperf (a hash function generator)
apt-get install -y build-essential # Install essential compilation tools
apt-get install -y zip # Install zip
apt-get install -y curl # Install the curl network transfer tool
apt-get install -y zlib1g-dev # Install the zlib development library
apt-get install -y libgl1-mesa-dev # Install OpenGL library development files
apt-get install -y gcc-multilib # Install GCC multi-library support
apt-get install -y g++-multilib # Install G++ multi-library support
apt-get install -y libc6-dev-i386 # Install libc6 development files
apt-get install -y lib32ncurses5-dev # Install ncurses development libraries
apt-get install -y x11proto-core-dev # Install the X11 protocol core development libraries
apt-get install -y libx11-dev # Install libx11 development libraries
apt-get install -y lib32z-dev # Install 32-bit zlib development libraries
apt-get install -y libxml2-utils # Install the libxml2 utilities
apt-get install -y xsltproc # Install the XSLT processor
apt-get install -y unzip # Install unzip
apt-get install -y python # Reinstall python
apt-get install -y bc # Install bc (a calculator)
apt-get install -y imagemagick # Install ImageMagick
apt-get install -y ccache # Install ccache (a compiler cache)
apt-get install -y schedtool # Install the schedtool utility
apt-get install -y libssl-dev # Install SSL development libraries
apt-get install -y libncurses* # Install ncurses development libraries
apt-get install -y clang # Install the Clang compiler
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Run the above commands as shown below:
SDK Compilation
Full Compilation
Run the compilation command in the SDK directory:
root@lckfb:/home/lckfb_tspi/android11/Release/tspi_android_sdk_20230909# cd u-boot && ./make.sh rk3566 && cd ../kernel && make clean && make distclean && make ARCH=arm64 tspi_defconfig rk356x_evb.config android-11.config && make ARCH=arm64 tspi-rk3566-user-v10.img -j16 && cd .. && source build/envsetup.sh && lunch rk3566_tspi-userdebug && make installclean -j16 && make -j16 && ./mkimage.sh
Command Explanation:
cd
u-boot
- Enter the
u-boot
directory, which contains the U-Boot bootloader source code and build scripts.
- Enter the
./make.sh
rk3566
- Execute the
make.sh
script with therk3566
parameter to compile and build the U-Boot bootloader for the RK3566 platform.
- Execute the
cd ../kernel
- Return to the parent directory and enter the
kernel
directory, which contains the Linux kernel source code and build scripts.
- Return to the parent directory and enter the
make clean && make distclean
- Use
make clean
to remove previous build results. - Use
make distclean
to further clean up previous configurations and generated files.
- Use
make ARCH=arm64 tspi_defconfig rk356x_evb.config android-11.config
- Use
make
with theARCH=arm64
parameter to compile the kernel. - The command uses
tspi_defconfig
as the base configuration - Add
rk356x_evb.config
andandroid-11.config
as additional configuration options.
- Use
make ARCH=arm64 tspi-rk3566-user-v10.img -j16
- Use
make
with theARCH=arm64
parameter to compile the kernel. - The
tspi-rk3566-user-v10.img
configuration is selected for the build. - The
-j16
flag indicates that 16 threads will be used for parallel compilation.
- Use
cd ..
- Return to the parent directory, which is the root of the SDK.
source build/envsetup.sh
- Run the
envsetup.sh
script to set up the build environment variables and functions.
- Run the
lunch rk3566_tspi-userdebug
- Use the
lunch
command to set the build target tork3566_tspi-userdebug
, selecting the configuration for the RK3566 platform with the Taishan development board.
- Use the
make installclean -j16
- Use the
make
command to clean up previous build results. - The
-j16
flag indicates 16 threads for parallel operations.
- Use the
make -j16
- Use the
make
command to compile the project. - The
-j16
flag indicates 16 threads for parallel compilation.
- Use the
./mkimage.sh
- Run the
mkimage.sh
script to generate the upgrade image.
- Run the
If your environment is set up correctly, the compilation should succeed, and the image will be packaged and generated. The compilation process can be quite lengthy, especially for the first time. Subsequent compilations will be faster depending on your computer's specifications. In my case, the compilation took over four hours. If you encounter errors during the build process, review the logs carefully to resolve them. Most errors are due to environment dependencies. If you receive memory-related warnings, try reducing the number of compilation threads, for example, using -j8.
Compilation Success: The image files will be generated in the rockdev/Image-rk3566_tspi directory. Let's go ahead and check the generated images.
root@lckfb:/home/lckfb_tspi/android11/Release/tspi_android_sdk_20230909/rockdev/Image-rk3566_tspi# ls
baseparameter.img boot.img dtbo.img misc.img pcba_small_misc.img recovery.img super.img vbmeta.img
boot-debug.img config.cfg MiniLoaderAll.bin parameter.txt pcba_whole_misc.img resource.img uboot.img
2
3
Image Descriptions:
baseparameter.img
: Stores display configuration information for the Rockchip platform, such as resolution and display effect adjustments. It ensures the display effect is consistent across reboots. This must be flashed to the baseparameter partition.boot-debug.img
: Compared toboot.img
, this image allows users to flash it for root access operations.boot.img
:: The Android boot image, which includes the ramdisk root file system, kernel image (Image), kernel device tree binary (DTB), and resource image (resource.img). This needs to be flashed to the boot partition of the development board.config.cfg
: Configuration file for Rockchip's downloader tool.dtbo.img
: Used for compatibility across multiple products, supporting the Device Tree Overlays (DTO) feature for Android 10.0 and above. This should be flashed to the dtbo partition.MiniLoaderAll.bin
:: A loader code that runs before U-Boot on the RK3566 platform (earlier than U-Boot in the bootloader process). It consists of two parts: TPL (for DDR initialization, running in SRAM) and SPL (running in DDR, responsible for loading and booting uboot.img).misc.img
:Contains Android Bootloader Control Block (BCB) information and A/B system data. It needs to be flashed to the misc partition. This partition is crucial as it contains the BCB (which controls the system boot process and interaction mechanisms between Android, the bootloader, and recovery) and A/B system data. It also includes recovery-wipe flags for entering recovery mode, often used for PCBA testing.pcba_small_misc.img
: Contains PCBA boot flags. Flashing this will enter a simplified PCBA mode, rarely used.pcba_whole_misc.img
: Contains PCBA boot flags. Flashing this will enter the full PCBA mode, rarely used.parameter.txt
:: A text file that records the partition table information for the RK3566 platform, including partition names, start addresses, and end addresses. This file is not flashed to Flash storage (like eMMC or NAND) but is used to define partitions during the flashing process.recovery.img
:A combined image containing recovery-ramdisk, kernel image (Image), DTB, DTBO, and resource image (resource.img). It is used to enter recovery mode for device repair, upgrades, and updates. It must be flashed to the recovery partition.resource.img
:A resource image defined by Rockchip, containing the logo and DTB. It is not flashed separately but is bundled within the boot.img and recovery.img.super.img
:A super image, composed of several other images including odm.img, product.img, system.img, system_ext.img, and vendor.img. It must be flashed to the super partition of the development board.uboot.img
:A combined image containing the trust image (ARM Trusted Firmware + OP-TEE OS), U-Boot image, and U-Boot DTB. These are packaged together during U-Boot compilation into a single uboot.img. It should be flashed to the U-Boot partition of the development board.vbmeta.img
:Contains AVB (Android Verified Boot) verification information used for AVB checks. AVB is a firmware verification process designed by Google.
Download the Image
When we perform a full compilation, we execute the following command, which generates the split upgrade image (.img):
./mkimage.sh
Note: If you have previously compiled the kernel separately, you need to execute the command below to regenerate some boot.img images, otherwise, you may encounter startup issues.
make ARCH=arm64 tspi_defconfig rk356x_evb.config android-11.config && make ARCH=arm64 tspi-rk3566-user-v10.img -j16
We can view all the generated images in the SDK/rockdev/Image-rk3566_tspi# directory:
SDK/rockdev/Image-rk3566_tspi# ls
baseparameter.img boot.img dtbo.img misc.img pcba_small_misc.img recovery.img super.img vbmeta.img
boot-debug.img config.cfg MiniLoaderAll.bin parameter.txt pcba_whole_misc.img resource.img uboot.img
2
3
Download Configuration File:
File Download
📌 Download Center (Click to Redirect)
📌 In Download Center
->Baidu Netdisk Resource Content
-> Chapter 06. System Images
->[Image] Android
->Android_All_Config.cfg
。
Open the Rockchip development tool and import the configuration file downloaded above:
Configuration file successfully imported:
After successful import, the download options, addresses, and names should be correct. However, the paths are from the author's computer, so you need to change the paths to your own SDK/rockdev/Image-rk3566_tspi#xxx.img paths. After entering Loader on the LCSC Taishan-RK3566-Linux Dev Board, click to execute, and the image can be burned. If you only want to update a single image, you can choose to check the corresponding option.Pack and Generate update.img Firmware
The following command will combine all the images into a single update.img image. The method provided in Chapter 06. System Images uses this method to generate the image:
./build.sh -u
After running the command, the image will be output to the following directory:
SDK/rockdev/Image-rk3566_tspi# ls
baseparameter.img boot.img dtbo.img misc.img pcba_small_misc.img recovery.img super.img update.img #here
boot-debug.img config.cfg MiniLoaderAll.bin parameter.txt pcba_whole_misc.img resource.img uboot.img vbmeta.img
2
3
4
5
An additional update.img image will appear in the SDK/rockdev/Image-rk3566_tspi# directory.
You can directly upgrade this image through the second row of the upgrade firmware in the download tool.
Single Compilation of u-boot
cd u-boot && ./make.sh rk3566
Single Compilation of Kernel
make ARCH=arm64 BOOT_IMG=../rockdev/Image-rk3566_tspi/boot.img tspi-rk3566-user-v10.img -j32
After the compilation is complete, boot.img will be generated in the kernel directory. You can burn boot.img separately to apply kernel modifications.
Update boot.img Separately
To perform this operation, you need to have previously upgraded the firmware successfully and be able to enter Loader mode (note that it is not maskrom mode). This method is mainly used to quickly apply kernel changes. Download the configuration file here, and right-click to import it into the Rockchip development tool.
After importing successfully, you can see that only Boot is checked, so only the boot image will be burned.
The path to the Boot image is from the author's computer, so you need to change it to your own SDK/kernel/boot.img path, not the boot.img in SDK/rockdev/Image-rk3566_tspi.
Next, enter upgrade mode on LCSC Taishan-RK3566-Linux Dev Board and click execute to update boot.img separately. Since only the boot.img image is updated, the upgrade speed will be very fast, and it will be done in a few seconds. The same principle applies when updating other images.
Single Compilation of Android
If you open a new terminal window, you need to first configure the environment. Run this command once, and it will remain active as long as you don't close the window:
source build/envsetup.sh && lunch rk3566_tspi-userdebug
Note: Do not run make clean unless absolutely necessary, because it will significantly increase compilation time. If you find that the changes haven't taken effect, usually running installclean followed by a recompile will resolve the issue:
make installclean -j16 && make -j16
Sometimes, to improve efficiency, we opt to compile individual modules in Android, and then use adb or other methods to push them directly to the device for debugging:
mm # Compile the module in the current directory (the directory must contain an Android.mk file)
mmm # Compile a module in a specified path (the specified path must contain an Android.mk file)
2