Quick Start

Last Updated on : 2024-07-26 04:30:49download

This topic describes the TuyaOS Gateway Development Kit directory, along with the compilation process, configuration files, and terminal login for the THP23-X-D development kit.

Directory

The directory structure of the TuyaOS Gateway Development Kit:

├── hardware                  # Hardware documentation.
├── pc
│    └── tools                # Development tools.
├── software
│    ├── packages             # SDK package.
│    ├── SDKInformation.json  # SDK information file.
│    └── TuyaOS               # SDK directory.
│        ├── apps             # The sample applications, which can be modified as needed.
│        ├── build
│        ├── docs             # API reference.
│        ├── include          # SDK header files.
│        ├── libs             # SDK libraries. You can link them as needed.
│        ├── scripts
│        ├── build_app.sh     # The build script.
│        ├── CHANGELOG.md
│        ├── LICENSE          # Tuya MIT License
│        ├── Makefile
│        ├── output           # The build output.
│        ├── README.md
│        └── vendor           # The toolchain. When you build a project, the toolchain is automatically downloaded to this directory.
└── tuya.json

The directory structure of the THP23-X-D Development Kit:

├── application_components    # Open source components
├── application_drivers
├── build                     # Files packaged into the firmware
├── build.conf
├── build.sh
├── include                   # Application header file
├── libs                      # Application library file
├── local.mk
├── Makefile
├── output                    # Output directory
├── package.json
├── README.md
└── src                       # Application source file

Build firmware

Here is how to build firmware:

  1. You have downloaded the THP23-X-D development kit to the TuyaOS/apps directory. For more information, see Get Development Kit.

  2. In Visual Studio Code, right-click the development kit directory and choose Build Project.

    Quick Start
  3. Enter the version number in the format x.x.x (where x is a number) and press Enter to start building.

    Quick Start
  4. The process output is shown in the Visual Studio Code Terminal window. After the process is completed, you can find the firmware file in the TuyaOS/output/tuyaos_core_board-tuyaos_gw_ssd202d/pack directory.

    Description of the generated files:

    File name Description
    gateway.tar.gz The application package for debugging.
    tuyaos_core_board-tuyaos_gw_ssd202d_*_debug The application with a symbol table for debugging with GDB.
    tuyaos_core_board-tuyaos_gw_ssd202d_fw_PROD_*.tar.gz The full firmware for production. This archive contains firmware for three different programming options.
    • Flash a blank chip
    • Flash via serial port
    • Flash via USB
    tuyaos_core_board-tuyaos_gw_ssd202d_fw_UG_*.bin The firmware update, used for OTA updates.

Configuration file

The configuration file for the THP23-X-D application is located at build > image > tuya_user1 > config.json. You can edit the configuration file as needed. For example, change the default product ID.

Description of the fields in the configuration file:

Field Required Description
pid Yes The product ID of the device.
user_cfg_file Yes The full path of this configuration file, used by the startup script.
uuid No The authorization information, typically read from flash memory and written during the production phase. This field is used only when reading fails.
authkey No The authorization information, typically read from flash memory and written during the production phase. This field is used only when reading fails.
storage_path Yes The data storage path that must be readable, writable, and end with /.
log_path Yes The log storage path that must be readable, writable, and end with /.
cache_path Yes The cache storage path that must be readable, writable, and end with /.
bin_path Yes The path of the executable file.
backup_path Yes The backup storage path. If not specified, it defaults to the storage_path.
sync_systime No Specifies whether to synchronize the system time.
log_level Yes Set the log level.
tuya No Service configuration.
tuya.zigbee No Zigbee service.
tuya.zigbee.dev_name No The serial port number.
tuya.zigbee.cts No Specifies whether to enable hardware flow control.
  • 0: Disable
  • 1: Enable
Note: Hardware flow control must be enabled for all Zigbee modules.
tuya.zigbee.thread_mode No The startup method of the Zigbee host.
  • 0: Start in process mode.
  • 1: Start in thread mode.
tuya.bt No Bluetooth service
tuya.bt.dev_name No The serial port number.
tuya.bt.enable_hb No Specifies whether to enable the Bluetooth LE heartbeat check.
  • 0: Disable
  • 1: Enable
tuya.bt.scan_timeout No The scanning interval for Bluetooth LE, in seconds.
tuya.bt.subdev_type No Set the supported sub-device types for Bluetooth. See BLE_SUBDEV_TYPE_E for the supported types.
tuya.dp_engine No DP engine service.
tuya.dp_engine.storage_path No The storage path for DP configuration files that must be readable, writable, and end with /.
tuya.dp_engine.file_max_count No The maximum number of DP configuration files.
tuya.dp_engine.pidTable_max_count No The maximum number of the pid_table elements in the DP configuration file.
tuya.dp_engine.enable_zigbee_trans No Specifies whether the DP engine supports the Zigbee protocol.
  • 0: Not supported
  • 1: Supported
tuya.dp_engine.enable_matter_trans No Specifies whether the DP engine supports the Matter protocol.
  • 0: Not supported
  • 1: Supported

Terminal login

The THP23-X-D development board uses a one-device-one-key encryption scheme. You need the password before logging in. Submit a ticket to request the password by providing the SN of your THP23-X-D development board.

  • Username: root
  • The password for U-Boot mode and the default password for full firmware flashing is tygw@SSD20x. To obtain the factory password, submit a ticket.

Log in via serial port

Connect a USB to UART converter to the debugging port on the THP23-X-D development board. Refer to the table below for wire connections:

USB to UART converter THP23-X-D development board
TX RX
RX TX
GND GND

The debugging port on the THP23-X-D development board:

Quick Start

Connect to the development board using a serial debugger such as PuTTY or SecureCRT, setting the baud rate to 115200.

Log in via SSH

SSH listens on port 2333, but it is disabled by default. You can log in via the serial port and then enable the SSH feature.

Run the following command to enable SSH.

root@SmartGateway:~# nvram set enable_ssh true
root@SmartGateway:~# nvram commit
root@SmartGateway:~# reboot

Processes

The processes for the gateway are as follows:

1100 root      2932 S    /bin/sh ./app_detect.sh ./tyZ3Gw /tmp/tuya /tmp/tuya/config.json
1106 root      2932 S    /bin/sh ./log_detect.sh /tmp/tuya.log 3
1114 root      2932 S    /bin/sh ./process_monitor.sh /tmp/tuya /tmp/tuya/config.json
1121 root      324m S    ./tyZ3Gw /tmp/tuya/tuya_user1 /tmp/tuya/config.json
Process Description
app_detect.sh Monitor the main process and restart it if it exits unexpectedly.
log_detect.sh The log backup script that compresses the backup when the log size exceeds 3 MB.
process_monitor.sh The software watchdog for the main process.
tyZ3Gw The main process.