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#

The K230 RTOS SDK is a multi-repository integrated development suite managed by repo, including core components such as U-Boot, OpenSBI, RT-Smart, and MPP. This document provides two build methods:

  • Build using Docker (recommended): No need to install any build dependencies; one command completes the build

  • Native build directly: Manually set up the environment on Ubuntu 20.04


Direct Local Compilation#

Docker compilation is recommended. Only refer to the following manual setup process when Docker is unavailable.

System Requirements#

  • Operating System: Ubuntu 20.04 LTS (x86_64)

  • Memory: ≥ 2GB

  • Disk: ≥ 10GB

Install System Dependencies#

sudo dpkg --add-architecture i386
sudo apt update
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
sudo apt clean

Configure Python Environment#

pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
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

Download Code and Compile#

mkdir -p ~/rtos_k230 && cd ~/rtos_k230

# Download from Gitee (Domestic, requires SSH key)
repo init -u git@gitee.com:canmv-k230/manifest.git --repo-url=git@gitee.com:canmv-k230/git-repo.git

# Download from GitHub (International)
# repo init -u https://github.com/canmv-k230/manifest --repo-url=https://github.com/canmv-k230/git-repo.git

repo sync -j $(nproc)

# Download toolchain (first time only)
make dl_toolchain

# Select board configuration and compile
make k230_rtos_01studio_defconfig
time make

Building RTOS Image from CanMV defconfig#

Some boards only have k230_canmv_*_defconfig and do not have a corresponding k230_rtos_*_defconfig. You can build a pure RTOS image based on the CanMV defconfig:

make k230_canmv_xxx_defconfig
make menuconfig

In menuconfig:

  1. Disable CanMV Components Configuration

  2. Enable RT-Smart UserSpace Examples Configuration > Enable xxxx examples as needed

  3. To build custom applications, enable the corresponding switch under Applications Configuration

After saving, compile:

make

To save as a new defconfig:

make savedefconfig
# Save the generated configuration to configs/ for team reuse

Build Output#

The generated firmware images are located in output/<defconfig>/images/, common files include:

  • *.img: SD card burning or command-line burning

  • *.kdimg: K230BurningTool USB burning or OTA upgrade


Directory Structure#

rtos_k230/
├── boards/          # Board Support Package (BSP), power, pins, DDR, etc. configuration
├── configs/         # defconfig configuration entry
├── output/          # Build output (organized by defconfig directory)
├── src/
│   ├── applications # User-defined applications
│   ├── opensbi/     # OpenSBI (secondary boot)
│   ├── rtsmart/     # RT-Smart kernel, drivers, MPP, examples
│   ├── uboot/       # U-Boot
│   └── canmv/       # CanMV components
└── tools/           # Build scripts, kconfig, toolchain management

Key Directories#

Directory

Description

output/<defconfig>/images/

Final flashable images

configs/

Default configuration templates (all options seen by make list-def)

src/rtsmart/examples/

Official example source code

src/applications/

User-defined application entry

tools/

Build infrastructure (make menuconfig, make list-def, etc.)


FAQ#

k230 command not found#

Run source ~/.bashrc or re-login to the terminal. Verify that ~/.local/bin is in $PATH.

repo sync fails#

  1. Check your network connection; users in China should use the Gitee repository

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

  3. Verify that the Gitee SSH key is configured and the corresponding private key exists under ~/.ssh

Toolchain download fails#

The toolchains are stored in the Docker Volume k230_toolchains. The initial download is large, and you can download in batches when the network is unstable:

k230 download-toolchains TC1     # Download TC1 first
k230 download-toolchains TC3     # Then download TC3

Docker permission denied#

sudo usermod -aG docker $USER
newgrp docker

Next Steps#

Comments list
Comments
Log in