Skip to main content

SDK Image Compilation

Luckfox-Nova-SDK is primarily developed and tested on the Ubuntu 22.04 LTS operating system. To minimize potential compilation errors and other issues during development, it is recommended that users use the same version of the OS to ensure consistency and stability of the development environment.

[TIP]
  1. Currently, only Ubuntu 22.04 x86_64 is supported; other platforms and architectures are not yet compatible.
  2. Following the instructions in this document strictly will ensure successful image compilation. If errors occur, please first check your own environment.

1. Introduction to Luckfox-Nova-SDK

An SDK (Software Development Kit) is a set of tools, libraries, sample code, documentation, and related resources that help developers build applications for a specific platform, OS, hardware, or software. The operating system on the development board is usually customized and developed based on the SDK. The SDK provides the fundamental software (kernel, drivers, bootloader, etc.) required by the board. Developers can customize on top of this base to generate system firmware that runs on the board.

1.1 SDK SDK Directory Structure

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

  1. SDK directory layout:

    ├── build.sh -> device/rockchip/common/scripts/build.sh ---- SDK build script
    ├── app ----------------------------- Upper-layer applications and demos
    ├── buildroot ----------------------- Root filesystem based on Buildroot (2024)
    ├── device/rockchip ----------------- Board configuration and firmware build scripts/files
    ├── docs ---------------------------- General guides, chip platform docs, Linux system development docs, etc.
    ├── external ------------------------ Third-party repos (display, multimedia, camera, network, security, etc.)
    ├── kernel -------------------------- Linux kernel source
    ├── output -------------------------- Stores firmware outputs, build info, XMLs, host environment details
    ├── prebuilts ----------------------- Cross-compilation toolchains
    ├── rkbin --------------------------- Rockchip binary blobs and tools
    ├── rockdev ------------------------- Firmware output directory (symlink to output/firmware)
    ├── tools --------------------------- Common tools for Linux and Windows
    ├── u-boot -------------------------- U-Boot source (based on v2017.09)
    └── yocto --------------------------- Yocto 5.0-based root filesystem
  2. Firmware image directory:

    rockdev/
    ├── MiniLoaderAll.bin --------------- 1st-stage bootloader loaded by BootROM; initializes hardware and loads U-Boot; usually provided by SoC vendor
    ├── parameter.txt -------------------- Firmware packaging configuration (partition sizes, order, addresses, etc.)
    ├── trust.img ------------------------ TrustZone firmware (e.g., Arm Trusted Firmware, OP-TEE) for secure boot and services
    ├── uboot.img ------------------------ U-Boot 2nd-stage loader; initializes devices and loads the kernel
    ├── boot.img ------------------------ Contains Linux kernel and initial boot scripts (initramfs or ramdisk)
    ├── rootfs.img ----------------------- Root filesystem ("/") including apps, libraries, configs; typically ext4 or squashfs
    └── update.img ----------------------- Complete firmware upgrade package combining the above components

1.2 SDK Configuration Files

1.Configuration files for the Nova series SDK are located in the device/rockchip/rk3308 directory.

-rwxrwxr-x 1 xt xt 333  58 10:07 luckfox_rk3308b_64bit_defconfig
-rw-rw-r-- 1 xt xt 541 58 10:07 parameter-64bit-luckfox.txt
-rw-rw-r-- 1 xt xt 599 58 10:07 parameter-64bit.txt
-rw-rw-r-- 1 xt xt 347 58 10:07 rockchip_defconfig

2. Compiling Images on Ubuntu 22.04

1.1 Set Up Build Environment and Compile the Entire Image

  1. Install required dependencies: (Not listed here but assumed necessary):

    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 curl
  2. Set up Python environment:

    #默认情况下链接的是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 provided network disk link and extract it.(Note: Do not copy the extraction command directly, as the SDK filename may change with updates.)

    mkdir Nova-sdk && cd Nova--sdk
    tar -xzvf Luckfox_Nova_SDK_250430.tar.gz
  4. Unpack the downloaded SDK archive.

    .repo/repo/repo sync -l
  5. Compile the firmware image:

    $ ./build.sh lunch

    ############### Rockchip Linux SDK ###############

    Manifest: luckfox-linux-5.10-rk3308_v1.0_20250407.xml

    Log colors: message notice warning error fatal

    Parsing supported commands...

    Log saved at /home/xt/Luckfox/rk3308/250508/output/sessions/2025-06-19_21-17-41
    Pick a defconfig:

    1. rockchip_defconfig
    2. luckfox_rk3308b_64bit_defconfig
    Which would you like? [1]: 2
    $ ./build.sh

1.2 Partial Compilation

In embedded development, firmware usually consists of multiple partition images such as boot, rootfs, and uboot. To improve efficiency, developers often use "partial compilation" to only rebuild the modified components instead of the entire system, speeding up debugging and deployment.

For example, if you modify the kernel driver configuration or device tree, you can simply recompile the kernel to regenerate boot.img, then either flash that image separately or include it in the final firmware package.

  1. Compile U-Boot separately.

    ./build.sh uboot
    • Generates: rockdev/MiniLoaderAll.bin, rockdev/uboot.img
  2. Compile kernel separately

    ./build.sh kernel
    • Generates: rockdev/boot.img
  3. Package firmware (actual steps not shown)

    ./build.sh firmware