summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-06-02 11:01:29 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-03 09:17:27 +0200
commit5005f599ca88519dfa5139d4e90f3f5c5290bf31 (patch)
treeec58d976e8f993719ce799a7b89e5c5b146e275e /common
parent109e95cce7c77d8401d393831d26b33655759318 (diff)
downloadbarebox-5005f599ca88519dfa5139d4e90f3f5c5290bf31.tar.gz
barebox-5005f599ca88519dfa5139d4e90f3f5c5290bf31.tar.xz
bbu: add flag for enabling eMMC boot ack
bbu_mmcboot_handler() already takes care to switch $mmc.boot to the freshly read inactive partition. On some SoCs like the STM32MP1, this is not enough, but the boot ack bit must be set as well, so the BootROM can communicate with the eMMC. Have this happen as part of the eMMC boot switch after a successful update if bbu_data::flags has BBU_FLAG_MMC_BOOT_ACK set. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/bbu.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/common/bbu.c b/common/bbu.c
index 4d92d70ff9..26b997c02e 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -310,7 +310,7 @@ int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
{
struct bbu_data _data = *data;
int ret;
- char *devicefile = NULL, *bootpartvar = NULL;
+ char *devicefile = NULL, *bootpartvar = NULL, *bootackvar = NULL;
const char *bootpart;
const char *devname = devpath_to_name(data->devicefile);
@@ -346,10 +346,25 @@ 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) {
+ ret = asprintf(&bootackvar, "%s.boot_ack", devname);
+ if (ret < 0)
+ goto out;
+
+ ret = setenv(bootackvar, "1");
+ if (ret)
+ goto out;
+ }
+
/* on success switch boot source */
ret = setenv(bootpartvar, bootpart);
out:
+ free(bootackvar);
free(devicefile);
free(bootpartvar);