mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2023-10-10 13:37:43 +02:00
properly handle flash size limits
This commit is contained in:
parent
b200ce3596
commit
eb427a8df2
@ -119,7 +119,7 @@ static int update_flash(struct ddflash *ddf)
|
|||||||
printf("Flash: %s\n", ddf->flash_name);
|
printf("Flash: %s\n", ddf->flash_name);
|
||||||
printf("Version: %08x\n", ddf->id.hw);
|
printf("Version: %08x\n", ddf->id.hw);
|
||||||
printf("REGMAP : %08x\n", ddf->id.regmap);
|
printf("REGMAP : %08x\n", ddf->id.regmap);
|
||||||
if ((res = update_image(ddf, fname, 0x10000, 0x100000, 1, 0)) == 1)
|
if ((res = update_image(ddf, fname, 0x10000, ddf->size / 2, 1, 0)) == 1)
|
||||||
stat |= 1;
|
stat |= 1;
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
@ -968,12 +968,10 @@ static int flashcmp(struct ddflash *ddf, int fs, uint32_t addr, uint32_t maxlen,
|
|||||||
return -1;
|
return -1;
|
||||||
len = off - fw_off;
|
len = off - fw_off;
|
||||||
lseek(fs, fw_off, SEEK_SET);
|
lseek(fs, fw_off, SEEK_SET);
|
||||||
#if 0
|
|
||||||
if (len > maxlen) {
|
if (len > maxlen) {
|
||||||
printf("file too big\n");
|
printf("file too big\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
//printf("flash file len %u, compare to %08x in flash: ", len, addr);
|
//printf("flash file len %u, compare to %08x in flash: ", len, addr);
|
||||||
for (j = 0; j < len; j += bl, addr += bl) {
|
for (j = 0; j < len; j += bl, addr += bl) {
|
||||||
if (len - j < bl)
|
if (len - j < bl)
|
||||||
@ -1132,9 +1130,15 @@ static int check_fw(struct ddflash *ddf, char *fn, uint32_t *fw_off)
|
|||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
if (devid == ddf->id.device) {
|
if (devid == ddf->id.device) {
|
||||||
if (version <= (ddf->id.hw & 0xffffff)) {
|
if (version < (ddf->id.hw & 0xffffff)) {
|
||||||
printf("%s is older or same version as flash\n", fn);
|
printf("%s is older version than flash\n", fn);
|
||||||
ret = -3; /* same id but no newer version */
|
if (!ddf->force)
|
||||||
|
ret = -3; /* same id but older newer version */
|
||||||
|
}
|
||||||
|
if (version == (ddf->id.hw & 0xffffff)) {
|
||||||
|
printf("%s is same version as flash\n", fn);
|
||||||
|
if (!ddf->force)
|
||||||
|
ret = 2; /* same and same version */
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -1147,7 +1151,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int update_image(struct ddflash *ddf, char *fn,
|
static int update_image(struct ddflash *ddf, char *fn,
|
||||||
uint32_t adr, uint32_t len,
|
uint32_t adr, uint32_t maxlen,
|
||||||
int has_header, int no_change)
|
int has_header, int no_change)
|
||||||
{
|
{
|
||||||
int fs, res = 0;
|
int fs, res = 0;
|
||||||
@ -1167,7 +1171,7 @@ static int update_image(struct ddflash *ddf, char *fn,
|
|||||||
printf("File %s not found \n", fn);
|
printf("File %s not found \n", fn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
res = flashcmp(ddf, fs, adr, len, fw_off);
|
res = flashcmp(ddf, fs, adr, maxlen, fw_off);
|
||||||
if (res == -2) {
|
if (res == -2) {
|
||||||
printf("Flash already identical to %s\n", fn);
|
printf("Flash already identical to %s\n", fn);
|
||||||
if (ddf->force) {
|
if (ddf->force) {
|
||||||
@ -1177,9 +1181,9 @@ static int update_image(struct ddflash *ddf, char *fn,
|
|||||||
}
|
}
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto out;
|
goto out;
|
||||||
res = flashwrite(ddf, fs, adr, len, fw_off);
|
res = flashwrite(ddf, fs, adr, maxlen, fw_off);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
res = flashcmp(ddf, fs, adr, len, fw_off);
|
res = flashcmp(ddf, fs, adr, maxlen, fw_off);
|
||||||
if (res == -2) {
|
if (res == -2) {
|
||||||
res = 1;
|
res = 1;
|
||||||
printf("Flash verify OK!\n");
|
printf("Flash verify OK!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user