Files
TencentOS-tiny/components/ota/common/image/ota_image.c
daishengdong 5b51d50ade add ota algorithm for device
1. effective "Differential Upgrade" patch algorithm with high compression rate
2. effective recovery algorithm support recovery firmware in blocks which has low memory consumption and wear-leveling strategies, especially suitable for embeded devices with low RAM.
3. add sample ota bootloader project, see:
board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_bootloader_recovery
4. add sample application project for download firmware through http, see:
board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_application_download_through_http
5. add sample application project for download firmware through qcloud explorer console, see:
board\TencentOS_tiny_EVB_MX_Plus\KEIL\ota\ota_application_download_through_qcloud_iot_explorer
6. an OTA markdown document is pending
2020-06-02 15:03:42 +08:00

23 lines
706 B
C

#include "crc8.h"
#include "ota_image.h"
uint8_t ota_img_hdr_crc(ota_img_hdr_t *img_hdr)
{
uint8_t crc = 0;
crc = crc8(crc, (uint8_t *)&img_hdr->magic, sizeof(uint16_t));
crc = crc8(crc, (uint8_t *)&img_hdr->new_version, sizeof(ota_img_vs_t));
crc = crc8(crc, (uint8_t *)&img_hdr->old_version, sizeof(ota_img_vs_t));
crc = crc8(crc, (uint8_t *)&img_hdr->new_crc, sizeof(uint8_t));
crc = crc8(crc, (uint8_t *)&img_hdr->new_size, sizeof(uint32_t));
crc = crc8(crc, (uint8_t *)&img_hdr->old_crc, sizeof(uint8_t));
crc = crc8(crc, (uint8_t *)&img_hdr->old_size, sizeof(uint32_t));
crc = crc8(crc, (uint8_t *)&img_hdr->patch_size, sizeof(uint32_t));
return crc;
}