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
.
This chapter introduces the composition of the development environment, and how to set up the CLI environment. Both Windows and Linux platforms will be coverd.
For Windows: Windows 10 64-bit is used as a platform.
For Linux server: Ubuntu 22.04 64-bit is used as a platform.
Preparing GCC Environment
The GCC environment includes the CMake compilation environment, Python environment, and other tool software, as shown in the table below。
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 |
Users can download the software package provided by Realtek and configure environment variables by scripts. This method will not affect the user’s original software environment and can avoid compatibility issues caused by software version differences.
Download the compressed package and extract it to the
/opt/rtk-toolchainfolder.mkdir /opt/rtk-toolchain cd /opt/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 you encounter network issues when downloading, try to use the aliyun url:
wget https://rs-wn.oss-cn-shanghai.aliyuncs.com/prebuilts-linux-1.0.3.tar.gzNote
The compressed package needs to be extracted to the default
/opt/rtk-toolchainpath. If need to change the path, refer to change toolchain path .Install Python manually since a portable version of Python cannot be provided under Linux.
sudo apt install python3 python3-pip python3-venvNote
Run
python --versionto check version of Python, recommended to use version greater than 3.10.If pip version is outdated, it’s recommended to update using the command:
pip install --upgrade pip.If there are multiple versions of Python on the host, you can use the command
update-alternatives --install /usr/bin/python python /usr/ bin/python3.x 1to select a specific version of Python, wherexinpython3.x 1represents the desired version number.If you encounter the error
command 'python' not found, try running the following command to solve the issue:ln -s /usr/bin/python3 /usr/bin/python
Install dependencies
sudo apt install libssl-dev libncurses-devEnter into the root directory of SDK and run
source ameba.sh, which will automatically configure the environment variables.source ameba.sh PIP CHECK... All packages are installed correctly! ======================================================== | First choose IC platform: cd [IC]_gcc_project | Configure command: menuconfig.py | Build command: build.py ======================================================== (.venv)
Note
The environment variables will be reset after terminal closed. Therefore, the scripts need to be run again when you open a new terminal.
Create a new folder
C:\rtk-toolchainunder Disk C.Download the compressed package and extract it to the
C:\rtk-toolchainfolder.Download Link
Users in mainland China are advised to use the aliyun link.
Note
The compressed package needs to be extracted to the specified
C:\rtk-toolchainpath. If you need to change the path, refer to change toolchain path.Navigate to the SDK root directory and double-click the
ameba.batscript. This will automatically configure the environment variables, then you can type commands in this opened terminal.PIP CHECK... All packages are installed correctly! ======================================================== | First choose IC platform: cd [IC]_gcc_project | Configure command: menuconfig.py | Build command: build.py ======================================================== (.venv) C:\sdk>
Note
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 ameba.sh.
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 ameba.bat script again. This will automatically reinstall the Python virtual environment.
Installing Toolchain
By default, the toolchain will be automatically installed in default path when building the project at the first time:
Linux:
/opt/rtk-toolchainWindows:
C:\rtk-toolchain
Before the compilation, the build scripts will check if the toolchain exists and if the version of the toolchain match the lastest version. Once error occurs, you should fix the error according to the prompts on the screen and try building again.
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 any issues with the download, please verify that your host machine can correctly access GitHub. If you cannot access GitHub, use the following commands to switch the download source:
build.py -D USE_ALIYUN_URL=True
If you need to modify the toolchain installation path, create an environment variable
RTK_TOOLCHAIN_DIRin your system and assign it the modified installation path.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 ~/.bashrc
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.
Note
If you already have a downloaded toolchain archive, move the archive to the installation path and run
build.pyagain.If you encounter the error
Download Failed, check your network connection. If the issue persists, refer to Step 2.If you encounter the error
Create Toolchain Dir Failed. May Not Have Permission, try creating the folder manually. If the issue persists, refer to Step 3 to change the default installation path.
After completing the above steps, the following files will be present under the rtk-toolchain path:
|--- prebuilts-[win/linux]-1.x.x
|
|--- asdk-10.3.1-xxxx
|
|--- vsdk-10.3.1-xxxx