Skip to main content

SDK Image Compilation

Luckfox-Lyra-SDK is primarily developed and tested on the Ubuntu 22.04 LTS system. To minimize potential compilation errors and other issues during the development process, it is recommended that users utilize the same operating system as us to ensure consistency and stability in the development environment.

[NOTE]
  1. Currently, only the Ubuntu 22.04 x86_64 environment is supported. Other platform architectures are not yet compatible.
  2. Follow the documentation steps strictly to compile the image successfully. If you encounter errors, check your environment settings first.

1. Introduction to Luckfox-Lyra-SDK

SDK (Software Development Kit) is a collection of tools, libraries, sample code, documentation, and related support files to help developers build applications for specific platforms, operating systems, hardware, or other software. The operating system on the development board is typically customized and developed based on the SDK. The SDK provides the basic software required for the development board (kernel, drivers, Bootloader, etc.), which developers can customize to create the final system firmware that runs on the development board.

1.1 SDK Directory Explanation

The SDK project directory includes directories such as buildroot, yocto, app, kernel, u-boot, device, docs, external, and prebuilts. It uses a manifest to manage the repositories and the repo tool to manage each directory or its corresponding git projects.

  1. SDK Directory Structure.

    ├── build.sh -> device/rockchip/common/scripts/build.sh ---- SDK compilation script
    ├── app ----------------------------- Contains upper-layer applications (mainly demo apps)
    ├── buildroot ----------------------- Root filesystem developed based on Buildroot (2024)
    ├── device ----------------- Contains chip board-level configurations and scripts/files for SDK compilation and firmware packaging
    ├── docs ---------------------------- Contains general development guidance documents, chip platform-related documents, Linux system development-related documents, and other reference materials
    ├── external --------------------- Contains third-party related repositories, including display, audio and video, cameras,networking, security, etc.
    ├── kernel -------------------------- Contains code for Kernel development
    ├── output -------------------------- Stores information on generated firmware, compilation information, XML files, host environment, etc.
    ├── prebuilts ----------------------- Contains cross-compilation toolchains
    ├── rkbin --------------------------- Contains Rockchip-related binaries and tools
    ├── rockdev ------------------------- Stores compiled output firmware, actually a symlink to output/firmware
    ├── tools --------------------------- Contains commonly used tools for Linux and Windows operating systems
    ├── u-boot -------------------------- Contains U-Boot code developed based on version v2017.09
    └── yocto --------------------------- Contains root filesystem developed based on Yocto 5.0
  2. Image Storage Directory.

    rockdev/
    ├── MiniLoaderAll.bin --------------- SPL bootloader, responsible for initializing the basic hardware and loading subsequent firmware
    ├── parameter.txt -------------------- Partition table information
    ├── uboot.img ------------------------ U-Boot image
    ├── boot.img ------------------------ Kernel image
    ├── rootfs.img ----------------------- Root filesystem image file
    └── update.img ----------------------- Complete image file

1.2 SDK Configuration File Explanation

  1. Lyra series SDK configuration files are located in the device/rockchip/rk3506 directory.

    -rw-rw-r-- 1 xt xt 1538 1210 19:58 amp_linux.its
    -rw-rw-r-- 1 xt xt 482 1210 20:00 luckfox_lyra_buildroot_sdmmc_defconfig
    -rw-rw-r-- 1 xt xt 527 1210 20:00 luckfox_lyra_buildroot_spinand_defconfig
    -rw-rw-r-- 1 xt xt 487 1210 20:00 luckfox_lyra_plus_buildroot_sdmmc_defconfig
    -rw-rw-r-- 1 xt xt 532 1210 20:00 luckfox_lyra_plus_buildroot_spinand_defconfig
    -rw-rw-r-- 1 xt xt 344 1210 20:00 parameter-lyra-sdmmc.txt
    -rw-rw-r-- 1 xt xt 333 1210 20:00 parameter-lyra-spinand.txt
    drwxrwxr-x 2 xt xt 4096 1210 19:58 rk3506_oem
    -rw-rw-r-- 1 xt xt 1053 1210 19:58 smp.its
    -rw-rw-r-- 1 xt xt 1738 1210 19:58 thunderboot4recovery.its
    -rw-rw-r-- 1 xt xt 1234 1210 19:58 thunderboot.its
    -rw-rw-r-- 1 xt xt 1665 1210 19:58 zboot4recovery.its
    -rw-rw-r-- 1 xt xt 1424 1210 19:58 zboot.its

2. Compiling Images in Ubuntu 22.04 Environment

[TIP]

Avoid using the sudo command indiscriminately during the image compilation process. Improper use may lead to file permission changes and cause the build to fail.

