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.

Advanced - Custom Firmware#

Note

This chapter introduces how to develop on K230 CanMV. If you do not have custom requirements, you may skip this chapter.

Overview#

K230 CanMV is a Micropython + OpenMV application platform developed based on the K230 SDK, allowing users to call hardware resources through the Python language. This document provides two build methods:

  • Build with Docker (recommended): No need to install any build dependencies, completes the build with a single command

  • Build directly on host: Manually set up the environment on Ubuntu 20.04


Direct Local Compilation#

It is recommended to use Docker for compilation. Only when Docker cannot be used, refer to the following manual setup process.

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 \
    mtd-utils inetutils-ping locales \
    make cmake binutils build-essential gcc g++ bash patch perl tar cpio unzip \
    rsync file bc dosfstools mtools bison flex autoconf automake \
    python3 python3-pip python3-dev python-is-python3 \
    lib32z1 scons libncurses5-dev fakeroot pigz tree doxygen gawk pkg-config \
    libyaml-dev libconfuse-dev libssl-dev libc6-dev-i386 libncurses5:i386
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 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 ~/canmv_k230 && cd ~/canmv_k230

# Download from Gitee (recommended for users in China, 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 users)
# repo init -u https://github.com/canmv-k230/manifest \
#   --repo-url=https://github.com/canmv-k230/git-repo.git --repo-branch stable

repo sync -j $(nproc)

# Download toolchain (only once for the first time)
make dl_toolchain

# Select board-level configuration and compile
make k230_canmv_01studio_defconfig
time make

Build Output#

After the build completes, the image files will be generated in the output/<defconfig>/images/ directory.

Common files:

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

  • *.kdimg: K230BurningTool USB flashing or OTA upgrade


Directory Structure#

canmv_k230/
├── boards/          # Board Support Package (BSP)
├── configs/         # defconfig configuration entries
├── output/          # Build output (organized by defconfig)
├── src/
│   ├── applications # User-defined applications
│   ├── canmv/       # CanMV components
│   ├── opensbi/     # OpenSBI (secondary bootloader)
│   ├── rtsmart/     # RT-Smart kernel, drivers, MPP
│   └── uboot/       # U-Boot
└── tools/           # Build scripts, kconfig, etc.

Key Directories#

Directory

Description

output/<defconfig>/images/

Final flashable image

configs/

Default configuration templates (run make list-def to view all)

src/canmv/

CanMV component source code

src/applications/

User-defined application entry

Frequently Asked Questions#

k230 command not found#

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

repo sync failed#

  1. Check the network connection; domestic users should use the Gitee mirror

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

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

Toolchain download failed#

The toolchain is stored in the Docker volume k230_toolchains. The first download is large; when the network is unstable, you can download in batches:

k230 download-toolchains TC1     # Download TC1 first
k230 download-toolchains TC3     # Then download TC3
Comments list
Comments
Log in