[PATCH 05/24] filetype: detect TF-A Firmware Image Packages (FIP)

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Feb 20 04:47:17 PST 2022


FIP is the new format for firmware loaded by ARM Trusted Firmware. It
can contain non-secure firmware, hardware config (device tree), firmware
config (configuration DT) and optionally OP-TEE.

In future, we may want to mount FIP to chain boot barebox out of it, but
for now, just let barebox filetype detect it correctly.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/filetype.c  | 4 ++++
 include/filetype.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 53517da70d39..0ded64b83c00 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -75,6 +75,7 @@ static const struct filetype_str filetype_str[] = {
 	[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" },
+	[filetype_fip] = { "TF-A Firmware Image Package", "fip" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -315,6 +316,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 		return filetype_riscv_barebox_image;
 	if (strncmp(buf8, "RKNS", 4) == 0)
 		return filetype_rockchip_rkns_image;
+	if (le32_to_cpu(buf[0]) == le32_to_cpu(0xaa640001))
+		return filetype_fip;
+
 	if ((buf8[0] == 0x5a || buf8[0] == 0x69 || buf8[0] == 0x78 ||
 	     buf8[0] == 0x8b || buf8[0] == 0x9c) &&
 	    buf8[0x1] == 0 && buf8[0x2] == 0 && buf8[0x3] == 0 &&
diff --git a/include/filetype.h b/include/filetype.h
index 8bc179ac0817..9b7499fdf307 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -56,6 +56,7 @@ enum filetype {
 	filetype_zynq_image,
 	filetype_mxs_sd_image,
 	filetype_rockchip_rkns_image,
+	filetype_fip,
 	filetype_max,
 };
 
-- 
2.30.2




More information about the barebox mailing list