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
From 5231a7ba250634ca09fdba160b71eb4491d9ff8d Mon Sep 17 00:00:00 2001 From: Lucas Stach <l.stach@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx> --- 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
_______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox