nvt_fw_update
* firm_upd_firm,USB ethernet UART烧写?
* flash启动,不升级。
* 接TF卡,loader中检查固件,并设置LDCF_UPDATE_FW标志?
TF |
FW.bin |
firm_upd_firm |
LdCtrl2 |
接 |
存在 |
0 |
0x1 LDCF_UPDATE_FW |
不存在 |
0 |
0x0 | |
不接 |
0 |
0x8 LDCF_BOOT_FLASH |
FW_UPDATE
board/novatek/nvt-ns02302-a64/ns02302evb.c
CONFIG_NVT_IVOT_SOC_FW_UPDATE_SUPPORT=y
BOOT_FUNC
arch/arm/include/asm/nvt-common/nvt_common.h
116 /*Bininfo boot info. */
117 #define COMM_UBOOT_BOOT_FUNC_BOOT_UPDFIRM 1
118 #define COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_USB 2
119 #define COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_ETH 3
120 #define COMM_UBOOT_BOOT_FUNC_BOOT_FORMAT_ROOTFS 4
121 #define COMM_UBOOT_BOOT_FUNC_BOOT_RECOVERY_SYS 5
122 #define COMM_UBOOT_BOOT_FUNC_BOOT_REASON_MASK 0xff << 0
123 #define COMM_UBOOT_BOOT_FUNC_BOOT_DONE 1 << 8
124 #define COMM_UBOOT_BOOT_FUNC_BOOT_NG 2 << 8
125 #define COMM_UBOOT_BOOT_FUNC_BOOT_DONE_MASK 0xff << 8
126 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_MASK 0xff << 16
127 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_DONE 1 << 16
128 #define COMM_UBOOT_BOOT_FUNC_LOAD_DSP_NG 2 << 16
Include/modelext/shm_info.h
loader中BOOT_REASON定义。
79 //BOOT_REASON
80 #define BOOT_REASON_NORMAL 0 // normal or from sd
81 #define BOOT_REASON_FWUPDFW 1 // Firmware update Firmware
82 #define BOOT_REASON_FROM_USB 2 // Update from USB
83 #define BOOT_REASON_FROM_ETH 3 // Update from ethernet
84 #define BOOT_REASON_FORMAT_ROOTFS 4 // Format rootfs because rootfs broken is detected
85 #define BOOT_REASON_RECOVERY_SYS 5 // System recovery from eMMC
86 #define BOOT_REASON_FROM_UART 6 // Update from uart
LibExt/LIBExt_src/Ctrl_Flow/bl_func.c
只搜索到BOOT_REASON_FROM_UART、BOOT_REASON_FROM_USB、BOOT_REASON_NORMAL、BOOT_REASON_FROM_ETH。
misc_init_r
nvt_handle_fw_auto
根据boot_reason进行不同处理:USB、ETH烧写,TF卡启动、FORMAT_ROOTFS、RECOVERY_SYS、TF卡升级(flash或eMMC启动)。
358 #ifdef CONFIG_NVT_IVOT_SOC_FW_UPDATE_SUPPORT
359 static int nvt_handle_fw_auto(void)
360 {
361 int ret = 0;
362 unsigned long boot_reason = nvt_readl((ulong)nvt_shminfo_comm_uboot_boot_func) & COMM_UBOOT_BOOT_FUNC_BOOT_REASON_MASK;
363
364 if ((boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_USB) || \
365 (boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_UPD_FRM_ETH)){
366 // Update by USB/ETH: firmware will be loaded by loader.
367 ret = nvt_handle_update_fw_by_usb_eth();
368 if (ret < 0)
369 return ret;
370 } else if (nvt_detect_fw_tbin()) {
371 ret = nvt_handle_fw_tbin();
372 if (ret < 0)
373 return ret;
374 } else if (boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_FORMAT_ROOTFS){
375 printf("%s: COMM_UBOOT_BOOT_FUNC_BOOT_FORMAT_ROOTFS is not supported\n", __func__);
376 return -1;
377 } else if (boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_RECOVERY_SYS){
378 // Recovery system if loader send event to do system recovery. (EMMC boot only)
379 ret = nvt_handle_recovery_sys();
380 if (ret < 0)
381 return ret;
382 } else {
383 ret = nvt_handle_fw_abin();
384 if (ret < 0)
385 return ret;
386 }
387
388 return 0;
389 }
390 #endif
nvt_handle_update_fw_by_usb_eth
USB、ETH烧写,nvt_fw_update(true),loader已经把固件加载到内存。
nvt_detect_fw_tbin
从RAM、SD卡启动、异常情况,从SD卡加载xxxT.bin固件运行。
* T.bin Boot from Ram,!="LD_NVT",Boot from SD card
* A.bin Boot from flash or emmc
163 int nvt_detect_fw_tbin(void)
164 {
165 SHMINFO *p_shminfo;
166 #ifdef CONFIG_NVT_IVOT_SOC_BOOT_FROM_RAM
167 nvt_dbg(IND, "Boot from Ram\n");
168 return 1;
169 #endif
170
171 p_shminfo = (SHMINFO *)nvt_memory_cfg[MEMTYPE_SHMEM].addr;
172 if (strncmp(p_shminfo->boot.LdInfo_1, "LD_NVT", 6) != 0) {
173 return -1;
174 } else {
175 if (p_shminfo->boot.LdCtrl2 & LDCF_BOOT_CARD) {
176 /* T.bin */
177 nvt_dbg(IND, "Boot from SD card\n");
178 return 1;
179 } else {
180 /* A.bin */
181 nvt_dbg(IND, "Boot from flash or emmc\n");
182 return 0;
183 }
184 }
185 }
ns02302_ldr/Include/modelext/shm_info.h
45 /**
46 Loader information
47
48 MUST 28 WORDS
49 */
50 typedef struct _BOOTINFO {
51 char LdInfo_1[16]; ///< LD-NAME(16) ------ w by Ld
52 UINT32 LdCtrl; ///< Fw flag (4) ----------- r by Ld
53 ///< BIT 0.enable part-load (0=full load,1=part load)
54 UINT32 LdCtrl2; ///< Ld flag (4) ----------- w by Ld
55 ///< BIT 0.UPDATE_FW (0=no,1=yes)
56 ///< BIT 1.UPDATE_LOADER (0=no,1=yes)
57 ///< BIT 2.BOOT_CARD (0=no,1=yes)
58 ///< BIT 3.BOOT_FLASH (0=no,1=yes)
59 ///< BIT 4.UPDATE_CAL (0=no,1=yes)
60 ///< BIT 8.UPDATE_FW_DONE (0=no,1=yes)
61 //< BIT 9.BOOT FROM S3 STATE (0=no,1=yes)
62 UINT32 LdLoadSize; ///< Ld load size (4) ------ w by Ld (NOTE: this value must be block size align)
63 UINT32 LdLoadTime; ///< Ld exec time(us) (4) -- w by Ld
64 UINT32 LdResvSize; ///< Ld size (by bytes, reserved size in partition) (4) ------ w by Ld
65 UINT32 FWResvSize; ///< FW reserved size (4) ------ w by Ld
66 UINT16 LdPackage; ///< IC package expected by Ld (0xFF: ES, 0: 660, 3: 663, 5: 665, etc...)
67 UINT16 LdStorage; ///< Internal storage expected by Ld (0: unkown, 1: nand, 2: spi nand, 3: spi nor)
68 UINT32 fdt_addr;
69 UINT32 Resv[16]; ///< (4*5) ------------ reserved for project Ld
70 } BOOTINFO;
nvt_handle_fw_tbin
TF卡读取固件(NVT_BIN_NAME_TYPE_RUNFW)运行?
board/novatek/nvt-ns02302-a64/ns02302evb.c
258 #ifdef CONFIG_NVT_IVOT_SOC_FW_UPDATE_SUPPORT
259 static int nvt_handle_fw_tbin(void)
260 {
261 int ret = 0;
262 char cmdline[1024] = {0};
263 char buf[1024] = {0};
264
265 ret = nvt_fw_load_tbin();
266 if (ret < 0) {
267 switch (ret) {
268 case ERR_NVT_UPDATE_OPENFAILED:
269 printf("Open SD fail:%s No SD device? (%s) %s\r\n", ANSI_COLOR_YELLOW, get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW), ANSI_COLOR_RESET);
270 break;
271 case ERR_NVT_UPDATE_NO_NEED:
272 case ERR_NVT_UPDATE_READ_FAILED:
273 printf("%sRead SD fail (%s) %s\r\n", ANSI_COLOR_RED, get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW), ANSI_COLOR_RESET);
274 return -1;
275 break;
276 default:
277 break;
278 }
279 } else
280 printf("%sLoad successfully %s\r\n", ANSI_COLOR_YELLOW, ANSI_COLOR_RESET);
281
282 ret = nvt_fdt_init(false);
283 if (ret < 0) {
284 printf("modelext init fail\n");
285 return ret;
286 }
287
288 /*
289 * To handle bootargs expanding for the kernel /proc/cmdline and uboot mtdids env setting
290 */
291 sprintf(buf,"%s ",env_get("bootargs"));
292 strcat(cmdline, buf);
293 ret = nvt_part_config((char *)cmdline, NULL);
294 if (ret < 0)
295 return ret;
296
297 env_set("bootargs",cmdline);
298
299 return 0;
300 }
301 #endif
nvt_fw_load_tbin
board/novatek/common/nvt_ivot_fw_update_utils.c
135 int nvt_fw_load_tbin(void)
136 {
137 loff_t size = 0;
138 int ret = 0;
139
140 if (nvt_fs_set_blk_dev())
141 return ERR_NVT_UPDATE_OPENFAILED;
142 else {
143 if (!fs_exists(get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW))) {
144 return ERR_NVT_UPDATE_NO_NEED;
145 }
146 }
147
148 if (nvt_fs_set_blk_dev())
149 return ERR_NVT_UPDATE_OPENFAILED;
150 else {
151 ret = fs_read(get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW), (ulong)nvt_memory_cfg[MEMTYPE_ALL_IN_ONE].addr, 0, 0, &size);
152 if (size <= 0 || ret < 0) {
153 nvt_dbg(ERR, "Read %s at 0x%lx failed ret=%lld\n", get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW), nvt_memory_cfg[MEMTYPE_ALL_IN_ONE].addr, si ze);
154 return ERR_NVT_UPDATE_READ_FAILED;
155 } else {
156 nvt_dbg(IND, "Read %s at 0x%lx successfully, size=%lld\n", get_nvt_bin_name(NVT_BIN_NAME_TYPE_RUNFW), nvt_memory_cfg[MEMTYPE_ALL_IN_ONE]. addr, size);
157 }
158 }
159
160 return 0;
161 }
get_nvt_bin_name
169 typedef enum
170 {
171 NVT_BIN_NAME_TYPE_FW = 1,
172 NVT_BIN_NAME_TYPE_RUNFW,
173 NVT_BIN_NAME_TYPE_RECOVERY_FW,
174 NVT_BIN_NAME_TYPE_MODELEXT,
175 } NVT_BIN_NAME_TYPE;
从设备树/nvt_info节点获取BIN_NAME属性的值作为前缀,不同类型组成不同的名字。
TYPE | name | |
FW | xxxxxxxx.bin | |
RUNFW | xxxxxxxT.bin | SD卡启动 |
RECOVERY_FW | xxxxxxxR.bin | |
MODELEXT | xxxxxxxx.fdt.bin | 设备树 |
nvt-info.dtsi
5 / {
6 nvt_info { /* Get from ModelConfig.txt */
7 BIN_NAME = "FW98539A";
8 BIN_NAME_T = "FW98539T";
354 /*
355 * get from bin info.
356 * select:
357 * 0: FW_NAME
358 * 1: RUNFW_NAME
359 * 2: MODELEXT_NAME
360 */
361 char *get_nvt_bin_name(NVT_BIN_NAME_TYPE type)
362 {
363 int nodeoffset, len = 0;
364 const void *nodep; /* property node pointer */
365
366 nodeoffset = fdt_path_offset((const void*)nvt_fdt_buffer, "/nvt_info");
367
368 if (nodeoffset < 0) {
369 printf("failed to fdt_path_offset() for /nvt_info, er = %d\n", nodeoffset);
370 return NULL;
371 }
372
373 nodep = fdt_getprop((const void *)nvt_fdt_buffer, nodeoffset, "BIN_NAME", &len);
374 // check before calling strcpy
375 if (nodep == NULL) {
376 return NULL;
377 }
378
379 if (nvt_bin_name == NULL) {
380 nvt_bin_name = calloc(sizeof(char),15);
381 if (!nvt_bin_name) {
382 printf( "%s: allocation failure \n", __FUNCTION__);
383 return NULL;
384 }
385 strcpy(nvt_bin_name, nodep);
386 strcat(nvt_bin_name, ".bin");
387 }
388
389 if ( nvt_bin_name_t == NULL) {
390 nvt_bin_name_t = calloc(sizeof(char),15);
391 if (!nvt_bin_name_t) {
392 printf( "%s: allocation failure \n", __FUNCTION__);
393 free(nvt_bin_name);
394 return NULL;
395 }
396 strcpy(nvt_bin_name_t, nodep);
397 nvt_bin_name_t[strlen(nvt_bin_name_t) - 1] = '\0';
398 strcat(nvt_bin_name_t, "T.bin");
399 }
400
401 if ( nvt_bin_name_r == NULL) {
402 nvt_bin_name_r = calloc(sizeof(char),15);
403 if (!nvt_bin_name_r) {
404 printf( "%s: allocation failure \n", __FUNCTION__);
405 free(nvt_bin_name);
406 free(nvt_bin_name_t);
407 return NULL;
408 }
409 strcpy(nvt_bin_name_r, nodep);
410 nvt_bin_name_r[strlen(nvt_bin_name_r) - 1] = '\0';
411 strcat(nvt_bin_name_r, "R.bin");
412 }
413
414 if ( nvt_bin_name_fdt == NULL) {
415 nvt_bin_name_fdt = calloc(sizeof(char),15);
416 if (!nvt_bin_name_fdt) {
417 printf( "%s: allocation failure \n", __FUNCTION__);
418 free(nvt_bin_name);
419 free(nvt_bin_name_t);
420 free(nvt_bin_name_r);
421 return NULL;
422 }
423 strcpy(nvt_bin_name_fdt, nodep);
424 strcat(nvt_bin_name_fdt, ".fdt.bin");
425 }
426
427 if (type == NVT_BIN_NAME_TYPE_FW) {
428 return nvt_bin_name;
429 } else if (type == NVT_BIN_NAME_TYPE_RUNFW) {
430 return nvt_bin_name_t;
431 } else if (type == NVT_BIN_NAME_TYPE_RECOVERY_FW) {
432 return nvt_bin_name_r;
433 } else {
434 return nvt_bin_name_fdt;
435 }
436 }
nvt_handle_recovery_sys
nvt_process_sys_recovery从eMMC第3个分区(FAT文件系统)读取固件进行升级。
nvt_handle_fw_abin
TF卡升级nvt_fw_update(false),从TF卡(FAT文件系统)加载固件。
nvt_fw_update
nvt_fs_set_blk_dev
先尝试TF卡第一个分区FAT文件系统,再尝试TF卡不带分区FAT文件系统。
461 int nvt_fs_set_blk_dev(void)
462 {
463 #if 0
464 if (fs_set_blk_dev("mmc", "0:1", FS_TYPE_FAT))
465 if (fs_set_blk_dev("mmc", "0:1", FS_TYPE_EXFAT))
466 if (fs_set_blk_dev("mmc", "0:0", FS_TYPE_FAT))
467 if (fs_set_blk_dev("mmc", "0:0", FS_TYPE_EXFAT)){
468 printf("MMC interface configure failed\n");
469 return -1;
470 }
471 #else
472 if (fs_set_blk_dev("mmc", "0:1", FS_TYPE_FAT))
473 if (fs_set_blk_dev("mmc", "0:0", FS_TYPE_FAT)) {
474 printf("MMC interface configure failed\n");
475 return -1;
476 }
477 #endif
478
479 return 0;
480 }
fs_size获取固件大小,fs_read读固件(NVT_BIN_NAME_TYPE_FW)。nvt_process_all_in_one进行升级,失败会继续尝试,总共3次。
board/novatek/common
708 nvt_ivot_common.c
1822 nvt_ivot_fw_update.c
878 nvt_ivot_fw_update_utils.c
529 nvt_ivot_pack.c
2013 nvt_ivot_soc_utils.c
nvt_ivot_common.c
nvt_ivot_fw_update.c
nvt_flash_write
nvt_update_partitions
nvt_read_partitions
nvt_update_fs_partition
nvt_read_fs_partition
MemCheck_CalcCheckSum16Bit
nvt_chk_last_ebr
nvt_chk_app
nvt_chk_loader
nvt_chk_modelext
nvt_chk_rtos
nvt_chk_atf
nvt_chk_teeos
nvt_chk_ai
nvt_chk_uboot
nvt_chk_linux
nvt_chk_rootfs
nvt_chk_all_in_one_valid
nvt_on_partition_enum_sanity
nvt_switch_boot_patition
nvt_on_partition_enum_update
nvt_on_partition_enum_mtd_readback
nvt_getfdt_emb_addr_size
nvt_checkfdt_part_is_match
nvt_process_all_in_one
nvtpack_verify
nvt_process_sys_recovery
nvt_fw_update
nvt_process_all_in_one
nvt_ivot_fw_update_utils.c
nvt_chk_mtd_fdt_is_null
nvt_fw_load_tbin
nvt_detect_fw_tbin
LD_NVT -1
LDCF_BOOT_CARD 1 T.bin Boot from SD card
0 A.bin Boot from flash or emmc
get_nvt_bin_name
nvt_check_is_fw_update_fw
438 int nvt_check_is_fw_update_fw(void)
439 {
440 unsigned long boot_reason;
441
442 boot_reason = nvt_readl((ulong)nvt_shminfo_comm_uboot_boot_func) & COMM_UBOOT_BOOT_FUNC_BOOT_REASON_MASK;
443
444 return (boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_UPDFIRM);
445 }
nvt_check_is_fomat_rootfs
447 int nvt_check_is_fomat_rootfs(void)
448 {
449 unsigned long boot_reason;
450 static int is_format = -1;
451
452 if(is_format != -1)
453 return is_format;
454
455 boot_reason = nvt_readl((ulong)nvt_shminfo_comm_uboot_boot_func) & COMM_UBOOT_BOOT_FUNC_BOOT_REASON_MASK;
456 is_format = ((boot_reason == COMM_UBOOT_BOOT_FUNC_BOOT_FORMAT_ROOTFS) ? 1 : 0);
457
458 return is_format;
459 }
nvt_ivot_pack.c
nvtpack_er
nvtpack_calc_nvt_sum
nvtpack_verify
52 // {B5CB64AE-05DD-46FA-B906-0C62D22958D6}
53 static const GUID GUID_RES =
54 { 0xb5cb64ae, 0x05dd, 0x46fa, { 0xb9, 0x06, 0x0c, 0x62, 0xd2, 0x29, 0x58, 0xd6 } };
55
56 // {8827BE90-36CD-4FC2-A987-73A8484E84B1}
57 static const GUID GUID_FW =
58 { 0x8827be90, 0x36cd, 0x4fc2, { 0xa9, 0x87, 0x73, 0xa8, 0x48, 0x4e, 0x84, 0xb1 } };
59
60 // {D6012E07-10BC-4F91-B28A-352F82261A50}
61 static const GUID GUID_FW2 =
62 { 0xd6012e07, 0x10bc, 0x4f91, { 0xb2, 0x8a, 0x35, 0x2f, 0x82, 0x26, 0x1a, 0x50 } };
GUID比较,计算校验和
95 _NVTPACK_EXTERN_C NVTPACK_ER nvtpack_verify(NVTPACK_MEM *p_mem, NVTPACK_VERIFY_OUTPUT *p_output)
96 {
97 NVTPACK_MEM chk_mem = {0};
98
99 memset(p_output, 0, sizeof(*p_output));
100
101 if(IsEqualGUID(&GUID_FW2, (GUID *)p_mem->p_data)) {
102 if(nvtpack_calc_nvt_sum(p_mem) != 0) {
103 return nvtpack_er(NVTPACK_ER_CHECK_SUM);
104 }
105 p_output->ver = NVTPACK_VER_16072017;
106 p_output->partition_cnt = ((NVTPACK_FW_HDR2 *)p_mem->p_data)->TotalRes;
107 return nvtpack_er(NVTPACK_ER_SUCCESS);
108 }
109
110 return nvtpack_er(NVTPACK_ER_UNKNOWN_FORMAT);
111 }
nvt_ivot_pack.h
固件头128字节,每个分区头12字节,PartitionID 1 (modelext must always put in partition[1]) nvt-evb.bin。
17 #define NVTPACK_CHKSUM_HDR_VERSION 0x16040719U
18 #define NVTPACK_FW_HDR2_VERSION 0x16071515U
19
20 typedef enum _NVTPACK_ER {
21 NVTPACK_ER_SUCCESS = 0,
22 NVTPACK_ER_FAILED = -1,
23 NVTPACK_ER_UNKNOWN_FORMAT = -2,
24 NVTPACK_ER_CHECK_SUM = -3,
25 NVTPACK_ER_NOT_FOUND = -4,
26 NVTPACK_ER_USER_BREAK = -5,
27 NVTPACK_ER_PARAM = -6,
28 NVTPACK_ER_MEM_NOT_ENOUGH = -7,
29 NVTPACK_ER_RTOS_SIZE_ALIGN4 = -8, ///< rtos size must align by 4
30 NVTPACK_ER_INVALID_WHOLE_SIZE = -9, ///< after nvtpack, whole size must align by 4
31 NVTPACK_ER_SRC_NAME_BLANK = -10, ///< resource's SrcName cannot be NULL or blank
32 NVTPACK_ER_SRC_NAME_EXCEED = -11, ///< resource's SrcName cannot exceed 12 bytes
33 NVTPACK_ER_SRC_NAME_INVALID = -12, ///< resource's SrcName include invalid character
34 NVTPACK_ER_SRC_NAME_ALIKE = -13, ///< there resource's SrcName are alike.
35 } NVTPACK_ER;
36
37 typedef enum _NVTPACK_VER {
38 NVTPACK_VER_UNKNOWN, ///< UNKNOWN
39 NVTPACK_VER_13012816, ///< NT9666X, NT9850X
40 NVTPACK_VER_16072017, ///< NT9668X
41 } NVTPACK_VER;
42
43 #if !defined(_WIN32)
44 typedef struct _GUID {
45 unsigned int Data1;
46 unsigned short Data2;
47 unsigned short Data3;
48 unsigned char Data4[8];
49 } GUID;
50 #endif
51
52 typedef struct _NVTPACK_RES_HDR {
53 GUID guid; ///< {B5CB64AE-05DD-46FA-B906-0C62D22958D6}
54 unsigned int TotalSize;
55 unsigned int CheckSum;
56 unsigned int ContentSize;
57 char SrcName[16]; ///< original packed bin file name
58 char DstName[16]; ///< target file name
59 } NVTPACK_RES_HDR;
60
61 typedef struct _NVTPACK_FW_HDR {
62 GUID guid; ///< {8827BE90-36CD-4FC2-A987-73A8484E84B1}
63 unsigned int TotalSize; ///< sizeof(NVTPACK_FW_HDR) + n*sizeof(NVTPACK_PARTITION_HDR)
64 unsigned int CheckSum; ///< check sum of sizeof(NVTPACK_FW_HDR) + n*sizeof(NVTPACK_PARTITION_HDR)
65 unsigned int TotalRes; ///< total partitions
66 } NVTPACK_FW_HDR;
67
68 typedef struct _NVTPACK_FW_HDR2 {
69 GUID guid; ///< {D6012E07-10BC-4F91-B28A-352F82261A50}
70 unsigned int uiVersion; ///< NVTPACK_FW_HDR2_VERSION
71 unsigned int uiHdrSize; ///< sizeof(NVTPACK_FW_HDR2);
72 unsigned int TotalRes; ///< total resource counts
73 unsigned int TotalSize; ///< whole bin size
74 unsigned int uiChkMethod; ///< 0: CheckSum
75 unsigned int uiChkValue; ///< check sum value or crc value within NVTPACK_FW_HDR2
76 unsigned int uiUserData[4]; ///< user defined data that may be used in future
77 unsigned int uiReversed[18];///< align to 128 bytes
78 } NVTPACK_FW_HDR2;
79
80 typedef struct _NVTPACK_PARTITION_HDR {
81 unsigned int Offset;
82 unsigned int Size;
83 unsigned int PartitionID;
84 } NVTPACK_PARTITION_HDR;
arch/arm/include/asm/nvt-common/modelext/emb_partition_info.h
32 enum {
33 EMBTYPE_UNKNOWN = 0x00,
34 EMBTYPE_LOADER = 0x01, /* loader must always put in partition[0] */
35 EMBTYPE_FDT = 0x02, /* modelext must always put in partition[1] */
36 EMBTYPE_OBSOLETE1 = 0x03,
37 EMBTYPE_OBSOLETE2 = 0x04,
38 EMBTYPE_UBOOT = 0x05,
39 EMBTYPE_LINUX = 0x06,
40 EMBTYPE_DSP = 0x07,
41 EMBTYPE_PSTORE = 0x08,
42 EMBTYPE_FAT = 0x09,
43 EMBTYPE_EXFAT = 0x0A,
44 EMBTYPE_ROOTFS = 0x0B,
45 EMBTYPE_RAMFS = 0x0C,
46 EMBTYPE_UENV = 0x0D, /* u-boot environment data */
47 EMBTYPE_MBR = 0x0E, /* for emmc partition, mbr always put in partition[0] instead of loader */
48 EMBTYPE_ROOTFSL = 0x0F, /* for emmc logical partition */
49 EMBTYPE_RTOS = 0x10, /* freertos */
50 EMBTYPE_APP = 0x11, /* for APP , like IQ configs */
51 EMBTYPE_TEEOS = 0x12, /* for secure os*/
52 EMBTYPE_AI = 0x13, /* for fastboot-ai*/
53 EMBTYPE_ATF = 0x14, /* for ATF */
54 EMBTYPE_BANK = 0x15, /* for dual rtos, extra partition called bank */
55 EMBTYPE_MCU = 0x16, /* MCU firmware, such as 8051, andes */
56 EMBTYPE_SIZE,
57 };
board/novatek/common/nvt_ivot_fw_update_utils.c分区转换表。
42 EMB_PARTITION_FDT_TRANSLATE_TABLE emb_part_fdt_map[EMBTYPE_TOTAL_SIZE] = {
43 {"partition_mbr", EMBTYPE_MBR},
44 {"partition_loader", EMBTYPE_LOADER},
45 {"partition_fdt", EMBTYPE_FDT},
46 {"partition_fdt.app", EMBTYPE_FDT}, // fastboot application.bin (fdt format)
47 {"partition_fdt.fast", EMBTYPE_FDT}, // fastboot nvt-fastboot.bin (fdt format)
48 {"partition_teeos", EMBTYPE_TEEOS},
49 {"partition_uboot", EMBTYPE_UBOOT},
50 {"partition_uenv", EMBTYPE_UENV},
51 {"partition_kernel", EMBTYPE_LINUX},
52 {"partition_rootfs", EMBTYPE_ROOTFS},
53 {"partition_rootfsl", EMBTYPE_ROOTFSL},
54 {"partition_usr", EMBTYPE_USER},
55 {"partition_usrraw", EMBTYPE_USERRAW},
56 {"partition_rtos", EMBTYPE_RTOS},
57 {"partition_rtos_s", EMBTYPE_RTOS},
58 {"partition_app", EMBTYPE_APP},
59 {"partition_ai", EMBTYPE_AI},
60 {"partition_atf", EMBTYPE_ATF},
61 {"partition_bank", EMBTYPE_BANK},
62 {"partition_loader.aov", EMBTYPE_LOADER}, // 2nd loader for always on video
63 {"partition_mcu", EMBTYPE_MCU}, // mcu firmware
64 };
nvt_ivot_soc_utils.c
nvt_chk_key
nvt_chk_key_on_uboot
nvt_chk_signature_on_uboot
nvt_chk_signature
nvt_decrypt_aes_on_uboot
nvt_decrypt_aes
nvt_part_config
nvt_runfw_bin_chk_valid
nvt_on_partition_enum_copy_to_dest
gz_uncompress
nvt_runfw_bin_unpack_to_dest
uimage_gen_dcrc
uimage_gen_hcrc
uimage_gen_fake_header
is_gzip_image
1456 inline static int is_gzip_image(unsigned long image)
1457 {
1458 return (((NVTPACK_BFC_HDR *)image)->uiFourCC ==
1459 MAKEFOURCC('B', 'C', 'L', '1'));
1460 }
nvt_ker_img_ungzip_linux
nvt_ramdisk_img_ungzip_linux
nvt_boot_linux_bin_auto
nvt_boot_rootfs_bin_auto
nvt_boot_fw_init_detect
nvt_set_bootargs_by_dts
do_nvt_boot_cmd
ns02302_ldr
bl_mainFlow
LibExt/LIBExt_src/Ctrl_Flow/bl_func.c
93 static UINT8 *LOADER_START_STR = {(UINT8 *)"\r\nLoader Start ..."};
3362 prj_main();
3376 #if defined(ROM_GetCurrBS)
3377 if (ROM_GetCurrBS() == BOOT_SOURCE_UART) {
3378 debug_msg("Boot from UART ...\r\n");
3379 #if UART_UPDATE
3380 bl_uart();//never returned.
3381 #else
3382 bl_displayErrMsg("loader must be STORAGEEXT = Uart\r\n");
3383 #endif
3384 }
3385
3386 if ((ROM_GetCurrBS() == BOOT_SOURCE_USB)||(ROM_GetCurrBS() == BOOT_SOURCE_USB_FULL)) {
3387 debug_msg("Boot from USB ...\r\n");
3388 #if USB_WRITELOADER
3389 bl_usb(); //never returned.
3390 #else
3391 bl_displayErrMsg("loader must be STORAGEEXT = Usb\r\n");
3392 #endif
3393 }
3394 #endif
debug_msg
20 extern void debug_set_console(CONSOLE_OBJ *p_obj);
21 extern CONSOLE_OBJ *debug_get_console(void);
22 extern void debug_err(char *str);
23 extern void debug_err_var(char *str, int var);
24 extern void debug_msg(char *str) __attribute__ ((section (".part1")));
25 extern void debug_msg_var(char *str, int var) __attribute__ ((section (".part1")));
26 extern void debug_dump_addr(UINT32 addr, UINT32 size);
27 extern int printf(char const *fmt, ...);
Project/Model/Loader539_Data/Release/ObjectLds/Debug/debug.o
ARC/Lib/Release/Debug.a
debug_put_string
fw_update_by_cache
patch