Download MCU Update Files

Last Updated on : 2024-07-31 03:40:01download

The MCU can send this command to the module to initiate an update download. This OTA command differs from the OTA firmware update, which is initiated by the module.

Download MCU updates (Initiate) (0x1E)

The MCU sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1e
Data length 2 N
Data 52
  • Data[0]: the subcommand 0x00, used to request the firmware update information.
  • Data[1-n]: {"f":"calendar.bin","p":"gps?in=567","o":5678}
    Parameter description:
    • f: the file name, in string format.
    • p: the download parameter, in string format. Pass in null if no parameter is specified.
    • o: the offset address of an integer. It can be used for resumable download.
  • Data[0]: the subcommand 0x01, used to resume a download.
  • Data[0]: the subcommand 0x02, used to stop a download.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example:

  • The MCU sends the subcommand 0x00 to request the firmware update information:

    55 aa 00 1e 00xx 00 xxxxxxxxxxxxxxxx XX
    
  • The MCU sends the subcommand 0x01 to resume a download:

    55 aa 00 1e 0001 01 XX
    
  • The MCU sends the subcommand 0x02 to stop a download:

    55 aa 00 1e 0001 02 XX
    

The module returns the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1e
Data length 2 0x0009
Data 9
  • Data[0]: 0x10 indicates the firmware update information is obtained successfully.
    Data[1-4]: the size of the update, 0x000013CF.
    Data[5-8]: the CRC32 check value, 0xC20A5FBB.
  • Data[0]: 0x11 indicates obtaining the firmware update information failed.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example:

  • The module returns 0x10 to indicate the firmware update information is obtained successfully:

    55 aa 00 1e 0001 10 XX
    
  • The module returns 0x11 to indicate obtaining the firmware update information failed and the update download is stopped.

    55 aa 00 1e 0001 11 XX
    

Download MCU updates (Transfer) (0x1F)

The module sends the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1f
Data length 2 0x0044 (offset and data length)
Data 4
  • Data[0-3]: the packet offset 0x00000000.
  • Data[4-n]: the actual data payload.
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 firmware update is 530 bytes and each packet is fixed to 256 bytes in size.

  • The middle packet:

    55 AA 00 1f 01 04 00000000 xxx...xxx XX
    55 AA 00 1f 01 04 00000100 xxx...xxx XX
    
  • For the last packet, the packet offset is 0x00000212, and the packet length is 0 bytes.

    55 AA 00 1f 00 04 00000212 XX
    

The MCU returns the following data.

Field Bytes Description
Header 2 0x55aa
Version 1 0x00
Command 1 0x1f
Data length 2 0x0000/0x0001
Data 1 Data[0]:
  • 0x00: The CRC32 check succeeds.
  • 0x01: The CRC32 check fails.
Checksum 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example

  • The MCU responds to the middle packet:

    55 AA 00 1f 0000 0C          // The packet is received successfully.
    
  • The MCU responds to the last packet:

    55 AA 00 1f 0001 00 0D     // CRC32 check succeeds.
    55 AA 00 1f 0001 01 0E     // CRC32 check fails.
    

Check file download progress (0xC3)

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
  • 0x00: No file is being downloaded.
  • 0x01: File is being downloaded.
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 01 01 18 dc