From 5231a7ba250634ca09fdba160b71eb4491d9ff8d Mon Sep 17 00:00:00 2001 From: Lucas Stach 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 --- 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