Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

How to Build Firmware#

Overview#

K230 RTOS SDK is a multi-repository integrated development kit managed by repo. It includes core components such as U-Boot, OpenSBI, RT-Smart, and MPP. This document provides a complete guide to setting up the development environment, downloading the source code, and building the firmware.

Development Environment Requirements#

It is recommended to use a virtual machine or Docker and to back up your work regularly to prevent data loss.

System Requirements#

  • Operating System: Ubuntu 20.04 LTS (x86_64) Other Linux distributions have not been fully tested and may have compatibility issues.

Hardware Requirements#

  • Memory: ≥ 2 GB recommended

  • Disk space: ≥ 10 GB free space recommended

Setting Up the Development Environment#

Install System Dependencies#

# Add support for i386 architecture
sudo dpkg --add-architecture i386
sudo apt update

# Install the compiler toolchain and dependencies
sudo apt install -y --no-install-recommends \
    sudo vim wget curl git git-lfs openssh-client net-tools sed tzdata expect \
    make cmake binutils build-essential gcc g++ bash patch perl tar cpio unzip \
    file bc bison flex autoconf automake python3 python3-pip python3-dev \
    lib32z1 libncurses5-dev fakeroot pigz tree doxygen gawk pkg-config \
    libssl-dev libc6-dev-i386 libncurses5:i386 libconfuse-dev python-is-python3 scons libyaml-dev mtools

# Clean package cache
sudo apt clean

Configure the Python Environment#

# Configure a PIP mirror source (recommended)
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# Install Python dependencies
pip3 install -U pyyaml pycryptodome gmssl jsonschema jinja2

Install the repo Tool#

mkdir -p ~/.bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+rx ~/.bin/repo
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Downloading the Source Code and Building#

Directory Structure#

rtos_k230/
├── boards/          # Board support packages (BSP): power, pin, boot media, DDR configurations
├── configs/         # defconfig collection (entry-level configurations)
├── output/          # Build output directory (organized by defconfig)
├── src/
│   ├── applications # User applications (custom apps, packaged to /sdcard/app)
│   ├── opensbi/     # OpenSBI (second-stage bootloader)
│   ├── rtsmart/     # RT-Smart kernel, drivers, MPP, samples, etc.
│   ├── uboot/       # U-Boot (boot loader, partition/image loading)
│   └── canmv/       # CanMV components (included in build when CONFIG_SDK_ENABLE_CANMV is enabled)
└── tools/           # Build scripts, Kconfig, toolchain management scripts

Key Directory Details#

boards/#

  • Purpose: Stores board-level difference configurations (BSP), such as memory specifications, boot media, peripheral multiplexing, and image layout settings.

  • Typical use: Adding a new board, adjusting board-level hardware parameters (e.g. certain GPIO/power/DDR settings).

configs/#

  • Purpose: Stores *_defconfig files, which are the configuration entry points for the project.

  • Usage: After running make <board>_defconfig, the configuration is expanded into the root .config file. Subsequent make menuconfig operations build on top of this.

  • Recommendation: Fix a single verified defconfig for your team to avoid configuration drift.

output/#

  • Purpose: Output directory for each build.

  • Structure: output/<defconfig>/...

  • Common subdirectories:

    • output/<defconfig>/images/: Final flashable images (typically *.img, *.kdimg)

    • output/<defconfig>/rtsmart/: RT-Smart intermediate build artifacts

    • output/<defconfig>/uboot/, opensbi/, applications/: Per-module build artifacts

src/rtsmart/#

  • Purpose: The main RTOS directory—the core source of most runtime capabilities and samples.

  • Key top-level subdirectories:

    • rtsmart/: RT-Smart core (kernel, system components, tools)

    • mpp/: Multimedia Processing Platform (video/audio/image kernel and user-space APIs)

    • examples/: Official sample projects (peripheral, MPP, AI, integrated)

    • libs/: Common libraries and HAL (e.g. rtsmart_hal, 3rd-party, nncase, OpenCV)

  • Common development scenarios and where to look:

    • Adjusting RT-Smart system behavior: start with src/rtsmart/rtsmart/

    • Adjusting media pipeline or driver interfaces: start with src/rtsmart/mpp/

    • Testing hardware or features: pick the appropriate sample from src/rtsmart/examples/

    • Adding low-level driver wrappers or shared capabilities: start with src/rtsmart/libs/

  • Relationship to image contents:

    • src/rtsmart/examples/ compiles to the samples directory in the image (typically /sdcard/app/examples/)

    • Changes to src/rtsmart/mpp/ and src/rtsmart/libs/ affect the corresponding runtime libraries and sample behavior

src/applications/#

  • Purpose: Entry point for user-defined applications (more suitable for project delivery than samples).

  • Common workflow: Create an application directory → register in apps.mk/Kconfig → enable in menuconfig → compile and package with make.

src/canmv/#

  • Purpose: CanMV-related components and resources.

  • Note: When CONFIG_SDK_ENABLE_CANMV is disabled, this directory is not included in the build—suitable for pure RTOS image scenarios.

tools/#

  • Purpose: Build system infrastructure, including toolchain download, Kconfig parsing, and helper scripts.

  • Common command entry points: make dl_toolchain, make menuconfig, make list-def.

Common Locations for Getting Started#

  • Find flashable images: output/<defconfig>/images/

  • Find the current editable configuration: root .config (generated from defconfig + menuconfig)

  • Find default configuration templates: configs/

  • Find sample source code: src/rtsmart/examples/

  • Find custom application source code: src/applications/

Troubleshooting#

Source Code Sync Failure#

  • Symptom: repo sync reports an error or hangs

  • Solution:

    1. Check your network connection. Users in China should prefer the Gitee repository.

    2. Retry with: repo sync -j4 --fail-fast

Toolchain Not Found#

  • Symptom: make reports that the toolchain cannot be found

  • Solution: Ensure you have run make dl_toolchain and check that the toolchain files exist under ~/.kendryte/k230_toolchains.

Dependency Conflict#

  • Symptom: A library version incompatibility error during the build

  • Solution:

    1. Check installed versions with apt list --installed.

    2. Install a specific version with sudo apt install <package>=<version>.

Image Packaging Failure#

  • Symptom: The final packaging step reports that a partition is too small

  • Solution: Reduce the number of enabled examples, or modify the board’s image configuration file to increase the size of the affected partition.

Next Steps#

After following this guide, you have set up the K230 RTOS SDK development environment and built the firmware. If you have further questions, refer to the official documentation or open an issue in the code repository.

Comments list
Comments
Log in