Skip to contentSkip to conversation

arm: mach-qemu: add support for qemu booted from TF-A.

PATCH In review [email protected] 2 participants 3 messages Sep 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mach-qemu: add support for qemu booted from TF-A.

From: Chali Anis <[email protected]>

add the ability to be booted from Arm Trusted Firmware for qemu aarch64, to do so we need to skip NOR flash partition setup.
U-boot launched as BL33 from TF-A is supported and Tested on arm64 with qemu-system-aarch64 and the qemu ARM64 support ARCH_SUPPORT_TFABOOT.

---
 arch/arm/mach-qemu/Kconfig             | 1 +
 board/emulation/common/qemu_mtdparts.c | 2 ++
 2 files changed, 3 insertions(+)
arch/arm/mach-qemu/Kconfig +1 -0
index 9c06c6a3a5ce..316dde5145c0 100644
@@ -18,6 +18,7 @@ config TARGET_QEMU_ARM_64BIT
 	bool "ARMv8, 64bit"
 	select ARM64
 	select BOARD_LATE_INIT
+	select ARCH_SUPPORT_TFABOOT
 
 config TARGET_QEMU_ARM_SBSA
 	bool "SBSA Reference"
board/emulation/common/qemu_mtdparts.c +2 -0
index c1501276789c..c3863d3b0479 100644
@@ -59,6 +59,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 			debug("mtd device = %s\n", dev->name);
 		}
 
+#ifndef CONFIG_TFABOOT
 		mtd = get_mtd_device_nm("nor0");
 		if (!IS_ERR_OR_NULL(mtd)) {
 			mtd_partition = CONFIG_MTDPARTS_NOR0;
@@ -72,6 +73,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
 			board_get_mtdparts("nor1", mtd_partition, ids, parts);
 			put_mtd_device(mtd);
 		}
+#endif
 	}
 
 	mtd_initialized = true;
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 8 lines · On Fri, 19 Sept 2025 at 18:24, <[email protected]> wrote:

From: Chali Anis <[email protected]>

add the ability to be booted from Arm Trusted Firmware for qemu aarch64, to do so we need to skip NOR flash partition setup.
U-boot launched as BL33 from TF-A is supported and Tested on arm64 with qemu-system-aarch64 and the qemu ARM64 support ARCH_SUPPORT_TFABOOT.

Actually the patch is trying to skip part of the initialization when U-Boot is running as BL33, so the statement like "add the ability to be booted...", "U-boot launched as BL33 from TF-A is supported" won't help as U-Boot is working as BL33 already.

Quoted 31 lines
---
 arch/arm/mach-qemu/Kconfig             | 1 +
 board/emulation/common/qemu_mtdparts.c | 2 ++
 2 files changed, 3 insertions(+)
arch/arm/mach-qemu/Kconfig +1 -0
index 9c06c6a3a5ce..316dde5145c0 100644
@@ -18,6 +18,7 @@ config TARGET_QEMU_ARM_64BIT
        bool "ARMv8, 64bit"
        select ARM64
        select BOARD_LATE_INIT
+       select ARCH_SUPPORT_TFABOOT
 
 config TARGET_QEMU_ARM_SBSA
        bool "SBSA Reference"
board/emulation/common/qemu_mtdparts.c +1 -0
index c1501276789c..c3863d3b0479 100644
@@ -59,6 +59,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
                        debug("mtd device = %s\n", dev->name);
                }
 
+#ifndef CONFIG_TFABOOT
                mtd = get_mtd_device_nm("nor0");
                if (!IS_ERR_OR_NULL(mtd)) {
                        mtd_partition = CONFIG_MTDPARTS_NOR0;

board/emulation/common/qemu_mtdparts.c void board_mtdparts_default(const char **mtdids, const char **mtdparts) · line 77

Quoted 5 lines
board/emulation/common/qemu_mtdparts.c +1 -0
@@ -72,6 +73,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
                        board_get_mtdparts("nor1", mtd_partition, ids, parts);
                        put_mtd_device(mtd);
                }
+#endif
 

Skipping the default NOR mtdparts when TFABOOT is selected looks fine. However, qemu_dfu.c still sets dfu_alt_info based on those NOR partitions (used by DFU/EFI capsule flows).

