1. Compile Linux firmware

1.1. Download Firefly_Linux_SDK

Please contact sales (sales@t-firefly.com) to obtain the SDK download link and read the readme document associated with the download link.

Attention:

1. SDK uses cross-compile, so download SDK to your X86_64 PC, do not download SDK to arm64 board.

2. Build environment needs to be Ubuntu22.04 (real PC or docker container), other versions may cause build failure.

3. Do not put SDK under shared directory of VM or non-English path.

4. Please get/build SDK as a normal user, root privilege are neither allowed nor required (except installing sth. with apt) ## Linux SDK Configuration Introduction

1.1.1. Directory

$ tree -L 1
.
├── app
├── buildroot	# Buildroot root file system compilation directory
├── build.sh -> device/rockchip/common/scripts/build.sh # Compilation script
├── Copyright_Statement.md -> docs/licenses/LICENSE
├── device		# Compilation-related configuration files
├── docs		# Documentation
├── external
├── firefly-release.sh -> device/rockchip/common/scripts/firefly-release.sh
├── firefly-update.sh -> device/rockchip/common/scripts/firefly-update.sh
├── hal
├── kernel -> kernel-6.1
├── kernel-6.1
├── Makefile -> device/rockchip/common/Makefile
├── prebuilts	# Cross-compilation toolchain
├── rkbin
├── rkflash.sh -> device/rockchip/common/scripts/rkflash.sh
├── rtos
├── tools		# Tools directory
├── u-boot
└── yocto		# Compile yocto file system directory

1.1.2. Introduction to configuration files

In the device/rockchip/rv1126b/ directory, there are configuration files (xxxx.mk) for different board types, which are used to manage the compilation configuration of each project of the SDK. The relevant configuration introduction:

Configuration file naming conventions:

<vendor>_<chip>_<model>-<extra>_<OS>_defconfig

vendor: Product supplier
chip: Chip used in the product
model: Product model, indicating that this configuration file is for this product model
extra: Additional attributes, can be empty
OS: Operating system the product will run

Configuration file content description, for example firefly_rv1126b_aio-1126bjd4v0_debian_defconfig:

#include "firefly.config"
RK_UBOOT_INI="RV1126BMINIALL.ini"
RK_UBOOT_SPL=y
RK_KERNEL_DTS_NAME="rv1126b-firefly-aio-1126bjd4v0"		# Specifies the device tree used for compiling the kernel.
RK_KERNEL_CFG="rockchip_linux_defconfig"
RK_MISC_RECOVERY=y
RK_RECOVERY_RAMDISK="common-recovery-arm64.cpio.gz"		# Specifies the pre-compiled recovery file system
RK_BOOT_FIT_ITS_NAME="bootramdisk.its"
RK_RAMDISK_IMG="kernel/ramdisk-64.img"
RK_PRODUCT_MODEL="AIO-1126BJD4V0"				# Product name/model
RK_PARAMETER="parameter-debian-fit.txt"				# Specifies the firmware partition table
PREBUILT_ROOTFS_IMG="prebuilt_rootfs/rv1126b_debian_rootfs.img" # Specifies the pre-compiled file system to use

1.1.3. Partition table

1.1.3.1. parameter

The parameter.txt file contains the partition information of the firmware. Take parameter-ubuntu-fit.txt as an example:

path: device/rockchip/rv1126b/parameter-xxxxxx-fit.txt

