* [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot
@ 2024-02-08 7:52 Sascha Hauer
2024-02-08 7:52 ` [PATCH 2/2] ARM: i.MX: bbu: fix i.MX9 eMMC boot bbu handler Sascha Hauer
2024-02-09 12:34 ` [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-02-08 7:52 UTC (permalink / raw)
To: Barebox List
This adds a standard bbu handler to be used when an update is just
a matter of writing an image to the eMMC boot partitions.
As these may also want to set the BBU_FLAG_MMC_BOOT_ACK flag, it is
moved up one level to struct bbu_handler::flags to make it configurable
when struct bbu_data is not yet instantiated.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-stm32mp/bbu.c | 2 +-
common/bbu.c | 38 ++++++++++++++++++++++++++++++++-----
include/bbu.h | 13 ++++++++++++-
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-stm32mp/bbu.c b/arch/arm/mach-stm32mp/bbu.c
index 56fd4941d0..5d6d61db7d 100644
--- a/arch/arm/mach-stm32mp/bbu.c
+++ b/arch/arm/mach-stm32mp/bbu.c
@@ -129,7 +129,7 @@ static int stm32mp_bbu_mmc_fip_handler(struct bbu_handler *handler,
pr_debug("Handling %s\n", file_type_to_string(filetype));
- data->flags |= BBU_FLAG_MMC_BOOT_ACK;
+ handler->flags |= BBU_HANDLER_FLAG_MMC_BOOT_ACK;
ret = bbu_mmcboot_handler(handler, data, stm32mp_bbu_mmc_update);
if (ret == -ENOENT) {
diff --git a/common/bbu.c b/common/bbu.c
index ed41c92f38..f08ce7e0d5 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -360,11 +360,7 @@ int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
if (ret < 0)
goto out;
- /*
- * This flag can be set in the chained handler or by
- * bbu_mmcboot_handler's caller
- */
- if ((_data.flags | data->flags) & BBU_FLAG_MMC_BOOT_ACK) {
+ if (handler->flags & BBU_HANDLER_FLAG_MMC_BOOT_ACK) {
ret = asprintf(&bootackvar, "%s.boot_ack", devname);
if (ret < 0)
goto out;
@@ -385,6 +381,38 @@ int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
return ret;
}
+static int bbu_internal_mmcboot_update(struct bbu_handler *handler,
+ struct bbu_data *data)
+{
+ int ret;
+
+ ret = bbu_mmcboot_handler(handler, data, bbu_std_file_handler);
+ if (ret == -ENOENT)
+ pr_err("Couldn't read the value of .boot parameter\n");
+
+ return ret;
+}
+
+int bbu_mmcboot_register_handler(const char *name,
+ const char *devicefile,
+ unsigned long flags)
+{
+ struct bbu_handler *handler;
+ int ret;
+
+ handler = xzalloc(sizeof(*handler));
+ handler->devicefile = devicefile;
+ handler->name = name;
+ handler->handler = bbu_internal_mmcboot_update;
+ handler->flags = flags;
+
+ ret = bbu_register_handler(handler);
+ if (ret)
+ free(handler);
+
+ return ret;
+}
+
int bbu_std_file_handler(struct bbu_handler *handler,
struct bbu_data *data)
{
diff --git a/include/bbu.h b/include/bbu.h
index 0a4f324ade..5105d2ac70 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -10,7 +10,6 @@
struct bbu_data {
#define BBU_FLAG_FORCE (1 << 0)
#define BBU_FLAG_YES (1 << 1)
-#define BBU_FLAG_MMC_BOOT_ACK (1 << 2)
unsigned long flags;
int force;
const void *image;
@@ -27,6 +26,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_FLAG_MMC_BOOT_ACK (1 << 16)
/*
* The lower 16bit are generic flags, the upper 16bit are reserved
* for handler specific flags.
@@ -66,6 +66,10 @@ int bbu_register_std_file_update(const char *name, unsigned long flags,
void bbu_append_handlers_to_file_list(struct file_list *files);
+int bbu_mmcboot_register_handler(const char *name,
+ const char *devicefile,
+ unsigned long flags);
+
#else
static inline int bbu_register_handler(struct bbu_handler *unused)
@@ -84,6 +88,13 @@ static inline void bbu_append_handlers_to_file_list(struct file_list *files)
/* none could be registered, so nothing to do */
}
+static inline int bbu_mmcboot_register_handler(const char *name,
+ const char *devicefile,
+ unsigned long flags)
+{
+ return -ENOSYS;
+}
+
#endif
#if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB)
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ARM: i.MX: bbu: fix i.MX9 eMMC boot bbu handler
2024-02-08 7:52 [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
@ 2024-02-08 7:52 ` Sascha Hauer
2024-02-09 12:34 ` [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-02-08 7:52 UTC (permalink / raw)
To: Barebox List
The i.MX9 eMMC boot bbu handler does not work currently, because the
code expects a i.MX image which is not what we need on i.MX9.
The code is also full of i.MX image specific quirks which we don't need
on i.MX9, so use the just created
imx_bbu_internal_mmcboot_register_handler() for i.MX9.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/imx-bbu-internal.c | 5 -----
include/mach/imx/bbu.h | 16 +++++++---------
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index e26317e8bf..8cdaab5c16 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -617,11 +617,6 @@ int imx8m_bbu_internal_mmcboot_register_handler(const char *name,
unsigned long flags)
__alias(imx_bbu_internal_mmcboot_register_handler);
-int imx9_bbu_internal_mmcboot_register_handler(const char *name,
- const char *devicefile,
- unsigned long flags)
- __alias(imx_bbu_internal_mmcboot_register_handler);
-
/*
* Register an i.MX53 internal boot update handler for i2c/spi
* EEPROMs / flashes. Nearly the same as MMC/SD, but we do not need to
diff --git a/include/mach/imx/bbu.h b/include/mach/imx/bbu.h
index f6397a9dd7..9a35b0074d 100644
--- a/include/mach/imx/bbu.h
+++ b/include/mach/imx/bbu.h
@@ -82,8 +82,6 @@ int imx8m_bbu_internal_mmc_register_handler(const char *name, const char *device
unsigned long flags);
int imx8m_bbu_internal_mmcboot_register_handler(const char *name, const char *devicefile,
unsigned long flags);
-int imx9_bbu_internal_mmcboot_register_handler(const char *name, const char *devicefile,
- unsigned long flags);
int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
unsigned long flags);
@@ -184,13 +182,6 @@ static inline int imx8m_bbu_internal_mmcboot_register_handler(const char *name,
return -ENOSYS;
}
-static inline int imx9_bbu_internal_mmcboot_register_handler(const char *name,
- const char *devicefile,
- unsigned long flags)
-{
- return -ENOSYS;
-}
-
static inline int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
unsigned long flags)
{
@@ -231,4 +222,11 @@ static inline int imx_bbu_external_nand_register_handler(const char *name, const
}
#endif
+static inline int imx9_bbu_internal_mmcboot_register_handler(const char *name,
+ const char *devicefile,
+ unsigned long flags)
+{
+ return bbu_mmcboot_register_handler(name, devicefile, flags);
+}
+
#endif /* __MACH_IMX_BBU_H */
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot
2024-02-08 7:52 [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
2024-02-08 7:52 ` [PATCH 2/2] ARM: i.MX: bbu: fix i.MX9 eMMC boot bbu handler Sascha Hauer
@ 2024-02-09 12:34 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-02-09 12:34 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Thu, 08 Feb 2024 08:52:16 +0100, Sascha Hauer wrote:
> This adds a standard bbu handler to be used when an update is just
> a matter of writing an image to the eMMC boot partitions.
> As these may also want to set the BBU_FLAG_MMC_BOOT_ACK flag, it is
> moved up one level to struct bbu_handler::flags to make it configurable
> when struct bbu_data is not yet instantiated.
>
>
> [...]
Applied, thanks!
[1/2] bbu: create a standard bbu handler for eMMC boot
https://git.pengutronix.de/cgit/barebox/commit/?id=4aaed9dd2737 (link may not be stable)
[2/2] ARM: i.MX: bbu: fix i.MX9 eMMC boot bbu handler
https://git.pengutronix.de/cgit/barebox/commit/?id=8545e6e8eaa5 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-09 12:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08 7:52 [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
2024-02-08 7:52 ` [PATCH 2/2] ARM: i.MX: bbu: fix i.MX9 eMMC boot bbu handler Sascha Hauer
2024-02-09 12:34 ` [PATCH 1/2] bbu: create a standard bbu handler for eMMC boot Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox