diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2016-09-28 20:50:16 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-10-04 21:14:20 +0200 |
commit | 481274a9353ef62b64cbaf9e5b25cae47235b7f2 (patch) | |
tree | 02707764d88f1f8be3c6fdde52ebe250a487413f | |
parent | 90184dbc3691fd0ba188682fdc55d82a2af230ed (diff) | |
download | barebox-481274a9353ef62b64cbaf9e5b25cae47235b7f2.tar.gz barebox-481274a9353ef62b64cbaf9e5b25cae47235b7f2.tar.xz |
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>
-rw-r--r-- | scripts/kwboot.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/kwboot.c b/scripts/kwboot.c index 1fcb49b7ac..9e4181e539 100644 --- a/scripts/kwboot.c +++ b/scripts/kwboot.c @@ -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; |