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 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: # 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 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: 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 "/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. The format of each partition is: "[@](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: Separate partitions with commas ",". 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. If the first partition starts from the 0x0 address, no offset is added. Otherwise, the offset must be added. Subsequent partitions optionally add offsets. The offset and size of the idblock partition are fixed, please do not modify them. 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