How to Get the Source Code¶
提示
Please contact toybrick@rock-chips.com to get the source code.
rootfs.img is not in source code, toybrick has compiled and preconfigured rootfs.img for multiple deb packages, please get from released image.
Apply Patches to Source Code¶
ROOT_DIR
: The working directory for the Linux source code SDK; the directory shown in the documentation is/home/toybrick/work/edge
.Patches need to be applied to the
${ROOT_DIR}/rootfs/debian/initrd/
and${ROOT_DIR}/rkbin/
directories in order to compile the firmware properly. The patch packages are located in the corresponding directories under${ROOT_DIR}/patches/
.To apply the patch in the
${ROOT_DIR}/rootfs/debian/initrd/
directory, please follow these steps:Obtain the commit ID from
${ROOT_DIR}/patches/initrd/commit_base.txt
.
cat ../../../patches/initrd/commit_base.txt
Copy the string in the second column of the line containing the commit. Assuming the current version is 0dfde98ba6aa1fa87a0efb0315b534b0742014d1, then reset to this baseline version:
git reset --hard 0dfde98ba6aa1fa87a0efb0315b534b0742014d1
To apply the patch:
git am ../../../patches/initrd/*.patch
Similarly, follow analogous steps in the
${ROOT_DIR}/rkbin/
directory (modify the Commit ID, such as cf04d2f1699570344d189b0e6ff2eeb3f532f16c, according to the specific situation):cat ../patches/rkbin/commit_base.txt git reset --hard cf04d2f1699570344d189b0e6ff2eeb3f532f16c git am ../patches/rkbin/*.patch
rootfs.img Introduction¶
The debian11 root file system consists of a series of deb packages. Download these software packages from the Debian official website or image website using scripts to build debian11 root file system.
Debian china official websit: http://ftp.cn.debian.org/debian
Recommended Debian image website:http://mirros.163.com/debian
Obtain the source code package method: Modify /etc/apt/source.list and add deb-src , specify the source code address of the Ubuntu distribution (For more information, refer to the debian forum or download the Debian package source code by search engine).
More detail please refer to Create custom Debian11 image section.
Compiling Source Code¶
Set Up a Development Environment¶
System Requirement of Compile Host¶
It is recommend use Ubuntu18.04 or higher version and Debian11 to development, and the recommend memory greater than 16GB.
The user name can’t contain Chinese characters.
please set up the development environment only as a common user, not as the root user. If you need root permission please use
sudo
command.
Install Compilation Rely Software¶
Install compilation rely software on Debian
sudo apt -y install python lz4 coreutils qemu qemu-user-static python3 \
devicetree-compiler clang bison flex lld libssl-dev bc genext2fs git make
Install compilation rely software on Ubuntu
sudo apt -y install python lz4 coreutils qemu qemu-user-static python3 \
device-tree-compiler clang bison flex lld libssl-dev bc genext2fs git make
Compiling Configuration¶
Perform the following operation at the root directory of the source code you obtained. The edge
executable file is preset at the root directory of the source code.
For documentation purposes, define the variables as follow:
BOARD: development board/product model name; for example: TB-RK3588SD development board model name is TB-RK3588SD0.
DTB: Kernel device tree; for example: TB-RK3588SD0 development board kernel device tree is rk3588-toybrick-d0-linux.
ROOT_DIR: Linux BSP work directory; the directory shown in the document is /home/toybrick/work/edge.
CHIP: the chip model of development board; TB-RK3588SD Linux BSP support RK3588 and RK3588S.
OUT_DIR: the path of images ${ROOT_DIR}/out/${CHIP}/${BOARD}/images, for example TB-RK3588SD images path is /home/toybrick/work/edge/out/rk3588/TB-RK3588SD0/images.
Setting Configuration Information¶
Run the following command and enter the product model number (for example, the serial number of the RK3588SD development board is 5) to set the configuration information.
./edge set
[EDGE DEBUG] Board list:
> rk3588
0. RK3588-EVB4
1. TB-RK3588B0
2. TB-RK3588X0
3. RK3588s-EVB1
4. RK3588-EVB1
5. TB-RK3588SD0
> rk3568
6. TB-RK3568X0
Enter the number of the board: 5
重要
Please run this command again to update the configuration ,when you update or modify the code.
Configuration file saved in vendor/common/config.json
and vendor/${CHIP}/${BOARD}/config.json
, more detail please refer to Configuration information introduction section.
Configuration Information¶
Run the following command to check the current configuration information.
./edge env
[EDGE DEBUG] root path: /home1/jax/rk-sd0-edge-sdk
[EDGE DEBUG] out path: /home1/jax/rk-sd0-edge-sdk/out/rk3588/TB-RK3588SD0/images
[EDGE DEBUG] board: TB-RK3588SD0
[EDGE DEBUG] chip: rk3588
[EDGE DEBUG] arch: arm64
[EDGE DEBUG] bootmode: flash
[EDGE DEBUG] hyper: not set
[EDGE DEBUG] > Secureboot:
[EDGE DEBUG] enable: False
[EDGE DEBUG] rollback: [0, 0]
[EDGE DEBUG] burnkey: False
[EDGE DEBUG] > Partition:
[EDGE DEBUG] vnvm: ['0x00000500', '0x00000500']
[EDGE DEBUG] uboot: ['0x00000A00', '0x00000800']
[EDGE DEBUG] boot: ['0x00001200', '-']
[EDGE DEBUG] > Uboot:
[EDGE DEBUG] config: rk3588-toybrick-sd0
[EDGE DEBUG] > Kernel:
[EDGE DEBUG] version: 5.10
[EDGE DEBUG] config: rk3588_edge.config rk3588_toybrick.config rk3588_toybrick_sd0.config
[EDGE DEBUG] dtbname: rk3588s-toybrick-d0-linux
[EDGE DEBUG] size: 64
[EDGE DEBUG] docker: False
[EDGE DEBUG] debug: 0xfeb50000
[EDGE DEBUG] > Rootfs:
[EDGE DEBUG] osname: debian
[EDGE DEBUG] version: 11
[EDGE DEBUG] type: gnome
[EDGE DEBUG] apturl: http://repo.rock-chips.com
[EDGE DEBUG] uuid: 614e0000-0000-4b53-8000-1d28000054a9
[EDGE DEBUG] size: auto
[EDGE DEBUG] user: toybrick
[EDGE DEBUG] password: toybrick
[EDGE DEBUG] relver: 1.1.0
[EDGE DEBUG] key: GPG-KEY-ROCKCHIP
Configuration Information Introduction¶
Common Configuration¶
Common configuration is saved in vendor/common/config.json
, The value of not set
configuration items must be set in the “board level” ; Other configuration items can be modified in “board Configuration” as required.
Kernel¶
config: menuconfig configuration of kernel, the default value are
rk3588_edge.config
andrk3588_tobrick.config
, it will loadrockchip_linux_defconfig
;rk3588_edge.config
andrk3588_toybrick.config
when compilation. If need modify kernel configuration can modifiedkernel/linux-5.10/arch/arm64/configs/rk3588_toybrick.config
.docker: The default value is
false
. False indicates to disable docker configuration. True indicates to enable docker configuration.
Board Configuration¶
Board configuration is saved invendor/${CHIP}/${BOARD}/config.json
, and the value will override the value of the same configuration item in the common configuration.
Name | Description |
---|---|
board | Development board or products model name, it's value must be same as ${BOARD} directory name in vendor/${CHIP} directory. |
chip | Chip type, currently supported rk3588、rk3588s |
arch | Chip architecture, currently the supported chip both are arm64 architecture. |
uboot | Default value is rk3588-toybrick-sd0, you can modify uboot/configs/rk3588-toybrick-sd0.config if necessary. |
kernel | linuxdtb: product/ development board kernel device tree name, for example RK3588SD development board dtbname is rk3588s-toybrick-d0-linux |
Announcements¶
config.json
in product directory only need add the fields you want to change.edge script will load
vendor/common/config.json
firstly; then loadvendor/${CHIP}/${BOARD}/config.json
to update the value of same fields.The chip value of kernel subset in configuration information of RK3588 and RK3588s both are set to rk3588:
rk3588
。
Compiling Image¶
Before execute the following command please set the configuration information firstly./edge set
, more detail please refer to Setting configuration information section.
注意
rootfs.img not compiled, rootfs.img can download from released firmware.If you want to generate custom rootfs.img, please refer to “Creating custom Debian11 image” section.
Automatic Compilation¶
Execute the following commands to automatically complete all compilation (include MiniLoaderAll.bin,uboot.img,kernel.img,boot.img, rootfs.img), and save it in OUT_DIR directory.
./edge build -a
Compiling Uboot¶
Execute the following command to generate MiniLoaderAll.bin and uboot.img, and saved them in OUT_DIR directory.
./edge build -u
Compiling Kernel¶
Execute the following command to generate boot_linux.img and resource.img, and saved them in OUT_DIR directory.
./edge build -k
View Compilation Help¶
Execute the following command to view supported compilation parameters.
./edge build -h
Create Custom Debian11 Image¶
After deploying the product software on the tb-rk3588SD development board successfully, you can follow this section to customize debian11 firmware and create customized rootfs.img for mass production.
Create Rootfs¶
Execute the following operations on TB-RK3588SD directly. and perform the following steps to create rootfs.
Insert the U-disk (please ensure the U-disk have sufficient capacity) and mount the U-disk to the/mnt directory:
mount /dev/sda1 /mnt
Package all rootfs file:
cd /sysroot tar cvpfJ ../mnt/rootfs.tar.xz * cd -
Create an empty file system and format it as an EXT4 file system:
dd if=/dev/zero of=/mnt/rootfs.img bs=2K count=3M // The size of a file system is 6 GB (2K x 3M). You can change the size of count to set the size of the file system. mkfs.ext4 /mnt/rootfs.img
Mount an empty file system to /rootfs directory.
mkdir /rootfs mount /mnt/rootfs.img /rootfs
Unzip package file to /rootfs directory.
tar xvpfJ /mnt/rootfs.tar.xz /rootfs
Umount /rootfs directory and U-disk.
umount /rootfs umount /mnt
Get rootfs.img on U-disk.