FIRMWARE_VER: 1.0
MACHINE_MODEL: RV1126B
MACHINE_ID: 007
MANUFACTURER: RV1126B
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
GROW_ALIGN: 0
CMDLINE: mtdparts=:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00040000@0x00008000(boot),0x00040000@0x00048000(recovery),0x00010000@0x00088000(backup),0x00a00000@0x00098000(rootfs),-@0x00a98000(userdata:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
uuid:boot=7A3F0000-0000-446A-8000-702F00006273

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

The unit of the numbers in the parameter is “blocks,” and each block is 512 bytes. Therefore, the uboot partition size is 0x00002000, which is 8192 blocks, totaling 8192 x 512 / 1024 / 1024 = 4 MiB.

1.2. Compile Yocto firmware

1.2.1. Compile

1.2.1.1. Select image

The Yocto project provides some images that can be used without layers. The following table lists currently supported build images and associated recipes.

Image name Target provided by layer
core-image-minimal A small image that only allows a device to boot Poky
core-image-minimal-xfce A XFCE minimal demo image meta-openembedded/meta-xfce
core-image-sato Image with Sato, a mobile environment and visual style for mobile devices. The image supports X11 with a Sato theme, Pimlico applications, and contains terminal, editor, and file manager Poky
core-image-weston A very basic Wayland image with a terminal Poky
core-image-x11 A very basic X11 image with a terminal Poky

1.2.2. Build image

The process of building with the bitbake command needs to ensure that the network connection is normal. If it is a customer in inland China, you need to ensure that it can ping the external network

  • Enter the directory <path/to/yocto/poky> and execute the following commands in sequence

# Install the required environment packages
# sudo apt install zstd
source oe-init-build-env

# add layer
bitbake-layers add-layer ../../meta-openembedded/meta-oe
bitbake-layers add-layer ../../meta-openembedded/meta-python
bitbake-layers add-layer ../../meta-openembedded/meta-networking
bitbake-layers add-layer ../../meta-openembedded/meta-multimedia
bitbake-layers add-layer ../../meta-openembedded/meta-gnome
bitbake-layers add-layer ../../meta-openembedded/meta-xfce
bitbake-layers add-layer ../../meta-lts-mixins
bitbake-layers add-layer ../../meta-clang
bitbake-layers add-layer ../../meta-browser/meta-chromium
bitbake-layers add-layer ../../meta-rockchip

Choose one of the commands to compile the complete core-image recipes. The following is an x11 based core-image.

MACHINE=aio-1126bjd4v0 bitbake core-image-minimal
MACHINE=aio-1126bjd4v0 bitbake core-image-minimal-xfce
MACHINE=aio-1126bjd4v0 bitbake core-image-x11
MACHINE=aio-1126bjd4v0 bitbake core-image-sato

The following is a core-image based on wayland. You need to modify DISPLAY_PLATFORM to wayland in /path/to/yocto/meta-rockchip/conf/machine/include/display.conf. Modify as follows:

DISPLAY_PLATFORM ?= "wayland"
# DISPLAY_PLATFORM ?= "x11"

After completing the above modifications, execute the command to compile core-image-weston

MACHINE=aio-1126bjd4v0 bitbake core-image-weston

Note: If you need to change the compiled core-image recipes after you have already compiled core-image once, you need to clean up the currently compiled core-image and then compile a new core-image.

For example: the currently compiled one is core-image-minimal. You need to change it to core-image-sato.

MACHINE=aio-1126bjd4v0 bitbake core-image-minimal -c clean
MACHINE=aio-1126bjd4v0 bitbake core-image-sato

If you want to compile some recipes separately, you can refer to the following:

# kernel
MACHINE=aio-1126bjd4v0 bitbake linux-rockchip
        
# u-boot
MACHINE=aio-1126bjd4v0 bitbake u-boot-rockchip
        
# rkmpp
MACHINE=aio-1126bjd4v0 bitbake rockchip-mpp
        
# rockchip-librga
MACHINE=aio-1126bjd4v0 bitbake rockchip-librga
        
# See more compilation objects
MACHINE=aio-1126bjd4v0 bitbake -s

1.2.3. Adjust compilation speed

Modify the BB_NUMBER_THREADS and PARALLEL_MAKE variables in the file /path/to/yocto/meta-rockchip/conf/machine/firefly-rk3588.conf. If the number of threads is set too large, the machine may run out of memory and cause compilation failure. Please set the compilation speed according to the configuration of the compilation machine.

BB_NUMBER_THREADS = "4"
PARALLEL_MAKE = "-j 4"
  • BB_NUMBER_THREADS: The maximum number of threads BitBake simultaneously executes.

  • BB_NUMBER_PARSE_THREADS: The number of threads BitBake uses during parsing.

  • PARALLEL_MAKE: Extra options passed to the make command during the do_compile task in order to specify parallel compilation on the local build host.

  • PARALLEL_MAKEINST: Extra options passed to the make command during the do_install task in order to specify parallel installation on the local build host.

1.2.4. More bitbake options

Fundamentally, BitBake is a generic task execution engine that allows shell and Python tasks to be run efficiently and in parallel while working within complex inter-task dependency constraints. One of BitBake’s main users, OpenEmbedded, takes this core and builds embedded Linux software stacks using a task-oriented approach.For more detailed usage, please check《bitbake-user-manual》

MACHINE=aio-1126bjd4v0 bitbake <target> <paramater>
# e.g
MACHINE=aio-1126bjd4v0 bitbake u-boot-rockchip -c clean
MACHINE=aio-1126bjd4v0 bitbake u-boot-rockchip
Bitbake paramater Description
-c fetch Fetches if the downloads state is not marked as done
-c clean Removes all output files for a target
-c cleanall Removes all output files, shared state cache, and downloaded source files for a target
-c compile -f It is not recommended that the source code under the temporary directory is changed directly, but if it is, the Yocto Project might not rebuild it unless this option is used. Use this option to force a recompile after the image is deployed.
-c listtasks Lists all defined tasks for a target

1.2.5. Partition firmware upgrade

The compiled firmware is located in the directory <path/to/yocto>/build/tmp/deploy/images/<board>/

$ sudo upgrade_tool di -boot boot.img
$ sudo upgrade_tool di -uboot uboot.img
$ sudo upgrade_tool di -misc misc.img
$ sudo upgrade_tool di -recovery recovery.img
  • Partition burning is suitable for debugging stage. For firmware verification, please use the unified firmware burning below.

  • Rootfs does not support separate burning. You need to pack the complete firmware before burning.

1.2.6. Unified firmware upgrade

The compiled firmware is located in the directory <path/to/yocto>/build/tmp/deploy/images/<board>/, the files to be downloaded are .wic and update.img, and after entering the loader mode, execute the following commands :

$ sudo upgrade_tool wl 0 <IMAGE NAME>.wic
$ sudo upgrade_tool uf update.img
  • The default login account of the firmware is: root, password: firefly. The firmware contains a common user account named firefly, and the password is firefly.

Note: If you are developing on a Windows PC, you can use RKdevtool to directly burn update.img, no need to burn <IMAGE NAME>.wic. However, please note that update.img is a link file, so you must select the actual file that the link file points to.

1.2.8. Introduction to Yocto Project Release layer

layer path priority(The higher the number, the higher the priority) describe
meta-oe meta-openembedded/meta-oe 6 contains a large amount of additional recipes
meta-python meta-openembedded/meta-python 7 Provide Python recipes
meta-qt5 meta-qt5 7 Provides QT5 recipes
meta-clang meta-clang 7 clang compiler
meta-rockchip meta-rockchip 9 Rockchip board level support available
meta meta 5 Contains the OpenEmbedded-Core metadata
meta-poky meta-poky 5 Holds the configuration for the Poky reference distribution
meta-yocto-bsp meta-yocto-bsp 5 Configuration for the Yocto Project reference hardware board support package.
meta-chromium meta-chromium 7 Provide chromium browser recipe

1.3. Compile Debian firmware

1.3.1. Preparatory work

Execute the following two commands to install the required tools.

sudo apt update

sudo apt install repo 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 ncurses-dev p7zip-full

Download the root filesystem: Debian Root Filesystem (64-bit). Please use the filesystem located in the kernel-6.1 directory of the cloud drive.

After downloading, extract the file system to SDK/prebuilt_rootfs/ and create a symbolic link:

# Extract
7z x debian12_xxxx_rootfs_xxxx.7z

# Move the extracted rootfs image to sdk and create a symbolic link
mkdir ./SDK/prebuilt_rootfs/
mv debian12_xxxx_rootfs_xxxx.img ./SDK/prebuilt_rootfs/
cd ./SDK/prebuilt_rootfs/
ln -sf debian12_xxxx_rtoofs_xxxx.img rv1126b_debian_rootfs.img
cd ..

1.3.1.1. Pre-compilation Configuration

After downloading the SDK, you only need to execute ./build.sh to select the chip platform for compilation during the first compilation. Skip this step if it’s not the first compilation.

$ ./build.sh

############### Rockchip Linux SDK ###############

Manifest: rv1126b_linux6.1_release_20251212_v1.1.0a.xml

Log colors: message notice warning error fatal

Log saved at /home2/lvsx/project/rv1126b/output/sessions/2025-12-25_15-13-14
Pick a chip:

1. rk3562
2. rk356x
3. rk3576
4. rk3588
5. rv1126b
Which would you like? [1]:

Enter the ID and select platform rv1126b.

1.3.1.2. Select Board Configuration

Execute ./build.sh lunch to list all available configuration files. Enter the file number to select the corresponding configuration file. Note that you should select the configuration file containing “debian”:

$ ./build.sh lunch

############### Rockchip Linux SDK ###############

Manifest: rv1126b_linux6.1_release_20251212_v1.1.0a.xml

Log colors: message notice warning error fatal

Log saved at /home2/lvsx/project/rv1126b/output/sessions/2025-12-25_15-00-32
Pick a defconfig:

1. rockchip_defconfig
2. firefly_rv1126b_aio-1126bjd4_buildroot_defconfig
3. firefly_rv1126b_aio-1126bjd4_debian_defconfig
4. firefly_rv1126b_aio-1126bjd4_ubuntu_defconfig
5. firefly_rv1126b_aio-1126bjd4v0_buildroot_defconfig
6. firefly_rv1126b_aio-1126bjd4v0_debian_defconfig
7. firefly_rv1126b_aio-1126bjd4v0_ubuntu_defconfig
8. firefly_rv1126b_aio-1126bq38_buildroot_defconfig
9. firefly_rv1126b_aio-1126bq38_debian_defconfig
10. firefly_rv1126b_aio-1126bq38_ubuntu_defconfig
11. firefly_rv1126b_cam-1126bq38_buildroot_defconfig
12. firefly_rv1126b_cam-1126bq38_debian_defconfig
13. firefly_rv1126b_cam-1126bq38_ubuntu_defconfig
...
Which would you like? [1]:

Enter the board type by entering the board number: firefly_rv1126b_aio-1126bjd4v0_debian_defconfig.

1.3.2. Compilation

1.3.2.1. Complete Compilation

Execute the following command:

./build.sh all

After compilation, a complete firmware output/update/update.img will be generated.

1.3.2.1.1. Partial Compilation

Generally, custom development only involves the kernel and uboot. Therefore, after a complete compilation, if the kernel or uboot is subsequently modified, partial compilation can be performed to speed up the process.

  • Compile u-boot separately, generating u-boot/uboot.img

./build.sh uboot
  • Compile kernel separately, generating kernel/boot.img

./build.sh kernel
  • Compile recovery separately, generating output/recovery/ramboot.img

./build.sh recovery
  • Package all components into update.img

./build.sh updateimg

1.4. Compile Buildroot firmware

1.4.1. Preparatory work

Execute the following two commands to install the required tools.

sudo apt update

sudo apt install repo 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 ncurses-dev

1.4.1.1. Precompile Configuration

After downloading the SDK, you only need to execute ./build.sh to select the chip platform for compilation during the first compilation. Skip this step if it is not the first compilation.

$ ./build.sh

############### Rockchip Linux SDK ###############

Manifest: rv1126b_linux6.1_release_20251212_v1.1.0a.xml

Log colors: message notice warning error fatal

Log saved at /home2/lvsx/project/rv1126b/output/sessions/2025-12-25_15-13-14
Pick a chip:

1. rk3562
2. rk356x
3. rk3576
4. rk3588
5. rv1126b
Which would you like? [1]:

Enter the ID and select platform rv1126b.

1.4.1.2. Select Board Type Configuration

Execute ./build.sh lunch to list all available configuration files. Enter the file number to select the corresponding configuration file. Note that you should select the configuration file containing the words “buildroot”:

$ ./build.sh lunch

############### Rockchip Linux SDK ###############

Manifest: rv1126b_linux6.1_release_20251212_v1.1.0a.xml

Log colors: message notice warning error fatal

Log saved at /home2/lvsx/project/rv1126b/output/sessions/2025-12-25_15-00-32
Pick a defconfig:

1. rockchip_defconfig
2. firefly_rv1126b_aio-1126bjd4_buildroot_defconfig
3. firefly_rv1126b_aio-1126bjd4_debian_defconfig
4. firefly_rv1126b_aio-1126bjd4_ubuntu_defconfig
5. firefly_rv1126b_aio-1126bjd4v0_buildroot_defconfig
6. firefly_rv1126b_aio-1126bjd4v0_debian_defconfig
7. firefly_rv1126b_aio-1126bjd4v0_ubuntu_defconfig
8. firefly_rv1126b_aio-1126bq38_buildroot_defconfig
9. firefly_rv1126b_aio-1126bq38_debian_defconfig
10. firefly_rv1126b_aio-1126bq38_ubuntu_defconfig
11. firefly_rv1126b_cam-1126bq38_buildroot_defconfig
12. firefly_rv1126b_cam-1126bq38_debian_defconfig
13. firefly_rv1126b_cam-1126bq38_ubuntu_defconfig
...
Which would you like? [1]:

Enter the board type by entering the board number: firefly_rv1126b_aio-1126bjd4v0_buildroot_defconfig.

1.4.2. Compilation

1.4.2.1. Full Compilation

Execute the following command:

./build.sh all

After compilation, the complete firmware output/update/update.img will be generated.

1.4.2.2. Partial Compilation

After a full compilation, if you subsequently modify the kernel or uboot, you can perform a partial compilation to speed up the process.

  • Compile u-boot separately, generating u-boot/uboot.img

./build.sh uboot
  • Compile kernel separately, generating kernel/boot.img

./build.sh kernel
  • Compile recovery separately, generating output/recovery/ramboot.img

./build.sh recovery
  • Package all components into update.img

./build.sh updateimg

However, if you modify the buildroot, you need to recompile completely.