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 can be performed in any directory. The ameba.py build [args] command is used for building. Please refer to the Common Commands section for more details on this command.
The building steps are as follows:
Set up the environment:
source path/to/your/sdk/env.sh(on Windows, executeenv.bat)Select the SoC model:
ameba.py socExecute the build command:
ameba.py buildto start compiling.Intermediate files generated by CMake will be stored in the
build_RTLxxx/builddirectory.Upon completion, the firmware will be copied to the
build_RTLxxxdirectory under the current directory, whereRTLxxxrepresents the SoC model.
For more usage of the build command, please refer to Build Command.
The final build product is the image files, which users need to download into the chip.
Build Commands
ameba.py build command wraps the underlying script tools/scripts/build.py. Common commands are listed below:
Function |
Command |
Description |
|---|---|---|
Help |
|
List supported commands |
Build |
|
Incremental build of project |
Pristine Build |
|
Remove all products and build |
Specify Example |
|
Build example named ‘APP’ |
Specify Target |
|
Build specified target |
Cleanup |
|
Clean compilation products |
Debug |
|
Enter debug mode |
Help Command
If you are using the build command for the first time, use the following command to understand its usage.
ameba.py build -h
With the -h or --help option, all supported commands will be listed.
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.
ameba.py build -p
Note
A clean build will also remove the
menuconfigfolder, 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
ameba.py build -ccommand for cleanup.
Incremental Build
Without any arguments, the project will undergo incremental build, which significantly saves time compared to full build.
ameba.py build
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 ameba.py build using the -a or --app options.
ameba.py build -a <APP>
For instance, to build the ${SDK}/component/example/network_protocol/http_client example, you can input the following command:
ameba.py build -a ${SDK}/component/example/network_protocol/http_client
//or
ameba.py build -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, runningameba.py build -a <APP>will combinecomponent/soc/amebaxxx/project/default.confwithexample/.../<APP>/prj.confto use initial configuration.If
menuconfigfolder already exists in the current project, you can runmenuconfig.py -f /.../prj.conffirst or reconfigure manually, then build it usingameba.py build -a <APP>. Alternatively, you can directly useameba.py build -a <APP> -pto 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.
ameba.py build -g <TARGET>
For example, to regenerate imgtool flashloader, enter the following command:
ameba.py build -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.
ameba.py build -c
Pass CMake Cache Variables
CMake cache variables’ initial values can be set using the -D option. To inherit this functionality, ameba.py build also supports the -D option. Predefined values by CMake and user-defined values can both follow after -D.
ameba.py build -D CACHE_VAL1=VALUE1 CACHE_VAL2=VALUE2 …
Note
Native CMake command requires each variable definition to have a
-Dprefix, e.g.,-DCACHE_VAL1=VALUE1 -DCACHE_VAL2=VALUE2However,
ameba.py buildrequires all variables to follow a single-Dwith spaces, e.g.,-D CACHE_VAL1=VALUE1 CACHE_VAL2=VALUE2
Download Image
We provide ImageTool specifically for firmware download. Please refer to Image Tool .