Skip to main content

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.

Tip
  1. Currently, only the Ubuntu 22.04 x86_64 environment is supported. Other platform architectures are not compatible for now.
  2. 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

  1. 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.git
    git clone https://github.com/LuckfoxTECH/luckfox-pico.git
  2. 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
  3. 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
  4. 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.mk
    BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Pi-IPC.mk BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk
    BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra-IPC.mk BoardConfig-SPI_NAND-Busybox-RV1106_Luckfox_Pico_Pro_Max-IPC_FASTBOOT.mk
    BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Zero-IPC.mk luckfox-buildroot-nocsi-oem-pre.sh
    BoardConfig-EMMC-Busybox-RV1106_Luckfox_Pico_Ultra-IPC_FASTBOOT.mk luckfox-buildroot-oem-pre.sh
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico-IPC.mk luckfox-glibc-oem-pre.sh
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Mini-IPC.mk luckfox-rv1106-tb-emmc-post.sh
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk luckfox-rv1106-tb-spi_nand-post.sh
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_WebBee-IPC.mk luckfox-systemd-off-modem-post.sh
    BoardConfig-SD_CARD-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk luckfox-userdata-pre.sh
    BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Mini-IPC.mk overlay
    BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk
  5. Take BoardConfig-SD_CARD-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk as an example. The key configuration items are described below.
    # Config CMA size in environment
    export RK_BOOTARGS_CMA_SIZE="66M"

    # Kernel dts
    export RK_KERNEL_DTS=rv1106g-luckfox-pico-pro-max.dts

    # Target boot medium
    export RK_BOOT_MEDIUM=sd_card

    export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot),512M(oem),256M(userdata),6G(rootfs),-(media)"

    # Target rootfs
    export LF_TARGET_ROOTFS=buildroot

    # Buildroot defconfig
    export RK_BUILDROOT_DEFCONFIG=luckfox_pico_defconfig

    # declare overlay directory
    export 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

Tip

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

  1. Install the required dependencies.

    sudo apt update
    sudo 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
  2. Select the corresponding branch according to the actual development board model. For model information, refer to Product Introduction.

    ./build.sh lunch

    Taking the Luckfox Pico Ultra series as an example, select RV1106_Luckfox_Pico_Ultra directly.

    Loading terminal...
  3. Then compile the full image.

    ./build.sh

2.2 Common Compilation Commands

  1. Compile the kernel separately.
    ./build.sh clean kernel
    ./build.sh kernel
  2. Compile U-Boot separately.
    ./build.sh clean uboot
    ./build.sh uboot
  3. Compile rootfs separately.
    ./build.sh clean rootfs
    ./build.sh rootfs
  4. Package the firmware. This is useful when packaging custom files.
    ./build.sh firmware

3. Common Compilation Issues

  1. 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 from PATH.
    export PATH=$(echo "$PATH" | tr -d ' \t\n')
  2. 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 nameDescriptionDownload
      dlBuildroot packagesBaidu Netdisk link
      sha256sum -c dl.tar.bz2.sha256
      # If the download is complete, it outputs:
      # dl.tar.bz2: OK
    • Replace the dl folder under luckfox-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