mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	barebox@lists.infradead.org,
	Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Subject: Re: [PATCH 2/2] ARM: i.MX: Add support for ZII RDU1 board
Date: Tue, 19 Jun 2018 14:42:20 +0200	[thread overview]
Message-ID: <1529412140.7211.22.camel@pengutronix.de> (raw)
In-Reply-To: <5226f251-0465-e9ca-6f5a-c0b29f5eda39@cogentembedded.com>

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

Am Dienstag, den 19.06.2018, 14:34 +0300 schrieb Nikita Yushchenko:
> > > > > > +	imx51_bbu_internal_spi_i2c_register_handler("spi",
> > > > > > +						    "/dev/dataflash0.barebox",
> > > +						    BBU_HANDLER_FLAG_DEFAULT);
> > 
> > Did you test that this works? The Barebox partition has an offset and
> > according the RM the BootROM looks at a specific location for the image
> > header, so I think the Barebox image needs to be truncated for this to
> > work.
> 
> Yes, this works, together with this patch:
> 
> https://github.com/CogentEmbedded/barebox-zodiac/commit/9b523e459e198960b94594b7185baa0dd2649feb
> 
> I've copied this code from earlier version developed by Andrey Gusakov [CCed].
> 
> I did not try to change anything there, to ensure board stays bootable ;).

But this isn't a generic fix that can be applied upstream. Nothing in
the i.MX51 boot specification says that the first 1024 bytes of flash
shouldn't be written and in fact this is cutting the Barebox image
signature from the image written to flash, which is generally
undesirable.

And it probably also doesn't work with the barebox partition having an
offset on the flash, as is done with this patch.

I've added a ugly workaround in the BSP patchstack, which _might_ be
acceptable upstream. See attached patch.

Regards,
Lucas

[-- Attachment #2: 0001-bbu-add-flag-to-skip-writing-the-padding-before-the-.patch --]
[-- Type: text/x-patch, Size: 2152 bytes --]

From 5231a7ba250634ca09fdba160b71eb4491d9ff8d Mon Sep 17 00:00:00 2001
From: Lucas Stach <l.stach@pengutronix.de>
Date: Mon, 7 May 2018 12:54:15 +0200
Subject: [PATCH] bbu: add flag to skip writing the padding before the flash
 header

This is ugly, but needed as on the ZII RDU1 board the flash holds some
important data in the first 1024 bytes, so we need to avoid writing
anything into this. This is implemented by having the barebox partition
start at this offset, but BBU needs to truncate the image accordingly.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 11 ++++++++++-
 include/bbu.h                        |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index c7375ff52aee..45610f0ef9ac 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -160,15 +160,24 @@ static int imx_bbu_internal_v1_update(struct bbu_handler *handler, struct bbu_da
 {
 	struct imx_internal_bbu_handler *imx_handler =
 		container_of(handler, struct imx_internal_bbu_handler, handler);
+	const void *databuf = data->image;
+	int len = data->len;
 	int ret;
 
 	ret = imx_bbu_check_prereq(data->devicefile, data);
 	if (ret)
 		return ret;
 
+	if (handler->flags & BBU_HANDLER_SKIP_HEADER_OFFSET)
+	{
+		databuf += imx_handler->flash_header_offset;
+		len -= imx_handler->flash_header_offset;
+	}
+
 	printf("updating to %s\n", data->devicefile);
 
-	ret = imx_bbu_write_device(imx_handler, data->devicefile, data, data->image, data->len);
+	ret = imx_bbu_write_device(imx_handler, data->devicefile, data,
+				   databuf, len);
 
 	return ret;
 }
diff --git a/include/bbu.h b/include/bbu.h
index def568e498d4..16f498e5724a 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -25,6 +25,7 @@ struct bbu_handler {
 	struct list_head list;
 #define BBU_HANDLER_FLAG_DEFAULT	(1 << 0)
 #define BBU_HANDLER_CAN_REFRESH		(1 << 1)
+#define BBU_HANDLER_SKIP_HEADER_OFFSET	(1 << 2)
 	unsigned long flags;
 
 	/* default device file, can be overwritten on the command line */
-- 
2.17.1


[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

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

  reply	other threads:[~2018-06-19 12:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19  5:43 [PATCH 1/2] ARM: babbage: Make PMIC initialization shareable Andrey Smirnov
2018-06-19  5:43 ` [PATCH 2/2] ARM: i.MX: Add support for ZII RDU1 board Andrey Smirnov
2018-06-19  8:51   ` Lucas Stach
2018-06-19 11:34     ` Nikita Yushchenko
2018-06-19 12:42       ` Lucas Stach [this message]
2018-06-19 16:24     ` Andrey Smirnov
2018-06-19  8:51 ` [PATCH 1/2] ARM: babbage: Make PMIC initialization shareable Lucas Stach
2018-06-19 16:55   ` Andrey Smirnov
2018-06-20  7:16     ` Sascha Hauer
2018-06-20 18:13       ` Andrey Smirnov

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=1529412140.7211.22.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=andrey.gusakov@cogentembedded.com \
    --cc=barebox@lists.infradead.org \
    --cc=nikita.yoush@cogentembedded.com \
    /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