9
0
Fork 0

scripts: kwboot: set boot source to UART before sending

Sending an image that specifies one of the alternative boot sources doesn't
make sense. So change the boot source to UART on the fly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Uwe Kleine-König 2016-09-28 20:50:16 +02:00 committed by Sascha Hauer
parent 90184dbc36
commit 481274a935
1 changed files with 11 additions and 3 deletions

View File

@ -600,7 +600,7 @@ out:
}
static int
kwboot_check_image(const unsigned char *img, size_t size)
kwboot_check_image(unsigned char *img, size_t size)
{
size_t i;
size_t header_size, image_size;
@ -613,12 +613,20 @@ kwboot_check_image(const unsigned char *img, size_t size)
}
switch (img[0x0]) {
case 0x5a: /* SPI/NOR */
case 0x69: /* UART0 */
break;
case 0x5a: /* SPI/NOR */
case 0x78: /* SATA */
case 0x8b: /* NAND */
case 0x9c: /* PCIe */
/* change boot source to UART and fix checksum */
img[0x1f] -= img[0x0];
img[0x1f] += 0x69;
img[0x0] = 0x69;
break;
default:
fprintf(stderr,
"Unknown boot source: 0x%hhx\n", img[0x0]);
@ -674,7 +682,7 @@ kwboot_mmap_image(const char *path, size_t *size)
if (rc)
goto out;
img = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
img = mmap(NULL, st.st_size, PROT_WRITE, MAP_PRIVATE, fd, 0);
if (img == MAP_FAILED) {
img = NULL;
goto out;