English
English
简体中文
Contact Us
Register
Log In

Flash Firmware and Authorize Module

Last Updated on : 2022-11-24 02:49:28download

Firmware can be generated and uploaded to the Tuya IoT Development Platform based on the no-code development solution or custom development solution. Then, you must flash the firmware to the module and authorize the module.

This topic describes the following three methods to flash the firmware and authorize the module:

  • Custom development: applies to the product release step in the custom development solution.

  • Sandwich development board: flashes firmware to and authorizes the Sandwich development board.

  • Flashing tool from the chip manufacturer: applies to the development step. In this method, the module is authorized only once and firmware can be flashed multiple times.

    In the following sections, a credential, a license, and a token mean the same thing.

Preparation

Before you flash the firmware and authorize the module, the following requirements must be met:

  • A PMS account is requested.
  • The Cloud Module Burning Authorization Platform software is downloaded.
  • The Beken Writer flashing tool from the chip manufacturer is downloaded.
  • A USB to UART adapter is obtained.

Register with the PMS

Select Personal developer in Type and enter the registration information. Then, you will receive Tuya’s approval email.

Flash Firmware and Authorize Module

Download and install Cloud Module Burning Authorization Platform

Download Cloud Module Burning Authorization Platform

Log in to the Smart PMS. Choose Knowledge Base Management > Software Download. Find Cloud Module Burning Authorization Platform and download it.

Flash Firmware and Authorize Module

Install Cloud Module Burning Authorization Platform

  1. Open the installer. When you are prompted with the following window, click More info and then click Run anyway.

    Flash Firmware and Authorize Module
  2. Follow the onscreen instructions to begin installing. You can specify an installation directory as needed.

  3. After installation, open the software and log in with your Smart PMS account and password. Click Network Module to install the flashing and authorization software.

  4. Check the installation result.

    Flash Firmware and Authorize Module

  5. Open the software and click File > Set Up.

    Flash Firmware and Authorize Module

  6. Go to Basic Setting, change 1*1 for Multi Selection to 1*2, and then click OK.

    Flash Firmware and Authorize Module
  7. You will have two yellow screen sections.

  8. Then, change 1*2 back to 1*1. This software will work fine.

Download flashing tool

Click bk_writer_gui to download the Beken Writer flashing tool.

Flash firmware

The flashing process varies, depending on different development boards or modules. If you develop with the Sandwich development board, we recommend that you use the Cloud Module Burning Authorization Platform software to flash the firmware.

Custom development

This method applies to the product release step in the custom development solution. Specifically, upload the compiled firmware to the Tuya IoT Development Platform, get the token, and then use the Cloud Module Burning Authorization Platform software to flash the firmware and authorize the module.

The module can access the Tuya IoT Development Platform only after it is authorized. To flash the existing or updated firmware to the authorized module, follow the instructions in Flashing tool from chip manufacturer.

Upload firmware

  1. Log in to the Tuya IoT Development Platform, click the target product, and then go to the Hardware Development step. Click Add Custom Firmware and complete the required information.

    Parameter Description
    Firmware Identifier The Firmware Identifier must be identical to the name of the project folder under the apps directory. Assume that the firmware identifier is wifi_one_light. Upload the production file of the project wifi_one_light under the apps directory.
    Flash Size The Flash Size is 16 Mbit, equal to 2 MB. For more information about the supported flash models, see the network module documentation. Note: 1 byte = 8 bits. 16 Mbit ÷ 8 = 2 MB
    Parameters not boxed in red Use default settings.

    Flash Firmware and Authorize Module

  2. Click Upload Firmware to upload the firmware in the next step. Set the following parameters and click Save.

    Parameter Description
    Firmware Version The Firmware Version must be identical to the one used for compilation.
    Production Firmware Upload the binary file with the suffix QIO.
    User Area Firmware Upload the binary file with the suffix UA.
    Firmware Updates Upload the binary file with the suffix UG.
    Flash Firmware and Authorize Module
  3. Click Enable Firmware.

    Flash Firmware and Authorize Module
  4. Select General availability in Deployment Scope and click Save and Enable.

    General availability is selected to facilitate product management for you as an individual developer. If your product is built for mass production, proceed with caution when choosing the development scope.

    Flash Firmware and Authorize Module

