From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 5/7] filetype: differentiate between STM32MP FSBL and SSBL images
Date: Thu, 2 Jun 2022 11:01:31 +0200 [thread overview]
Message-ID: <20220602090133.3190450-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220602090133.3190450-1-a.fatoum@pengutronix.de>
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>
---
arch/arm/mach-stm32mp/include/mach/bbu.h | 2 +-
arch/arm/mach-stm32mp/stm32image.c | 2 +-
common/filetype.c | 13 ++++++++++---
include/filetype.h | 3 ++-
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/arch/arm/mach-stm32mp/include/mach/bbu.h b/arch/arm/mach-stm32mp/include/mach/bbu.h
index d49fb045ea06..3a6951a8f1a0 100644
--- a/arch/arm/mach-stm32mp/include/mach/bbu.h
+++ b/arch/arm/mach-stm32mp/include/mach/bbu.h
@@ -10,7 +10,7 @@ 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);
}
#endif /* MACH_STM32MP_BBU_H_ */
diff --git a/arch/arm/mach-stm32mp/stm32image.c b/arch/arm/mach-stm32mp/stm32image.c
index caff68651c47..7867418e6caa 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/filetype.c b/common/filetype.c
index 0ded64b83c00..3e9e14c1d79e 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)
diff --git a/include/filetype.h b/include/filetype.h
index 9b7499fdf307..00d54e48d528 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,
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-06-02 9:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-02 9:01 [PATCH 0/7] ARM: stm32mp: bbu: add FIP update handler Ahmad Fatoum
2022-06-02 9:01 ` [PATCH 1/7] bbu: move barebox_update eMMC boot handling into common code Ahmad Fatoum
2022-06-02 9:01 ` [PATCH 2/7] bbu: use free(NULL) to simplify function cleanup Ahmad Fatoum
2022-06-02 9:01 ` [PATCH 3/7] bbu: add flag for enabling eMMC boot ack Ahmad Fatoum
2022-06-02 9:01 ` [PATCH 4/7] bbu: export bbu_std_file_handler for use in custom handlers Ahmad Fatoum
2022-06-02 9:01 ` Ahmad Fatoum [this message]
2022-06-02 9:01 ` [PATCH 6/7] ARM: stm32mp: bbu: add FIP update handler Ahmad Fatoum
2022-06-02 9:01 ` [PATCH 7/7] fastboot: support TF-A FSBL and FIP images for barebox update Ahmad Fatoum
2022-06-03 7:17 ` [PATCH 0/7] ARM: stm32mp: bbu: add FIP update handler Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220602090133.3190450-6-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox