summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/cpu/cpuinfo.c18
-rw-r--r--arch/arm/cpu/mmu-common.c15
-rw-r--r--arch/arm/cpu/start.c8
-rw-r--r--arch/arm/include/asm/barebox-arm.h1
-rw-r--r--arch/arm/mach-imx/imx-bbu-internal.c48
-rw-r--r--arch/arm/mach-omap/syslib.c15
-rw-r--r--arch/arm/mach-stm32mp/Makefile1
-rw-r--r--arch/arm/mach-stm32mp/bbu.c197
-rw-r--r--arch/arm/mach-stm32mp/include/mach/bbu.h18
-rw-r--r--arch/arm/mach-stm32mp/stm32image.c2
-rw-r--r--common/bbu.c100
-rw-r--r--common/booti.c30
-rw-r--r--common/filetype.c15
-rw-r--r--include/bbu.h7
-rw-r--r--include/filetype.h3
15 files changed, 394 insertions, 84 deletions
diff --git a/arch/arm/cpu/cpuinfo.c b/arch/arm/cpu/cpuinfo.c
index a08fc253ef..aea50e80d1 100644
--- a/arch/arm/cpu/cpuinfo.c
+++ b/arch/arm/cpu/cpuinfo.c
@@ -27,6 +27,7 @@
#define ARM_CPU_PART_CORTEX_A15 0xC0F0
#define ARM_CPU_PART_CORTEX_A53 0xD030
#define ARM_CPU_PART_CORTEX_A57 0xD070
+#define ARM_CPU_PART_CORTEX_A72 0xD080
static void decode_cache(unsigned long size)
{
@@ -191,7 +192,7 @@ static int do_cpuinfo(int argc, char *argv[])
if (cpu_arch >= CPU_ARCH_ARMv7) {
unsigned int major, minor;
- char *part;
+ const char *part = NULL;
major = (mainid >> 20) & 0xf;
minor = mainid & 0xf;
switch (mainid & 0xfff0) {
@@ -216,12 +217,23 @@ static int do_cpuinfo(int argc, char *argv[])
case ARM_CPU_PART_CORTEX_A57:
part = "Cortex-A57";
break;
+ case ARM_CPU_PART_CORTEX_A72:
+ part = "Cortex-A72";
+ break;
default:
- part = "unknown";
+ printf("core: unknown (0x%08lx) r%up%u\n",
+ mainid, major, minor);
+ break;
}
- printf("core: %s r%up%u\n", part, major, minor);
+
+ if (part)
+ printf("core: %s r%up%u\n", part, major, minor);
}
+#ifdef CONFIG_CPU_64v8
+ printf("exception level: %u\n", current_el());
+#endif
+
if (cache & (1 << 24)) {
/* separate I/D cache */
printf("I-cache: ");
diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c
index 2ef1fa231f..488a189f1c 100644
--- a/arch/arm/cpu/mmu-common.c
+++ b/arch/arm/cpu/mmu-common.c
@@ -9,6 +9,7 @@
#include <dma.h>
#include <mmu.h>
#include <asm/system.h>
+#include <asm/barebox-arm.h>
#include <memory.h>
#include "mmu.h"
@@ -58,14 +59,24 @@ void dma_free_coherent(void *mem, dma_addr_t dma_handle, size_t size)
static int mmu_init(void)
{
- if (list_empty(&memory_banks))
+ if (list_empty(&memory_banks)) {
+ resource_size_t start;
+ int ret;
+
/*
* If you see this it means you have no memory registered.
* This can be done either with arm_add_mem_device() in an
* initcall prior to mmu_initcall or via devicetree in the
* memory node.
*/
- panic("MMU: No memory bank found! Cannot continue\n");
+ pr_emerg("No memory bank registered. Limping along with initial memory\n");
+
+ start = arm_mem_membase_get();
+ ret = barebox_add_memory_bank("initmem", start,
+ arm_mem_endmem_get() - start);
+ if (ret)
+ panic("");
+ }
__mmu_init(get_cr() & CR_M);
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index c61db66865..14cc310312 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -28,6 +28,7 @@
unsigned long arm_stack_top;
static unsigned long arm_barebox_size;
static unsigned long arm_endmem;
+static unsigned long arm_membase;
static void *barebox_boarddata;
static unsigned long barebox_boarddata_size;
@@ -114,6 +115,12 @@ unsigned long arm_mem_endmem_get(void)
}
EXPORT_SYMBOL_GPL(arm_mem_endmem_get);
+unsigned long arm_mem_membase_get(void)
+{
+ return arm_membase;
+}
+EXPORT_SYMBOL_GPL(arm_mem_membase_get);
+
static int barebox_memory_areas_init(void)
{
if(barebox_boarddata)
@@ -148,6 +155,7 @@ __noreturn __no_sanitize_address void barebox_non_pbl_start(unsigned long membas
pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize);
+ arm_membase = membase;
arm_endmem = endmem;
arm_stack_top = arm_mem_stack_top(membase, endmem);
arm_barebox_size = barebox_size;
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 15b3b6c444..8240cce9bf 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -84,6 +84,7 @@ static inline void boarddata_create(void *adr, u32 machine)
u32 barebox_arm_machine(void);
unsigned long arm_mem_ramoops_get(void);
+unsigned long arm_mem_membase_get(void);
unsigned long arm_mem_endmem_get(void);
struct barebox_arm_boarddata *barebox_arm_get_boarddata(void);
diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 64d4d77ff5..3b0c587cc5 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -422,54 +422,12 @@ static int imx_bbu_update(struct bbu_handler *handler, struct bbu_data *data)
static int imx_bbu_internal_mmcboot_update(struct bbu_handler *handler,
struct bbu_data *data)
{
- struct bbu_data _data = *data;
int ret;
- char *bootpartvar;
- const char *bootpart;
- char *devicefile;
- const char *devname = devpath_to_name(data->devicefile);
- ret = device_detect_by_name(devname);
- if (ret) {
- pr_err("Couldn't detect device '%s'\n", devname);
- return ret;
- }
-
- ret = asprintf(&bootpartvar, "%s.boot", devname);
- if (ret < 0)
- return ret;
-
- bootpart = getenv(bootpartvar);
- if (!bootpart) {
- pr_err("Couldn't read the value of '%s'\n", bootpartvar);
- ret = -ENOENT;
- goto free_bootpartvar;
- }
-
- if (!strcmp(bootpart, "boot0")) {
- bootpart = "boot1";
- } else {
- bootpart = "boot0";
- }
-
- ret = asprintf(&devicefile, "/dev/%s.%s", devname, bootpart);
- if (ret < 0)
- goto free_bootpartvar;
-
- _data.devicefile = devicefile;
-
- ret = imx_bbu_update(handler, &_data);
- if (ret)
- goto free_devicefile;
-
- /* on success switch boot source */
- ret = setenv(bootpartvar, bootpart);
-
-free_devicefile:
- free(devicefile);
+ ret = bbu_mmcboot_handler(handler, data, imx_bbu_update);
-free_bootpartvar:
- free(bootpartvar);
+ if (ret == -ENOENT)
+ pr_err("Couldn't read the value of .boot parameter\n");
return ret;
}
diff --git a/arch/arm/mach-omap/syslib.c b/arch/arm/mach-omap/syslib.c
index 42da348c5a..488f0ab859 100644
--- a/arch/arm/mach-omap/syslib.c
+++ b/arch/arm/mach-omap/syslib.c
@@ -52,19 +52,16 @@ void sdelay(unsigned long loops)
* @param[in] read_addr address to read from
* @param[in] bound max iterations
*
- * @return 1 if match_value is found, else if bound iterations reached,
+ * @return non zero if match_value is found, else if bound iterations reached,
* returns 0
*/
u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
{
- u32 i = 0, val;
do {
- ++i;
- val = readl(read_addr) & read_bit_mask;
+ u32 val = readl(read_addr) & read_bit_mask;
if (val == match_value)
- return 1;
- if (i == bound)
- return 0;
- } while (1);
-}
+ break;
+ } while (--bound);
+ return bound;
+}
diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile
index 86c13b8fca..837449150c 100644
--- a/arch/arm/mach-stm32mp/Makefile
+++ b/arch/arm/mach-stm32mp/Makefile
@@ -4,3 +4,4 @@ obj-y := init.o
obj-pbl-y := ddrctrl.o
pbl-y := bl33-generic.o
obj-$(CONFIG_BOOTM) += stm32image.o
+obj-$(CONFIG_BAREBOX_UPDATE) += bbu.o
diff --git a/arch/arm/mach-stm32mp/bbu.c b/arch/arm/mach-stm32mp/bbu.c
new file mode 100644
index 0000000000..545965198f
--- /dev/null
+++ b/arch/arm/mach-stm32mp/bbu.c
@@ -0,0 +1,197 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#define pr_fmt(fmt) "stm32mp-bbu: " fmt
+#include <common.h>
+#include <malloc.h>
+#include <bbu.h>
+#include <filetype.h>
+#include <errno.h>
+#include <fs.h>
+#include <fcntl.h>
+#include <linux/sizes.h>
+#include <linux/stat.h>
+#include <ioctl.h>
+#include <mach/bbu.h>
+#include <libfile.h>
+#include <linux/bitfield.h>
+
+#define STM32MP_BBU_IMAGE_HAVE_FSBL BIT(0)
+#define STM32MP_BBU_IMAGE_HAVE_FIP BIT(1)
+
+struct stm32mp_bbu_handler {
+ struct bbu_handler handler;
+ loff_t offset;
+};
+
+#define to_stm32mp_bbu_handler(h) container_of(h, struct stm32mp_bbu_handler, h)
+
+static int stm32mp_bbu_gpt_part_update(struct bbu_handler *handler,
+ const struct bbu_data *data,
+ const char *part, bool optional)
+{
+ struct bbu_data gpt_data = *data;
+ struct stat st;
+ int ret;
+
+ gpt_data.devicefile = basprintf("%s.%s", gpt_data.devicefile, part);
+ if (!gpt_data.devicefile)
+ return -ENOMEM;
+
+ pr_debug("Attempting %s update\n", gpt_data.devicefile);
+
+ ret = stat(gpt_data.devicefile, &st);
+ if (ret == -ENOENT) {
+ if (optional)
+ return 0;
+ pr_err("Partition %s does not exist\n", gpt_data.devicefile);
+ }
+ if (ret)
+ goto out;
+
+ ret = bbu_std_file_handler(handler, &gpt_data);
+out:
+ kfree_const(gpt_data.devicefile);
+ return ret;
+}
+
+static int stm32mp_bbu_mmc_update(struct bbu_handler *handler,
+ struct bbu_data *data)
+{
+ struct stm32mp_bbu_handler *priv = to_stm32mp_bbu_handler(handler);
+ int fd, ret;
+ size_t image_len = data->len;
+ const void *buf = data->image;
+ struct stat st;
+
+ pr_debug("Attempting eMMC boot partition update\n");
+
+ ret = bbu_confirm(data);
+ if (ret)
+ return ret;
+
+ fd = open(data->devicefile, O_RDWR);
+ if (fd < 0)
+ return fd;
+
+ ret = fstat(fd, &st);
+ if (ret)
+ goto close;
+
+ if (st.st_size < priv->offset || image_len > st.st_size - priv->offset) {
+ ret = -ENOSPC;
+ goto close;
+ }
+
+ ret = pwrite_full(fd, buf, image_len, priv->offset);
+ if (ret < 0)
+ pr_err("writing to %s failed with %pe\n", data->devicefile, ERR_PTR(ret));
+
+close:
+ close(fd);
+
+ return ret < 0 ? ret : 0;
+}
+
+/*
+ * TF-A compiled with STM32_EMMC_BOOT will first check for FIP image
+ * at offset SZ_256K and then in GPT partition of that name.
+ */
+static int stm32mp_bbu_mmc_fip_handler(struct bbu_handler *handler,
+ struct bbu_data *data)
+{
+ struct stm32mp_bbu_handler *priv = to_stm32mp_bbu_handler(handler);
+ enum filetype filetype;
+ int image_flags = 0, ret;
+ bool is_emmc = true;
+
+ filetype = file_detect_type(data->image, data->len);
+
+ switch (filetype) {
+ case filetype_stm32_image_fsbl_v1:
+ priv->offset = 0;
+ image_flags |= STM32MP_BBU_IMAGE_HAVE_FSBL;
+ if (data->len > SZ_256K)
+ image_flags |= STM32MP_BBU_IMAGE_HAVE_FIP;
+ break;
+ default:
+ if (!bbu_force(data, "incorrect image type. Expected: %s, got %s",
+ file_type_to_string(filetype_fip),
+ file_type_to_string(filetype)))
+ return -EINVAL;
+ /* If forced assume it's a SSBL */
+ filetype = filetype_fip;
+ fallthrough;
+ case filetype_fip:
+ priv->offset = SZ_256K;
+ image_flags |= STM32MP_BBU_IMAGE_HAVE_FIP;
+ break;
+ }
+
+ pr_debug("Handling %s\n", file_type_to_string(filetype));
+
+ data->flags |= BBU_FLAG_MMC_BOOT_ACK;
+
+ ret = bbu_mmcboot_handler(handler, data, stm32mp_bbu_mmc_update);
+ if (ret == -ENOENT) {
+ pr_debug("Not an eMMC, falling back to GPT fsbl1 partition\n");
+ is_emmc = false;
+ ret = 0;
+ }
+ if (ret < 0) {
+ pr_debug("eMMC boot update failed: %pe\n", ERR_PTR(ret));
+ return ret;
+ }
+
+ if (!is_emmc && (image_flags & STM32MP_BBU_IMAGE_HAVE_FSBL)) {
+ struct bbu_data fsbl1_data = *data;
+
+ fsbl1_data.len = min_t(size_t, fsbl1_data.len, SZ_256K);
+
+ /*
+ * BootROM tells TF-A which fsbl slot was booted in r0, but TF-A
+ * doesn't yet propagate this to us, so for now always flash
+ * fsbl1
+ */
+ ret = stm32mp_bbu_gpt_part_update(handler, &fsbl1_data, "fsbl1", false);
+ }
+
+ if (ret == 0 && (image_flags & STM32MP_BBU_IMAGE_HAVE_FIP)) {
+ struct bbu_data fip_data = *data;
+
+ if (image_flags & STM32MP_BBU_IMAGE_HAVE_FSBL) {
+ fip_data.image += SZ_256K;
+ fip_data.len -= SZ_256K;
+ }
+
+ /* No fip GPT partition in eMMC user area is usually ok, as
+ * that means TF-A is configured to load FIP from eMMC boot part
+ */
+ ret = stm32mp_bbu_gpt_part_update(handler, &fip_data, "fip", is_emmc);
+ }
+
+ if (ret < 0)
+ pr_debug("eMMC user area update failed: %pe\n", ERR_PTR(ret));
+
+ return ret;
+}
+
+int stm32mp_bbu_mmc_fip_register(const char *name,
+ const char *devicefile,
+ unsigned long flags)
+{
+ struct stm32mp_bbu_handler *priv;
+ int ret;
+
+ priv = xzalloc(sizeof(*priv));
+
+ priv->handler.flags = flags;
+ priv->handler.devicefile = devicefile;
+ priv->handler.name = name;
+ priv->handler.handler = stm32mp_bbu_mmc_fip_handler;
+
+ ret = bbu_register_handler(&priv->handler);
+ if (ret)
+ free(priv);
+
+ return ret;
+}
diff --git a/arch/arm/mach-stm32mp/include/mach/bbu.h b/arch/arm/mach-stm32mp/include/mach/bbu.h
index d49fb045ea..b469cdeb7c 100644
--- a/arch/arm/mach-stm32mp/include/mach/bbu.h
+++ b/arch/arm/mach-stm32mp/include/mach/bbu.h
@@ -10,7 +10,23 @@ static inline int stm32mp_bbu_mmc_register_handler(const char *name,
unsigned long flags)
{
return bbu_register_std_file_update(name, flags, devicefile,
- filetype_stm32_image_v1);
+ filetype_stm32_image_ssbl_v1);
}
+#ifdef CONFIG_BAREBOX_UPDATE
+
+int stm32mp_bbu_mmc_fip_register(const char *name, const char *devicefile,
+ unsigned long flags);
+
+#else
+
+static inline int stm32mp_bbu_mmc_fip_register(const char *name,
+ const char *devicefile,
+ unsigned long flags)
+{
+ return -ENOSYS;
+}
+
+#endif
+
#endif /* MACH_STM32MP_BBU_H_ */
diff --git a/arch/arm/mach-stm32mp/stm32image.c b/arch/arm/mach-stm32mp/stm32image.c
index caff68651c..7867418e6c 100644
--- a/arch/arm/mach-stm32mp/stm32image.c
+++ b/arch/arm/mach-stm32mp/stm32image.c
@@ -40,7 +40,7 @@ static int do_bootm_stm32image(struct image_data *data)
static struct image_handler image_handler_stm32_image_v1_handler = {
.name = "STM32 image (v1)",
.bootm = do_bootm_stm32image,
- .filetype = filetype_stm32_image_v1,
+ .filetype = filetype_stm32_image_ssbl_v1,
};
static int stm32mp_register_stm32image_image_handler(void)
diff --git a/common/bbu.c b/common/bbu.c
index cd7bdc40b7..d243ac89dd 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -19,6 +19,7 @@
#include <malloc.h>
#include <linux/stat.h>
#include <image-metadata.h>
+#include <environment.h>
#include <file-list.h>
static LIST_HEAD(bbu_image_handlers);
@@ -304,23 +305,79 @@ struct bbu_std {
enum filetype filetype;
};
-static int bbu_std_file_handler(struct bbu_handler *handler,
- struct bbu_data *data)
+int bbu_mmcboot_handler(struct bbu_handler *handler, struct bbu_data *data,
+ int (*chained_handler)(struct bbu_handler *, struct bbu_data *))
+{
+ struct bbu_data _data = *data;
+ int ret;
+ char *devicefile = NULL, *bootpartvar = NULL, *bootackvar = NULL;
+ const char *bootpart;
+ const char *devname = devpath_to_name(data->devicefile);
+
+ ret = device_detect_by_name(devname);
+ if (ret) {
+ pr_err("Couldn't detect device '%s'\n", devname);
+ return ret;
+ }
+
+ ret = asprintf(&bootpartvar, "%s.boot", devname);
+ if (ret < 0)
+ return ret;
+
+ bootpart = getenv(bootpartvar);
+ if (!bootpart) {
+ ret = -ENOENT;
+ goto out;
+ }
+
+ if (!strcmp(bootpart, "boot0")) {
+ bootpart = "boot1";
+ } else {
+ bootpart = "boot0";
+ }
+
+ ret = asprintf(&devicefile, "/dev/%s.%s", devname, bootpart);
+ if (ret < 0)
+ goto out;
+
+ _data.devicefile = devicefile;
+
+ ret = chained_handler(handler, &_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);
+
+ return ret;
+}
+
+int bbu_std_file_handler(struct bbu_handler *handler,
+ struct bbu_data *data)
{
- struct bbu_std *std = container_of(handler, struct bbu_std, handler);
int fd, ret;
- enum filetype filetype;
struct stat s;
unsigned oflags = O_WRONLY;
- filetype = file_detect_type(data->image, data->len);
- if (filetype != std->filetype) {
- if (!bbu_force(data, "incorrect image type. Expected: %s, got %s",
- file_type_to_string(std->filetype),
- file_type_to_string(filetype)))
- return -EINVAL;
- }
-
device_detect_by_name(devpath_to_name(data->devicefile));
ret = stat(data->devicefile, &s);
@@ -369,6 +426,23 @@ err_close:
return ret;
}
+static int bbu_std_file_handler_checked(struct bbu_handler *handler,
+ struct bbu_data *data)
+{
+ struct bbu_std *std = container_of(handler, struct bbu_std, handler);
+ enum filetype filetype;
+
+ filetype = file_detect_type(data->image, data->len);
+ if (filetype != std->filetype) {
+ if (!bbu_force(data, "incorrect image type. Expected: %s, got %s",
+ file_type_to_string(std->filetype),
+ file_type_to_string(filetype)))
+ return -EINVAL;
+ }
+
+ return bbu_std_file_handler(handler, data);
+}
+
/**
* bbu_register_std_file_update() - register a barebox update handler for a
* standard file-to-device-copy operation
@@ -399,7 +473,7 @@ int bbu_register_std_file_update(const char *name, unsigned long flags,
handler->flags = flags;
handler->devicefile = devicefile;
handler->name = name;
- handler->handler = bbu_std_file_handler;
+ handler->handler = bbu_std_file_handler_checked;
ret = bbu_register_handler(handler);
if (ret)
diff --git a/common/booti.c b/common/booti.c
index a2d63d8c31..dde1605fe1 100644
--- a/common/booti.c
+++ b/common/booti.c
@@ -6,11 +6,31 @@
#include <bootm.h>
#include <linux/sizes.h>
+static unsigned long get_kernel_address(unsigned long os_address,
+ unsigned long text_offset)
+{
+ resource_size_t start, end;
+ int ret;
+
+ if (os_address == UIMAGE_SOME_ADDRESS ||
+ os_address == UIMAGE_INVALID_ADDRESS) {
+ ret = memory_bank_first_find_space(&start, &end);
+ if (ret)
+ return UIMAGE_INVALID_ADDRESS;
+
+ return ALIGN(start, SZ_2M) + text_offset;
+ }
+
+ if (os_address >= text_offset && IS_ALIGNED(os_address - text_offset, SZ_2M))
+ return os_address;
+
+ return ALIGN(os_address, SZ_2M) + text_offset;
+}
+
void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
{
const void *kernel_header =
data->os_fit ? data->fit_kernel : data->os_header;
- resource_size_t start, end;
unsigned long text_offset, image_size, devicetree, kernel;
unsigned long image_end;
int ret;
@@ -19,11 +39,9 @@ void *booti_load_image(struct image_data *data, phys_addr_t *oftree)
text_offset = le64_to_cpup(kernel_header + 8);
image_size = le64_to_cpup(kernel_header + 16);
- ret = memory_bank_first_find_space(&start, &end);
- if (ret)
- return ERR_PTR(ret);
-
- kernel = ALIGN(start, SZ_2M) + text_offset;
+ kernel = get_kernel_address(data->os_address, text_offset);
+ if (kernel == UIMAGE_INVALID_ADDRESS)
+ return ERR_PTR(-ENOENT);
ret = bootm_load_os(data, kernel);
if (ret)
diff --git a/common/filetype.c b/common/filetype.c
index 0ded64b83c..8f79f48bc1 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -71,7 +71,8 @@ static const struct filetype_str filetype_str[] = {
[filetype_layerscape_qspi_image] = { "Layerscape QSPI image", "layerscape-qspi-PBL" },
[filetype_ubootvar] = { "U-Boot environmemnt variable data",
"ubootvar" },
- [filetype_stm32_image_v1] = { "STM32 image (v1)", "stm32-image-v1" },
+ [filetype_stm32_image_fsbl_v1] = { "STM32MP FSBL image (v1)", "stm32-fsbl-v1" },
+ [filetype_stm32_image_ssbl_v1] = { "STM32MP SSBL image (v1)", "stm32-ssbl-v1" },
[filetype_zynq_image] = { "Zynq image", "zynq-image" },
[filetype_mxs_sd_image] = { "i.MX23/28 SD card image", "mxs-sd-image" },
[filetype_rockchip_rkns_image] = { "Rockchip boot image", "rk-image" },
@@ -372,8 +373,14 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
return filetype_unknown;
if (strncmp(buf8, "STM\x32", 4) == 0) {
- if (buf8[74] == 0x01)
- return filetype_stm32_image_v1;
+ if (buf8[74] == 0x01) {
+ switch(le32_to_cpu(buf[63])) {
+ case 0x00000000:
+ return filetype_stm32_image_ssbl_v1;
+ case 0x10000000:
+ return filetype_stm32_image_fsbl_v1;
+ }
+ }
}
if (bufsize < 512)
@@ -477,6 +484,8 @@ bool filetype_is_barebox_image(enum filetype ft)
case filetype_ch_image_be:
case filetype_layerscape_image:
case filetype_layerscape_qspi_image:
+ case filetype_stm32_image_fsbl_v1:
+ case filetype_fip:
return true;
default:
return false;
diff --git a/include/bbu.h b/include/bbu.h
index 3128339068..2dad26a127 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -10,6 +10,7 @@
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;
@@ -50,6 +51,12 @@ void bbu_handlers_list(void);
struct file_list;
+int bbu_mmcboot_handler(struct bbu_handler *, struct bbu_data *,
+ int (*chained_handler)(struct bbu_handler *, struct bbu_data *));
+
+int bbu_std_file_handler(struct bbu_handler *handler,
+ struct bbu_data *data);
+
#ifdef CONFIG_BAREBOX_UPDATE
int bbu_register_handler(struct bbu_handler *);
diff --git a/include/filetype.h b/include/filetype.h
index 9b7499fdf3..00d54e48d5 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -52,7 +52,8 @@ enum filetype {
filetype_layerscape_image,
filetype_layerscape_qspi_image,
filetype_ubootvar,
- filetype_stm32_image_v1,
+ filetype_stm32_image_fsbl_v1,
+ filetype_stm32_image_ssbl_v1,
filetype_zynq_image,
filetype_mxs_sd_image,
filetype_rockchip_rkns_image,