成功解析额外的oem数据 运行正常
This commit is contained in:
@@ -390,6 +390,7 @@ void board_oem_signal_mtx_binding(iot_board_info_v1_t *rc_info)
|
||||
|
||||
|
||||
|
||||
extern int32_t sbl_printf(const char *fmt, ...);
|
||||
|
||||
|
||||
uint32_t board_load_oem_cfg()
|
||||
@@ -418,13 +419,13 @@ uint32_t board_load_oem_cfg()
|
||||
g_board_cpu_idx = cpu_get_mhartid();
|
||||
#endif
|
||||
|
||||
iot_printf("start load oemcfg\n");
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("start load oemcfg\n");
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
ret = iot_oem_get_cfg(&oemcfg);
|
||||
if (ret != ERR_OK) {
|
||||
goto out;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
g_board_info.board_id = oemcfg->board_id;
|
||||
IOT_ASSERT(oemcfg->board_cfg_ver == IOT_OEM_VER_V1);
|
||||
|
||||
@@ -440,21 +441,22 @@ uint32_t board_load_oem_cfg()
|
||||
goto out;
|
||||
}
|
||||
// 读取oem的差分部分
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
ret = iot_oem_read_mtd(buf_oem, oem_part_size - oem_diff_offset,
|
||||
oem_diff_offset);
|
||||
if (ret != ERR_OK) {
|
||||
goto out;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
|
||||
ret = ERR_FAIL;
|
||||
hw_ver_cal = iot_board_hw_version_hex();
|
||||
/* if hw_version is not written during production test, it defaults to f */
|
||||
if (hw_ver_cal == 0xffffffff) {
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
hw_ver_cal = 0;
|
||||
}
|
||||
sbl_printf("board_hw_ver=%08x\n",hw_ver_cal);
|
||||
// ptr_rc 是 iot_board_info_v1_t 类型的指针
|
||||
ptr_hdr = &ptr_rc->hdr;
|
||||
hw_ver_rc = ptr_hdr->hw_version;
|
||||
@@ -465,6 +467,7 @@ hdr_check:
|
||||
if (ptr_hdr->have_next == 0) {
|
||||
if(read_oem_ext_flag ||
|
||||
iot_oem_read_mtd_ext(&buf_oem[offset],BOARD_OEM_INFO_SIZE_MAX-offset)){
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
goto out;
|
||||
} else {
|
||||
ptr_hdr->have_next = 1;
|
||||
@@ -480,6 +483,7 @@ hdr_check:
|
||||
hw_ver_rc = ptr_hdr->hw_version;
|
||||
goto hdr_check;
|
||||
}
|
||||
sbl_printf("count_rc=%d\n",cnt_rc);
|
||||
|
||||
/* prevent array out of bounds */
|
||||
// 最多只支持63个硬件识别码
|
||||
|
@@ -109,6 +109,17 @@ uint32_t iot_oem_read_mtd(uint8_t *buf, uint32_t size, uint32_t offset)
|
||||
}
|
||||
|
||||
|
||||
extern int32_t sbl_printf(const char *fmt, ...);
|
||||
|
||||
|
||||
static void data_printf(const uint8_t *data,int len){
|
||||
for (int i=0;i<len;i++){
|
||||
sbl_printf("%02x ",data[i]);
|
||||
}
|
||||
sbl_printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 抓取额外的差分oem数据
|
||||
uint32_t iot_oem_read_mtd_ext(uint8_t *buff,uint32_t buff_size)
|
||||
@@ -120,45 +131,51 @@ uint32_t iot_oem_read_mtd_ext(uint8_t *buff,uint32_t buff_size)
|
||||
uint8_t fw_prtition = PART_NUM_FW1;
|
||||
char str_buff[10]={0};
|
||||
imgHdr hdr={0};
|
||||
const imgHdr *run_fw_hdr;
|
||||
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__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
|
||||
do {
|
||||
status = dev_get_boot_fw_part_num(&fw_prtition);
|
||||
if (status) {
|
||||
break;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_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;
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
img_header_construct(&run_fw_hdr,(char *)(hdr.v1.runAddr-HEADER_TOLTAL_SIZE));
|
||||
data_printf((const uint8_t *)&run_fw_hdr,32);
|
||||
fw_size=run_fw_hdr.v1.imgSize;
|
||||
sbl_printf("fw_size:%ld\n",fw_size);
|
||||
data=(const uint8_t *)(hdr.v1.runAddr+fw_size-oem_ext_magic_str_len);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("oem_ext_magic_str_addr:%p\n",data);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
os_mem_cpy(str_buff,data,oem_ext_magic_str_len);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("str_buff:%s\n",str_buff);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
if(iot_strcmp(str_buff,oem_ext_magic_str) != 0){
|
||||
break;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
data-=4;
|
||||
oem_size=((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3]);
|
||||
sbl_printf("oem_size:%ld\n",oem_size);
|
||||
data=data-oem_size;
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
if(buff_size<oem_size){
|
||||
break;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
os_mem_cpy(buff,data,oem_size);
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
ret = ERR_OK;
|
||||
} while(0);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -271,9 +271,14 @@ void iot_mode_set(int fw_mode)
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern int32_t sbl_printf(const char *fmt, ...);
|
||||
|
||||
|
||||
// 硬件部分初始化
|
||||
void iot_hw_init()
|
||||
{
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
// 初始化efuse
|
||||
iot_efuse_init();
|
||||
// 初始化时钟
|
||||
@@ -297,9 +302,14 @@ void iot_hw_init()
|
||||
// 目前是空函数
|
||||
iot_cal_data_init();
|
||||
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
write_hw_version(0x0D0A0113);
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
|
||||
#if (IOT_FLASH_BUILD == 1)
|
||||
/* board info config*/
|
||||
iot_board_cfg_init();
|
||||
sbl_printf("%s:%d\n",__FILE__,__LINE__);
|
||||
#endif
|
||||
|
||||
iot_led_init();
|
||||
|
Reference in New Issue
Block a user