mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/7] scripts: kwboot: set boot source to UART before sending
Date: Wed, 28 Sep 2016 20:50:16 +0200	[thread overview]
Message-ID: <20160928185017.25002-7-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20160928185017.25002-1-u.kleine-koenig@pengutronix.de>

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>
---
 scripts/kwboot.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scripts/kwboot.c b/scripts/kwboot.c
index 1fcb49b7acda..9e4181e539ac 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;
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-09-28 18:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 18:50 [PATCH 0/7] scripts: kwboot: various improvements Uwe Kleine-König
2016-09-28 18:50 ` [PATCH 1/7] scripts: kwboot: try to resync on packet boundary after receiving a NAK Uwe Kleine-König
2016-09-28 18:50 ` [PATCH 2/7] scripts: kwboot: flush input and output only once Uwe Kleine-König
2016-09-28 18:50 ` [PATCH 3/7] scripts: kwboot: improve diagnostic output Uwe Kleine-König
2016-09-28 18:50 ` [PATCH 4/7] scripts: kwboot: shorten delay between two boot messages Uwe Kleine-König
2016-09-28 18:50 ` [PATCH 5/7] scripts: kwboot: simplify kwboot_mmap_image Uwe Kleine-König
2016-09-28 18:50 ` Uwe Kleine-König [this message]
2016-09-28 18:50 ` [PATCH 7/7] images: mvebu: don't generate uart images Uwe Kleine-König
2016-10-04  6:05 ` [PATCH 0/7] scripts: kwboot: various improvements Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160928185017.25002-7-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox