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.
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-RK3588X0 development board model name is TB-RK3588X0.
DTB: Kernel device tree; for example: TB-RK3588X0 development board kernel device tree is rk3588-toybrick-x0-linux.
ROOT_DIR: TB-RK3588X Linux BSP work directory; the directory shown in the document is /home/toybrick/work/edge.
CHIP: the chip model of development board; TB-RK3588X Linux BSP support RK3588 and RK3568.
OUT_DIR: the path of images ${ROOT_DIR}/out/${CHIP}/${BOARD}/images, for example TB-RK3588X0 images path is /home/toybrick/work/edge/out/rk3588/TB-RK3588X0/images.
Setting Configuration Information¶
Run the following command and enter the product model number (for example, the serial number of the RK3588X0 development board is 0) to set the configuration information.
./edge set
[EDGE DEBUG] Board list:
> rk3588
0. TB-RK3568X0
Enter the number of the board: 0
重要
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: /home/toybrick/edge/edge-toybrick
[EDGE DEBUG] out path: /home/toybrick/edge/edge-toybrick/out/rk3588/TB-RK3588X0/images
[EDGE DEBUG] board: TB-RK3588X0
[EDGE DEBUG] chip: rk3588
[EDGE DEBUG] arch: arm64
[EDGE DEBUG] bootmode: extlinux
[EDGE DEBUG] > Partition:
[EDGE DEBUG] uboot: ['0x00002000', '0x00004000']
[EDGE DEBUG] misc: ['0x00006000', '0x00002000']
[EDGE DEBUG] boot_linux:bootable: ['0x00008000', '0x00020000']
[EDGE DEBUG] recovery: ['0x00028000', '0x00040000']
[EDGE DEBUG] resource: ['0x00068000', '0x00010000']
[EDGE DEBUG] rootfs:grow: ['0x00078000', '-']
[EDGE DEBUG] > Uboot:
[EDGE DEBUG] config: rk3588-toybrick
[EDGE DEBUG] > Kernel:
[EDGE DEBUG] version: 5.10
[EDGE DEBUG] config: rk3588_edge.config rk3588_toybrick.config
[EDGE DEBUG] dtbname: rk3588-toybrick-x0-linux
[EDGE DEBUG] size: 64
[EDGE DEBUG] docker: False
[EDGE DEBUG] debug: 0xfeb50000
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, you can modify uboot/configs/rk3588-toybrick.config if necessary. |
kernel | linuxdtb: product/ development board kernel device tree name, for example RK3588 EVB1 development board dtbname is rk3588-toybrick-x0-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,resource.img), package update.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-rk3588x 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-RK3588X directly. and perform the following steps to create rootfs.
Mount rootfs partition to sysroot directory: After enter emergency mode system will mount rootfs partition to sysroot automatically.
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.