Merge pull request #12 from Tencent/master

2020-06-29merge
This commit is contained in:
Mculover666
2020-06-29 19:18:34 +08:00
committed by GitHub
3 changed files with 22 additions and 5 deletions

View File

@@ -1226,7 +1226,7 @@ static int patch_test(uint8_t *old, size_t oldsize, uint8_t *new, size_t newsize
ctrl_blk += sizeof(uint16_t);
Z = offtin_u32(ctrl_blk);
ctrl_blk += sizeof(uint16_t);
ctrl_blk += sizeof(uint32_t);
old_idx = BLK_IDX(Z, blk_len);
old_offset = Z - BLK_LOWER_BOUND(old_idx, blk_len);

View File

@@ -24,7 +24,7 @@ int hal_tcp_connect(const char *host, uint16_t port)
char port_str[PORT_MAX] = { 0 };
#define IP_MAX 16
char ip[16] = { 0 };
char ip[IP_MAX] = { 0 };
snprintf(port_str, PORT_MAX, "%u", port);

View File

@@ -20,6 +20,22 @@
#include "ota_partition.h"
#include "lzma_uncompress.h"
static int32_t offtin_u32(uint8_t *buf)
{
int32_t y;
y = buf[3] & 0x7F;
y = y * 256; y += buf[2];
y = y * 256; y += buf[1];
y = y * 256; y += buf[0];
if (buf[3] & 0x80) {
y = -y;
}
return y;
}
static uint16_t offtin_u16(uint8_t *buf)
{
int32_t y;
@@ -132,7 +148,8 @@ int ota_patch(uint32_t patch, size_t patchsize, size_t ota_size)
/* the patch4blk stuff */
uint8_t X;
uint16_t I, N, Y, Z, C, D;
uint32_t Z;
uint16_t I, N, Y, C, D;
uint8_t *ctrl_blk, *diff_blk, *extra_blk;
uint16_t cursor = 0;
uint16_t old_idx, old_offset;
@@ -285,8 +302,8 @@ int ota_patch(uint32_t patch, size_t patchsize, size_t ota_size)
Y = offtin_u16(ctrl_blk);
ctrl_blk += sizeof(uint16_t);
Z = offtin_u16(ctrl_blk);
ctrl_blk += sizeof(uint16_t);
Z = offtin_u32(ctrl_blk);
ctrl_blk += sizeof(uint32_t);
old_idx = BLK_IDX(Z, blk_len);
old_offset = Z - BLK_LOWER_BOUND(old_idx, blk_len);