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 Add a New Configuration File (New Board)#

Before starting the operation, you first need to download the K230 SDK. For the specific download path, please refer to How to Build Firmware.

Next, we will use 01studio’s board as an example to explain in detail how to add a new configuration item based on the board’s hardware conditions. In this process, the folders involved in modifications are mainly the following ones, and each step below corresponds to the specific modification method of the corresponding directory.

Module

Source File Path

Description

Global

./boards/Kconfig

Global file configuration information, used to manage system-wide related configurations

Global

./boards/

Stores packaging files for each board, which contain various board-related resources and configurations.

Global

./config/

defconfig files for each board

canmv Module

./src/canmv/port/boards

This directory stores the configuration information about boards in CanMV, used for the adaptation between CanMV software and the board

boot Module

./src/uboot/uboot/arch/riscv

The relevant directory for adding board information in U-Boot

boot Module

./src/uboot/uboot/board/kendryte

The directory for storing U-Boot configuration information

boot Module

./src/uboot/uboot/arch/riscv/dts

Records the hardware configuration information of the board, such as power and GPIO-related configurations, and is the directory where important configuration files for hardware-software interaction are located

boot Module

./src/uboot/uboot/config

Contains U-Boot menuconfig configuration information, used to configure U-Boot menu options and functions

rtsmart Module

./src/rtsmart/rtsmart/kernel/bsp/maix3/configs

Stores RTSmart menuconfig configuration information, used for RTSmart system configuration management

The following are the specific operation steps:

Modify the KConfig File to Add Board Definitions#

In the ./boards/Kconfig file, we need to add a new configuration name. The specific content to add is as follows:

        config BOARD_K230_CANMV_LCKFB
            bool "K230 CanMV LCKFB, Onboard 1GiB LPDDR4"

      + config BOARD_K230_CANMV_01STUDIO
      +     bool "K230 CanMV 01 Studio, Onboard 1GiB LPDDR4"

        config BOARD_K230D_CANMV_BPI_ZERO
            bool "K230D CanMV BPI-Zero, SiP 128MiB LPDDR4"
    default "k230_canmv_lckfb" if BOARD_K230_CANMV_LCKFB
  + default "k230_canmv_01studio" if BOARD_K230_CANMV_01STUDIO
    default "k230d_canmv_bpi_zero" if BOARD_K230D_CANMV_BPI_ZERO
config BOARD_NAME
        string "Board Generate Image Name"
        default "CanMV_K230_V1P0_P1" if BOARD_K230_CANMV
        default "CanMV_K230_V3P0" if BOARD_K230_CANMV_V3P0
        default "CanMV_K230_LCKFB" if BOARD_K230_CANMV_LCKFB
      + default "CanMV_K230_01Studio" if BOARD_K230_CANMV_01STUDIO
        default "CanMV_K230D_Zero" if BOARD_K230D_CANMV_BPI_ZERO
    source "$(SDK_BOARDS_DIR)/k230_canmv_lckfb/Kconfig"
  + source "$(SDK_BOARDS_DIR)/k230_canmv_01studio/Kconfig"
    source "$(SDK_BOARDS_DIR)/k230d_canmv_bpi_zero/Kconfig"

Add a New Board Directory in the board Directory#

The path of the newly added directory needs to be consistent with the path defined in the source section in the previous modification. The specific operation is to run the following command:

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/boards$ cp ./k230_canmv_dongshanpi ./k230_canmv_01studio -rf
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/boards/k230_canmv_01studio$ ls
Kconfig  default.env  genimage-sdcard-kdimg.cfg  genimage-sdcard-rtos.cfg  genimage-sdcard.cfg

After the addition is complete, there will be 5 files in this directory, which are introduced as follows:

  • Kconfig: is the file that must be relied upon when executing the make menuconfig command, used to configure related options. The file that make menuconfig must rely on

  • default: mainly used to define the U-Boot startup parameters, which plays a key role in the U-Boot startup process. Defines uboot startup parameters

  • genimage-sdcard-kdimg.cfg: is a segmented packaging file, used for segmented packaging of related content. Segmented packaging file

  • genimage-sdcard-rtos.cfg: the packaging file for RTSmart, related to the packaging of the RTSmart system. rtsmart packaging file

  • genimage-sdcard.cfg: the packaging file for MicroPython, used for MicroPython packaging operations. micropython packaging file

