STM Update

STM can update itself through OTA. It will flash itself through IAP and after verifying the flashed data, it will restart into the new application.

OTA has a few communication enums that can be passed into the Command message:

CommandParameterDescription
OtaOtaEraseErases the flash and prepares for flashing
OtaShowUpdatePopupShows the update popup that notifies the user that an update is underway
OtaStartTells the instrument that the update will follow

OtaErase should be sent if the instrument returned 0 in the Ok after the OtaInfo packet. If there are some packets present on the instrument, we should skip that many packets and continue from where it was last.

ShowUpdatePopup should be sent before a device starts updating and should be sent for both nRF and STM updates. The popup hides when the End is sent at the end of update.

OtaInfo contains a field overall_crc32, which should be compared with the last update that was done, so that we can track if there are some packets of this update already present or not.

OTA has a message called OTA with three fields:

FieldDescription
seq_numNumber of the packet in the update procedure
addressThe location the bytes will be written to
byte_arrayThe bytes to be written

OTAInfo has a message called OTAInfo with three fields:

FieldDescription
number_of_packetsNumber of all packets in the update procedure
overall_crc32CRC32 calculated over the whole binary
firmware_versionVersion of the new firmware

OTA also reuses the global End command:

CommandParameterDescription
EndFinish the update

After the End command is sent, the STM verifies the flashed parts of the flash, switches to the new application and reboots.

If the overall checksum doesn't match, it returns N_OK and shows a popup, otherwise it returns OK and reboots.

Replies

Commands OtaErase, Start and End will reply with OK or N_OK commands depending on the status of the command that was executed last.

STM Update procedure

STM Update procedure