修改 ah fw 在fw img 之后读取附加的oem数据

This commit is contained in:
2024-10-26 14:10:20 +08:00
parent 1a60d3f171
commit d5325ac3aa
6 changed files with 93 additions and 17 deletions

View File

@@ -5,7 +5,7 @@
#include <stdint.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include "sha256.h"
#include "../ram/inc/sha256.h"
#include "iot_img_hdr.h"
char default_hash_iv[]={0x12,0x34,0x56,0x78,0x87,0x65,0x43,0x21,0x5A,0x5A,0x5A,0x5A,0x00,0x7E,0xC3,0x00};
@@ -575,6 +575,38 @@ int ah_GetConfig(char *pcfgName, ah_cfg *pcfg)
#define PACKAGE_HEADER_SIZE 96
// 填充额外的oem数据
int ah_add_oem_ext(char *buf)
{
int file_size;
char *buf_start=buf;
FILE *fp = NULL;
struct stat st;
const char *file_name="oem_ext.bin";
const char *oem_magic_str="_oem_ext";
if((0 != stat(file_name, &st))
||(NULL == (fp=fopen(file_name, "r"))))
{
printf(NEW_LINE"Cannot open image file(%s)."NEW_LINE, file_name);
return 0;
}
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);
fread(buf, 1, file_size, fp);
buf += file_size;
fclose(fp);
fp = NULL;
return buf-buf_start;
}
// 这里添加的是img的头
void ah_fillHeader(char* p_buf, ah_cfg *cfg, int cnt, int fileSize, int _CRC,
unsigned char *sha)
@@ -998,6 +1030,11 @@ 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);
}
/*new bin file's size*/
len = p_buf - p_saved_buf;
total_size += len;

View File

@@ -8,8 +8,9 @@
#include "../../../inc/hw/reg/riscv3/2/gpio_mtx_sig.h"
#include "oem_common.h"
#include "../oem_common.h"
#include "oem_tool_hw.h"
#include "iot_oem_struct_v1.h"
#define RC_TOTAL_GPIO 128
#define RC_TOTAL_UART IOT_UART_MAX_NUM_V1