update boot images validation

This commit is contained in:
pvvx 2018-01-21 00:36:37 +03:00
parent 39a516cd39
commit 52cdbed72a

View file

@ -549,8 +549,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_img2_head(uint32 faddr, PIMG2HEAD hdr) {
return ret; return ret;
} }
LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr, uint8 flgload) {
uint8 flgload) {
uint32 fnextaddr = faddr; uint32 fnextaddr = faddr;
uint8 segnum = 0; uint8 segnum = 0;
while (1) { while (1) {
@ -560,7 +559,7 @@ LOCAL uint32 BOOT_RAM_TEXT_SECTION load_segs(uint32 faddr, PIMG2HEAD hdr,
|| seg_id == SEG_ID_SDRAM)) { || seg_id == SEG_ID_SDRAM)) {
#if CONFIG_DEBUG_LOG > 1 #if CONFIG_DEBUG_LOG > 1
DBG_8195A("Load Flash seg%d: 0x%08x -> %s: 0x%08x, size: %d\n", 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); hdr->seg.size);
#endif #endif
fnextaddr += flashcpy(fnextaddr, (void *)hdr->seg.ldaddr, hdr->seg.size); 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 #endif
fnextaddr += hdr->seg.size; fnextaddr += hdr->seg.size;
} else { } else {
// seg_id == UNK
fnextaddr -= 8;
break; break;
} }
fnextaddr += flashcpy(fnextaddr, &hdr->seg, sizeof(IMGSEGHEAD)); fnextaddr += flashcpy(fnextaddr, hdr, sizeof(IMGSEGHEAD)) + 8;
segnum++; segnum++;
} }
return fnextaddr; return fnextaddr;
@ -589,6 +590,7 @@ LOCAL int BOOT_RAM_TEXT_SECTION loadUserImges(int imgnum) {
DBG_8195A("Selected Image %d.\n", imgnum); DBG_8195A("Selected Image %d.\n", imgnum);
while (1) { while (1) {
// новая image только с нового сектора flash
faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1)); faddr = (faddr + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
uint32 img_id = load_img2_head(faddr, &hdr); uint32 img_id = load_img2_head(faddr, &hdr);
if ((img_id >> 8) > 4 && (uint8) img_id != 0) { // есть подпись "RTKW" + RUN или SWP, сегмент != unknown 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); DBG_8195A("No Image%d! Trying Image0...\n", imgnum);
// пробуем загрузить image по умолчанию, по записи в секторе установок // пробуем загрузить image по умолчанию, по записи в секторе установок
flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr)); flashcpy(FLASH_SYSTEM_DATA_ADDR, &faddr, sizeof(faddr));
if (faddr < 0x8000000) if (faddr < 0x08000000)
faddr += SPI_FLASH_BASE; faddr += SPI_FLASH_BASE;
if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) { if (get_seg_id(faddr, 0x100) == SEG_ID_FLASH) {
// если указывает в область flash
imagenum = 0; imagenum = 0;
imgnum = 0; imgnum = 0;
} else { } else {