改为 在压缩前添加 oem_ext 但固件启动不起来
This commit is contained in:
@@ -113,52 +113,52 @@ 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,uint32_t buff_size)
|
||||
{
|
||||
int fd = 0;
|
||||
int offset;
|
||||
int oem_size;
|
||||
int status;
|
||||
int fw_size;
|
||||
uint32_t ret = ERR_FAIL;
|
||||
uint8_t fw_prtition = PART_NUM_FW1;
|
||||
char str_buff[10]={0};
|
||||
imgHdr hdr={0};
|
||||
const imgHdr *run_fw_hdr;
|
||||
const uint8_t *data;
|
||||
const char *oem_ext_magic_str = IOT_OEM_EXT_MAGIC_STR;
|
||||
int oem_ext_magic_str_len = strlen(oem_ext_magic_str);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
status = dev_seek(fd, offset, DEV_SEEK_SET);
|
||||
if (status < 0) {
|
||||
break;
|
||||
}
|
||||
status = dev_read(fd, buff, oem_ext_magic_str_len);
|
||||
if (status < 0) {
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
mtd_get_hdr(fw_prtition,&hdr);
|
||||
if(hdr.v1.hdrVer!=hdrVer_10){
|
||||
break;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
run_fw_hdr=(const imgHdr *)(hdr.v1.runAddr-HEADER_TOLTAL_SIZE);
|
||||
fw_size=run_fw_hdr->v1.imgSize;
|
||||
data=(const uint8_t *)(hdr.v1.runAddr+fw_size-oem_ext_magic_str_len);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
os_mem_cpy(str_buff,data,oem_ext_magic_str_len);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
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) {
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
data-=4;
|
||||
oem_size=((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3]);
|
||||
data=data-oem_size;
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
if(buff_size<oem_size){
|
||||
break;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
os_mem_cpy(buff,data,oem_size);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
ret = ERR_OK;
|
||||
} while(0);
|
||||
if (fd) {
|
||||
dev_close(fd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user