CLI Development Environment Setup
Video Resources
Introduction
Ameba SDK supports two development environments: the CLI environment and the VS code extension environment. When developing through the VS code extension , the environment will be checked and automatically installed. For more information, please refer to
VS Code User Guide
.
The development environment of Ameba SDK consists of two parts:
Software suite: including essential tools such as cmake, ninja.
Cross-compilation toolchain: SDK supports automatic installation
This chapter introduces how to set up the CLI environment. Both Windows and Linux platforms will be covered.
For Windows: Windows 10 64-bit is used as a platform.
For Linux server: Ubuntu 22.04 64-bit is used as a platform.
Install the Software Suite
The required softwares and version requirements are as shown in the following table.
Software |
Version |
|---|---|
cmake |
3.20 or later |
ninja |
1.10.1 or later |
make |
3.82 or later |
ccache |
4.5.1 or later |
python3 |
Recommended 3.10 or later |
wget |
Recommended latest |
7zip |
Recommended latest |
Manually installing the above softwares directly into the operating system may pollute the existing software environment or cause version compatibility issues.
To address this, Realtek provides a software suite that contains all the necessary softwares and supports running in an independent environment.
Once configured, the Ameba SDK development environment is isolated within the current terminal session. The system environment outside this terminal remains unaffected, effectively avoiding software version compatibility issues.
The detailed steps for configuring the software environment on Linux and Windows are described below.
Install Python. Linux does not provide a portable Python distribution, so it must be installed via the system package manager.
sudo apt install python3 python3-pip python3-venvNote
Run
python --versionto check the Python version. 3.10 or later is recommended.If the pip version is outdated, update it with:
pip install --upgrade pip.If multiple Python versions exist on the host, use
update-alternatives --install /usr/bin/python python /usr/bin/python3.x 1to select a specific version, wherexis the desired version number.If you encounter the error
command 'python' not found, runsudo ln -s /usr/bin/python3 /usr/bin/pythonto resolve it.
Install dependencies
sudo apt install libssl-dev libncurses-devGo to the SDK root directory and run
source env.sh. The script will automatically download prebuilts and configure the environment variables.source env.sh PIP CHECK... All packages are installed correctly! ================================================================================ | Setup complete. The Ameba SDK is now ready for use. | Go to the project root directory and run ameba.py | Usage: ameba.py [COMMAND] [ARGS] | Build: ameba.py build | Select SoC: ameba.py soc | Help: ameba.py help ================================================================================ (.venv)
If the automatic download fails, manually download and extract the prebuilts to
~/rtk-toolchain(i.e.,/home/user_name/rtk-toolchain), then re-runsource env.sh:mkdir ~/rtk-toolchain cd ~/rtk-toolchain wget https://github.com/Ameba-AIoT/ameba-toolchain/releases/download/prebuilts-v1.0.3/prebuilts-linux-1.0.3.tar.gz tar -xzf prebuilts-linux-1.0.3.tar.gz
If the download fails (e.g., GitHub is inaccessible), users in mainland China are advised to use the aliyun URL instead:
wget https://rs-wn.oss-cn-shanghai.aliyuncs.com/prebuilts-linux-1.0.3.tar.gzNote
The compressed package must be extracted to the default
~/rtk-toolchain(i.e.,/home/user_name/rtk-toolchain) path. To change the path, refer to change toolchain path.
Note
The environment variables will be reset after the terminal is closed. Run source env.sh again each time you open a new terminal.
Create a new folder
C:\rtk-toolchainunder Disk C.Navigate to the SDK root directory and double-click the
env.batscript. The script will automatically download prebuilts and configure the environment variables. Once complete, you can type commands in this opened terminal.PIP CHECK... All packages are installed correctly! ================================================================================ | Setup complete. The Ameba SDK is now ready for use. | Go to the project root directory and run ameba.py | Usage: ameba.py [COMMAND] [ARGS] | Build: ameba.py build | Select SoC: ameba.py soc | Help: ameba.py help ================================================================================ (.venv) C:\sdk>
Note
The automatic download requires
curl.exeandtar.exe, which are built into Windows 10 version 1803 and later.If users want to use a Unix-like command-line environment such as Git Bash or MSYS2 on Windows, open a new terminal in the SDK root directory and run
source env.sh.
If the automatic download fails (e.g., no network connection or
curl.exeis unavailable), manually download the compressed package, save it asC:\rtk-toolchain\prebuilts-win-1.0.3.zip, then re-runenv.bat. The script will automatically extract it:Download Link
Users in mainland China are advised to use the aliyun link.
Note
To change the installation path, refer to change toolchain path.
Tip
This method relies on Python virtual environment. If you encounter Python system errors, such as messages indicating that a DLL dynamic library missing, try to remove the .venv folder in the root directory of the SDK and then run the env.bat script again. This will automatically reinstall the Python virtual environment.
Install Toolchain
The installation and update of the cross-compilation toolchain are handled automatically.
When building an SoC project for the first time, the required toolchain will be automatically installed to the following default paths:
Linux:
/home/user_name/rtk-toolchainWindows:
C:\rtk-toolchain
Please note that different MCUs may require different toolchain versions. The system will automatically check for updates and upgrade the toolchain with every build.
If an error message pops up, please resolve the issue according to the message and try to build again.
After the installation is complete, the following files will be present under the rtk-toolchain directory:
|--- prebuilts-[win/linux]-1.x.x
|
|--- asdk-1x.3.1-xxxx # for ARM
|
|--- [vsdk-10.3.1-xxxx] # for RISC-V (if required)
Note
If you already have a downloaded toolchain archive, move the archive to the installation path and run
ameba.py buildagain.If you encounter the error
Download Failed, check your network connection. If the issue persists, refer to change download source.If you encounter the error
Create Toolchain Dir Failed. May Not Have Permission, try creating the folder manually. If the issue persists, refer to change the default installation path.
Alternative Download Source
The toolchain compressed package is available on GitHub, and the system will attempt to download the toolchain from GitHub by default before the first build. If you encounter download issues or slow speeds, please try changing the download source using the following command:
ameba.py build -D USE_ALIYUN_URL=True
After executing this command, the toolchain will be downloaded from Aliyun, and compilation will proceed.
Modify Installation Path
If you do not wish to install the toolchain in the default path mentioned above, you can modify the installation path by setting the environment variable RTK_TOOLCHAIN_DIR. The setting method is as follows:
Linux:
Open the
~/.bashrcfile and add the following line at the end:export RTK_TOOLCHAIN_DIR="/path/to/your/toolchain/dir"To make the environment variable take effect immediately, please run:
source ~/.bashrcWindows:
Click to create a new variable named
RTK_TOOLCHAIN_DIRwith the value set to the desired installation path.To make the environment variable take effect, please reopen the terminal.
After modifying the installation path, please extract the Realtek software suite to this directory. The toolchain will be automatically installed into this directory when building.