- From https://gitlab.collabora.com/mediatek/aiot/boot/-/tree/main/patches/trusted-firmware-a at bc779c20dd5ea72a9f3edd248eb08460e3c837b6
244 lines
8.6 KiB
Diff
244 lines
8.6 KiB
Diff
From e4574b2767c3ac8b63138d119ca88e7209007ff9 Mon Sep 17 00:00:00 2001
|
|
From: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
|
|
Date: Thu, 25 Sep 2025 14:48:12 -0300
|
|
Subject: [PATCH] plat: mediatek: mt8188/8195/8365/8391: Support FIP image on
|
|
bootpart
|
|
|
|
Currently, fip.bin is loaded from a specific hardcoded GPT partition. In
|
|
order to avoid having a mandatory partition table, this commit adds
|
|
specific options to store fip.bin in the mmc boot partition.
|
|
|
|
These options allows to manually set a specific offset, so the FIP
|
|
binary can be embedded along the BL2 image.
|
|
|
|
Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
|
|
---
|
|
plat/mediatek/common/mtk_bl2_common.c | 6 ++++++
|
|
plat/mediatek/mt8188/bl2_plat_setup.c | 11 +++++++++++
|
|
plat/mediatek/mt8188/platform_bl2.mk | 5 +++++
|
|
plat/mediatek/mt8195/bl2_plat_setup.c | 15 +++++++++++++++
|
|
plat/mediatek/mt8195/platform.mk | 6 ++++++
|
|
plat/mediatek/mt8365/bl2_plat_setup.c | 11 +++++++++++
|
|
plat/mediatek/mt8365/platform.mk | 6 ++++++
|
|
plat/mediatek/mt8391/bl2_plat_setup.c | 9 +++++++++
|
|
plat/mediatek/mt8391/platform.mk | 6 ++++++
|
|
9 files changed, 75 insertions(+)
|
|
|
|
diff --git a/plat/mediatek/common/mtk_bl2_common.c b/plat/mediatek/common/mtk_bl2_common.c
|
|
index d7adb9776..bb4504127 100644
|
|
--- a/plat/mediatek/common/mtk_bl2_common.c
|
|
+++ b/plat/mediatek/common/mtk_bl2_common.c
|
|
@@ -371,6 +371,12 @@ int bl2_plat_handle_pre_image_load(unsigned int image_id)
|
|
storage.start = BL2_STORAGE_NOR_START_ADDR;
|
|
storage.length = BL2_STORAGE_NOR_LENGTH;
|
|
entry = &storage;
|
|
+#elif defined(STORAGE_APPEND_FIP)
|
|
+ partition_entry_t storage;
|
|
+
|
|
+ storage.start = STORAGE_FIP_OFFSET;
|
|
+ storage.length = STORAGE_BOOT_LENGTH;
|
|
+ entry = &storage;
|
|
#else
|
|
entry = get_partition_entry(name);
|
|
if (entry == NULL) {
|
|
diff --git a/plat/mediatek/mt8188/bl2_plat_setup.c b/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
index 38113e3e9..70a0564ff 100644
|
|
--- a/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
+++ b/plat/mediatek/mt8188/bl2_plat_setup.c
|
|
@@ -156,8 +156,13 @@ static io_block_dev_spec_t emmc_dev_spec = {
|
|
.length = PLAT_PARTITION_BLOCK_SIZE,
|
|
},
|
|
.ops = {
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+ .read = mmc_boot_part_read_blocks,
|
|
+ .write = NULL,
|
|
+#else
|
|
.read = mmc_read_blocks,
|
|
.write = mmc_write_blocks,
|
|
+#endif
|
|
},
|
|
.block_size = MMC_BLOCK_SIZE,
|
|
};
|
|
@@ -475,6 +480,12 @@ int bl2_plat_handle_pre_image_load(unsigned int image_id)
|
|
storage.start = BL2_STORAGE_NOR_START_ADDR;
|
|
storage.length = BL2_STORAGE_NOR_LENGTH;
|
|
entry = &storage;
|
|
+#elif defined(STORAGE_APPEND_FIP)
|
|
+ partition_entry_t storage;
|
|
+
|
|
+ storage.start = STORAGE_FIP_OFFSET;
|
|
+ storage.length = STORAGE_BOOT_LENGTH;
|
|
+ entry = &storage;
|
|
#else
|
|
if((entry = get_partition_entry(name)) == NULL) {
|
|
partition_init(GPT_IMAGE_ID);
|
|
diff --git a/plat/mediatek/mt8188/platform_bl2.mk b/plat/mediatek/mt8188/platform_bl2.mk
|
|
index 958516695..a851dc98b 100644
|
|
--- a/plat/mediatek/mt8188/platform_bl2.mk
|
|
+++ b/plat/mediatek/mt8188/platform_bl2.mk
|
|
@@ -68,4 +68,9 @@ include lib/libfdt/libfdt.mk
|
|
else
|
|
BL2_SOURCES += drivers/mmc/mmc.c \
|
|
${MTK_PLAT}/common/drivers/mmc/mtk-sd.c
|
|
+ifeq (${STORAGE_APPEND_FIP},1)
|
|
+$(eval $(call add_define,STORAGE_APPEND_FIP))
|
|
+$(eval $(call add_define_val,STORAGE_FIP_OFFSET,${STORAGE_FIP_OFFSET}))
|
|
+$(eval $(call add_define_val,STORAGE_BOOT_LENGTH,${STORAGE_BOOT_LENGTH}))
|
|
+endif
|
|
endif
|
|
diff --git a/plat/mediatek/mt8195/bl2_plat_setup.c b/plat/mediatek/mt8195/bl2_plat_setup.c
|
|
index 14af7fc4f..85e524827 100644
|
|
--- a/plat/mediatek/mt8195/bl2_plat_setup.c
|
|
+++ b/plat/mediatek/mt8195/bl2_plat_setup.c
|
|
@@ -137,7 +137,11 @@ static uintptr_t fip_dev_handle;
|
|
static uint32_t mmc_buf_in_sram[PLAT_PARTITION_BLOCK_SIZE / sizeof(uint32_t)];
|
|
|
|
#if defined(STORAGE_UFS)
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+#define MAIN_STORAGE_LUN 0
|
|
+#else
|
|
#define MAIN_STORAGE_LUN 2
|
|
+#endif /* STORAGE_APPEND_FIP */
|
|
size_t mtk_ufs_read(int lba, uintptr_t buf, size_t size)
|
|
{
|
|
return ufs_read_blocks(MAIN_STORAGE_LUN, lba, buf, size);
|
|
@@ -186,8 +190,13 @@ static io_block_dev_spec_t emmc_dev_spec = {
|
|
.length = PLAT_PARTITION_BLOCK_SIZE,
|
|
},
|
|
.ops = {
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+ .read = mmc_boot_part_read_blocks,
|
|
+ .write = NULL,
|
|
+#else
|
|
.read = mmc_read_blocks,
|
|
.write = mmc_write_blocks,
|
|
+#endif
|
|
},
|
|
.block_size = MMC_BLOCK_SIZE,
|
|
};
|
|
@@ -503,6 +512,12 @@ int bl2_plat_handle_pre_image_load(unsigned int image_id)
|
|
storage.start = BL2_STORAGE_NOR_START_ADDR;
|
|
storage.length = BL2_STORAGE_NOR_LENGTH;
|
|
entry = &storage;
|
|
+#elif defined(STORAGE_APPEND_FIP)
|
|
+ partition_entry_t storage;
|
|
+
|
|
+ storage.start = STORAGE_FIP_OFFSET;
|
|
+ storage.length = STORAGE_BOOT_LENGTH;
|
|
+ entry = &storage;
|
|
#else
|
|
if((entry = get_partition_entry(name)) == NULL) {
|
|
partition_init(GPT_IMAGE_ID);
|
|
diff --git a/plat/mediatek/mt8195/platform.mk b/plat/mediatek/mt8195/platform.mk
|
|
index de9e41a1c..f62b8551d 100644
|
|
--- a/plat/mediatek/mt8195/platform.mk
|
|
+++ b/plat/mediatek/mt8195/platform.mk
|
|
@@ -130,6 +130,12 @@ $(eval $(call add_define,BL2_STORAGE_NOR_LENGTH))
|
|
$(eval $(call add_define,BL2_STORAGE_NOR_BOOTCTRL))
|
|
endif
|
|
|
|
+ifeq (${STORAGE_APPEND_FIP},1)
|
|
+$(eval $(call add_define,STORAGE_APPEND_FIP))
|
|
+$(eval $(call add_define_val,STORAGE_FIP_OFFSET,${STORAGE_FIP_OFFSET}))
|
|
+$(eval $(call add_define_val,STORAGE_BOOT_LENGTH,${STORAGE_BOOT_LENGTH}))
|
|
+endif
|
|
+
|
|
BL31_SOURCES += common/desc_image_load.c \
|
|
drivers/delay_timer/delay_timer.c \
|
|
drivers/gpio/gpio.c \
|
|
diff --git a/plat/mediatek/mt8365/bl2_plat_setup.c b/plat/mediatek/mt8365/bl2_plat_setup.c
|
|
index 18c389cd4..e1fd1a8ab 100644
|
|
--- a/plat/mediatek/mt8365/bl2_plat_setup.c
|
|
+++ b/plat/mediatek/mt8365/bl2_plat_setup.c
|
|
@@ -146,8 +146,13 @@ static const io_block_dev_spec_t emmc_dev_spec = {
|
|
.length = 0x1000000,
|
|
},
|
|
.ops = {
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+ .read = mmc_boot_part_read_blocks,
|
|
+ .write = NULL,
|
|
+#else
|
|
.read = mmc_read_blocks,
|
|
.write = mmc_write_blocks,
|
|
+#endif
|
|
},
|
|
.block_size = MMC_BLOCK_SIZE,
|
|
};
|
|
@@ -436,6 +441,12 @@ int bl2_plat_handle_pre_image_load(unsigned int image_id)
|
|
const char *ab_boot = plat_ab_handle_boot();
|
|
|
|
entry = get_partition_entry(ab_boot);
|
|
+#elif defined(STORAGE_APPEND_FIP)
|
|
+ partition_entry_t storage;
|
|
+
|
|
+ storage.start = STORAGE_FIP_OFFSET;
|
|
+ storage.length = STORAGE_BOOT_LENGTH;
|
|
+ entry = &storage;
|
|
#else
|
|
partition_init(GPT_IMAGE_ID);
|
|
entry = get_partition_entry(name);
|
|
diff --git a/plat/mediatek/mt8365/platform.mk b/plat/mediatek/mt8365/platform.mk
|
|
index 9566a4cc2..dece918ad 100644
|
|
--- a/plat/mediatek/mt8365/platform.mk
|
|
+++ b/plat/mediatek/mt8365/platform.mk
|
|
@@ -82,6 +82,12 @@ BL2_SOURCES += ${MTK_PLAT}/common/mtk_ab.c \
|
|
$(eval $(call add_define,PLAT_AB_BOOT_ENABLE))
|
|
endif
|
|
|
|
+ifeq (${STORAGE_APPEND_FIP},1)
|
|
+$(eval $(call add_define,STORAGE_APPEND_FIP))
|
|
+$(eval $(call add_define_val,STORAGE_FIP_OFFSET,${STORAGE_FIP_OFFSET}))
|
|
+$(eval $(call add_define_val,STORAGE_BOOT_LENGTH,${STORAGE_BOOT_LENGTH}))
|
|
+endif
|
|
+
|
|
BL31_SOURCES += common/desc_image_load.c \
|
|
drivers/delay_timer/delay_timer.c \
|
|
drivers/delay_timer/generic_delay_timer.c \
|
|
diff --git a/plat/mediatek/mt8391/bl2_plat_setup.c b/plat/mediatek/mt8391/bl2_plat_setup.c
|
|
index 2223deb11..da773e7bf 100644
|
|
--- a/plat/mediatek/mt8391/bl2_plat_setup.c
|
|
+++ b/plat/mediatek/mt8391/bl2_plat_setup.c
|
|
@@ -51,7 +51,11 @@ static struct msdc_compatible msdc_compat = {
|
|
.top_base = MSDC0_TOP_BASE,
|
|
};
|
|
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+#define MAIN_STORAGE_LUN 0
|
|
+#else
|
|
#define MAIN_STORAGE_LUN 2
|
|
+#endif /* STORAGE_APPEND_FIP */
|
|
size_t mtk_ufs_read(int lba, uintptr_t buf, size_t size)
|
|
{
|
|
return ufs_read_blocks(MAIN_STORAGE_LUN, lba, buf, size);
|
|
@@ -80,8 +84,13 @@ static io_block_dev_spec_t emmc_dev_spec = {
|
|
.length = PLAT_PARTITION_BLOCK_SIZE,
|
|
},
|
|
.ops = {
|
|
+#if defined(STORAGE_APPEND_FIP)
|
|
+ .read = mmc_boot_part_read_blocks,
|
|
+ .write = NULL,
|
|
+#else
|
|
.read = mmc_read_blocks,
|
|
.write = mmc_write_blocks,
|
|
+#endif
|
|
},
|
|
.block_size = MMC_BLOCK_SIZE,
|
|
};
|
|
diff --git a/plat/mediatek/mt8391/platform.mk b/plat/mediatek/mt8391/platform.mk
|
|
index 6d0cc9a9e..b5f43d290 100644
|
|
--- a/plat/mediatek/mt8391/platform.mk
|
|
+++ b/plat/mediatek/mt8391/platform.mk
|
|
@@ -69,6 +69,12 @@ else
|
|
PLAT_PARTITION_BLOCK_SIZE := 512
|
|
endif
|
|
|
|
+ifeq (${STORAGE_APPEND_FIP},1)
|
|
+$(eval $(call add_define,STORAGE_APPEND_FIP))
|
|
+$(eval $(call add_define_val,STORAGE_FIP_OFFSET,${STORAGE_FIP_OFFSET}))
|
|
+$(eval $(call add_define_val,STORAGE_BOOT_LENGTH,${STORAGE_BOOT_LENGTH}))
|
|
+endif
|
|
+
|
|
ifeq (${PLAT_HW_CRYPTO},1)
|
|
BL2_LIBS += ${MTK_PLAT}/lib/crypt/libarmcrypt.a
|
|
$(eval $(call add_define,PLAT_HW_CRYPTO))
|