This actually brings one concern related to capsule update: currently the QEMU ARM64 board depends on mtdparts to make EFI capsule update work.
It raises a question: do we actually want to support capsule update when U-Boot is running as BL33?
If yes, then the current patch breaks capsule update and more work is needed. If no, we should make it explicit (e.g. prevent EFI_CAPSULE_FIRMWARE_MANAGEMENT from being selected together with TFABOOT).

BTW, can you please add a rev number in the subject line? E.g. [PATCH v2], [PATCH v3]... See the patterns from other patches.

Regards,
Raymond

Quoted 6 lines
board/emulation/common/qemu_mtdparts.c +0 -0
        }
 
        mtd_initialized = true;

--
2.34.1

author
#2 lore raw

Okay thenk you for feedback. I will check this next week, I will reformat the patch, concerning the second point for efi capsules I didn't consider it, for me u-boot didn't support to run as an efi application in arm64 systems but it is interesting to know that.

Regards.
Anis.

Quoted 80 lines · Raymond Mao

Hi,

Quoted 8 lines · On Fri, 19 Sept 2025 at 18:24, <[email protected]> wrote:

From: Chali Anis <[email protected]>

add the ability to be booted from Arm Trusted Firmware for qemu aarch64, to do so we need to skip NOR flash partition setup.
U-boot launched as BL33 from TF-A is supported and Tested on arm64 with qemu-system-aarch64 and the qemu ARM64 support ARCH_SUPPORT_TFABOOT.

Actually the patch is trying to skip part of the initialization when U-Boot is running as BL33, so the statement like "add the ability to be booted...", "U-boot launched as BL33 from TF-A is supported" won't help as U-Boot is working as BL33 already.

Quoted 31 lines
---
 arch/arm/mach-qemu/Kconfig             | 1 +
 board/emulation/common/qemu_mtdparts.c | 2 ++
 2 files changed, 3 insertions(+)
arch/arm/mach-qemu/Kconfig +1 -0
index 9c06c6a3a5ce..316dde5145c0 100644
@@ -18,6 +18,7 @@ config TARGET_QEMU_ARM_64BIT
        bool "ARMv8, 64bit"
        select ARM64
        select BOARD_LATE_INIT
+       select ARCH_SUPPORT_TFABOOT
 
 config TARGET_QEMU_ARM_SBSA
        bool "SBSA Reference"
board/emulation/common/qemu_mtdparts.c +1 -0
index c1501276789c..c3863d3b0479 100644
@@ -59,6 +59,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
                        debug("mtd device = %s\n", dev->name);
                }
 
+#ifndef CONFIG_TFABOOT
                mtd = get_mtd_device_nm("nor0");
                if (!IS_ERR_OR_NULL(mtd)) {
                        mtd_partition = CONFIG_MTDPARTS_NOR0;

board/emulation/common/qemu_mtdparts.c void board_mtdparts_default(const char **mtdids, const char **mtdparts) · line 77

Quoted 5 lines
board/emulation/common/qemu_mtdparts.c +1 -0
@@ -72,6 +73,7 @@ void board_mtdparts_default(const char **mtdids, const char **mtdparts)
                        board_get_mtdparts("nor1", mtd_partition, ids, parts);
                        put_mtd_device(mtd);
                }
+#endif
 

Skipping the default NOR mtdparts when TFABOOT is selected looks fine. However, qemu_dfu.c still sets dfu_alt_info based on those NOR partitions (used by DFU/EFI capsule flows).

This actually brings one concern related to capsule update: currently the QEMU ARM64 board depends on mtdparts to make EFI capsule update work.
It raises a question: do we actually want to support capsule update when U-Boot is running as BL33?
If yes, then the current patch breaks capsule update and more work is needed. If no, we should make it explicit (e.g. prevent EFI_CAPSULE_FIRMWARE_MANAGEMENT from being selected together with TFABOOT).

BTW, can you please add a rev number in the subject line? E.g. [PATCH v2], [PATCH v3]... See the patterns from other patches.

Regards,
Raymond

Quoted 6 lines
board/emulation/common/qemu_mtdparts.c +0 -0
        }
 
        mtd_initialized = true;

--
2.34.1