改为 在压缩前添加 oem_ext 但固件启动不起来

This commit is contained in:
2024-10-28 19:37:39 +08:00
parent 538d4b4ac4
commit 8b0435853d
8 changed files with 128 additions and 100 deletions

View File

@@ -581,6 +581,7 @@ int ah_GetConfig(char *pcfgName, ah_cfg *pcfg)
int ah_add_oem_ext(char *buf)
{
int file_size;
int used_size;
char *buf_start=buf;
FILE *fp = NULL;
struct stat st;
@@ -594,8 +595,6 @@ int ah_add_oem_ext(char *buf)
} else {
printf(NEW_LINE"Open image file(%s)."NEW_LINE, file_name);
}
memcpy(buf,oem_magic_str,strlen(oem_magic_str));
buf += strlen(oem_magic_str);
fseek(fp, 0, SEEK_END);
file_size = ftell(fp);
fseek(fp, 0, SEEK_SET);
@@ -603,6 +602,16 @@ int ah_add_oem_ext(char *buf)
buf += file_size;
fclose(fp);
fp = NULL;
// 保存oem占用的长度 不包括魔法字符串长度和 used_size占用的4个字节
used_size=file_size;
// 大端
buf[0]=(used_size>>24)&0xff;
buf[1]=(used_size>>16)&0xff;
buf[2]=(used_size>>8)&0xff;
buf[3]=(used_size)&0xff;
buf+=4;
memcpy(buf,oem_magic_str,strlen(oem_magic_str));
buf += strlen(oem_magic_str);
return buf-buf_start;
}
@@ -776,6 +785,9 @@ int ah_addHeader(char argc, char *argv[])
fclose(fps);
fps = NULL;
// 在这里添加 oem_ext.bin
fileSize+=ah_add_oem_ext(p_buf + imgHeaderSize + fileSize);
crcSize = IMAGE_LEN_FOR_CRC(fileSize);
/* Clear pad bytes to '0' */
@@ -1032,10 +1044,10 @@ int ah_funConstruct(char argc, char *argv[])
/*update buffer pointer*/
p_buf += len;
// 在这里添加 oem_ext.bin
if(cfg.image[cnt].image_type == imgV1FRWPLC){
p_buf+=ah_add_oem_ext(p_buf);
}
// // 在这里添加 oem_ext.bin
// if(cfg.image[cnt].image_type == imgV1FRWPLC){
// p_buf+=ah_add_oem_ext(p_buf);
// }
/*new bin file's size*/
len = p_buf - p_saved_buf;