Flash Firmware and Authorize Module

Last Updated on : 2024-11-20 02:14:53download

The firmware and license must be flashed to the module to enable the connection to the cloud services. Tuya provides various approaches to flashing and authorizing devices of different protocols.

Overview

Flashing and authorization combined

This approach allows you to complete both firmware flashing and module authorization by using the Cloud Module Burning Authorization Platform. This platform is integrated with the software for flashing firmware to Tuya standard chip. Before flashing firmware, you need to upload the firmware binary file to the Tuya Developer Platform as instructed and get the license (also known as the credential).

Flashing and authorization separated

This approach is used when you debug code or when the Cloud Module Burning Authorization Platform is not integrated with the flashing software for the chip you use. You have two options for flashing firmware, depending on how you implement authorization.

  • Write the license without using Tuya’s host: Tuya provides a license list in a spreadsheet. You need to write the license to firmware and perform firmware flashing and module authorization by using flashing software.
  • Write the license using Tuya’s host: Upload the firmware binary file to the Tuya Developer Platform as instructed and get the credential (authorization only). Then, authorize your module by using Tuya’s Cloud Module Burning Authorization Platform and flash firmware by using flashing software.

Upload binaries

To use Tuya’s Cloud Module Burning Authorization Platform for authorization, upload the firmware binary file to the Tuya Developer Platform in the Hardware Development step.

  1. Add firmware

    Go to Hardware Development and click Add Custom Firmware.

    Flash Firmware and Authorize Module

  2. Enter firmware information

    You can hover over the question mark ? right after each item to check out the description.

    • Firmware identifier: It must be identical to the one set in the step Configure firmware.

    • Flash size: It can be found in the module datasheet.

      Flash Firmware and Authorize Module Flash Firmware and Authorize Module

    After setup, click Generate Firmware Key. If you get an error saying The firmware identifier already exists, change it to another one. Make sure the firmware identifier is unique. You can set it as you prefer. For example, chipset platform + product type + product feature + manufacturer or individual name initials.

  3. Configure firmware

    Open the tuya_ble_sdk_demo.h file under tuya_ble_sdk_demo\app. Set the value for PID, firmware identifier, and firmware version. Make sure the firmware identifier is identical to the one set in the step Enter firmware information.

    For more information about defining firmware version, see Firmware Versions. For Bluetooth Low Energy (LE) firmware, the version number is in the format bv.sv (0.0 to 99.99), corresponding to the lower 16 bits of the value of TY_DEVICE_FVER_NUM. For example, if the version number is 1.10, the value of TY_DEVICE_FVER_NUM is set as 0x0000010A (00 00 01 0A).

    /* Replace "xxxxxxxx" with the PID of your Bluetooth product created on the Tuya Developer Platform. */
    #define TY_DEVICE_PID         "xxxxxxxx"
    
    /* Set the firmware name and version number, which must be identical to the one specified when you add firmware. */
    #define TY_DEVICE_FIR_NAME    "ble_module_sdk_development_demo"
    #define TY_DEVICE_FVER_NUM    0x00000001
    #define TY_DEVICE_FVER_STR    "0.1"
    

    Open the tuya_ble_sdk_test.h file under tuya_ble_sdk_demo\app. Set the value of TUYA_BLE_SDK_TEST as 0 to disable the test mode.

    /* Change 1 to 0 to disable the test mode. */
    #define TUYA_BLE_SDK_TEST     0
    
  4. Build firmware

    Build the code to generate firmware. For the TLSR825x platform, we recommend that you refresh the project in the workspace before building the project. In the example, the generated firmware binary file is ble_sdk_multimode\8258_module\8258_module.bin.

    Flash Firmware and Authorize Module
  5. Add firmware version

    Click New firmware version to upload the firmware binary file.

    Flash Firmware and Authorize Module

  6. Upload firmware

    You can hover over the question mark ? right after each item to check out the description.

    • Firmware version: It must be identical to the one set in the step Configure firmware.

    • Production firmware: The manufacturer will flash it to the chip.

    • User area firmware: The manufacturer will flash it to the chip.

    • Firmware updates: Used for deploying an OTA update. If you upload firmware for the first time, you can ignore this option.

      For the TLSR825x platform, we upload the same 8258_module\8258_module.bin file for the production firmware, user area firmware, and firmware updates.

      Flash Firmware and Authorize Module

    If you upload firmware in the step Enter firmware information and get an error saying The firmware identifier already exists after clicking Save, click Back and change the firmware identifier. Make sure to change the value of TY_DEVICE_FIR_NAME in the tuya_ble_sdk_demo.h accordingly. After modification, go back to the Upload Firmware page. Hover over the uploaded file 8258_module.bin, click Delete, and upload the updated file.

  7. Enable firmware

    Flash Firmware and Authorize Module

  8. Select the firmware to enable and set the deployment scope. Click Save and Enable.

    Flash Firmware and Authorize Module
  9. Manage firmware

    In the left navigation pane, choose Product > Firmware Management. Click Details to view firmware information.

    Flash Firmware and Authorize Module