In addition, the newly added Kconfig file also needs to be modified, where the BOARD definition must be consistent with the content defined in the first step KConfig. The modification content is as follows:

if BOARD_K230_CANMV_01STUDIO

endif

Add a defconfig Configuration File in config#

In the config directory, we need to add a configuration file for a new board. You can copy one from an existing file and rename it. The specific operation command is as follows:

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/configs$ cp k230_canmv_dongshanpi_defconfig k230_canmv_01studio_defconfig

After copying, the new config configuration file needs to be modified, and at the same time, carefully check whether the configuration items inside meet the actual needs (i.e., whether these configuration items need to be used). The specific modification content is as follows:

#Modify CONFIG_BOARD_K230_CANMV_DONGSHANPAI to CONFIG_BOARD_K230_CANMV_01STUDIO
CONFIG_BOARD_K230_CANMV_01STUDIO=y
#Modify CONFIG_BOARD_CONFIG_NAME
CONFIG_BOARD_CONFIG_NAME="k230_canmv_01studio_defconfig"
CONFIG_MPP_DEFAULT_SENSOR_CSI_2=y

Add Configuration Information Under ./src/canmv/port/boards#

In the boards directory, we need to add a configuration file for a new board. You can copy one from an existing directory and rename it. The specific operation command is as follows:

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/canmv/port/boards$ cp -rf ./k230_canmv_dongshanpi/ ./k230_canmv_01studio
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/canmv/port/boards/k230_canmv_01studio$ ls
manifest.py  mpconfigboard.h

There are two files in this directory, which are:

  • manifest.py: configuration file required by micropython

  • mpconfigboard.h: header file required by micropython

The configuration of mpconfigboard.h needs to be modified:

//Select K230 or K230D according to the chip used
#define MICROPY_HW_MCU_NAME                 "K230"
#define OMV_ARCH_STR                        ""
//Modify OMV_BOARD_TYPE
#define OMV_BOARD_TYPE                      "CanMV K230 01Studio - %d%c"

Modify the Kconfig File Under ./src/uboot/uboot/arch/riscv#

+ config TARGET_K230_CANMV_01STUDIO
+ bool "Support k230_CANMV(01STUDIO)"
+ select SYS_CACHE_SHIFT_6

  source "board/kendryte/k230_canmv/Kconfig"
+ source "board/kendryte/k230_canmv_01studio/Kconfig"
  source "board/kendryte/k230d_canmv_bpi_zero/Kconfig"

Add a New Board Directory and Files Under ./src/uboot/uboot/board/kendryte#

The names of the newly added directory and files need to be consistent with the path of the source in the previous step, and the internal file names need to be modified and named as 01studio. The specific operations are as follows:

//Copy folder
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/uboot/uboot/board/kendryte$ cp -rf ./k230_canmv_dongshanpi ./k230_canmv_01studio
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/uboot/uboot/board/kendryte$ cd k230_canmv_01studio/
//Modify the file name, steps omitted (use the command mv canmv_dongshanpi_lpddr3_init_2133.c canmv_01studio_lpddr3_init_2133.c)
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/uboot/uboot/board/kendryte/k230_canmv_01studio$ ls
Kconfig   board.c                            canmv_01studio_lpddr3_init_2133.c  canmv_01studio_lpddr4_init_32_swap_2667.c
Makefile  canmv_01studio_lpddr3_init_1600.c  canmv_01studio_lpddr3_init_800.c   canmv_01studio_lpddr4_init_32_swap_3200.c
  • Makefile: is the compilation file, used to guide the compilation process, defining compilation rules and targets. Compilation file

  • Kconfig: the file that stores configuration information, used to configure related parameters and options. Configuration information file

  • board.c: this file contains the relevant information of hardware power and GPIO pins, and needs to be modified according to the actual hardware settings

  • canmv_01studio_lpddr*.c: this is the DDR configuration file. It is recommended to follow the configuration information of the reference development board to ensure the normal operation of DDR.

