改为 在压缩前添加 oem_ext 但固件启动不起来
This commit is contained in:
@@ -11,40 +11,43 @@ import sys
|
||||
env_dict=os.environ.copy()
|
||||
|
||||
|
||||
env_dict.pop('SHELL',None)
|
||||
env_dict.pop('COLORTERM',None)
|
||||
env_dict.pop('TERM_PROGRAM_VERSION',None)
|
||||
env_dict.pop('LANGUAGE',None)
|
||||
env_dict.pop('XDG_SESSION_TYPE',None)
|
||||
env_dict.pop('VSCODE_GIT_ASKPASS_NODE',None)
|
||||
env_dict.pop('MOTD_SHOWN',None)
|
||||
env_dict.pop('HOME',None)
|
||||
env_dict.pop('LANG',None)
|
||||
env_dict.pop('LS_COLORS',None)
|
||||
env_dict.pop('SSL_CERT_DIR',None)
|
||||
env_dict.pop('GIT_ASKPASS',None)
|
||||
env_dict.pop('SSH_CONNECTION',None)
|
||||
env_dict.pop('VSCODE_GIT_ASKPASS_EXTRA_ARGS',None)
|
||||
env_dict.pop('LESSCLOSE',None)
|
||||
env_dict.pop('XDG_SESSION_CLASS',None)
|
||||
env_dict.pop('TERM',None)
|
||||
env_dict.pop('LESSOPEN',None)
|
||||
env_dict.pop('USER',None)
|
||||
env_dict.pop('VSCODE_GIT_IPC_HANDLE',None)
|
||||
env_dict.pop('SHLVL',None)
|
||||
env_dict.pop('XDG_SESSION_ID',None)
|
||||
env_dict.pop('XDG_RUNTIME_DIR',None)
|
||||
env_dict.pop('SSL_CERT_FILE',None)
|
||||
env_dict.pop('SSH_CLIENT',None)
|
||||
env_dict.pop('VSCODE_GIT_ASKPASS_MAIN',None)
|
||||
env_dict.pop('XDG_DATA_DIRS',None)
|
||||
env_dict.pop('BROWSER',None)
|
||||
env_dict.pop('PATH',None)
|
||||
env_dict.pop('DBUS_SESSION_BUS_ADDRESS',None)
|
||||
env_dict.pop('OLDPWD',None)
|
||||
env_dict.pop('TERM_PROGRAM',None)
|
||||
env_dict.pop('VSCODE_IPC_HOOK_CLI',None)
|
||||
env_dict.pop('aaaaaaa',None)
|
||||
_pop_list=[
|
||||
'SHELL',
|
||||
'COLORTERM',
|
||||
'TERM_PROGRAM_VERSION',
|
||||
'LANGUAGE',
|
||||
'XDG_SESSION_TYPE',
|
||||
'VSCODE_GIT_ASKPASS_NODE',
|
||||
'MOTD_SHOWN',
|
||||
'HOME',
|
||||
'LANG',
|
||||
'LS_COLORS',
|
||||
'SSL_CERT_DIR',
|
||||
'GIT_ASKPASS',
|
||||
'SSH_CONNECTION',
|
||||
'VSCODE_GIT_ASKPASS_EXTRA_ARGS',
|
||||
'LESSCLOSE',
|
||||
'XDG_SESSION_CLASS',
|
||||
'TERM',
|
||||
'LESSOPEN',
|
||||
'USER',
|
||||
'VSCODE_GIT_IPC_HANDLE',
|
||||
'SHLVL',
|
||||
'XDG_SESSION_ID',
|
||||
'XDG_RUNTIME_DIR',
|
||||
'SSL_CERT_FILE',
|
||||
'SSH_CLIENT',
|
||||
'VSCODE_GIT_ASKPASS_MAIN',
|
||||
'XDG_DATA_DIRS',
|
||||
'BROWSER',
|
||||
'PATH',
|
||||
'DBUS_SESSION_BUS_ADDRESS',
|
||||
'OLDPWD',
|
||||
'TERM_PROGRAM',
|
||||
'VSCODE_IPC_HOOK_CLI',
|
||||
]
|
||||
for item in _pop_list:
|
||||
env_dict.pop(item,None)
|
||||
|
||||
|
||||
|
||||
|
@@ -764,7 +764,7 @@ e_err:
|
||||
* @param hdr: pointer to save header information.
|
||||
* @return ERR_FAIL: failed; ERR_OK: succeed.
|
||||
*/
|
||||
static uint32_t mtd_get_hdr(uint8_t part_num, imgHdr *hdr)
|
||||
uint32_t mtd_get_hdr(uint8_t part_num, imgHdr *hdr)
|
||||
{
|
||||
int fd;
|
||||
static uint8_t last_part = PART_NUM_INVALID;
|
||||
|
@@ -418,10 +418,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__);
|
||||
ret = iot_oem_get_cfg(&oemcfg);
|
||||
if (ret != ERR_OK) {
|
||||
goto out;
|
||||
}
|
||||
iot_printf("%s:%d\n"__FILE__,__LINE__);
|
||||
g_board_info.board_id = oemcfg->board_id;
|
||||
IOT_ASSERT(oemcfg->board_cfg_ver == IOT_OEM_VER_V1);
|
||||
|
||||
@@ -437,16 +440,19 @@ uint32_t board_load_oem_cfg()
|
||||
goto out;
|
||||
}
|
||||
// 读取oem的差分部分
|
||||
iot_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__);
|
||||
|
||||
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__);
|
||||
hw_ver_cal = 0;
|
||||
}
|
||||
// ptr_rc 是 iot_board_info_v1_t 类型的指针
|
||||
@@ -457,7 +463,7 @@ uint32_t board_load_oem_cfg()
|
||||
hdr_check:
|
||||
if (hw_ver_cal != hw_ver_rc) {
|
||||
if (ptr_hdr->have_next == 0) {
|
||||
if(read_oem_ext_flag ||
|
||||
if(read_oem_ext_flag ||
|
||||
iot_oem_read_mtd_ext(&buf_oem[offset],BOARD_OEM_INFO_SIZE_MAX-offset)){
|
||||
goto out;
|
||||
} else {
|
||||
|
@@ -17,6 +17,7 @@ Information is free from patent or copyright infringement.
|
||||
|
||||
#include "iot_flash_api.h"
|
||||
#include "iot_flash_layout.h"
|
||||
#include "iot_img_hdr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -244,6 +245,14 @@ int32_t iot_log_save_done(uint8_t lock);
|
||||
*/
|
||||
uint32_t mtd_copy_part(uint8_t src_part, uint8_t dest_part);
|
||||
|
||||
/**
|
||||
* @brief mtd_get_hdr(): get firmware header information of specified partition.
|
||||
* @param part_num: the specified partition.
|
||||
* @param hdr: pointer to save header information.
|
||||
* @return ERR_FAIL: failed; ERR_OK: succeed.
|
||||
*/
|
||||
uint32_t mtd_get_hdr(uint8_t part_num, imgHdr *hdr);
|
||||
|
||||
/**
|
||||
* @brief mtd_get_hdr_img_size(uint8_t part) - get img size in hdr
|
||||
* @param part: part number in flash block.
|
||||
|
@@ -48,9 +48,6 @@ extern "C" {
|
||||
|
||||
#define IOT_OEM_SECTION_SEC_ADDR (3072)
|
||||
|
||||
#define IOT_OEM_EXT_SECTION_OFFSET(fw_size) \
|
||||
(((fw_size+31)&(~0x1f))+IOT_OEM_SECTION_START_ADDR)
|
||||
|
||||
#define IOT_OEM_EXT_MAGIC_STR "_oem_ext"
|
||||
|
||||
#define IOT_OEM_DUMMY_LEN 106
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -344,6 +344,38 @@ if [ "x${CHIP_VER_UPPER}" == "x3" ]; then
|
||||
else
|
||||
cp ${TOP_DIR}/ap/.output/plc/lib/${HT_FILE} $CUR_DIR/ht.bin
|
||||
fi
|
||||
|
||||
# prepare oem.bin
|
||||
# 根据core类型指定oem文件
|
||||
if [ "x${CORE_TYPE_UPPER}" == "xAMPPLC" ]; then
|
||||
if [ ${IOT_SMART_BUILD} == 1 ]; then
|
||||
OEM_CFG=${BOARD_UPPER}"_AMPIOT_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_AMPIOT_OEM.bin"
|
||||
else
|
||||
OEM_CFG=${BOARD_UPPER}"_AMPSG_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_AMPSG_OEM.bin"
|
||||
fi
|
||||
else
|
||||
OEM_CFG=${BOARD_UPPER}"_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_OEM.bin"
|
||||
fi
|
||||
cp $TOP_DIR/tools/oem/$OEM_CFG ./tmp_oem.ini
|
||||
#set mid for iot board(cco and sta use same oem.ini)
|
||||
# smart模式需要根据img类型动态修改mid值
|
||||
if [ ${IOT_SMART_BUILD} == 1 ]; then
|
||||
if [ "${IMG_UPPER}" == "CCO" ]; then
|
||||
sed -i "s/mid.*/mid 1/g" ./tmp_oem.ini
|
||||
elif [ "${IMG_UPPER}" == "STA" ]; then
|
||||
sed -i "s/mid.*/mid 0/g" ./tmp_oem.ini
|
||||
fi
|
||||
fi
|
||||
if [ "${RUN_UPPER}" != "UPGRADE" ]; then
|
||||
# 打包非升级文件的时候生成 oem.bin
|
||||
./oem_tool --input=./tmp_oem.ini --output=$TOP_DIR/tools/oem/$OEM_FILE
|
||||
fi
|
||||
rm ./tmp_oem.ini
|
||||
cp $TOP_DIR/tools/oem/$OEM_FILE $CUR_DIR/oem.bin
|
||||
|
||||
# 修改配置文件中的layout index配置
|
||||
sed -i "/img_type=./a layout_index=${FLASH_LAYOUT_INDEX}" ${TMP_CFG_NAME}
|
||||
|
||||
@@ -512,37 +544,6 @@ if [ "x${CHIP_VER_UPPER}" == "x3" ]; then
|
||||
sed -i "s,vendor_id=18516,vendor_id=22864,g" ${TMP_CFG_NAME}
|
||||
fi
|
||||
|
||||
# prepare oem.bin
|
||||
# 根据core类型指定oem文件
|
||||
if [ "x${CORE_TYPE_UPPER}" == "xAMPPLC" ]; then
|
||||
if [ ${IOT_SMART_BUILD} == 1 ]; then
|
||||
OEM_CFG=${BOARD_UPPER}"_AMPIOT_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_AMPIOT_OEM.bin"
|
||||
else
|
||||
OEM_CFG=${BOARD_UPPER}"_AMPSG_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_AMPSG_OEM.bin"
|
||||
fi
|
||||
else
|
||||
OEM_CFG=${BOARD_UPPER}"_OEM.ini"
|
||||
OEM_FILE=${BOARD_UPPER}"_OEM.bin"
|
||||
fi
|
||||
cp $TOP_DIR/tools/oem/$OEM_CFG ./tmp_oem.ini
|
||||
#set mid for iot board(cco and sta use same oem.ini)
|
||||
# smart模式需要根据img类型动态修改mid值
|
||||
if [ ${IOT_SMART_BUILD} == 1 ]; then
|
||||
if [ "${IMG_UPPER}" == "CCO" ]; then
|
||||
sed -i "s/mid.*/mid 1/g" ./tmp_oem.ini
|
||||
elif [ "${IMG_UPPER}" == "STA" ]; then
|
||||
sed -i "s/mid.*/mid 0/g" ./tmp_oem.ini
|
||||
fi
|
||||
fi
|
||||
if [ "${RUN_UPPER}" != "UPGRADE" ]; then
|
||||
# 打包非升级文件的时候生成 oem.bin
|
||||
./oem_tool --input=./tmp_oem.ini --output=$TOP_DIR/tools/oem/$OEM_FILE
|
||||
fi
|
||||
rm ./tmp_oem.ini
|
||||
cp $TOP_DIR/tools/oem/$OEM_FILE $CUR_DIR/oem.bin
|
||||
|
||||
# prepare pib file
|
||||
# 根据board类型来选择pib文件
|
||||
PIB_IMG=${BOARD_UPPER}
|
||||
|
Reference in New Issue
Block a user