Get license

Module

On the Hardware Development page, select the desired module and then perform the following steps to get licenses.

  1. Click Buy Now to buy the module.

    New users are entitled to two free licenses. For more information, see Step 5 in this section.

    Flash Firmware and Authorize Module

  2. Set the Quantity and click Buy Now to confirm the order. If everything is correct, click Submit Order.

    Flash Firmware and Authorize Module

  3. If you want to buy a license only, in the left navigation pane, choose Purchase > Production. Under the Materials & Licenses tab, buy the Generic License.

    Flash Firmware and Authorize Module

  4. On the Details page, click Select Product and Delivery Mode.

    Flash Firmware and Authorize Module

    Flash Firmware and Authorize Module

    Flash Firmware and Authorize Module

  5. If you click Get 2 Free Licenses, select Delivery Mode and confirm.

    Flash Firmware and Authorize Module

  6. Choose Purchase > Order > Debugging & Sample Order. Download the license for your product.

    Flash Firmware and Authorize Module

Sandwich development board

This section describes how to get the license for Tuya Sandwich development board.

  1. In the left navigation pane, choose Product > Evaluation Kit. Click Add Development Board and enter the required information.

    Flash Firmware and Authorize Module

  2. Click Request a new authorization code. Select the target product and click OK to get the license.

    Flash Firmware and Authorize Module

    If you fail to request the authorization code, you need to create an account with Smart PMS system first. The phone number used to create the Smart PMS account must be the same as the one for your Tuya Developer Platform account.

Flash firmware and authorize module

Before flashing firmware, make sure you have done the following. For more information, see Set up environment.

  • Registered with the Smart PMS system.
  • Installed the Tuya production toolkit and the flashing software provided by the chip vendor. For more information about the BTU module, see Telink BDT.
  • A development board with Tuya Bluetooth module, chip-specific programmer, and USB to TTL converter.

This section describes how to flash the firmware and authorize the module in terms of three delivery modes of the license.

Credential

  1. Connect your development board with the USB to TTL converter and the Telink programmer.

    For some chip platforms, you only need to connect the development board with the USB to TTL converter.
    For TLSR825x based board, you must connect it with both the USB to TTL converter and the Telink programmer.

    Flash Firmware and Authorize Module

  2. Open the Production Toolkit software. Log in with your Smart PMS account.

    Flash Firmware and Authorize Module
  3. Click TYDA to install the Cloud Module Burning Authorization Platform.

    Flash Firmware and Authorize Module

  4. Choose the correct COM Port. Enter Token. Select Burning Authorization for the work station.

    Flash Firmware and Authorize Module

  5. Click Run to flash the firmware and authorize the module.

    Flash Firmware and Authorize Module

License list

  1. Connect your development board with the Telink programmer.

    Flash Firmware and Authorize Module

  2. Open the tuya_ble_sdk_demo.h file. Enter a set of UUID, Authkey, and MAC address from the license list to the corresponding macro.

    #define TY_DEVICE_PID         "xxxxxxxx" /* PID */
    #define TY_DEVICE_MAC         "xxxxxxxx" /* MAC */
    #define TY_DEVICE_DID         "xxxxxxxx" /* UUID */
    #define TY_DEVICE_AUTH_KEY    "xxxxxxxx" /* Authkey */
    
  3. In the tuya_ble_sdk_demo.c file, set use_ext_license_key and device_id_len to 1 and DEVICE_ID_LEN (that is 16) respectively to enable the license to take effect.

       static tuya_ble_device_param_t tuya_ble_device_param = {
           .use_ext_license_key = 1,             /* 1-info in tuya_ble_sdk_demo.h, 0-auth info */
           .device_id_len       = DEVICE_ID_LEN, /* DEVICE_ID_LEN-info in tuya_ble_type.h, 0-auth info */
           .p_type              = TUYA_BLE_PRODUCT_ID_TYPE_PID,
           .product_id_len      = 8,
           .adv_local_name_len  = 4,
           .firmware_version    = TY_DEVICE_FVER_NUM,
           .hardware_version    = TY_DEVICE_HVER_NUM,
       };
    
  4. Build code and flash the generated binary file 8258_module.bin to the module by using the Telink Burning and Debugging Tool (BDT).

    Flash Firmware and Authorize Module

