From 52cdbed72a09efb6e247a6a05e0cb8a89fdcbd53 Mon Sep 17 00:00:00 2001 From: pvvx Date: Sun, 21 Jan 2018 00:36:37 +0300 Subject: [PATCH] update boot images validation --- .../soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c b/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c index 3cb6862..6329c06 100644 --- a/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/ram_lib/rtl_boot.c @@ -549,8 +549,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) { return ret; } -LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, - uint8 flgload) { +LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, uint8 flgload) { uint32 fnextaddr = faddr; uint8 segnum = 0; while (1) { @@ -560,7 +559,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, || seg_id == SEG_ID_SDRAM)) { #if CONFIG_DEBUG_LOG > 1 DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", - segnum, faddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, + segnum, fnextaddr, txt_tab_seg[seg_id], hdr->seg.ldaddr, hdr->seg.size); #endif fnextaddr += flashcpy(fnextaddr, (void *)hdr->seg.ldaddr, hdr->seg.size); @@ -571,9 +570,11 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, #endif fnextaddr += hdr->seg.size; } else { + // seg_id == UNK + fnextaddr -= 8; break; } - fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD)); + fnextaddr += flashcpy(fnextaddr, hdr, sizeof(IMGSEGHEAD)) + 8; segnum++; } return fnextaddr; @@ -589,6 +590,7 @@ LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) { DBG_8195A("Selected Image %d.\n", imgnum); while (1) { + // новая image только с нового сектора flash faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); uint32 img_id = load_img2_head(faddr, &hdr); if ((img_id >> 8) > 4 && (uint8) img_id != 0) { // есть подпись "RTKW" + RUN или SWP, сегмент != unknown @@ -602,9 +604,10 @@ LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) { DBG_8195A("No Image%d! Trying Image0...\n", imgnum); // пробуем загрузить image по умолчанию, по записи в секторе установок flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr)); - if (faddr < 0x8000000) + if (faddr < 0x08000000) faddr += SPI_FLASH_BASE; if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) { + // если указывает в область flash imagenum = 0; imgnum = 0; } else {