Ubuntu System Compilation

Hardware Configuration

Recommended hardware configuration for compiling Ubuntu development environment:

  • 64-bit CPU

  • Ubuntu 20.04, do not use Windows Subsystem (WSL)

  • 16GB of RAM

  • 250GB free space for compiling

  • Normal user to compile, do not use root user to compile

Software Configuration

Installation packages

sudo apt update
sudo apt-get install git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler libncurses-dev

sudo pip install python-pip pyelftools

Installation configuration git

sudo apt install git-all

Configure account name and email

git config --global user.email "your_name@xxx.com"
git config --global user.name "your_name"

Get SDK

Email support@neardi.com for development materials

After downloading, check the MD5 code and Neardi-3588-SDK-Linux-${Version}.tar.gz.md5sum for consistency before unzipping:

$ md5sum Neardi-3588-SDK-Linux-${Version}.tar.gz
******************************** Neardi-3588-SDK-Linux-${Version}.tar.gz

Unzip:

tar zxvf Neardi-3588-SDK-Linux-${Version}.tar.gz

Extract:

cd Neardi-3588-SDK-Linux-${Version}
git reset --hard

Compile SDK

Select Configuration

boardConfig explain
BoardConfig-rk3588-neardi-linux-lpm3588-f1.mk ETHx6 + HDMI1 + HDMI2 + DP + HDMIIN
./build.sh lunch BoardConfig-rk3588-neardi-linux-lpm3588-f1.mk

Fully Automatic Compilation

For the first compilation of the SDK, it is imperative to compile everything once, otherwise packaging will fail.

Fully automatic compilation will execute all compilations, generating u-boot, kernel, and buildroot.

./build.sh

Compile Ubuntu

20.04 system (main maintenance)

./build.sh focal

22.04 system(Not maintained yet)

./build.sh jammy

Packaging Firmware

RK firmware is packaged in a proprietary format by Rockchip, and can be flashed onto eMMC or SD card using tools provided by Rockchip (Note: Unless specified otherwise, the firmware mentioned on the WIKI by default refers to RK firmware).

# Package RK firmware
./build.sh updateimg

The complete firmware will be saved to  rockdev/update.img

Partial Compilation

  • Compile u-boot

./build.sh uboot
  • Compile kernel

./build.sh kernel
  • Compile recovery

./build.sh recovery

Partition Explanation

Parameter Partition Table

The parameter.txt file contains the partition information of the firmware:

Path:device/rockchip/rk3588/parameter.txt

FIRMWARE_VER: 1.0
MACHINE_MODEL: RK3588
MACHINE_ID: 007
MANUFACTURER: RK3588
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE: mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),-@0x00078000(rootfs:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
uuid:boot=7A3F0000-0000-446A-8000-702F00006273

The CMDLINE attribute is our focus. Taking uboot as an example, in 0x00002000@0x00004000(uboot), 0x00004000 is the starting position of the uboot partition, and 0x00002000 is the size of the partition, and so on.

package-file

The package-file is used to determine the required partition images and image paths when packaging firmware, and it needs to be consistent with the parameter.txt file.

Path:tools/linux/Linux_Pack_Firmware/rockdev/rk3588-package-file

# NAME          Relative path
#
#HWDEF          HWDEF
package-file    package-file
bootloader      Image/MiniLoaderAll.bin
parameter       Image/parameter.txt
uboot           Image/uboot.img
misc            Image/misc.img
boot            Image/boot.img
recovery        Image/recovery.img
rootfs          Image/rootfs.img
backup          RESERVED

FAQ

Compilation Errors

lz4 Error

Incorrect parameters
Usage :
      lz4 [arg] [input] [output]

input   : a filename
          with no FILE, or when FILE is - or stdin, read standard input
Arguments :
 -1     : Fast compression (default) 
 -9     : High compression 
 -d     : decompression (default for .lz4 extension)
 -z     : force compression
 -f     : overwrite output without prompting 
 -h/-H  : display help/long help and exit
arch/arm64/boot/Makefile:31: recipe for target 'arch/arm64/boot/Image.lz4' failed
make[2]: *** [arch/arm64/boot/Image.lz4] Error 1
make[2]: *** Deleting file 'arch/arm64/boot/Image.lz4'
arch/arm64/Makefile:170: recipe for target 'Image.lz4' failed
make[1]: *** [Image.lz4] Error 2
make[1]: *** Waiting for unfinished jobs....

Workaround, re-install LZ4 manually:

git clone https://github.com/lz4/lz4.git
cd lz4
make
sudo make install