Last Updated on : 2024-06-24 08:13:31download
An over-the-air (OTA) update is the wireless delivery of new software, firmware, or other data to connected devices.
The MCU SDK supports OTA updates for the MCU. You can first upload the update file to the Tuya Developer Platform. The Bluetooth module can download the update from the server and send it to the MCU through the serial port. This way, the MCU gets the update and writes it to the local flash memory for installation. For more information, see Update Firmware and Select and Manage Firmware Versions.
The OTA update consumes the memory of the MCU. After a device is paired, an OTA update can be initiated through the preset configuration or check for updates. The following diagram describes how it works.
The following table lists the commands used in the MCU OTA update process.
Command | Description |
---|---|
0xE8 | The Bluetooth module queries the MCU’s version number |
0xE9 | MCU proactively reports version number |
0xEA | Initiate an update request |
0xEB | Send the update file information |
0xEC | Request the update file offset |
0xED | Transmit the update file |
0xEE | Request the update result |
The Bluetooth module uses this command to query the MCU version number while it gets the MCU information using the command 0x01
.
The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xE8 |
4 5 |
2 | Data length | 0x00 0x00 |
6 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Example: 55 AA 00 E8 00 00 E7
The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xE8 |
4 5 |
2 | Data length | 0x00 0x06 |
6 to 11 | 6 | Data | See the following table |
12 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
1 to 3 | 4 to 6 |
---|---|
Soft_Ver | Hard_ver |
Soft_Ver
: The firmware version of the MCU. For example, 0x01 00 02
represents v1.0.2.
Hard_ver
: The hardware version of the MCU, the PCBA version number.
Example: 55 AA 00 E8 00 06 01 00 00 01 00 00 EF
The MCU proactively sends its version number to the module after startup (generally after the UART initialization). If the module does not respond, the MCU will resend the message.
The MCU sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xE9 |
4 5 |
2 | Data length | 0x00 0x06 |
6 to 11 | 6 | Data | See the following table |
12 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
1 to 3 | 4 to 6 |
---|---|
Soft_Ver | Hard_ver |
Soft_Ver
: The firmware version of the MCU. For example, 0x01 00 02
represents v1.0.2.Hard_ver
: The hardware version of the MCU, the PCBA version number.Example: 55 AA 00 E9 00 06 01 00 00 01 00 00 F0
The module returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xE9 |
4 5 |
2 | Data length | 0x00 0x01 |
6 | 1 | State | Return value |
7 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Return value of state
:
0x00
: SuccessExample: 55 AA 00 E9 00 01 00 E9
The Bluetooth module initiates an update request to get the maximum length of one packet for serial transmission.
The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEA |
4 5 |
2 | Data length | 0x00 0x02 |
6 to 7 | 2 | The maximum length of one packet Len1 |
See the description below |
8 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Len1
: The maximum length of a packet that can be transmitted over the serial port, in the unit of bytes.
Example: 55 AA 00 EA 00 02 00 C8 B3
The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEA |
4 5 |
2 | Data length | 0x00 0x06 |
6 to 11 | 6 | Data | See the following table |
12 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
1 | 2 to 4 | 5 to 6 |
---|---|---|
Flag | The MCU’s current firmware version (Version ) |
The MCU-specified maximum length of a packet (Len2 ) |
Flag
: 0x00
indicates the update is accepted. 0x01
indicates the update is rejected.Version
: The current firmware version. For example, 0x01 00 02
represents v1.0.2.Len1
: The module-specified maximum length of a packet.Len2
: The MCU-specified maximum length of a packet. If Len1
is less than Len2
, Len1
prevails. Otherwise, Len2
prevails.Example: 55 AA 00 EA 00 06 00 01 00 00 00 C8 B8
The module sends the information about the firmware update to the MCU. The MCU determines whether to accept the update accordingly.
The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEB |
4 5 |
2 | Data length | 0x00 0x23 |
6 to 40 | 35 | Data | See the following table |
41 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
8 bytes | 3 bytes | 16 bytes | 4 bytes | 4 bytes |
---|---|---|---|---|
Product ID (PID) | File version | File MD5 hash | File length | CRC32 |
0x010002
represents v1.0.2.The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEB |
4 5 |
2 | Data length | 0x00 0x19 |
6 to 30 | 25 | Data | See the following table |
31 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
1 byte | 4 bytes | 4 bytes | 16 bytes |
---|---|---|---|
State | The size of the update that has already been downloaded. | The CRC32 checksum of the update that has already been downloaded. | The MD5 hash value of the update that has already been downloaded. (Not used currently) |
State
:
0x00
: The update is performed as expected.0x01
: The received PID does not match the one written to the device.0x02
: The update version is earlier than or equal to the current version.0x03
: The update size exceeds the upper limit.0
, meaning downloading from scratch.Send the start offset of the file and compare it with the offset returned by the MCU. If the two match exactly, the file transfer can continue from that offset. Otherwise, the entire file will be transferred from scratch.
The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEC |
4 5 |
2 | Data length | 0x00 0x04 |
6 to 9 | 4 | Offset | See the following table |
10 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Offset
: Indicate where to start downloading the update. The value has four bytes.
The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEC |
4 5 |
2 | Data length | 0x00 0x04 |
6 to 9 | 4 | Offset | See the following table |
10 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Offset
: the start offset specified by the MCU.
The start offset address specified by the MCU should take precedence over the one provided by the app. The MCU-specified offset is usually less than the one provided by the app.
The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xED |
4 5 |
2 | Data length (Len) | Upper 8 bits Lower 8 bits |
6 to 6+Len-1 | Len | Data | See the following table |
6+Len | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Data format
2 bytes | 2 bytes | 2 bytes | n byte(s) |
---|---|---|---|
Packet ID | The length (n) of current packet data | The CRC16 checksum of the current packet | The payload of the current packet |
The packet ID starts from 0
. The length of the current packet cannot exceed the specified maximum length of a packet.
The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xED |
4 5 |
2 | Data length | 0x00 0x01 |
6 | 1 | State | Return value |
7 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Return value of state
:
0x00
: Success.0x01
: Packet ID error.0x02
: The data length does not match the expected one.0x03
: CRC check failed.0x04
: Other errors.The module sends the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEE |
4 5 |
2 | Data length | 0x00 0x00 |
6 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
The MCU returns the following data.
No. | Bytes | Field | Description |
---|---|---|---|
0 1 |
2 | Header | 0x55 0xAA |
2 | 1 | Version number | 0x00 |
3 | 1 | Command (CMD) | 0xEE |
4 5 |
2 | Data length | 0x00 0x01 |
6 | 1 | State | Return value |
7 | 1 | CRC8 | Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder |
Return value of state
:
0x00
: Success.0x01
: The total data length error.0x02
: The data length does not match the expected one.0x03
: Other errors.A: For Bluetooth LE + X devices, such as Bluetooth LE and LET Cat.1 combo devices, please note that a valid CRC32 checksum cannot be sent when the device is updated over the LTE Cat.1 channel. Therefore, the MCU should use MD5 to verify the update file. The CRC16 checksum of the update package is valid and available.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback