Skip to contentSkip to conversation

virtual/tpl: add

PATCH In review Trevor Woerner 2 participants 2 messages Oct 3, 2023 Arm Rockchip

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtual/tpl: add

Be more obvious regarding the roles of TF-A vs rkbin: both provide a TPL for Rockchip SoCs, but only one should be used.

---
 conf/machine/include/px30.inc                                | 1 +
 conf/machine/include/rk3328.inc                              | 1 +
 conf/machine/include/rk3399.inc                              | 1 +
 conf/machine/include/rk3588s.inc                             | 2 +-
 recipes-bsp/rkbin/rockchip-rkbin_git.bb                      | 2 +-
 recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend | 2 ++
 6 files changed, 7 insertions(+), 2 deletions(-)
conf/machine/include/px30.inc +1 -0
index a3727fbfca66..04cbd092a00d 100644
@@ -14,6 +14,7 @@ KBUILD_DEFCONFIG ?= "defconfig"
 KERNEL_CLASSES = "kernel-fitimage"
 KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"
 TFA_PLATFORM = "px30"
 TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3328.inc +1 -0
index f9f8792ca521..7f8673f062d1 100644
@@ -15,6 +15,7 @@ KERNEL_FEATURES:append:rk3328 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc
 KERNEL_CLASSES = "kernel-fitimage"
 KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"
 TFA_PLATFORM = "rk3328"
 TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3399.inc +1 -0
index 88c87af3a03e..09be584468b8 100644
@@ -15,6 +15,7 @@ KERNEL_FEATURES:append:rk3399 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc
 KERNEL_CLASSES = "kernel-fitimage"
 KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"
 TFA_PLATFORM = "rk3399"
 TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3588s.inc +1 -1
index 7bfc9474e96e..e66ad565585b 100644
@@ -10,7 +10,7 @@ KERNEL_FEATURES:append:rk3588s = " bsp/rockchip/remove-non-rockchip-arch-arm64.s
 KERNEL_CLASSES = "kernel-fitimage"
 KERNEL_IMAGETYPE = "fitImage"
 
-PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin"
+PREFERRED_PROVIDER_virtual/tpl = "rockchip-rkbin"
 PREFERRED_PROVIDER_optee-os = "rockchip-rkbin"
 
 UBOOT_SUFFIX ?= "itb"
recipes-bsp/rkbin/rockchip-rkbin_git.bb +1 -1
index 7fefb017053b..887a7fb61853 100644
@@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=15faa4a01e7eb0f5d33f9f2bcc7bff62"
 SRC_URI = "git://github.com/rockchip-linux/rkbin;protocol=https;branch=master"
 SRCREV = "b4558da0860ca48bf1a571dd33ccba580b9abe23"
 
-PROVIDES += "trusted-firmware-a"
+PROVIDES += "virtual/tpl"
 PROVIDES += "optee-os"
 
 inherit bin_package deploy
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +2 -0
index c9ad84c24857..f6566212746e 100644
@@ -2,6 +2,8 @@
 # toolchain
 DEPENDS:append:rk3399 = " gcc-arm-none-eabi-native"
 
+PROVIDES += "virtual/tpl"
+
 COMPATIBLE_MACHINE:append:rk3399 = "|rk3399"
 COMPATIBLE_MACHINE:append:rk3328 = "|rk3328"
 COMPATIBLE_MACHINE:append:px30 = "|px30"
Signature · 1 line
2.41.0.327.gaa9166bcc0ba
#1 lore raw

Hi Trevor,

Quoted 3 lines · Trevor Woerner via lists.yoctoproject.org

Be more obvious regarding the roles of TF-A vs rkbin: both provide a TPL for Rockchip SoCs, but only one should be used.

No, they don't.

U-Boot TPL is either a blob provided by Rockchip via the rockchip-rkbin (the one we call ddr-*.bin) recipe or directly generated by U-Boot recipe itself.

rockchip-rkbin has a blob for TF-A called bl31.elf which is TF-A but for which we don't have sources. If we had the sources, we could use trusted-firmware-a recipe instead.

The both of them are actually required because:
1) U-Boot TPL does the DDR init, which is essential
2) TF-A is required on Aarch64 platforms to be able to boot a Linux kernel

Quoted 15 lines
---
  conf/machine/include/px30.inc                                | 1 +
  conf/machine/include/rk3328.inc                              | 1 +
  conf/machine/include/rk3399.inc                              | 1 +
  conf/machine/include/rk3588s.inc                             | 2 +-
  recipes-bsp/rkbin/rockchip-rkbin_git.bb                      | 2 +-
  recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend | 2 ++
  6 files changed, 7 insertions(+), 2 deletions(-)
conf/machine/include/px30.inc +0 -0
index a3727fbfca66..04cbd092a00d 100644

conf/machine/include/px30.inc KBUILD_DEFCONFIG ?= "defconfig" · line 17

Quoted 4 lines
conf/machine/include/px30.inc +1 -0
@@ -14,6 +14,7 @@ KBUILD_DEFCONFIG ?= "defconfig"
  KERNEL_CLASSES = "kernel-fitimage"
  KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"

TPL is provided by upstream U-Boot for PX30 so better use that one. If it wasn't (or you don't want to use it), the proper change would be to use rockchip-rkbin for it.

conf/machine/include/rk3328.inc KERNEL_FEATURES:append:rk3328 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc · line 18

Quoted 12 lines
conf/machine/include/px30.inc +0 -0
  TFA_PLATFORM = "px30"
  TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3328.inc +1 -0
index f9f8792ca521..7f8673f062d1 100644
@@ -15,6 +15,7 @@ KERNEL_FEATURES:append:rk3328 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc
  KERNEL_CLASSES = "kernel-fitimage"
  KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"

