Welcome to Firefly
Switch language
Firefly Docsss
Last Updated: 2026-07-31 11:07:49

Compile Linux firmware

Get SDK

First prepare an empty folder to store the SDK. It is recommended to store the SDK in the home directory. This article uses ~/proj as an example.

Notice:

1. The SDK is cross-compiled, so use the SDK on an X86_64 computer and do not download the SDK to the board

2. Please use Ubuntu18.04 (real machine or docker container) for the compilation environment. Using other versions may cause compilation errors

3. Do not store or decompress the SDK in virtual machine shared folders or non-English directories

4. Please use an ordinary user to obtain and compile the SDK. Root privileges are not allowed or required (unless apt installation software is required)

Installation tools

To obtain the SDK, you need to install it first:

sudo apt update
sudo apt install -y repo git python

Initialize warehouse

*Method 1 (recommended for domestic users)

SDK source code is placed in the compressed package

After downloading, verify the MD5 code:

lvsx@tchip16:~ $ md5sum T36X.7z
a0aba53273aedef9ca085266bdad8806  T36X.7z

After confirming that it is correct, you can unzip:

7x x T36X.7z
```## Linux IPC SDK configuration introduction

### SDK directory structure description

| Directory Path                      | Introduction                                                 |
| ----------------------------------- | ------------------------------------------------------------ |
| build.sh                            | SDK compilation script<br/>Soft link to project/build.sh     |
| media                               | Multimedia codec, ISP and other algorithm related            |
| sysdrv                              | U-Boot, kernel, rootfs directory                             |
| project                             | Reference application, compilation configuration and script directory |
| docs                                | SDK Document Directory                                       |
| tools                               | Burning image packaging tool and burning tool                |
| output                              | SDK compiled image file storage directory                    |
| output/image                        | Burning image output directory                               |
| output/out                          | File generated by compilation                                |
| output/out/app_out                  | Refer to the compiled file of the application                |
| output/out/media_out                | media related compiled files                                 |
| output/out/sysdrv_out               | sysdrv compiled file                                         |
| output/out/sysdrv_out/kernel_drv_ko | ko files for peripherals and multimedia                      |
| output/out/rootfs_xxx               | File system packaging directory                              |
| output/out/S20linkmount             | Partition mount script                                       |
| output/out/userdata                 | userdata                                                     |

Note: media and sysdrv can be compiled independently from the SDK.

### Sysdrv directory description

Sysdrv can be compiled independently of the SDK and includes U-Boot, kernel, rootfs and some image packaging tools.
Compile command:
```bash
# Compile all by default
make all

# Compile U-Boot
make uboot_clean
make uboot

# Compile kernel
make kernel_clean
make kernel

# Compile rootfs
make rootfs_clean
make rootfs

# Clear compilation
make clean

# Clear compilation and delete out directory
make distclean

# Check the compilation configuration, such as uboot and kernel detailed compilation commands
make info
sysdrv subdirectoryDescription
cfgKernel and U-Boot compilation related configurations
outsysdrv compilation output directory
out/bin/board_glibc_xxxPrograms running on the board end
out/bin/pcPrograms running on PC
out/bin/image_glibc_xxxGenerated burning image output directory
out/bin/rootfs_glibc_xxxRoot file system directory
source/busyboxbusybox compilation directory, the source code is in sysdrv/tools/board/busybox
source/kernelKernel source code directory
source/ubootU-Boot source code directory and rkbin (ddr initialization precompiled image)
tools/boardBoard end program source code
tools/pcTools for PC-side image packaging

Configuration file introduction

In the project/cfg/BoardConfig_IPC/ directory, there are configuration files (xxxx.mk) for different board types, which are used to manage the compilation configuration of each link of the SDK. Related configuration introduction:

