diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-06-02 11:01:31 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-03 09:17:27 +0200 |
commit | 0a7bbd4e6ca36a311e4f2232c3d757faf58d7a8e (patch) | |
tree | 664f75e1bf88e2e3b939d6aadb2d12dd3a80429a /common | |
parent | cfe5484eb2cac97373da85706732678ab34cedc7 (diff) | |
download | barebox-0a7bbd4e6ca36a311e4f2232c3d757faf58d7a8e.tar.gz barebox-0a7bbd4e6ca36a311e4f2232c3d757faf58d7a8e.tar.xz |
filetype: differentiate between STM32MP FSBL and SSBL images
We have some special handling for legacy (non-FIP) STM32 images:
We have a bootm handler for chainloading and an update handler
for use with GPT ssbl partitions. Both aren't applicable to the
TF-A image used as FSBL. As barebox always has 0x00000000 at
offset 0xfc and TF-A alrways has 0x10000000, we can use that
to differentiate between the two images to make sure we refuse
TF-A images when barebox images are expected.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220602090133.3190450-6-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/filetype.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/common/filetype.c b/common/filetype.c index 0ded64b83c..3e9e14c1d7 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) |