Step 0: Environment Setup
Set up the toolchain TuyaOpen needs on your computer, download the repository, and activate tos.py โ the command-line tool you use to configure, build, and flash every project.
Prepare hardwareโ
Before you start, prepare the following:
- A TuyaOpen-compatible development board or module
- A USB data cable
- A computer running Windows, Linux, or macOS
Install the toolchainโ
Select your operating system and install the required tools.
It is recommended to use the LTS versions of Ubuntu 24, 22, and 20.
Install the necessary tools:
sudo apt-get install lcov cmake-curses-gui build-essential ninja-build wget git python3 python3-pip python3-venv libc6-i386 libsystemd-dev
Download and activate TuyaOpenโ
Clone the TuyaOpen repository.
You can adjust the git configuration to improve clone performance:
git config --global http.postBuffer 524288000
Do not use Chinese characters or special characters such as spaces in the project path. On Windows, do not place the project on the C drive.
# Use GitHub
git clone https://github.com/tuya/TuyaOpen.git
# Or use Gitee
git clone https://gitee.com/tuya-open/TuyaOpen.git
# Enter the project
cd TuyaOpen
Activate tos.py.
You must reactivate tos.py each time you reopen the terminal.
. ./export.sh
Verify the activation by running tos.py version and tos.py check. You should see output similar to the following:
โฏ tos.py version
[INFO]: Running tos.py ...
[INFO]: v1.3.0
โฏ tos.py check
[INFO]: Running tos.py ...
[INFO]: [git] (2.43.0 >= 2.0.0) is ok.
[INFO]: [cmake] (4.0.2 >= 3.28.0) is ok.
[INFO]: [make] (4.3 >= 3.0.0) is ok.
[INFO]: [ninja] (1.11.1 >= 1.6.0) is ok.
[INFO]: Downloading submodules...
[INFO]: [do subprocess]: cd /home/huatuo/work/open/TuyaOpen && git submodule update --init
[INFO]: Download submodules successfully.
If the check command fails:
# Tool validation failed. Please install or upgrade the required tools.
# Submodules download failed. Manually execute the git command.
git submodule update --init
When you are done, deactivate tos.py.
deactivate
For a full description of tos.py, run tos.py --help or see CLI - tos.py Development Tool.
FAQsโ
Activation of tos.py failsโ
-
Activation can fail because
python3-venvis not installed. Install it and try again.sudo apt-get install python3-venv -
Activating
tos.pycreates the./.venvdirectory automatically. If activation fails, delete the./.venvdirectory and activate again.