From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/2] ARM: AM33xx: swap MLO SPI image automatically
Date: Thu, 15 May 2014 12:45:27 +0200 [thread overview]
Message-ID: <1400150728-28314-1-git-send-email-s.hauer@pengutronix.de> (raw)
The MLO image for SPI differs in the normal MLO in that the
SPI version is big endian. As both types of images are floating
around detect whether or not the image is swapped automatically.
This also adds a check whether we have a valid MLO image.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-omap/am33xx_bbu_spi_mlo.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
index ff9f8a6..1aa3d7b 100644
--- a/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
+++ b/arch/arm/mach-omap/am33xx_bbu_spi_mlo.c
@@ -32,6 +32,18 @@ static int spi_nor_mlo_handler(struct bbu_handler *handler,
uint32_t readbuf;
int size = data->len;
void *image = data->image;
+ uint32_t *header;
+ int swap = 0;
+
+ header = data->image;
+ if (header[5] == 0x43485345) {
+ swap = 0;
+ } else if (header[5] == 0x45534843) {
+ swap = 1;
+ } else {
+ if (!bbu_force(data, "Not a MLO image"))
+ return -EINVAL;
+ }
dstfd = open(data->devicefile, O_WRONLY);
if (dstfd < 0) {
@@ -49,7 +61,8 @@ static int spi_nor_mlo_handler(struct bbu_handler *handler,
for (; size >= 0; size -= 4) {
memcpy((char *)&readbuf, image, 4);
- readbuf = cpu_to_be32(readbuf);
+ if (swap)
+ readbuf = cpu_to_be32(readbuf);
ret = write(dstfd, &readbuf, 4);
if (ret < 0) {
perror("write");
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2014-05-15 10:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 10:45 Sascha Hauer [this message]
2014-05-15 10:45 ` [PATCH 2/2] ARM: AM33xx: Add SPI bbu handler 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=1400150728-28314-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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