[U-Boot] [PATCH v2 0/2] arm: qemu: fix failure if booting from TF-A

With this patch, hang-up of U-Boot, as described in patch#2, will be fixed if it is loaded and started from TF-A.
Changes in v2 (July 3, 2019) * add patch#1 (preparatory patch) * remove a reference to unnecessary patch in the commit message
AKASHI Takahiro (2): arm: move CONFIG_TFABOOT to generic Kconfig arm: qemu: fix failure in flash initialization if booting from TF-A
arch/arm/Kconfig | 29 +++++++++++++++++++++++ arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 7 ------ include/configs/qemu-arm.h | 5 ++++ 3 files changed, 34 insertions(+), 7 deletions(-)

Currently, CONFIG_TFABOOT is located in armv8/fsl-layerscape Kconfig, but it will be also useful for other targets if some additional configuration are necessary. So move it to arch/arm/Kconfig.
Please note that CONFIG_TFABOOT still depends on CONFIG_ARCH_SUPPORT_TFABOOT and so the menu won't come up if any target doesn't need its own customization for TF-A boot. This will maintain the compatibility.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org Cc: Rajesh Bhagat rajesh.bhagat@nxp.com Cc: York Sun york.sun@nxp.com Cc: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com Cc: Priyanka Jain priyanka.jain@nxp.com Cc: Sriram Dash sriram.dash@nxp.com Cc: Hou Zhiqiang Zhiqiang.Hou@nxp.com Cc: Peng Ma peng.ma@nxp.com Cc: Yuantian Tang andy.tang@nxp.com Cc: Pankit Garg pankit.garg@nxp.com --- arch/arm/Kconfig | 28 +++++++++++++++++++++++ arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 7 ------ 2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 01ff57cf1bec..fe174d02d75a 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1089,6 +1089,7 @@ config TARGET_LS1088AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_INTERACTIVE if !SD_BOOT @@ -1104,6 +1105,7 @@ config TARGET_LS2080AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL imply SCSI @@ -1122,6 +1124,7 @@ config TARGET_LS2080ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_BIST @@ -1154,6 +1157,7 @@ config TARGET_LX2160ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for NXP LX2160ARDB platform. @@ -1167,6 +1171,7 @@ config TARGET_LX2160AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for NXP LX2160AQDS platform. @@ -1207,6 +1212,7 @@ config TARGET_LS1012AQDS bool "Support ls1012aqds" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for Freescale LS1012AQDS platform. @@ -1218,6 +1224,7 @@ config TARGET_LS1012ARDB bool "Support ls1012ardb" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI imply SCSI_AHCI @@ -1231,6 +1238,7 @@ config TARGET_LS1012A2G5RDB bool "Support ls1012a2g5rdb" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI help @@ -1243,6 +1251,7 @@ config TARGET_LS1012AFRWY bool "Support ls1012afrwy" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI imply SCSI_AHCI @@ -1256,6 +1265,7 @@ config TARGET_LS1012AFRDM bool "Support ls1012afrdm" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1012AFRDM platform. The LS1012A Freedom board (FRDM) is a high-performance @@ -1267,6 +1277,7 @@ config TARGET_LS1028AQDS select ARCH_LS1028A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1028AQDS platform The LS1028A Development System (QDS) is a high-performance @@ -1278,6 +1289,7 @@ config TARGET_LS1028ARDB select ARCH_LS1028A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1028ARDB platform The LS1028A Development System (RDB) is a high-performance @@ -1290,6 +1302,7 @@ config TARGET_LS1088ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_INTERACTIVE if !SD_BOOT @@ -1348,6 +1361,7 @@ config TARGET_LS1043AQDS select ARCH_LS1043A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select SUPPORT_SPL @@ -1362,6 +1376,7 @@ config TARGET_LS1043ARDB select ARCH_LS1043A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select SUPPORT_SPL @@ -1373,6 +1388,7 @@ config TARGET_LS1046AQDS select ARCH_LS1046A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select DM_SPI_FLASH if DM_SPI @@ -1392,6 +1408,7 @@ config TARGET_LS1046ARDB select ARCH_LS1046A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select DM_SPI_FLASH if DM_SPI @@ -1543,6 +1560,17 @@ config ARCH_ASPEED
endchoice
+config ARCH_SUPPORT_TFABOOT + bool + +config TFABOOT + bool "Support for booting from TF-A" + depends on ARCH_SUPPORT_TFABOOT + default n + help + Enabling this will make a U-Boot binary that is capable of being + booted via TF-A. + config TI_SECURE_DEVICE bool "HS Device Type Support" depends on ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index a843c1eb6515..83e6340f161b 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -622,10 +622,3 @@ config HAS_FSL_XHCI_USB help For some SoC(such as LS1043A and LS1046A), USB and QE-HDLC multiplex use pins, select it when the pins are assigned to USB. - -config TFABOOT - bool "Support for booting from TFA" - default n - help - Enabling this will make a U-Boot binary that is capable of being - booted via TFA.

