[Buildroot] [PATCH 1/1] boot/arm-trusted-firmware: optional Linux as BL33
Arnout Vandecappelle
arnout at rnout.be
Fri May 16 15:48:41 UTC 2025
Hi Jakob,
Very interesting contribution! Sorry that it took us so long to react... I
have a few questions. I'm also adding Vincent in Cc since he has more knowledge
about this.
On 19/12/2024 22:45, Jakob Kastelic wrote:
> Arm Trusted Firmware (TF-A) can be used to load U-Boot or another
> bootloader, which in turn loads the Linux kernel. However, TF-A is
> capable of loading the kernel directly. To this end, we need to define
> the BL33 and BL33_CFG compile options containing, respectively, the
> zImage and the DTB.
I didn't even know this was possible, so I checked the documentation, and it
talks about setting ARM_LINUX_KERNEL_AS_BL33=1 so I think that should be set as
well? Perhaps you use a patched TF-A version that has this set by default?
Also, on aarch64, it seems you have to set RESET_TO_SP_MIN=1 to be able to use
this option.
Perhaps it would also be a good idea to add a variant of the qemu defconfigs
that tests this option. We can use the qemu_arm_vexpress_tz_defconfig, drop
U-Boot from it, and switch to booting to Linux directly from TF-A. For aarch64
unfortunately we have no defconfigs that don't require UEFI so we don't have
anything to test this option with.
If you don't feel comfortable testing on aarch64, please add a "depends on
BR2_arm || BR2_armeb" and mention in the commit message why it's excluded.
> This config introduces a new config option,
> BR2_TARGET_ARM_TRUSTED_FIRMWARE_LINUX_AS_BL33, which sets the BL33 and
> BL33_CFG parameters, and ensures that the kernel is built before the
> TF-A by having linux as a _DEPENDENCY of the TF-A.
>
> Signed-off-by: Jakob Kastelic <jkastelic at thinksrs.com>
> ---
> boot/arm-trusted-firmware/Config.in | 19 +++++++++++++++++++
> .../arm-trusted-firmware.mk | 6 ++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
> index c8deede9cd..929561fc87 100644
> --- a/boot/arm-trusted-firmware/Config.in
> +++ b/boot/arm-trusted-firmware/Config.in
> @@ -182,6 +182,25 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33
> for the 'qemu_sbsa' platform. In this case, due to the EDK2
> build system, the dependency between ATF and EDK is reversed.
>
> +config BR2_TARGET_ARM_TRUSTED_FIRMWARE_LINUX_AS_BL33
> + bool "Linux kernel"
> + depends on BR2_LINUX_KERNEL
> + help
> + This option allows to embed the Linux kernel as the BL33 part
> + of the ARM Trusted Firmware.
> +
> + Do not choose this option if you intend to use U-Boot or
> + another second-stage bootloader. With this option, TF-A starts
> + Linux directly.
> +
> + With this option chosen, whenever the Linux zImage changes,
> + TF-A may need need to be re-built to create the latest FIP
> + file. Since Buildroot does not track package dependencies,
> + this has to be done manually by invoking `make
> + arm-trusted-firmware-rebuild`. The final boot medium image may
> + need to be re-generated as well to include the latest FIP file
> + version.
> +
> endchoice
>
> if BR2_TARGET_ARM_TRUSTED_FIRMWARE_BAREBOX_AS_BL33
> diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.mk b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> index 172a930b5c..6fc15ab700 100644
> --- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> +++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
> @@ -132,6 +132,12 @@ ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(ARM_TRUSTED_FIRMWARE_UB
> ARM_TRUSTED_FIRMWARE_DEPENDENCIES += uboot
> endif
>
> +ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_LINUX_AS_BL33),y)
> +ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/zImage
On aarch64, it is Image, not zImage. If you can't test it on aarch64, I'
Perhaps we should also depend on BR2_LINUX_KERNEL_ZIMAGE ||
BR2_LINUX_KERNEL_APPENDED_ZIMAGE (|| BR2_LINUX_KERNEL_IMAGE for aarch64)
otherwise the zImage will not appear in BINARIES_DIR.
Regards,
Arnout
> +ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33_CFG=$(BINARIES_DIR)/$(LINUX_DTBS)
> +ARM_TRUSTED_FIRMWARE_DEPENDENCIES += linux
> +endif
> +
> ifeq ($(BR2_TARGET_VEXPRESS_FIRMWARE),y)
> ARM_TRUSTED_FIRMWARE_MAKE_OPTS += SCP_BL2=$(BINARIES_DIR)/scp-fw.bin
> ARM_TRUSTED_FIRMWARE_DEPENDENCIES += vexpress-firmware
More information about the buildroot
mailing list