Configuration itemsDescription
RK_ARCHarm or arm64
Define compiling 32-bit or 64-bit programs
RK_CHIPUnmodifiable
Different chips correspond to different SDKs
RK_TOOLCHAIN_CROSSUnmodifiable
Define cross tool chain
RK_BOOT_MEDIUMemmc or spi_nor or spi_nand
Define board storage type
RK_UBOOT_DEFCONFIGU-Boot defconfig file name
File directory sysdrv/source/uboot/u-boot/configs
RK_UBOOT_DEFCONFIG_FRAGMENTU-Boot config file name (optional)
File directory sysdrv/source/uboot/u-boot/configs
Override the defconfig defined by RK_UBOOT_DEFCONFIG
RK_KERNEL_DEFCONFIGKernel defconfig file name
File directory sysdrv/source/kernel/arch/$RK_ARCH/configs
RK_KERNEL_DEFCONFIG_FRAGMENTKernel defconfig file name (optional)
File directory sysdrv/source/kernel/arch/$RK_ARCH/configs
Override the defconfig defined by RK_KERNEL_DEFCONFIG
RK_KERNEL_DTSKernel dts file name
RK_ARCH=arm Directory:
sysdrv/source/kernel/arch/arm/boot/dts
RK_ARCH=arm64 Directory:
sysdrv/source/ kernel/arch/arm64/boot/dts/rockchip
RK_MISCIf the recovery function is turned on, read the flag when the system starts to select the recovery system or application system (can be removed when there is no recovery)
RK_CAMERA_SENSOR_IQFILESIQ configuration file of Camera Sensor
File directory media/isp/camera_engine_rkaiq/iqfiles or
media/isp/camera_engine_rkaiq/rkaiq/iqfiles
Multiple IQ files are separated by spaces, for example
RK_CAMERA_SENSOR_IQFILES="iqfile_1 iqfile_2"
RK_PARTITION_CMD_IN_ENVConfigure partition table (important)
Partition table format:
<partdef>[,<partdef>]
<partdef>Format: <size >[@<offset>](part-name)
For detailed configuration, refer to [Partition Table Description Chapter]
RK_PARTITION_FS_TYPE_CFGConfigure the partition file system type and mount point (important)
Format description:
Partition name@partition mount point@partition file system type
Note: The partition of the root file system is mounted The default value of the load point is IGNORE (cannot be modified)
RK_SQUASHFS_COMPConfigure squashfs image compression algorithm (optional)
Support: lz4/lzo/lzma/xz/gzip (default xz)
RK_UBIFS_COMPConfigure ubifs image compression algorithm (optional)
Support: lzo/zlib (default lzo)
RK_APP_TYPEConfigure compiled reference applications (optional)
Run ./build.sh info to view supported reference applications
RK_APP_IPCWEB_BACKENDConfigure whether to compile web applications (optional)
y: enable
RK_BUILD_APP_TO_OEM_PARTITIONConfigure whether to install the application to the OEM partition (optional)
y: enable
RK_ENABLE_RECOVERYConfigure whether to enable the recovery function (optional)
y: enable
RK_ENABLE_FASTBOOTConfigure whether the fast boot function (optional)
y: enable
Needs to cooperate with U-Boot and kernel modifications, you can refer to the
BoardConfig-*-TB.mk provided by the SDK
RK_ENABLE_GDBConfigure whether to compile gdb (optional)
y: enable
RK_ENABLE_ADBDConfigure whether to support adb function (optional)
y: enable
Note: The kernel needs to open the corresponding USB configuration
RK_BOOTARGS_CMA_SIZEConfigure kernel CMA size (optional)
RK_POST_BUILD_SCRIPTThe configured script will be executed before packaging rootfs.img (the script is placed in the directory corresponding to
BoardConfig) (optional)
RK_PRE_BUILD_OEM_SCRIPTThe configured script will be executed before packaging oem.img (the script is placed in the directory corresponding to
BoardConfig) (optional)

Partition table description

The SDK uses the env partition to set up the partition table, and the partition table information is configured in the RK_PARTITION_CMD_IN_ENV parameter in <SDK>/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NOR-NONE-T36_V10-IPC.mk.

export RK_PARTITION_CMD_IN_ENV="64K(env),128K@64K(idblock),128K(uboot),3M(boot),3M(rootfs),7M(oem),2M(userdata),-(media)"

The partition table is saved in the configuration in the form of a string. The following are examples of partition tables for each storage medium.

Storage mediaPartition table
eMMCRK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),4M(uboot),32M(boot),2G(rootfs),-
(userdata)"
spi nand 或slc
nand
RK_PARTITION_CMD_IN_ENV="256K(env),256K@256K(idblock),1M(uboot),8M(boot),32M(rootfs),-
(userdata)"
spi norRK_PARTITION_CMD_IN_ENV="64K(env),128K@64K(idblock),128K(uboot),3M(boot),6M(rootfs),-
(userdata)"

The format of each partition is: <size>[@<offset>](part-name), where the partition size and partition name are required, and the offset depends on the situation (see below Note the third point). There are a few things to note when configuring the partition table:

  1. Separate partitions with commas ",".
  2. The units of partition size are: K/M/G/T/P/E, which are not case-sensitive. If there is no unit, the default is byte; "-" means that the partition size is the remaining capacity.
  3. If the first partition starts from the 0x0 address, no offset is added. Otherwise, the offset must be added. Subsequent partitions optionally add offsets.
  4. The offset and size of the idblock partition are fixed, please do not modify them.
  5. It is not recommended to modify the env partition name. (If you want to modify the env address and size, you need to modify the corresponding defconfig configuration CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE of U-Boot, regenerate the firmware, erase the env data at the 0 address of the board, and then burn the new firmware)

