From 6439a10e98523281c0f9be670bf9dd605a367025 Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Sat, 6 Apr 2024 16:54:29 +0200 Subject: [PATCH] boot/ti-k3-r5-loader: install tiboot3.bin and sysfw.itb to BINARIES_DIR With binman support enabled, u-boot for k3 r5 core (ti-k3-r5-loader) install different target image (tiboot3*.bin) depending on the K3 SoC boot ROM: - General Purpose devices (gp) - High Security - Field Securable devices (hs-fs) - High Security - Security Enforcing devices (hs) An additional firmware binary is required on certain TI K3 devices such as AM65 and J721e due to the "Split binary" boot flow [1]: - Split binary with a combined firmware: (eg: AM65) - Combined binary with a combined firmware: (eg: AM64) - Split binary with a split firmware: (eg: J721E) - Combined binary with a split firmware: (eg: AM62) K3 SoC using Split Binary Boot Flow also requires sysfw-*.itb file to boot (eg: am65, j721e). Only tiboot3*.bin is needed for other boot flow. From [1]: "It's important to rename the generated tiboot3.bin and sysfw.itb to match exactly tiboot3.bin and sysfw.itb as ROM and the wakeup UBoot SPL will only look for and load the files with these names." See the (not exhaustive) list of all tiboot3*.bin and sysfw*.itb file variant found in meta-ti: meta-ti-bsp/conf/machine/beaglebone-ai64-k3r5.conf:UBOOT_IMAGE = "tiboot3-${MAINMACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}" meta-ti-bsp/conf/machine/beaglebone-ai64-k3r5.conf:UBOOT_SYMLINK = "tiboot3-${MAINMACHINE}.${UBOOT_SUFFIX}" meta-ti-bsp/conf/machine/include/am62axx.inc:IMAGE_BOOT_FILES += "tiboot3-am62ax-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/am62axx.inc:IMAGE_BOOT_FILES += "tiboot3-am62ax-gp-evm.bin" meta-ti-bsp/conf/machine/include/am62axx.inc:IMAGE_BOOT_FILES += "tiboot3-am62ax-hs-evm.bin" meta-ti-bsp/conf/machine/include/am62pxx.inc:IMAGE_BOOT_FILES += "tiboot3-am62px-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/am62xx.inc:IMAGE_BOOT_FILES += "tiboot3-am62x-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/am62xx.inc:IMAGE_BOOT_FILES += "tiboot3-am62x-gp-evm.bin" meta-ti-bsp/conf/machine/include/am62xx.inc:IMAGE_BOOT_FILES += "tiboot3-am62x-hs-evm.bin" meta-ti-bsp/conf/machine/include/am64xx.inc:IMAGE_BOOT_FILES += "tiboot3-am64x_sr2-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/am64xx.inc:IMAGE_BOOT_FILES += "tiboot3-am64x-gp-evm.bin" meta-ti-bsp/conf/machine/include/am64xx.inc:IMAGE_BOOT_FILES += "tiboot3-am64x_sr2-hs-evm.bin" meta-ti-bsp/conf/machine/include/am65xx.inc:IMAGE_BOOT_FILES += "tiboot3-am65x_sr2-gp-evm.bin" meta-ti-bsp/conf/machine/include/am65xx.inc:IMAGE_BOOT_FILES += "tiboot3-am65x_sr2-hs-evm.bin" meta-ti-bsp/conf/machine/include/j7200.inc:IMAGE_BOOT_FILES += "tiboot3-j7200-gp-evm.bin" meta-ti-bsp/conf/machine/include/j7200.inc:IMAGE_BOOT_FILES += "tiboot3-j7200_sr2-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/j7200.inc:IMAGE_BOOT_FILES += "tiboot3-j7200_sr2-hs-evm.bin" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "tiboot3-j721e-gp-evm.bin" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "tiboot3-j721e_sr2-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "tiboot3-j721e_sr1_1-hs-evm.bin" meta-ti-bsp/conf/machine/include/j721s2.inc:IMAGE_BOOT_FILES += "tiboot3-j721s2-gp-evm.bin" meta-ti-bsp/conf/machine/include/j721s2.inc:IMAGE_BOOT_FILES += "tiboot3-j721s2-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/j722s.inc:IMAGE_BOOT_FILES += "tiboot3-j722s-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/j784s4.inc:IMAGE_BOOT_FILES += "tiboot3-j784s4-gp-evm.bin" meta-ti-bsp/conf/machine/include/j784s4.inc:IMAGE_BOOT_FILES += "tiboot3-j784s4-hs-fs-evm.bin" meta-ti-bsp/conf/machine/include/k3r5.inc:SPL_BINARY = "tiboot3-${SYSFW_SOC}-${SYSFW_SUFFIX}-${SYSFW_CONFIG}.${SPL_SUFFIX}" meta-ti-bsp/conf/machine/include/am65xx.inc:IMAGE_BOOT_FILES += "sysfw.itb" meta-ti-bsp/conf/machine/include/am65xx.inc:IMAGE_BOOT_FILES += "sysfw-am65x_sr2-gp-evm.itb" meta-ti-bsp/conf/machine/include/am65xx.inc:IMAGE_BOOT_FILES += "sysfw-am65x_sr2-hs-evm.itb" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "sysfw.itb" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "sysfw-j721e-gp-evm.itb" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "sysfw-j721e_sr2-hs-fs-evm.itb" meta-ti-bsp/conf/machine/include/j721e.inc:IMAGE_BOOT_FILES += "sysfw-j721e_sr1_1-hs-evm.itb" This firmware list can also be verified with the firmware name used in the u-boot devicetree k3-*-binman.dtsi files. On the SK-AM62B-P1, three tiboot3 binaries are built, one for each boot ROM variant: tiboot3-am62x-gp-evm.bin tiboot3-am62x-hs-evm.bin tiboot3-am62x-hs-fs-evm.bin A tiboot3.bin symlink is provided as default choice: tiboot3.bin -> tiboot3-am62x-hs-fs-evm.bin On this board, the tiboot3.bin symlink links to the hs-fs variant but it not always de case for all TI K3 devices. (ex: J721e use gp variant by default). The tiboot3.bin symlink links the -gp, -hs-fs, -hs tiboot3 binary according to where "symlink = "tiboot3.bin";" line is located in k3-*binman.dtsi. As reported by Michael Walle [2], such firmware name can also be customized by a SBC vendor [3], so we can't always be sure which firmware to use. If required, let the user provide a custom tiboot3 or sysfw firmware name from the defconfig. Otherwise use the default firmware choice by copying tiboot3.bin and sysfw.itb symlinks. [1] https://source.denx.de/u-boot/u-boot/-/blob/v2024.01/doc/board/ti/k3.rst [2] http://lists.busybox.net/pipermail/buildroot/2024-April/688943.html [3] https://elixir.bootlin.com/u-boot/v2024.04/source/arch/arm/dts/k3-am625-phycore-som-binman.dtsi#L14 Reviewed-by: Arnout Vandecappelle Signed-off-by: Dario Binacchi Signed-off-by: Romain Naour --- boot/ti-k3-r5-loader/Config.in | 40 +++++++++++++++++++++++++ boot/ti-k3-r5-loader/ti-k3-r5-loader.mk | 35 +++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/boot/ti-k3-r5-loader/Config.in b/boot/ti-k3-r5-loader/Config.in index 5f4f33b220..707f22ab4e 100644 --- a/boot/ti-k3-r5-loader/Config.in +++ b/boot/ti-k3-r5-loader/Config.in @@ -102,4 +102,44 @@ config BR2_TARGET_TI_K3_R5_LOADER_USE_BINMAN https://docs.u-boot.org/en/v2024.01/develop/package/binman.html +config BR2_TARGET_TI_K3_R5_LOADER_TIBOOT3_BIN + string "tiboot3.bin binary name" + default "tiboot3.bin" + help + Name of the TI K3 tiboot3.bin binary to use. + + The tiboot3 binary name must match with the TI K3 SoC boot + ROM: + + - General Purpose devices (gp) + - High Security - Field Securable devices (hs-fs) + - High Security - Security Enforcing devices (hs) + + Or if the tiboot3 binary generated use a custom name. + + If unsure, use the default tiboot3.bin (symlink) generated by + binman. + +config BR2_TARGET_TI_K3_R5_LOADER_SYSFW_ITB + string "sysfw.itb binary name" + default "sysfw.itb" + help + Name of the TI K3 sysfw.itb binary to use (if any required). + + sysfw*.itb are only generated for Split binary based Boot + Flow (eg: am65, j721e). This option is not used on other + TI K3 devices. + + The sysfw binary name must match with the TI K3 SoC boot + ROM: + + - General Purpose devices (gp) + - High Security - Field Securable devices (hs-fs) + - High Security - Security Enforcing devices (hs) + + Or if the sysfw binary generated use a custom name. + + If unsure, use the default sysfw.itb (symlink) generated by + binman. + endif diff --git a/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk b/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk index cf18b43871..36f87e577e 100644 --- a/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk +++ b/boot/ti-k3-r5-loader/ti-k3-r5-loader.mk @@ -73,7 +73,24 @@ TI_K3_R5_LOADER_DEPENDENCIES += \ host-python-pylibfdt \ host-python-setuptools TI_K3_R5_LOADER_MAKE_OPTS += BINMAN_INDIRS=$(BINARIES_DIR) -endif + +TI_K3_R5_LOADER_TIBOOT3_BIN = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_TIBOOT3_BIN)) + +define TI_K3_R5_LOADER_INSTALL_TIBOOT3_BIN + cp $(@D)/$(TI_K3_R5_LOADER_TIBOOT3_BIN) $(BINARIES_DIR)/tiboot3.bin +endef + +TI_K3_R5_LOADER_SYSFW_ITB = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_SYSFW_ITB)) + +# sysfw*.itb are only generated for Split binary based Boot Flow (eg: am65, j721e). +# So, if sysfw.itb symlink exist we must copy it or the custom sysfw.itb. +define TI_K3_R5_LOADER_INSTALL_SWSFW_ITB + if test -e $(@D)/sysfw.itb ; then \ + cp $(@D)/$(TI_K3_R5_LOADER_SYSFW_ITB) $(BINARIES_DIR)/sysfw.itb ; \ + fi +endef + +endif # BR2_TARGET_TI_K3_R5_LOADER_USE_BINMAN define TI_K3_R5_LOADER_BUILD_CMDS $(TARGET_CONFIGURE_OPTS) $(TI_K3_R5_LOADER_MAKE) -C $(@D) $(TI_K3_R5_LOADER_MAKE_OPTS) @@ -81,6 +98,22 @@ endef define TI_K3_R5_LOADER_INSTALL_IMAGES_CMDS cp $(@D)/spl/u-boot-spl.bin $(BINARIES_DIR)/r5-u-boot-spl.bin + $(TI_K3_R5_LOADER_INSTALL_TIBOOT3_BIN) + $(TI_K3_R5_LOADER_INSTALL_SWSFW_ITB) endef +# Checks to give errors that the user can understand +# Must be before we call to kconfig-package +ifeq ($(BR2_TARGET_TI_K3_R5_LOADER)$(BR_BUILDING),yy) + +ifeq ($(TI_K3_R5_LOADER_TIBOOT3_BIN),) +$(error No custom tiboot3 name specified, check your BR2_TARGET_TI_K3_R5_LOADER_TIBOOT3_BIN setting) +endif + +ifeq ($(TI_K3_R5_LOADER_SYSFW_ITB),) +$(error No custom sysfw name specified, check your BR2_TARGET_TI_K3_R5_LOADER_SYSFW_ITB setting) +endif + +endif # BR_BUILDING + $(eval $(kconfig-package))