Credential (authorization only)

  1. Connect your development board with the USB to TTL converter and the Telink programmer.

    Flash Firmware and Authorize Module

  2. Open the Production Toolkit software. Log in with your Smart PMS account.

    Flash Firmware and Authorize Module
  3. Click TYDA to install the Cloud Module Burning Authorization Platform.

    Flash Firmware and Authorize Module

  4. Choose File > Set Up. Enable Only Auth and click OK.

    Flash Firmware and Authorize Module

    Flash Firmware and Authorize Module

  5. Choose the correct COM Port. Enter Token. Select Burning Authorization for the work station and click OK.

    Flash Firmware and Authorize Module

  6. Click Run to authorize module.

    Flash Firmware and Authorize Module

  7. Open Telink BDT. Flash the binary file 8258_module.bin to the module as shown in the following figure.

    Flash Firmware and Authorize Module

Flash firmware again

During debugging, if you modify the firmware, you can use the flashing software from the chip vendor and the chip-specific programmer to flash the firmware again. You do not need to authorize the module again.

  1. Connect your development board with the Telink programmer.

    Flash Firmware and Authorize Module

  2. Build code and flash the generated binary file 8258_module.bin to the module by using the Telink Burning and Debugging Tool (BDT).

    Flash Firmware and Authorize Module

Test network connection

After you complete firmware flashing and module authorization, connect the Bluetooth module to the cloud by using the Smart Life app.

  1. Open the Smart Life app.

    Option 1: On the homepage, tap + in the top right corner and choose Add Device. Tap Add and select your product.

    Flash Firmware and Authorize Module

    Option 2: On the Add Device page, tap Sensors > Temperature and Humidity Sensor (Bluetooth). When your device is displayed on the screen, tap + to pair it with the app.

    Flash Firmware and Authorize Module
  2. Open the control panel and view the firmware version.

    On the homepage, tap the added device to enter the control panel. Tap the edit icon in the top right corner. Tap Device Update to view the firmware version.

    Flash Firmware and Authorize Module
  3. Get the virtual device ID to view cloud logs.

    Tap the edit icon in the top right corner. Tap Device Information to view the Virtual ID.

    Flash Firmware and Authorize Module Flash Firmware and Authorize Module

    Log in to the Tuya Developer Platform. In the left navigation pane, choose Product > Device Details or Device Logs. Search for the target device by Device ID.

    Flash Firmware and Authorize Module

FAQs

Flashing and authorization for different chip platforms

This topic describes how to flash the firmware and authorize the module for the TLSR825x-based BTU module. If you use Bluetooth modules of other chip platforms, refer to Flash Firmware to and Authorize BT Series Modules.

Cloud Module Burning Authorization Platform

  1. Failed to get token, no permissions for actions

    Log in to the Smart PMS. Choose Production Management > Work Order Management > Activation Code Verification to confirm the credential.

    Flash Firmware and Authorize Module

  2. Incorrect COM port

    Flash Firmware and Authorize Module

    If you are prompted with error incorrect COM port 2 after tapping Run, the possible causes are:

    • The serial port driver is not installed.
    • The USB to TTL converter is not connected properly due to incorrect wiring or loose connections.
    • The port is occupied. For example, the module debugging assistant enables the port.
  3. Fail to get firmware fingerprint

    The firmware identifier or firmware version flashed to the module is inconsistent with the one associated with the license. This error usually occurs when you use the credential (authorization only). Try the following to troubleshoot:

    • Authorize the module with the credential that matches the firmware identifier and firmware version associated with the module.
    • If you use other delivery modes, try flashing and authorization again.
  4. Fail to enter production test

    If you are prompted with error failed to enter test after tapping Run, the possible causes are:

    • The device has been connected to the network for more than 15 minutes so the testing channel is shut down. You must erase corresponding data from the flash memory to initiate a test again.

    • You might choose the wrong COM port or the TX and RX pins are wrongly connected.

    • Choose File > Set Up. Select the correct Burning Baud.

    • Some chips require a stable power supply. In this case, you must use a reliable USB hub to ensure a stable voltage supply.

    For more information about the Bluetooth module test, see Production Test.