Tuya CB Modules: Flash and Authorize Guide
Version: 20240614
1. Applicability
This guide applies to CBX series modules with the BK7231N built-in, including:
- CBU
- CBU-IPEX
- CBLC5
- CBLC9
- CB1S
- CB3S
- CB3L
- CB2S
- CB8P
- CB2L
- CB3SE
- CBU-NL
- CB3S-NL
2. Preparation
Before flashing and authorizing the module, ensure you have the following:
- An account on the Smart PMS.
- Production Toolkit software installed on your computer.
- Beken Writer from the chip vendor installed on your computer.
- A USB to UART converter.
2.1 Register with the PMS
Open Smart PMS, sign up, select 'Personal developer' in the 'Type' field, and enter your registration information. You will receive an email after registration.
The registration process involves filling in basic information such as area, type, company, mailbox, mobile number, verification code, applicant name, and the reason for application. You must also read and agree to the Terms of Service, Legal Notices, and Privacy Policy.
2.2 Download and Install Production Toolkit
2.2.1 Download Production Toolkit
- Log in to the Smart PMS.
- Navigate to 'Knowledge Base Management' > 'Software Download'.
- Find and download the 'Production Toolkit'.
2.2.2 Install Production Toolkit
- Open the installer. If prompted with a 'Windows protected your PC' message, click 'More info' and then 'Run anyway'.
- Follow the onscreen instructions to install, specifying the installation directory as needed.
- After installation, open the software and log in with your Smart PMS account and password.
- Click 'TYMZ'.
- Check the installation result. A yellow screen indicates a successful installation.
If you encounter a white blank screen, you need to configure the software:
- Go to 'File' > 'Set Up'.
- In 'Basic Setting', change 'Multi Selection' from '1*1' to '1*2' and click 'OK'.
- Change '1*2' back to '1*1'. The software should now work correctly.
2.3 Download Beken Writer
Download the Beken Writer flashing tool by clicking the provided link (e.g., bk_writer_gui_V1.6.3).
3. Flash Firmware
The flashing process varies depending on the development board or module. For the Sandwich development board, the Cloud Module Burning Authorization Platform software is recommended.
3.1 Custom Development
This method is for the product release step in a custom development solution. It involves uploading the compiled firmware to the Tuya Developer Platform, obtaining a token, and then using the Cloud Module Burning Authorization Platform software to flash and authorize the module. Only authorized modules can connect to the Tuya Developer Platform. The Beken Writer can be used to flash existing or updated firmware to an authorized module.
3.1.1 Upload Firmware
- Log in to the Tuya Developer Platform, select the target product, and navigate to the 'Hardware Development' step.
- Click 'Add custom firmware' and complete the required information.
Parameter Name: Firmware Identifier
Description: Must be identical to the project folder name under the 'apps' directory (e.g., wifi_one_light
). Upload the production file from this project folder.
Parameter Name: Flash Size
Description: Typically 16 Mbit (2 MB). Refer to the module's datasheet for the exact flash size.
Parameter Name: Firmware Version
Description: Must be identical to the version used during compilation.
Parameter Name: Firmware for production
Description: Upload the binary file with the .bin
or .QIO
suffix.
Parameter Name: User area firmware
Description: Upload the binary file with the .UA
suffix.
Parameter Name: Firmware updates
Description: Upload the binary file with the .UG
suffix.
Parameter Name: Operation mode
Description: Select the QIO
option.
After uploading firmware, click 'Upload Firmware' and then 'Save'.
Next, enable the firmware version:
- Click 'Enable Firmware'.
- Choose 'General availability' for the deployment scope and click 'Save and Enable'. 'General availability' is suitable for individual developers. Use caution for mass production scenarios.
3.1.2 Get Production Credentials
After the firmware is uploaded and enabled, obtain free licenses (credentials) from the Tuya Developer Platform. These are required for flashing and authorization using the Cloud Module Burning Authorization Platform software.
- Click 'Get 2 Free Licenses'.
- In 'Delivery Mode', select 'Credential' and click 'Submit'.
Types of credentials:
- Credential: Writes a unique credential to the device for flashing and authorization. Can be used in bulk.
- License List: Provides license information in plain text for manual entry.
- Credential (Authorization Only): Writes a unique credential for authorization without firmware.
Find your product by PID and click 'Download Credential'. Extract the downloaded file and copy the credential from the Token_information.txt
file.
Open the Cloud Module Burning Authorization Platform software, enter the credential in the token input box, and select 'Burning Authorization' for the work station.
3.1.3 Flashing and Authorization
- Open the Cloud Module Burning Authorization Platform software.
- Click 'Enter Token', input your credential, select 'Burning Authorization' as the work station, and click 'OK'.
- Connect your board to the computer using a USB to UART converter. Refer to the pin connection table for USB to UART converter pins and Sandwich SoC board pins (VCC, GND, TX, RX).
- Select the correct COM Port and click 'Run'. Immediately power off the board and then power it on again, or press the reset button to restart.
Important Notes:
- Do not disconnect the USB to UART converter during restart; this will cause flashing to fail. Disconnect and reconnect the VCC and GND jumper wires instead.
- For CBU boards with a CH340 chip, click 'Run' on the software and then press the reset button on the board.
(Optional) If you fail to enter production test, ensure the board has been connected to the network for less than 15 minutes, as the testing channel may shut down.
3.2 Sandwich Development Board
This method is for flashing and authorizing Sandwich development boards, particularly those created with the Tuya no-code development solution. The module must be bound with a Sandwich SoC microcontroller board to request credentials (tokens) from the Tuya Sandwich Evaluation Kit. Without this binding, tokens cannot be granted, and flashing/authorization cannot be performed.
3.2.1 Sandwich Development Board Setup
- Navigate to 'Tuya Developer Platform' > 'Product' > 'IoT Lab' > 'Evaluation Kit'.
- Click 'Add Development Board' and enter the board's ID and password in the dialog box.
3.2.2 Get the Token
After the board is bound, click 'Request a new authorization code for the board'. In the dialog box, select the target product to obtain the token.
3.2.3 Flashing and Authorization
- Copy the token from the Tuya Developer Platform and open the Cloud Module Burning Authorization Platform software.
- For more information, refer to the 'Flash firmware and authorize module' section.
3.3 Beken Writer
This method is for the development step, allowing unlimited flashing with a single authorization. The module must be authorized before flashing. Ensure the correct flash partition is selected for proper writing. The Cloud Module Burning Authorization Platform software is used for flashing and authorization each time. For efficiency, the chip vendor's flashing tool can flash authorized modules unlimited times.
3.3.1 Beken Writer Usage
The Beken Writer tool flashes firmware to the application zone and cannot authorize the module. It can be used to flash an authorized module. Firmware upload to the Tuya Developer Platform is not required for this tool.
- Select the target module's chip model from the 'Flashing Object' dropdown list (e.g., BK7231 for WB3S, BK7231N for CBU).
- Click 'Browse' and select the binary file with the
.UA
suffix. - Set 'Start Address' to
0x00011000
and 'Operation Length' to0x00119000
. - Select the correct serial port from 'COM Port' and set 'Baud Rate' to the maximum value for faster flashing.
- Click 'Run'. Power cycle the board to start flashing. The updated firmware will be flashed without needing re-authorization.
To erase memory data:
- Select the COM port.
- Click 'Erase Flash'.
- Restart the module.
For Beken chips, specific settings are:
- WB3S: Select BK7231 in 'Flashing Object'.
- CBU: Select BK7231N in 'Flashing Object'.
- Start address:
0x001EE000
, Operation length:0x00012000
.
4. FAQs
4.1 Failed to get token, no permissions for actions
Troubleshooting:
- Log in to Smart PMS.
- Navigate to 'Production Manage' > 'Work Order Management' > 'Activation Code Verification'.
- Enter your credential and click 'OK'.
- Return to the flashing software and re-enter your credential.
4.2 Bus contention error
Troubleshooting: Close all flashing tools or unplug and replug the USB to TTL converter.
4.3 Fail to get firmware fingerprint
This may occur if the flashed firmware name or version number does not match the authorized one.
Troubleshooting:
- Enter the correct token matching the firmware fingerprint and run authorization.
- Try flashing and authorization again (this does not apply to 'Authorization Only' certificates).
4.4 Fail to enter production test
This can happen if the module has been connected to the network for over 15 minutes, shutting down the testing channel. The message 'have activated over 15 min, not enter mf_init' indicates the device has disabled production test mode.
Troubleshooting: Erase flashing data before authorization.
4.4.1 Modify code (generic method)
To avoid authorization failure due to disabled production test, call the function mf_test_ignore_close_flag();
within the pre_device_init()
function in the tuya_device.c
file.
4.4.2 Erase data with chip manufacturer's tool for Beken series
Use the bk_writer
tool. Select the appropriate chip (BK7231 or BK7231N) in the 'Flashing Object'. Set the start address and operation length as specified (e.g., 0x001EE000
and 0x00012000
for CBU). Select the COM port, click 'Erase Flash', and restart the module.