Ditto.

conf/machine/include/rk3399.inc KERNEL_FEATURES:append:rk3399 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc · line 18

Quoted 12 lines
conf/machine/include/rk3328.inc +0 -0
  TFA_PLATFORM = "rk3328"
  TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3399.inc +1 -0
index 88c87af3a03e..09be584468b8 100644
@@ -15,6 +15,7 @@ KERNEL_FEATURES:append:rk3399 = " bsp/rockchip/remove-non-rockchip-arch-arm64.sc
  KERNEL_CLASSES = "kernel-fitimage"
  KERNEL_IMAGETYPE = "fitImage"
 
+PREFERRED_PROVIDER_virtual/tpl = "trusted-firmware-a"

Ditto.

conf/machine/include/rk3588s.inc KERNEL_FEATURES:append:rk3588s = " bsp/rockchip/remove-non-rockchip-arch-arm64.s · line 13

Quoted 12 lines
conf/machine/include/rk3399.inc +0 -0
  TFA_PLATFORM = "rk3399"
  TFA_BUILD_TARGET = "bl31"
 
conf/machine/include/rk3588s.inc +0 -1
index 7bfc9474e96e..e66ad565585b 100644
@@ -10,7 +10,7 @@ KERNEL_FEATURES:append:rk3588s = " bsp/rockchip/remove-non-rockchip-arch-arm64.s
  KERNEL_CLASSES = "kernel-fitimage"
  KERNEL_IMAGETYPE = "fitImage"
 
-PREFERRED_PROVIDER_trusted-firmware-a = "rockchip-rkbin"

This was actually correct.

recipes-bsp/rkbin/rockchip-rkbin_git.bb LIC_FILES_CHKSUM = "file://LICENSE;md5=15faa4a01e7eb0f5d33f9f2bcc7bff62" · line 8

Quoted 13 lines
conf/machine/include/rk3588s.inc +1 -0
+PREFERRED_PROVIDER_virtual/tpl = "rockchip-rkbin" >   PREFERRED_PROVIDER_optee-os = "rockchip-rkbin"
 
  UBOOT_SUFFIX ?= "itb"
recipes-bsp/rkbin/rockchip-rkbin_git.bb +1 -1
index 7fefb017053b..887a7fb61853 100644
@@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=15faa4a01e7eb0f5d33f9f2bcc7bff62"
  SRC_URI = "git://github.com/rockchip-linux/rkbin;protocol=https;branch=master"
  SRCREV = "b4558da0860ca48bf1a571dd33ccba580b9abe23"
 
-PROVIDES += "trusted-firmware-a"
+PROVIDES += "virtual/tpl"

Do not remove trusted-firmware-a PROVIDES, it is necessary to be able to select which recipe provides trusted-firmware-a (either rockchip-rkbin or trusted-firmware-a).

You can add virtual/tpl though.

recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend line 6

Quoted 13 lines
recipes-bsp/rkbin/rockchip-rkbin_git.bb +0 -0
  PROVIDES += "optee-os"
 
  inherit bin_package deploy
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +2 -0
index c9ad84c24857..f6566212746e 100644
@@ -2,6 +2,8 @@
  # toolchain
  DEPENDS:append:rk3399 = " gcc-arm-none-eabi-native"
 
+PROVIDES += "virtual/tpl"
+

This is incorrect.

It should be added to u-boot%.bbappend instead. And I think what we want to do is not possible.

So basically, my understand of what you're trying to do is to allow the selection of the TPL via a virtual recipe.

The TPL is used in U-Boot only and should be there before do_compile is executed. So the virtual recipe should have executed its own do_deploy before U-Boot's do_compile runs.

However, the TPL virtual recipe is either rockchip-rkbin (fine) or U-Boot itself, and I think you now have a circular dependency if you select U-Boot as the TPL virtual recipe provider.

What I've seen happen for some BSPs is the use of overrides or variables in conf files.

e.g. in rockchip-defaults.inc

# Use U-Boot TPL
UBOOT_TPL_PROVIDER ?= ""

in rk3588s.inc:
# Use blob because U-Boot doesn't generate a valid TPL yet UBOOT_TPL_PROVIDER = "rockchip-rkbin"

in u-boot%.bbappend:
do_compile[depends] += "${@'${UBOOT_TPL_PROVIDER}:do_deploy' if d.getVar('UBOOT_TPL_PROVIDER') else ''}"

or with overrides:
in rockchip-defaults.inc
UBOOT_TPL_PROVIDER:rkbin-tpl = "rockchip-rkbin"

in rk3588s.inc (or in board's conf):
MACHINEOVERRIDES =. "rkbin-tpl:" # or whatever the proper syntax is :)

in u-boot%.bbappend:
do_compile[depends] += "${@'${UBOOT_TPL_PROVIDER}:do_deploy' if d.getVar('UBOOT_TPL_PROVIDER') else ''}"

I'm not entirely sure this is all worth it though, as we would anyway need to modify the EXTRA_OEMAKE to add ROCKCHIP_TPL argument in the event we're using rockchip-rkbin as provider for the TPL, c.f. what's done for RK3588(S).

Cheers,
Quentin

Quoted 14 lines
recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend +0 -1
  COMPATIBLE_MACHINE:append:rk3399 = "|rk3399"
  COMPATIBLE_MACHINE:append:rk3328 = "|rk3328"
  COMPATIBLE_MACHINE:append:px30 = "|px30"
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#61200): https://lists.yoctoproject.org/g/yocto/message/61200
Mute This Topic: https://lists.yoctoproject.org/mt/101725325/6293953
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-