In addition, the Makefile also needs to be modified accordingly according to the modified file names and directories. At the same time, the information that needs to be modified in the Kconfig file is as follows:

+  if TARGET_K230_CANMV_01STUDIO

  config SYS_CPU
    default "k230"

  config SYS_VENDOR
    default "kendryte"

  config SYS_BOARD
+        default "k230_canmv_01studio"

  config SYS_CONFIG_NAME
+        default "k230_common"

  config BOARD_SPECIFIC_OPTIONS
    def_bool y
    select KENDRYTE_K230

  choice
    prompt "DDR Type And Frequency"
+        default CANMV_01STUDIO_LPDDR4_2667

+        config CANMV_01STUDIO_LPDDR3_2133
      bool "LPDDR3@2133"
+        config CANMV_01STUDIO_LPDDR3_1600
      bool "LPDDR3@1600"
+        config CANMV_01STUDIO_LPDDR3_800
      bool "LPDDR3@800"
+        config CANMV_01STUDIO_LPDDR4_2667
      bool "LPDDR4@2667"
+        config CANMV_01STUDIO_LPDDR4_3200
      bool "LPDDR4@3200"
  endchoice

endif

Determine the Board Configuration Information Based on the Hardware Under ./src/uboot/uboot/arch/riscv/dts#

#Copy an original file
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/uboot/uboot/arch/riscv/dts$ cp k230_canmv_dongshanpi.dts k230_canmv_01studio.dts

We provide an automated configuration tool IOMAX Generation Tool.

Add a uboot Configuration File Under ./src/uboot/uboot/config#

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/uboot/uboot/configs$ cp k230_canmv_dongshanpi_defconfig k230_canmv_01studio_defconfig

After copying, the following modifications need to be made:

  • Modify CONFIG_DEFAULT_DEVICE_TREE=”k230_canmv_01studio”

  • Modify CONFIG_TARGET_K230_CANMV_DONGSHANPAI to CONFIG_K230_CANMV_01STUDIO

Add a New Board menuconfig File Under ./src/rtsmart/rtsmart/kernel/bsp/maix3/configs and ./src/rtsmart/boards#

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/src/rtsmart/rtsmart/kernel/bsp/maix3/configs$ cp k230_canmv_dongshanpi_defconfig k230_canmv_01studio_defconfig

The config file also needs to be configured according to the hardware situation.

Build and Run#

The above steps complete the configuration. Next, we enter the system compilation and running:

aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard$ make list-def
Available configs:
1 [ ] k230_canmv_01studio_defconfig
2 [ ] k230_canmv_defconfig
3 [ ] k230_canmv_dongshanpi_defconfig
4 [ ] k230_canmv_labplus_1956_defconfig
5 [ ] k230_canmv_lckfb_defconfig
6 [ ] k230_canmv_v3p0_defconfig
7 [ ] k230_rtos_01studio_defconfig
8 [ ] k230_rtos_aihardware_defconfig
9 [ ] k230_rtos_evb_defconfig
10 [ ] k230_rtos_lckfb_defconfig
11 [ ] k230d_canmv_atk_dnk230d_defconfig
12 [ ] k230d_canmv_bpi_zero_defconfig
13 [ ] k230d_canmv_labplus_ai_camera_defconfig
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard$ make k230_canmv_01studio_defconfig
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard$ make
#Wait for the IMG file to be generated
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard$ cd output/k230_canmv_01studio_defconfig/
aaa@DESKTOP-OSN5BJK:~/canmv_k230_demoboard/output/k230_canmv_01studio_defconfig$ ls
CanMV_K230_01Studio_micropython_local_nncase_v2.9.0.img         Kconfig.app           applications  opensbi        rtsmart
CanMV_K230_01Studio_micropython_local_nncase_v2.9.0.img.gz      Kconfig.canmv         canmv         repo_info      uboot
CanMV_K230_01Studio_micropython_local_nncase_v2.9.0.img.gz.md5  Kconfig.rtt_examples  images        repo_info.tmp

After the compilation is complete, the generated *.img file can be copied out for upgrading the device.

Comments list
Comments
Log in