CLI Build and Download

Introduction

This chapter illustrates how to build Realtek’s SDK under CLI environment, then download the image to the chip.

Build Flow

Configuring and building need to be carried out under the SoC project directory, where the required Python scripts are located. The script build.py is used for building.

  • 进入工程目录: {SDK}/amebadplus_gcc_project

Note

{SDK} 替换为用户自己的 SDK 路径。

  • 执行编译脚本: build.py ,开始编译

  • 编译完成后,固件将被拷贝到 /amebadplus_gcc_project 路径下,用户也可以在如下文件夹看到固件:

    • /amebadplus_gcc_project/project_km0/asdk/image

    • /amebadplus_gcc_project/project_km4/asdk/image

  • CMake 生成的中间文件将会被存放在 build 文件夹。

  • 如果生成失败, 尝试运行 build.py -c 后重新编译。

../../_images/dplus_km4_km0_projects_make_all.png

KM4 & KM0 工程编译日志

../../_images/dplus_km4_km0_image_generation.png

KM4 & KM0 固件生成

Note

如果想要获取 .map 文件进行调试, 请在如下路径中查找:

  • /amebadplus_gcc_project/project_km0/asdk/image

  • /amebadplus_gcc_project/project_km4/asdk/image

The final build product is the image files, which users need to download into the chip.

Build Commands

Realtek provides a build.py script to simplify the build command of projects. Common commands are listed below:

Function

Command

Description

Help

build.py -h

List supported commands

Build

build.py

Incremental build of project

Pristine Build

build.py -p

Remove all products and build

Specify Example

build.py -a <APP>

Build example named ‘APP’

Specify Target

build.py -g target

Build specified target

Cleanup

build.py -c

Clean compilation products

Debug

build.py -debug

Enter debug mode

Help Command

If you are using the build.py script for the first time, use the following command to understand its usage.

build.py -h

With the -h or --help option, all supported commands will be listed.

build.py -h
usage: build.py [-h] [-a APP] [-c] [-p]
               [-g {flashloader,imgtool_flashloader,gen_imgtool_floader}]
               [-gdb] [-debug] [-D DEFINED [DEFINED ...]] [--new NEW [NEW ...]]

options:
-h, --help            show this help message and exit
-a APP, --app APP     application path
-c, --clean           clean
-p, --pristine        pristine build
-g {flashloader,imgtool_flashloader,gen_imgtool_floader}, --target {flashloader,imgtool_flashloader,gen_imgtool_floader}
                        custom target
-gdb, --gdb           gdb
-debug, --debug       debug
-D DEFINED [DEFINED ...], --Defined DEFINED [DEFINED ...]
                        user defined variables
--new NEW [NEW ...]   build.py --new-prj <target_dir> [-a <APP>]

Pristine Build

Pristine build means that there are no previous residual products affecting this build. All previously products and configurations will be removed before this build. The -p option is equivalent to the --pristine option.

build.py -p

Note

  • A clean build will also remove the menuconfig folder, and any previous configurations will be discarded. This build process will use initial configurations.

  • If you only need to clean up the build artifacts but want to retain the previous configurations, use the build.py -c command for cleanup.

Incremental Build

Without any arguments, the project will undergo incremental build, which significantly saves time compared to full build.

build.py

Build Specified Example

Some application examples are provided under the ${SDK}/component/example directory. To build one of these examples, pass the application name or path to build.py using the -a or --app options.

build.py -a <APP>

For instance, to build the ${SDK}/component/example/network_protocol/http_client example, you can input the following command:

build.py -a ${SDK}/component/example/network_protocol/http_client
//or
build.py -a http_client

If you do not pass an app name or path through -a, it will build a default application, which only enables wireless connection.

Note

  • The examples provide file named prj.conf. When you have not configured the project, running build.py -a <APP> will combine amebaxxx_gcc_project/default.conf with example/.../<APP>/prj.conf to use initial configuration.

  • If menuconfig folder already exists in the current project, you can run menuconfig.py -f /.../prj.conf first or reconfigure manually, then build it using build.py -a <APP>. Alternatively, you can directly use build.py -a <APP> -p to delete previous configuration files.

Build Specified Target

By default, all necessary targets will be built together. Specific targets can be built individually using the -g or --target options. Use the -h option to view all available targets.

build.py -g <TARGET>

For example, to regenerate imgtool flashloader, enter the following command:

build.py -g gen_imgtool_floader

Project Cleanup

Both -c and --clean clean up the current project’s products and intermediate files. But .config files will be retained.

build.py -c

Pass CMake Cache Variables

CMake cache variables’ initial values can be set using the -D option. To inherit this functionality, build.py also supports the -D option. Predefined values by CMake and user-defined values can both follow after -D.

build.py -D CACHE_VAL1=VALUE1 CACHE_VAL2=VALUE2 …

More details about cache variables for this project can be found in the CMakeLists.txt file under the ${SDK}/amebaxxx_gcc_project directory.

Note

  • Native CMake command requires each variable definition to have a -D prefix, e.g., -DCACHE_VAL1=VALUE1 -DCACHE_VAL2=VALUE2

  • However, build.py requires all variables to follow a single -D with spaces, e.g., -D CACHE_VAL1=VALUE1 CACHE_VAL2=VALUE2

Download Image

We provide ImageTool specifically for firmware download. Please refer to Image Tool .