2.1 Setting Up the Compilation Environment

  1. Install dependency environments.

    sudo apt update
    sudo apt-get update && sudo apt-get install git ssh make gcc libssl-dev \
    liblz4-tool expect expect-dev 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 \
    libgucharmap-2-90-dev bzip2 expat gpgv2 cpp-aarch64-linux-gnu libgmp-dev \
    libmpc-dev bc python-is-python3 python2
  2. Configure the Python environment.

    # By default, it links to python3
    $ python --version
    Python 3.10.12

    which python2
    sudo ln -sf /usr/bin/python2 /usr/bin/python
  3. Download the latest SDK from the cloud link and extract the files (please do not directly copy the extraction command, as the SDK name may change with updates).

    mkdir Lyra-sdk && cd Lyra-sdk
    tar -xzvf luckfox-lyra-241213.tar.gz
  4. Unpack the decompressed files.

    .repo/repo/repo sync -l
  5. Compile the Image.

    $ ./build.sh lunch

    ############### Rockchip Linux SDK ###############
    Manifest: luckfox_linux6.1_rk3506_release_v1.4_20250620.xml

    Log colors: message notice warning error fatal

    Log saved at /home/ubuntu/Luckfox/rk3506/250815/output/sessions/2025-10-28_14-54-29
    You're building on Linux
    Lunch menu...pick the Luckfox Lyra hardware version:
    选择 Luckfox Lyra 硬件版本:
    [0] RK3506G_Luckfox_Lyra
    [1] RK3506G_Luckfox_Lyra_Plus
    [2] RK3506B_Luckfox_Lyra_Ultra
    [3] RK3506B_Luckfox_Lyra_Ultra_W
    [4] RK3506B_Luckfox_Lyra_Zero_W
    [5] RK3506B_Luckfox_Lyra_Pi
    [6] RK3506B_Luckfox_Lyra_Pi_W
    [7] custom
    Which would you like? [0~7][default:0]: 4
    Lunch menu...pick the boot medium:
    选择启动媒介:
    [0] SD_CARD
    [1] SPI_NAND
    Which would you like? [0~1][default:0]: 1
    Lunch menu...pick the system version:
    选择系统版本:
    [0] Buildroot
    Which would you like? [0~1][default:0]: 0

    $ ./build.sh

2.2 Partial Compilation

  1. Compile U-Boot Separately

    ./build.sh uboot
    • Generated image files: rockdev/MiniLoaderAll.bin, rockdev/uboot.img
  2. Compile the Kernel Separately

    ./build.sh kernel
    • Generated image file: rockdev/boot.img
  3. Compile the Root Filesystem Separately

    ./build.sh rootfs
    • Generated image file: rockdev/rootfs.img
  4. Firmware Packaging

    ./build.sh firmware

3. Packaging Custom Files into the System Image

Before packaging, the Luckfox Lyra SDK uses an overlay mechanism to add specified files into the root filesystem.

  1. Create an overlay directory: add a custom folder (for example, luckfox-overlay) under SDK/buildroot/board/rockchip/rk3506.
    Luckfox
  2. Add the file path tobuildroot/configs/rockchip_rk3506_luckfox_defconfig.
    Luckfox
  3. Compile and package.
    ./build.sh firmware

4. File Sharing

File transfer between the virtual machine and Windows computer can be achieved using Samba services for file sharing. The virtual machine's filesystem can be easily accessed through the Network Neighborhood in Windows, making it very convenient.

4.1 Ubuntu Environment Configuration

  1. Download and install Samba.

    sudo apt-get update
    sudo apt-get install samba -y
  2. Configure the Samba service.

    sudo vim /etc/samba/smb.conf

    # Add the following content at the end of the file

    [share]
    comment = share folder
    browseable = yes
    path = /home/luckfox
    create mask = 0700
    directory mask = 0700
    valid users = luckfox
    force user = luckfox
    force group = luckfox
    public = yes
    available = yes
    writable = yes
    • Where "luckfox" is the hostname; fill in according to your actual hostname.
  3. Set the sharing account password.

    sudo smbpasswd -a luckfox
  4. Check the IP address of the virtual machine or host.

    luckfox@luckfox:~/Luckfox-Pico/luckfox-pico$ ifconfig
    enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.10.61 netmask 255.255.252.0 broadcast 192.168.11.255
    inet6 fe80::814f:a51e:5f24:f0f7 prefixlen 64 scopeid 0x20<link>
    ether 08:00:27:d2:60:b9 txqueuelen 1000 (Ethernet)
    RX packets 699559 bytes 754875799 (754.8 MB)
    RX errors 0 dropped 4 overruns 0 frame 0
    TX packets 53024 bytes 3278048 (3.2 MB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 1000 (Local Loopback)
    RX packets 190 bytes 24144 (24.1 KB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 190 bytes 24144 (24.1 KB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4.2 Windows Environment

  1. Enter the IP address in the Windows address bar (fill in according to your actual IP address).
    Luckfox
  2. The default password for the virtual machine account is "luckfox".
    Luckfox
  3. Successfully log in to the virtual machine or host.
    Luckfox

FAQ

  1. if you encounter environment variable errors while compiling with WSL2, such as Your PATH contains spaces, TABs, and/or newline (\n) characters. This doesn't work. Fix your PATH, you will need to remove spaces, tabs, and newlines.

    export PATH=$(echo "$PATH" | tr -d ' \t\n')