Hi Trevor,

On 10/3/23 02:08, Trevor Woerner via lists.yoctoproject.org wrote:
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

Signed-off-by: Trevor Woerner <twoer...@gmail.com>
---
  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(-)

diff --git a/conf/machine/include/px30.inc b/conf/machine/include/px30.inc
index a3727fbfca66..04cbd092a00d 100644
--- a/conf/machine/include/px30.inc
+++ b/conf/machine/include/px30.inc
@@ -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.

  TFA_PLATFORM = "px30"
  TFA_BUILD_TARGET = "bl31"
diff --git a/conf/machine/include/rk3328.inc b/conf/machine/include/rk3328.inc
index f9f8792ca521..7f8673f062d1 100644
--- a/conf/machine/include/rk3328.inc
+++ b/conf/machine/include/rk3328.inc
@@ -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.

  TFA_PLATFORM = "rk3328"
  TFA_BUILD_TARGET = "bl31"
diff --git a/conf/machine/include/rk3399.inc b/conf/machine/include/rk3399.inc
index 88c87af3a03e..09be584468b8 100644
--- a/conf/machine/include/rk3399.inc
+++ b/conf/machine/include/rk3399.inc
@@ -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.

  TFA_PLATFORM = "rk3399"
  TFA_BUILD_TARGET = "bl31"
diff --git a/conf/machine/include/rk3588s.inc b/conf/machine/include/rk3588s.inc
index 7bfc9474e96e..e66ad565585b 100644
--- a/conf/machine/include/rk3588s.inc
+++ b/conf/machine/include/rk3588s.inc
@@ -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.

+PREFERRED_PROVIDER_virtual/tpl = "rockchip-rkbin" >   PREFERRED_PROVIDER_optee-os = 
"rockchip-rkbin"
UBOOT_SUFFIX ?= "itb"
diff --git a/recipes-bsp/rkbin/rockchip-rkbin_git.bb 
b/recipes-bsp/rkbin/rockchip-rkbin_git.bb
index 7fefb017053b..887a7fb61853 100644
--- a/recipes-bsp/rkbin/rockchip-rkbin_git.bb
+++ b/recipes-bsp/rkbin/rockchip-rkbin_git.bb
@@ -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.

  PROVIDES += "optee-os"
inherit bin_package deploy
diff --git a/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend 
b/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend
index c9ad84c24857..f6566212746e 100644
--- a/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend
+++ b/recipes-bsp/trusted-firmware-a/trusted-firmware-a_%.bbappend
@@ -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

  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 (#61211): https://lists.yoctoproject.org/g/yocto/message/61211
Mute This Topic: https://lists.yoctoproject.org/mt/101725325/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to