Last Updated on : 2024-06-24 10:15:39download
This topic describes how to port a Bluetooth chip platform to TuyaOS, using nRF52832 as an example.
The process of porting your Bluetooth chip to TuyaOS is shown as follows:
If your chip platform is not supported by the TuyaOS development framework, you can file a request for porting to TuyaOS. After your request is approved, you will receive the TuyaOS SDK-based development framework applicable to your desired chip platform. Then, adapt, debug, and verify the TuyaOS kernel APIs on your own. After porting is completed, you can proceed with product development.
Have the following ready prior to porting.
Learn about TuyaOS.
Learn about and install Tuya Wind IDE.
Fill out the porting request using the provided template and send it to your Tuya representative.
Porting request template
Title: Apply for Porting to TuyaOS – Bluetooth
Applicant: <Your Tuya Developer Platform account>
Organization: <Your organization name>
Contact: <Your phone number>
Reason: <Specify why you want to port to TuyaOS>
Development type: <Networked product/gateway/central control product/IPC/Zigbee/Bluetooth/NB-IoT>
Remarks: <Specify your special requirements if any>
Chip details:
Name: <Chip name, such as nRF52832>
Vendor: <Chip vendor, such as Nordic>
Model: <Chip model, such as nRF52832>
Architecture: <Chip architecture, such as Arm Cortex-M4>
Chip type: <Wireless SoC or MCU>
Communication type: <This field applies when you select wireless SoC. Options include Ethernet/Wi-Fi/Wi-Fi & Bluetooth LE/Bluetooth/Zigbee/Cellular/NB-IoT>
Bit width: <16-bit/32-bit/64-bit>
Operating system: <Linux/RTOS/Non-OS>
Endianness: <Little-endian/big-endian>
Development environment:
- Development tool: such as Keil
- Development tool version: such as v5.28.0.0. You can attach a screenshot.
- Computer system: such as Windows 10 and later.
- Instructions for setting up the development environment: step-by-step instructions that should be tested on a different computer. Ensure that your instructions include the specific location and software to install.
- Step-by-step instructions for building and generating C libraries, as well as an example program. Ensure that your instructions include the required configuration options, potential errors, and their solutions.
- The purpose of the above two steps: Tuya compiles parts of the Tuya SDK source code into libraries based on the provided instructions and includes these libraries in the delivered SDK. Tuya is unfamiliar with the development environment you use so we need the instructions on generating C libraries to help us to provide the SDK you need. See the instruction template.
- Zip file: zip your files and name the compressed file as
TuyaOS_SDK_company name_chip model
, for example, TuyaOS_SDK_xxxx_nRF52832.Please find attached the TuyaOS_SDK_xxxx_nRF52832 for development environment information and instructions.
Recipient: contact your Tuya representative (account manager or project manager) for the recipient’s email address.
After your request is approved, open Tuya Wind IDE and select the TuyaOS SDK mode and then the development framework, type development kit, and chip platform to download the development framework. For more information, see Environment Setup.
Note: The security-related C library will be compiled into a library file according to your development environment. The development environment information you provide helps us generate the correct library files for your project.
Tuya prepares and provides the SDK for porting.
Review your request.
Tuya staff inputs your chip model and information into the system.
Tuya staff generates the library files based on the information you provide in Step 1. Currently, only three core component libraries are included in the Bluetooth LE development kit. .\software\TuyaOS\libs
stores the chip platforms imported by Tuya, whereas the chip platform adapted by you is located in .\software\TuyaOS\vendor\nrf52832_ble\sdk\lib
.
Generate the security library.
Package files to generate an SDK. Package the library files, source files, and other materials to create an SDK.
The SDK is published on the Tuya Wind IDE and has limited access through an allowlist. For information about how to get the SDK, see Environment Setup.
Before porting, you can try the chip platforms imported by Tuya to familiarize yourself with how the TuyaOS framework works. This can help you debug and troubleshoot your project later.
Steps to try TuyaOS:
Read the TuyaOS Quick Start and follow the instructions to download the development kit and explore the TuyaOS features.
Three key milestones in the process of porting to TuyaOS:
Put the files in the designated location.
Add the source and header files and the building succeeds.
Implement and test the APIs successfully.
.\software\TuyaOS\vendor
stores all the files for porting. Do not modify files and code in other locations.
Steps to port the SDK:
Open the SDK obtained in Step 2.
Put the chip vendor SDK in .\software\TuyaOS\vendor\xxxx_ble\sdk
.
Add all source and library files in the folders shown below to the example project provided by the chip vendor.
.\software\TuyaOS\apps\tuyaos_demo_ble_peripheral //tuyaos_demo_ble_peripheral The file name may be different
.\software\TuyaOS\components\……\src //"\software\TuyaOS\components" All subfolders under the folder.
.\software\TuyaOS\libs // If empty, do not add.
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\bluetooth
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\drivers
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\system
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\utilities
.\software\TuyaOS\vendor\nrf52832_ble\sdk\lib
Add the header file directory shown below to the example project provided by the chip vendor.
.\software\TuyaOS\apps\tuyaos_demo_ble_peripheral
.\software\TuyaOS\apps\tuyaos_demo_ble_peripheral\include
.\software\TuyaOS\components\……\include //"\software\TuyaOS\components" All subfolders under the folder.
.\software\TuyaOS\include //"\software\TuyaOS\include" All subfolders containing header files under the folder.
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
.\software\TuyaOS\vendor\nrf52832_ble\sdk\lib //".\software\TuyaOS\vendor\nrf52832_ble\sdk\lib" All subfolders containing header files under the folder.
Alter the code until it is built successfully.
With the header files in .\software\TuyaOS\include\vendor\adapter
and the API reference in \software\TuyaOS\vendor\ats2835x_bt_le\tuyaos_doc
, implement the TKL APIs stored in the source files as shown below.
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\bluetooth
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\drivers
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\include
.\software\TuyaOS\vendor\nrf52832_ble\tuyaos\system
It is not necessary to implement all the APIs. Refer to the chip platforms imported by Tuya and implement the APIs accordingly.
If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.
Self-test your implementation using the provided test cases and refer to the chip platforms imported by Tuya. After all implemented features match the imported chip platforms and all test cases are passed, send the test results to your Tuya representative.
If you encounter any issues during testing:
Refer to any of the chip platforms imported by Tuya to verify if you get the expected test results.
Post your questions in the Tuya Developer Forum.
Contact your Tuya representative.
After completing the porting and self-test, you can develop a product on your own or provide the SDK to third-party developers for product development.
To help other developers use the chip platform you have imported, it is recommended to document the platform feature descriptions. See Bluetooth LE–nRF52832 for the documentation structure.
Tuya archives the test results and your documentation of platform feature descriptions.
Most Bluetooth chips do not support RTOS, so the process above is for non-RTOS chips.
To integrate with a RTOS Bluetooth chip using TuyaOS Bluetooth LE SDK v3.9.0, follow these steps. Click to download the required file.
Replace the folder tuyaos_demo_ble_peripheral
in \software\TuyaOS\apps
.
Replace tuya_ble_port.c
and tuya_ble_main.c
in \software\TuyaOS\components\tal_ble_protocol\src
.
Add tkl_thread.c
and tkl_queue.c
in \software\TuyaOS\vendor\xxxx_ble\tuyaos\system
, where xxxx_ble
is determined by the chip platform to integrate.
Implement the APIs in tkl_thread.c
and tkl_queue.c
based on your chip platform. The example is the implementation for FR801x.
If the chip’s RAM is insufficient, you can use OS-related APIs to re-implement the APIs in tkl_memory.c
. Otherwise, it is not advisable to make any changes.
The remaining steps are the same as those for porting non-RTOS chips. See steps 1 to 6 in the previous section.
Except for fr801x_ble_os
, all the chip platforms imported by Tuya are non-RTOS chips. Download the development kit for fr801x_ble_os
:
Development Mode: TuyaOS OS Development
Type Development Kit: Sub-Device Development/Bluetooth Device Development Kit
Platform: Wireless SoC/FREQCHIP/Bluetooth/FR8018HA
TuyaOS Version: TuyaOS 3.9.4
Before downloading, contact the product manager to have your account added to the allowlist.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback