SDK Image Compilation
Luckfox Pico-SDK is mainly developed and tested on Ubuntu LTS systems, with primary support for Ubuntu 22.04. If you are using Ubuntu 22.04, you only need to install the required dependencies before compilation. To ensure compatibility with different Ubuntu versions, we also provide a convenient Docker environment for users.
- Currently, only the Ubuntu 22.04 x86_64 environment is supported. Other platform architectures are not compatible for now.
- Follow the steps in this document strictly to configure the environment and compile the image successfully. If an error occurs, check your environment first.
1. SDK Directory Introduction
- Get the latest SDK. You can choose either of the following methods. Gitee is recommended for users in China.
git clone https://gitee.com/LuckfoxTECH/luckfox-pico.gitgit clone https://github.com/LuckfoxTECH/luckfox-pico.git
- SDK directory structure.
├── build.sh -> project/build.sh ---- SDK compilation script├── media --------------------------- Multimedia codec, ISP, and algorithm-related files (can be compiled as an independent SDK)├── sysdrv -------------------------- U-Boot, kernel, and rootfs directories (can be compiled as an independent SDK)├── project ------------------------- Reference applications, compilation configuration, and script directories├── output -------------------------- Directory for generated image files after SDK compilation└── tools --------------------------- Image packaging tools and flashing tools
- Image output directory.
output/├── image│ ├── download.bin ---------------- Device-side program used for flashing-tool upgrade communication; it is only downloaded to board memory│ ├── env.img --------------------- Contains the partition table and boot parameters│ ├── uboot.img ------------------- U-Boot image│ ├── idblock.img ----------------- Loader image│ ├── boot.img -------------------- Kernel image│ ├── rootfs.img ------------------ Root filesystem│ └── userdata.img ---------------- Userdata image└── out├── app_out --------------------- Files generated after compiling reference applications├── media_out ------------------- Files generated after compiling media-related components├── rootfs_xxx ------------------ Filesystem packaging directory├── S20linkmount ---------------- Partition mount script├── sysdrv_out ------------------ Files generated after compiling sysdrv└── userdata -------------------- Userdata
- SDK configuration files in
luckfox-pico/project/cfg/BoardConfig_IPC.BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_WebBee-IPC.mkBoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Pi-IPC.mk BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mkBoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra-IPC.mk BoardConfig-SPI_NAND-Busybox-RV1106_Luckfox_Pico_Pro_Max-IPC_FASTBOOT.mkBoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Zero-IPC.mk luckfox-buildroot-nocsi-oem-pre.shBoardConfig-EMMC-Busybox-RV1106_Luckfox_Pico_Ultra-IPC_FASTBOOT.mk luckfox-buildroot-oem-pre.shBoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico-IPC.mk luckfox-glibc-oem-pre.shBoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Mini-IPC.mk luckfox-rv1106-tb-emmc-post.shBoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk luckfox-rv1106-tb-spi_nand-post.shBoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_WebBee-IPC.mk luckfox-systemd-off-modem-post.shBoardConfig-SD_CARD-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk luckfox-userdata-pre.shBoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Mini-IPC.mk overlayBoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk - Take
BoardConfig-SD_CARD-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mkas an example. The key configuration items are described below.# Config CMA size in environmentexport RK_BOOTARGS_CMA_SIZE="66M"# Kernel dtsexport RK_KERNEL_DTS=rv1106g-luckfox-pico-pro-max.dts# Target boot mediumexport RK_BOOT_MEDIUM=sd_cardexport RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot),512M(oem),256M(userdata),6G(rootfs),-(media)"# Target rootfsexport LF_TARGET_ROOTFS=buildroot# Buildroot defconfigexport RK_BUILDROOT_DEFCONFIG=luckfox_pico_defconfig# declare overlay directoryexport RK_POST_OVERLAY="overlay-luckfox-config overlay-luckfox-buildroot-init overlay-luckfox-buildroot-shadow"- RK_BOOTARGS_CMA_SIZE: The memory allocated to the camera. If the camera is not used, you can change it to 1M.
- RK_KERNEL_DTS: Specifies the device tree file.
- RK_BOOT_MEDIUM: Specifies the target boot medium. Available options include sd_card (SD card), spi_nand (SPI NAND Flash), and eMMC.
- RK_PARTITION_CMD_IN_ENV: Configures the partition table. If you need to match the storage space of the SD card, you can modify the rootfs partition.
- LF_TARGET_ROOTFS: Specifies the target root filesystem.
- RK_BUILDROOT_DEFCONFIG: Specifies the Buildroot configuration file.
- RK_POST_OVERLAY: Stores the files to be packaged in the overlay folder.
2. SDK Image Compilation
Do not abuse the sudo command during image compilation. Otherwise, file permissions may be changed, causing the compilation process to fail.
2.1 SDK Image Compilation Process
-
Install the required dependencies.
sudo apt updatesudo apt-get install -y git ssh make gcc gcc-multilib g++-multilib module-assistant expect g++ gawk texinfo libssl-dev bison flex fakeroot cmake unzip gperf autoconf device-tree-compiler libncurses5-dev pkg-config bc python-is-python3 passwd openssl openssh-server openssh-client vim file cpio rsync curl -
Select the corresponding branch according to the actual development board model. For model information, refer to Product Introduction.
./build.sh lunchTaking the Luckfox Pico Ultra series as an example, select RV1106_Luckfox_Pico_Ultra directly.
Loading terminal... -
Then compile the full image.
./build.sh
2.2 Common Compilation Commands
- Compile the kernel separately.
./build.sh clean kernel./build.sh kernel
- Compile U-Boot separately.
./build.sh clean uboot./build.sh uboot
- Compile rootfs separately.
./build.sh clean rootfs./build.sh rootfs
- Package the firmware. This is useful when packaging custom files.
./build.sh firmware
3. Common Compilation Issues
- If WSL2 reports an environment variable error such as
Your PATH contains spaces, TABs, and/or newline (\n) characters This doesn't work. Fix yOu PATH, remove spaces, tabs, and newline characters fromPATH.export PATH=$(echo "$PATH" | tr -d ' \t\n') - During image compilation, if Buildroot packages fail to download or the download speed is slow due to network issues, use the following method.
-
Download the offline package and verify that it is complete.
File name Description Download dl Buildroot packages Baidu Netdisk link sha256sum -c dl.tar.bz2.sha256# If the download is complete, it outputs:# dl.tar.bz2: OK -
Replace the
dlfolder underluckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/with your downloaded package.tar -xjvf dl.tar.bz2 -C luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6./build.sh
-