Last Updated on : 2024-07-30 03:31:16download
This topic describes how to update the MCU. You can specify how an OTA update is triggered. The module only serves as the channel for update transmission, without any data parsing operation.
Three trigger mechanisms are available:
Perform the MCU firmware update process as follows:
After the update packet transmission is finished, the module will send the command 0x01
to the MCU to query the product information.
The MCU must reply with the new MCU firmware version number within one minute. The new version number should be consistent with that configured on the Tuya Developer Platform.
Here is how the OTA update works:
The module sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x0C |
Packet length | 2 | 0x0008 |
Data | 8 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example
55 AA 00 0C 00 08 000013CF C20A5FBB DB
The MCU returns the following data.
The MCU returns the offset address to support resumable download.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x0C |
Data length | 2 | 0x0001/0x0005 |
Data | 5 |
Note: If the data length is |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example
55 AA 00 0C 00 01 00 0C // 64 bytes
55 AA 00 0C 00 01 01 0D // 128 bytes
55 AA 00 0C 00 01 02 0E // 256 bytes
55 AA 00 0C 00 05 02 00000800 1A // Start the download from the offset address of 2048 bytes.
Example:
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x0D |
Data length | 2 | 0x0044 (offset and data length) |
Data | 4 |
|
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example
Assume that the size of the update is 530 bytes, and the MCU needs to respond to the last packet.
For the first packet, the packet offset is 0x00000000
, and the packet length is 256 bytes.
55 AA 00 0D 01 04 00000000 xxx...xxx XX
For the second packet, the packet offset is 0x00000100
, and the packet length is 256 bytes.
55 AA 00 0D 01 04 00000100 xxx...xxx XX
For the third packet, the packet offset is 0x00000200
, and the packet length is 18 bytes.
55 AA 00 0D 01 04 00000200 xxx...xxx XX
For the last packet, the packet offset is 0x00000212
, and the packet length is 0 bytes.
55 AA 00 0D 00 04 00000212 XX
The MCU returns the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0x0D |
Data length | 2 | 0x0000/0x0001 |
Data | 1 | Data[0]:
Note: The module should wait for the CRC32 check result from the MCU. The legacy protocol is compatible, so it can run properly without any changes. See the example. |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example
Assume that the size of the update is 530 bytes, and the MCU needs to respond to the last packet.
For the last packet, the packet offset is 0x00000212
, and the packet length is 0 bytes.
55 AA 00 0D 00 04 00000212 XX
The MCU returns the following data.
No response within 10s // Consider that the CRC32 check succeeded.
55 AA 00 0D 00 00 0C // CRC32 check succeeded.
55 AA 00 0D 00 01 00 0D // CRC32 check succeeded.
55 AA 00 0D 00 01 01 0E // CRC32 check failed.
The MCU can send this command to request the progress of downloading the MCU updates or the NB-IoT updates.
The MCU sends the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0xC3 |
Data length | 2 | 0x0000 |
Data | 0 | None |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example:
55 AA 00 C3 00 00 C2
The module returns the following data.
Field | Bytes | Description |
---|---|---|
Header | 2 | 0x55aa |
Version | 1 | 0x00 |
Command | 1 | 0xC3 |
Data length | 2 | 0x0002 |
Data | 2 | The download status and progress. |
BYTE[0] | 1 |
|
BYTE[1] | 1 | The download progress in percentage (0 to 100). |
Checksum | 1 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder. |
Example:
55 AA 00 C3 00 02 01 05 CA
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback