修改 ah fw 在fw img 之后读取附加的oem数据
This commit is contained in:
@@ -31,6 +31,7 @@ Information is free from patent or copyright infringement.
|
||||
#include "iot_uart_api.h"
|
||||
#include "iot_crc_api.h"
|
||||
#include "iot_crypto_dsa_api.h"
|
||||
#include "iot_string.h"
|
||||
|
||||
/**
|
||||
* user type for iot
|
||||
@@ -110,14 +111,25 @@ uint32_t iot_oem_read_mtd(uint8_t *buf, uint32_t size, uint32_t offset)
|
||||
|
||||
|
||||
// 抓取额外的差分oem数据
|
||||
uint32_t iot_oem_read_mtd_ext(uint8_t *buff,size_t buff_size)
|
||||
uint32_t iot_oem_read_mtd_ext(uint8_t *buff,uint32_t buff_size)
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
int fd = 0;
|
||||
int offset;
|
||||
int status;
|
||||
int fw_prtition=PART_NUM_FW1;
|
||||
int fw_size;
|
||||
uint32_t ret = ERR_FAIL;
|
||||
uint8_t fw_prtition = PART_NUM_FW1;
|
||||
char str_buff[10]={0};
|
||||
const char *oem_ext_magic_str = IOT_OEM_EXT_MAGIC_STR;
|
||||
int oem_ext_magic_str_len = strlen(oem_ext_magic_str);
|
||||
|
||||
do {
|
||||
status = dev_get_boot_fw_part_num(&fw_prtition);
|
||||
if (status) {
|
||||
break;
|
||||
}
|
||||
fw_size=mtd_get_hdr_img_size(fw_prtition);
|
||||
offset=IOT_OEM_EXT_SECTION_OFFSET(fw_size);
|
||||
fd = dev_open(fw_prtition, 0);
|
||||
if (fd < 0) {
|
||||
fd = 0;
|
||||
@@ -127,6 +139,17 @@ uint32_t iot_oem_read_mtd_ext(uint8_t *buff,size_t buff_size)
|
||||
if (status < 0) {
|
||||
break;
|
||||
}
|
||||
status = dev_read(fd, buff, oem_ext_magic_str_len);
|
||||
if (status < 0) {
|
||||
break;
|
||||
}
|
||||
if(iot_strcmp(str_buff,oem_ext_magic_str) != 0){
|
||||
break;
|
||||
}
|
||||
status = dev_seek(fd, offset+oem_ext_magic_str_len, DEV_SEEK_SET);
|
||||
if (status < 0) {
|
||||
break;
|
||||
}
|
||||
status = dev_read(fd, buff, buff_size);
|
||||
if (status < 0) {
|
||||
break;
|
||||
@@ -137,7 +160,6 @@ uint32_t iot_oem_read_mtd_ext(uint8_t *buff,size_t buff_size)
|
||||
dev_close(fd);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user