Compile RKIPC firmware

This chapter introduces the compilation process of Buildroot firmware. It is recommended to develop under the Ubuntu 18.04 system environment. If you use other system versions, you may need to make corresponding adjustments to the compilation environment.

Preparation

Build the compilation environment

sudo apt-get 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 \

Compile SDK

CT36L configuration before compilation

In the project/cfg/BoardConfig_IPC/ directory, there are configuration files for different board types. Select configuration file 14:

./build.sh lunch
...
# Configuration files for other versions are omitted here
...
----------------------------------------------------------------
14. BoardConfig_IPC/BoardConfig-SPI_NOR-NONE-RV1106_T36_V10-IPC.mk
                             boot medium(启动介质): SPI_NOR
                          power solution(电源方案): NONE
                        hardware version(硬件版本): RV1106_T36_V10
                             application(应用场景): IPC
----------------------------------------------------------------

Which would you like? [0]: 14
[build.sh:info] switching to board: /home/lvsx/project/rv1106/test/T36X/project/cfg/BoardConfig_IPC/BoardConfig-SPI_NOR-NONE-RV1106_T36_V10-IPC.mk
[build.sh:info] Running build_select_board succeeded.

CT36B configuration before compilation

In the project/cfg/BoardConfig_IPC/ directory, there are configuration files for different board types. Select configuration file 4:

./build.sh lunch
...
# 此处省略其他版型的配置文件
...
----------------------------------------------------------------
4. BoardConfig_IPC/BoardConfig-EMMC-NONE-RV1106_T36B_V10-IPC.mk
                             boot medium(启动介质): EMMC
                          power solution(电源方案): NONE
                        hardware version(硬件版本): RV1106_T36B_V10
                             application(应用场景): IPC
----------------------------------------------------------------

Which would you like? [0]: 4
[build.sh:info] switching to board: /home/lvsx/project/rv1106/test/T36X/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-NONE-RV1106_T36B_V10-IPC.mk
[build.sh:info] Running build_select_board succeeded.

Compile

Fully automatic compilation

Fully automatic compilation will perform the above compilation and packaging operations to generate RKIPC firmware.

./build.sh

Package the firmware and the generated complete firmware will be saved to the output/image/ directory.

Partial compilation
  • Compile u-boot
./build.sh clean uboot
./build.sh uboot

# ./build.sh info You can view the detailed compilation command format of uboot

Generate image files: output/image/download.bin, output/image/idblock.img and output/image/uboot.img

  • Compile kernel
./build.sh clean kernel
./build.sh kernel

# ./build.sh info You can view the detailed compilation command

Generate image file: output/image/boot.img

  • Compile rootfs
./build.sh clean rootfs
./build.sh rootfs

After compilation, use the ./build.sh firmware command to package it into rootfs.img Generate image file: output/image/rootfs.img

  • Compile media
./build.sh clean media
./build.sh media

The storage directory of the generated files: output/out/media_out

  • Compile reference application
./build.sh clean app
./build.sh app

The directory where the generated files are stored: output/out/app_out Note: app depends on media

  • Compile kernel driver
./build.sh clean driver
./build.sh driver

The directory where the generated files are stored: output/out/sysdrv_out/kernel_drv_ko/

  • Package env.img
./build.sh env

env.img is packaged using uboot's mkenvimage tool. env.img packaging command format:

mkenvimage -s $env_partition_size -p 0x0 -o env.img env.txt

Note: $env_partition_size is different for different storage media. Please check the partition table description for details. View env.img content: strings env.img

# For example, the env.txt content of eMMC
blkdevparts=mmcblk0:32K(env),512K@32K(idblock),256K(uboot),32M(boot),2G(rootfs),1
G(oem),2G(userdata),-(media)
sys_bootargs=root=/dev/mmcblk0p5 rk_dma_heap_cma=64M rootfstype=ext4

Note: The content of env.img will be different for different storage media. You can use strings env.img to view it. blkdevparts and sys_bootargs will be passed to the kernel by uboot, and overwrite the kernel's corresponding bootargs parameters.

  • Packaged firmware
./build.sh firmware

The directory where the generated files are stored: output/image

On this page