Get production credentials

After the firmware is uploaded to and enabled on the Tuya IoT Development Platform, you can get free licenses. They are required when you flash the firmware and authorize the module by using the Cloud Module Burning Authorization Platform software.

  1. Click Get 2 Free Licenses.

    Flash Firmware and Authorize Module

  2. For Delivery Mode, choose Credential and click Submit.

    • Credential: The flashing and authorization software writes a unique credential to a device. It can read the specified numbers of credentials and write them to devices in bulk. To use credentials, make sure you have uploaded the production firmware to the Tuya IoT Development Platform.
    • License List: A list provides license information in plain text, which must be written to devices manually one by one.
    • Credential (Authorization Only): The flashing and authorization software writes a unique credential to a device for the purpose of authorization only without the need for firmware.

    Flash Firmware and Authorize Module

  3. Click View Order List.

  4. Find your product by PID and click Download Credential.

    Flash Firmware and Authorize Module

  5. Extract the downloaded file and open the Token_information.txt file. Copy the credential.

  6. Open the software, enter your credential in the token input box, and then select Burning Authorization for the work station.

    If you get an error message saying Failed to get token, no permissions for actions, follow the instructions in this FAQ to troubleshoot the problem.

  7. Your screen will look like the figure below. Basic Information displays the firmware states.

    Flash Firmware and Authorize Module

Flash firmware and authorize module

  1. Open the software, click Enter Token, enter your credential, select Burning Authorization for the work station, and then click OK.

    Flash Firmware and Authorize Module

  2. Connect your board to your computer. The pin connection table is as below:

    USB to UART converter pins Sandwich SoC development board pins
    VCC VCC
    GND GND
    TX RX
    RX TX
  3. Select the correct COM Port and click Run. Immediately power off the board and power on it again. Alternatively, you can directly press the reset button to restart the board.

    • To restart the board, do not directly disconnect the USB to UART converter from your computer. Otherwise, flashing will fail. We recommend that you disconnect the VCC and GND jumper wires between the board and the USB to UART converter and connect them again.
    • The CBU development board comes with a USB to serial CH340 chip. After you click Run on the software, press the reset button on the board to restart it.

    Flash Firmware and Authorize Module

  4. (Optional) If the production test failed to be entered, the possible cause is that the board has been connected to the network for more than 15 minutes and the testing channel has been shut down. For more information about this issue, see Failed to enter production test.

Sandwich development board

This method applies only when you flash the firmware to and authorize the Sandwich development board.

For the products created based on the no-code development solution on the Tuya IoT Development Platform, they must be bound with the Sandwich SoC microcontroller board. This way, you can request licenses as the credentials (tokens) from the Tuya Sandwich Evaluation Kit. Otherwise, if your account is not bound with a Sandwich SoC microcontroller board, the network module cannot be granted a token for the product in the no-code development solution. Thus, flashing and authorization cannot be implemented for the module.

Bind Sandwich development board

Go to Tuya IoT Development Platform > Product > IoT Lab > Evaluation Kit, and click Add Development Board. In the dialog box that appears, enter the ID and password of the board.

Flash Firmware and Authorize Module

Get the token

After the board is bound, click Request a new authorization code for the board, and in the dialog box that appears, select the target product to get the token.

Flash Firmware and Authorize Module

Flash firmware and authorize module

  1. Copy the token from the Tuya IoT Development Platform and open the Cloud Module Burning Authorization Platform software.

    Flash Firmware and Authorize Module
  2. Flash the firmware and authorize the module. For more information, see Flash firmware and authorize module.

