Add a new board
tos.py new board creates a new board support package for a chip platform that TuyaOpen already supports. Through an interactive prompt and a template system, the command adds a new board configuration to an existing chip platform, which simplifies hardware porting and adaptation.
This guide is for developers who design their own hardware boards and need to adapt the driver initialization flow for that board.
Board namingโ
A board name combines required and optional fields.
Required fieldsโ
- Manufacturer name: the manufacturer of the board. Boards released by Tuya start with TUYA.
- Chip name: the platform name, such as T2 or T5AI.
Optional fieldsโ
- Key features: a functional module or characteristic that reflects the board's main feature, such as LCD or CAM.
- Series name and version: some manufacturers maintain product series, which you can reflect in the name together with a version number.
- Other: any additional hardware identifier.
Naming rulesโ
- Use uppercase English letters.
- Connect fields with underscores (
_). - Order fields as Manufacturer name_Board name_Optional fields.
- Avoid special characters.
For example: TUYA_T5AI_BOARD.
Create the boardโ
-
Run
tos.py new boardand select the target platform. The command lists all available hardware platforms.[INFO]: Running tos.py ...--------------------1. BK7231X2. ESP323. LN882H4. T25. T36. T5AI7. Ubuntu--------------------Input "q" to exit.Choice platform: 6Use the arrow keys to select the platform (T5AI here), then press Enter to confirm.
-
Enter the board name.
[NOTE] Input new board name.input: MY_CUSTOM_BOARDtipFollow the naming rules above.
-
The command generates the following file structure.
boards/<platform>/<board_name>/โโโ Kconfig # Board-level configuration fileโโโ CMakeLists.txt # CMake build configurationโโโ board_com_api.h # Board-level API declarationsโโโ board_com_api.c # Board-level API implementationsThe command also updates
boards/<platform>/Kconfigto include the configuration options for the new board.config BOARD_CHOICE_MY_CUSTOM_BOARDbool "MY_CUSTOM_BOARD"if (BOARD_CHOICE_MY_CUSTOM_BOARD)rsource "./MY_CUSTOM_BOARD/Kconfig"endif
Next stepsโ
After creating the board, verify the compilation, adapt the board API, adjust the configuration, and save the board-level default configuration.
Verify the compilationโ
-
Run
tos.py new projectto create a new project, then enter the project directory. -
Run
tos.py config choiceto select an existing configuration for the same chip platform. This saves configuration time. -
Run
tos.py config menuand select the new board. -
Run
tos.py buildto verify the compilation.
Adapt the boardโ
Modify boards/<platform>/<board_name>/board_com_api.c to adapt the new board.
Locate the OPERATE_RET board_register_hardware(void) function in the file and modify it based on the board's hardware information. For example, add initialization code for peripherals such as KEY, LED, and I2C. Refer to existing boards for the implementation.
To add other source files or header directories, modify CMakeLists.txt and configure the LIB_SRCS and LIB_PUBLIC_INC variables.
Adjust configurationโ
Run tos.py config menu to open the configuration menu and adjust functional options and parameters. Then verify the functionality together with the previous step.
Save configurationโ
Copy the app_default.config file from the project directory to the boards/<platform>/config directory, and rename it to <board_name>.config so that other developers can reuse it.
FAQโ
How do I delete a created board?โ
Delete the boards/<platform>/<board_name> directory, then manually remove the related configuration from boards/<platform>/Kconfig.
How do I rename a created board?โ
Rename the board manually:
- Rename the board directory.
- Update the references in the platform's
Kconfig. - Update the default values in the board's internal
Kconfig.