Module Testing

Last Updated on : 2024-06-24 10:11:59download

This topic describes the production testing solution for modules and PCBAs based on Tuya’s Cloud Module Burning Authorization Platform.

Scenario

  • Firmware flashing by Tuya

    Tuya delivers the module that has been flashed with the license and firmware to you. The module is ready for use when you get it.

  • Firmware flashing by yourself

    You flash the license and firmware to the module with the provided tools and documentation.

  • Integrate with Tuya production testing

    Integrate your existing production system with Tuya’s host production testing SDK for authorization and testing.

  • Authorize modules with Tuya’s tool

    Authorize the module after accidentally erasing the authorization information during debugging, or update the authorization. Flash the purchased license to the module using Tuya’s Cloud Module Burning Authorization Platform.

    • To use Tuya’s Cloud Module Burning Authorization Platform, you need to upload your firmware to the Tuya Developer Platform. For more information, see Custom Firmware Management.
    • If you are not using Tuya’s Cloud Module Burning Authorization Platform and production testing SDK, you can ignore this feature.

Features

  • Flashing and authorization.

  • Read and write the MAC address, and write configuration information such as country code.

  • Test Wi-Fi and Bluetooth radio frequency.

  • Test module GPIOs.

    For TuyaOS 3.4.0 and later, GPIO testing needs to be implemented by the application.

  • Test the peripherals of PCBA.

    The peripherals vary for each PCBA board, so the framework does not handle the test commands for peripherals. Instead, it passes them to the application through callbacks for processing. You can contact your account manager or submit a service ticket to request the corresponding protocols.

Shut down testing mode

The device operates continuously for 15 minutes after activation, and then the testing mode shuts down.

How it works

Device Under TestHostTesting mode is on.Regularly send the command for entering a test.After the device is powered on, turn on the 500-millisecond window for receiving the test trigger.Enter the testing process.Send testing commands.Return the test result.Enter the normal process.alt[Command is received.][Command is not received.]Device Under TestHost

Development guide

Reference the header

  • mf_test.h

How to use

  1. Initialize the testing.
  2. If the module enters testing mode, you can initiate the testing process.
  3. If the module fails to enter testing mode, initiate the device initialization process and other initializations.
  4. Build the firmware and upload it to the Tuya Developer Platform.
  5. Purchase the license. For more information, see Cloud License and Advanced Features.
  6. Download and install Production Toolkit.
  7. Connect the module/PCBA’s test serial port to your computer using a TTL to USB converter.
  8. To test a module, use the Cloud Module Burning Authorization Platform.
    To test a PCBA, use the tools applicable to the specified product categories in the Production Solution.

API description

Initialize module testing

First, determine if the module is in testing mode. If not, the function will exit. If the module is in testing mode, a 500-millisecond window will begin for receiving the testing command.

  • If the module receives the testing command within 500 milliseconds, it will enter the testing process and run in this function.
  • If the module does not receive the testing command within 500 milliseconds, the function will exit.
  • If the function exits due to a testing mode shutdown or a timeout in receiving the testing command, it will return OPRT_OK.

typedef struct {
    MF_UART_INIT_CB uart_init;   // Initialize the test serial port.
    MF_UART_FREE_CB uart_free;   // Deinitialize the test serial port.
    MF_UART_SEND_CB uart_send;   // The test serial port sends data.
    MF_UART_RECV_CB uart_recv;   // The test serial port receives data.
    MF_USER_PRODUCT_TEST_CB mf_user_product_test;  // Commands for testing PCBA peripherals.
    MF_USER_BASIC_TEST_CB   mf_user_basic_test;    // User testing commands, such as GPIO testing.
    MF_USER_CALLBACK user_callback;                // Notification after device authorization.
    MF_USER_CALLBACK user_enter_mf_callback;       // Notification when entering module testing.
} MF_IMPORT_INTF_S;

/**
* @brief mf test init function
   *
 * @param[in] intf mf test configure data
 * @param[in] file_name App bin name
 * @param[in] file_ver User Software version
 * @param[in] wrMacEn Need write MAC or not
   *
 * @note some firmware need write MAC when mf test
   *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
   */

OPERATE_RET mf_init(IN CONST MF_IMPORT_INTF_S *intf, IN CHAR_T *file_name, IN CHAR_T *file_ver, IN BOOL_T wrMacEn);

Ignore testing mode timeout

This API is intended for debugging purposes only, to facilitate flashing and authorization. Do not use this API for production firmware.

Call this API before initializing module testing. The 500-millisecond window will be activated directly during module testing initialization, without checking if the module is in testing mode.

/**
 * @brief ignore mf test closed flag
 *
 */
VOID mf_test_ignore_close_flag(VOID);

Example

After downloading the Networked Product Development Framework, you can find the example code for all features in the tuyaos_demo_examples folder under the apps directory. See the code in service_mf_test. For the usage of the example code, see TuyaOS Example Collection.

Reference

FAQs

Why does the module fail to enter testing mode?

  • The device operates continuously for 15 minutes after activation, and then the testing mode shuts down.

  • The serial port of the module is not properly connected to the host computer.

  • The baud rate on the host does not match the serial port, causing the module to fail to receive data.

  • The user serial port and the test serial port are the same. You initialize the user serial port before initializing module testing, causing the initialization of the test serial port to fail. It is recommended to initialize the user serial port after the module testing is initialized.