Flashing tool from the chip manufacturer

This method applies to the development step. In this method, the module is authorized only once and firmware can be flashed multiple times. The module must be authorized before flashing. Select the correct flash partition to ensure writing to the right section. Otherwise, the program cannot run as expected.

During development, flashing and authorization is always required each time the Cloud Module Burning Authorization Platform software is used. To accelerate the development, you can use the tool from the chip manufacturer. In this case, the module is authorized only once and the authorization data is retained for flashing multiple times.

Beken Writer

The Beken Writer tool is used only to flash the firmware to the application zone and is unable to authorize the module. You can use this tool to flash an authorized module. Therefore, you do not need to upload firmware to the Tuya IoT Development Platform for flashing and authorization with the Cloud Module Burning Authorization Platform software each time the firmware is updated.

Perform the following steps:

  1. Select the chip model of the target module from the Flashing Object drop-down list (No.1). For more information, see Datasheets of Network Modules.

  2. Click Browse (No.2) to select the compiled binary file with the suffix UA. This file is the firmware in the application zone and the specified firmware is wifi_one_light.

  3. Set Start Address (No.3) to 0x00011000 and set Operation Length (No.4) to 0x00119000.

  4. Select the correct serial port from COM Port (No.5) and set Baud Rate (No.6) to the maximum value to accelerate the flashing speed.

  5. Click Run (No.7). Immediately power off the board and power on it again to start flashing. The updated firmware will be flashed to the module. In this method, repeated module authorization with the Cloud Module Burning Authorization Platform software is not required.

    Flash Firmware and Authorize Module

FAQs

Failed to get token, no permissions for actions

When you enter the credential, an error message saying Failed to get token, no permissions for actions is returned.

Flash Firmware and Authorize Module

Troubleshooting:
Log in to the Smart PMS. Choose Production Manage (No.1) > Work Order Management (No.2) > Activation Code Verification (No.3). Enter your credential with issue and click OK (No.5). Go back to the software. Enter your credential again and you should be good to go.

Flash Firmware and Authorize Module

Bus contention error

This error occurs possibly because other software occupies the required serial port for flashing.

Troubleshooting:
Close all flashing tools, or plug off the USB to TTL converter and plug it into the computer.

Failed to get firmware fingerprint

In the authorization-only scenario, the failure to get the firmware fingerprint might occur. The possible cause is that the flashed firmware name or version number does not match the authorized firmware name or version number.

Troubleshooting:

  1. Enter the token that matches the firmware fingerprint and then run authorization.

  2. Try flashing and authorization again. This method does not apply to the production certificate of Authorization Only.

    Flash Firmware and Authorize Module

Failed to enter production test

If the module is paired and powered for 15 minutes, the module cannot enter the test mode again. During flashing and authorization, if the failure of entering the production test occurs and the log entry have actived over 15 min, not enter mf_init appears, this means the device has disabled the production test.

Troubleshooting:
You need to erase the flashing data before the authorization is successful.

Flash Firmware and Authorize Module

Modify code (generic method)

If the failure of entering the production test occurs, you can call the function mf_test_ignore_close_flag() ; in the function pre_device_init() of the file tuya_device.c to ignore the flag that disables the production test. This avoids the authorization failure caused by the disabled production test.

Flash Firmware and Authorize Module

Erase data with chip manufacturer’s tool for Beken series

  1. Open the bk_writer tool provided by the chip manufacturer and change Flashing Object to the required chip. For more information, see Datasheets of Network Modules.

    Settings for development boards with Beken chips:

    • WB3S: Select BK7231 from the Flashing Object drop-down list.
    • CBU: Select BK7231N from the Flashing Object drop-down list.
    • Enter 0x001EE000 in Start Address (No.2) and 0x00012000 in Operation Length (No.3).
  2. Select the COM port (No.4), click Erase Flash (No.5), and then restart the module to start erasing the memory data.

    Flash Firmware and Authorize Module