On Wed, Jul 03, 2019 at 10:44:39AM +0900, AKASHI Takahiro wrote:
Currently, CONFIG_TFABOOT is located in armv8/fsl-layerscape Kconfig, but it will be also useful for other targets if some additional configuration are necessary. So move it to arch/arm/Kconfig.
Please note that CONFIG_TFABOOT still depends on CONFIG_ARCH_SUPPORT_TFABOOT and so the menu won't come up if any target doesn't need its own customization for TF-A boot. This will maintain the compatibility.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org Cc: Rajesh Bhagat rajesh.bhagat@nxp.com Cc: York Sun york.sun@nxp.com Cc: Prabhakar Kushwaha prabhakar.kushwaha@nxp.com Cc: Priyanka Jain priyanka.jain@nxp.com Cc: Sriram Dash sriram.dash@nxp.com Cc: Hou Zhiqiang Zhiqiang.Hou@nxp.com Cc: Peng Ma peng.ma@nxp.com Cc: Yuantian Tang andy.tang@nxp.com Cc: Pankit Garg pankit.garg@nxp.com
Applied to u-boot/master, thanks!

If U-Boot is loaded and started from TF-A (you need to change SYS_TEXT_BASE to 0x60000000), it will hang up at flash initialization.
If secure mode is off (default, or -machine virt,secure=off) at qemu, it will provide dtb with two flash memory banks: flash@0 { bank-width = <0x4>; reg = <0x0 0x0 0x0 0x4000000 0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; }; If secure mode is on, on the other hand, qemu provides dtb with 1 bank: flash@0 { bank-width = <0x4>; reg = <0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; };
As a result, flash_init()/flash_get_size() will eventually fail. With this patch applied, relevant CONFIG values are modified.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org Tested-by: Heinrich Schuchardt xypron.glpk@gmx.de --- arch/arm/Kconfig | 1 + include/configs/qemu-arm.h | 5 +++++ 2 files changed, 6 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index fe174d02d75a..64552ac5607e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -830,6 +830,7 @@ config ARCH_OWL
config ARCH_QEMU bool "QEMU Virtual Platform" + select ARCH_SUPPORT_TFABOOT select DM select DM_SERIAL select OF_CONTROL diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index 65fdb1e92981..35e3c5ad7a8d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -46,8 +46,13 @@ #define CONFIG_SYS_CBSIZE 512
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE +#ifdef CONFIG_TFABOOT +#define CONFIG_SYS_FLASH_BASE 0x4000000 +#define CONFIG_SYS_MAX_FLASH_BANKS 1 +#else #define CONFIG_SYS_FLASH_BASE 0x0 #define CONFIG_SYS_MAX_FLASH_BANKS 2 +#endif #define CONFIG_SYS_MAX_FLASH_SECT 256 /* Sector: 256K, Bank: 64M */
#endif /* __CONFIG_H */

On Wed, Jul 03, 2019 at 10:44:40AM +0900, AKASHI Takahiro wrote:
If U-Boot is loaded and started from TF-A (you need to change SYS_TEXT_BASE to 0x60000000), it will hang up at flash initialization.
If secure mode is off (default, or -machine virt,secure=off) at qemu, it will provide dtb with two flash memory banks: flash@0 { bank-width = <0x4>; reg = <0x0 0x0 0x0 0x4000000 0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; }; If secure mode is on, on the other hand, qemu provides dtb with 1 bank: flash@0 { bank-width = <0x4>; reg = <0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; };
As a result, flash_init()/flash_get_size() will eventually fail. With this patch applied, relevant CONFIG values are modified.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org Tested-by: Heinrich Schuchardt xypron.glpk@gmx.de
Applied to u-boot/master, thanks!

Hi Albert, Tuomas,
Ping. Can you review this patch, please?
-Takahiro Akashi
On Wed, Jul 03, 2019 at 10:44:38AM +0900, AKASHI Takahiro wrote:
With this patch, hang-up of U-Boot, as described in patch#2, will be fixed if it is loaded and started from TF-A.
Changes in v2 (July 3, 2019)
- add patch#1 (preparatory patch)
- remove a reference to unnecessary patch in the commit message
AKASHI Takahiro (2): arm: move CONFIG_TFABOOT to generic Kconfig arm: qemu: fix failure in flash initialization if booting from TF-A
arch/arm/Kconfig | 29 +++++++++++++++++++++++ arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 7 ------ include/configs/qemu-arm.h | 5 ++++ 3 files changed, 34 insertions(+), 7 deletions(-)
-- 2.21.0
participants (2)
-
AKASHI Takahiro
-
Tom Rini