Skip to contentSkip to conversation

rockchip: Support OP-TEE binaries in ARM FIT images

PATCH Superseded Alex Bee 3 participants 21 messages Jul 16, 2023 – Jul 26, 2023

Subsystems (3)
lore
Share & tools
lore

Alex Bee

author
#0 lore raw

cover rockchip: Support OP-TEE binaries in ARM FIT images

This adds support for OP-TEE binaries to Rockchip's ARM FIT image generation by binman.

Currently there is an extra (and outdated) rockchip-optee.dtsi which can create an u-boot.itb which can also hold the OP-TEE binary. It has to be included manually in the respective SoC-specific device trees. But even if that is done, it won't be merged in rockchip-u-boot.bin, which aims to be platform-consistent.
The bootable FIT image must therefore currently be created manually.

This will be done automatically with this patch-set and a single u-boot-rockchip.bin file with an bootable FIT image containing all binaries will be generated.

Additionally this series adds a configuration option which has to be set if a vendor-provided OP-TEE binary is used. This is required as those use a different calling convention.
For RK3036, RK3128 and RK3288 SoCs this currently the only option to get an TEE, as no upstream implementation exists for them.
Those binaries can be found at [1]

There are also some adaptions for RK322x in order to successfully use that FIT image and some changes to the documenation.

This series has been tested on RK3229 (both vendor and upstream OP-TEE) and RK3288 (vendor implementation only).

[1] https://github.com/rockchip-linux/rkbin

Alex Bee (5):
rockchip: Support OP-TEE for ARM in FIT images created by binman
evb-rk3229_defconfig: Drop SPL_STACK_R_MALLOC_SIMPLE_LEN
rockchip: RK322x: select SPL_OPTEE_IMAGE
rockchip: evb_rk3229: Update/fix README
optee: Support Rockchip OPTEE binaries

 arch/arm/dts/rk3288-u-boot.dtsi   |  1 -
 arch/arm/dts/rockchip-optee.dtsi  | 64 ---------------------------
 arch/arm/dts/rockchip-u-boot.dtsi | 38 ++++++++++++++--
 arch/arm/mach-rockchip/Kconfig    | 10 +++++
 board/rockchip/evb_rk3229/README  | 72 ++++++++++++++++++++-----------
 common/spl/spl_optee.S            |  4 ++
 configs/evb-rk3229_defconfig      |  1 -
 7 files changed, 97 insertions(+), 93 deletions(-)
 delete mode 100644 arch/arm/dts/rockchip-optee.dtsi

base-commit: e6e67bb9e0a40f3eb3c87d16935192821987c3e0

Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 1/5 rockchip: Support OP-TEE for ARM in FIT images created by binman

CONFIG_SPL_OPTEE_IMAGE option is used during DRAM size detection for Rockchip ARM platform to indicate that an OP-TEE binary was already loaded and a Trusted Execution Environment (TEE) is available in order to block/reserve a memory-region for it.

This adds a bunch of new #if's to u-boot-rockchip.dtsi to include the OP-TEE binary in the FIT image for ARM SOCs if CONFIG_SPL_OPTEE_IMAGE is selected.
That makes it a little harder to read, but I opted for that, because all the duplicates in an extra ARM-OP-TEE-specfic .dtsi would be the greater evil, IMHO. Besides it's more likley being "forgotten" to sync when changes in u-boot-rockchip.dtsi are made.

The no longer required rockchip-optee.dtsi and it's inclusions are dropped.

The hardcoded load address is common across all OP-TEE implemenations for Rockchip (vendor and upstream).

The OP-TEE-binary is non-optional if CONFIG_SPL_OPTEE_IMAGE is selected and there will be an error if the file does not exist and/or TEE= build option is missing.

---
 arch/arm/dts/rk3288-u-boot.dtsi   |  1 -
 arch/arm/dts/rockchip-optee.dtsi  | 64 -------------------------------
 arch/arm/dts/rockchip-u-boot.dtsi | 38 ++++++++++++++++--
 3 files changed, 35 insertions(+), 68 deletions(-)
 delete mode 100644 arch/arm/dts/rockchip-optee.dtsi
arch/arm/dts/rk3288-u-boot.dtsi +0 -1
index 1920698884..c4c5a2d225 100644
@@ -4,7 +4,6 @@
  */
 
 #include "rockchip-u-boot.dtsi"
-#include "rockchip-optee.dtsi"
 
 / {
 	aliases {
arch/arm/dts/rockchip-optee.dtsi deleted +0 -64

64 lines not on this page · raw message

arch/arm/dts/rockchip-u-boot.dtsi +35 -3
index 2878b80926..36a3fbf3ab 100644
@@ -33,9 +33,13 @@
 			};
 		};
 
-#if defined(CONFIG_SPL_FIT) && defined(CONFIG_ARM64)
+#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64)  || defined(CONFIG_SPL_OPTEE_IMAGE))
 		fit: fit {
+#ifdef CONFIG_ARM64
 			description = "FIT image for U-Boot with bl31 (TF-A)";
+#else
+			description = "FIT image with OP-TEE";
+#endif
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
 			filename = "u-boot.itb";
@@ -44,10 +48,14 @@
 			offset = <CONFIG_SPL_PAD_TO>;
 			images {
 				u-boot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
 					type = "standalone";
 					os = "U-Boot";
+#ifdef CONFIG_ARM64
 					arch = "arm64";
+#else
+					arch = "arm";
+#endif
 					compression = "none";
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
@@ -60,6 +68,7 @@
 #endif
 				};
 
+#ifdef CONFIG_ARM64
 				@atf-SEQ {
 					fit,operation = "split-elf";
 					description = "ARM Trusted Firmware";
@@ -99,6 +108,25 @@
 					};
 #endif
 				};
+#else
+				op-tee {
+					description = "OP-TEE";
+					type = "tee";
+					arch = "arm";
+					os = "tee";
+					compression = "none";
+					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+					entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+
+					tee-os {
+					};
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+					hash {
+						algo = "sha256";
+					};
+#endif
+				};
+#endif
 
 				@fdt-SEQ {
 					description = "fdt-NAME";
@@ -117,7 +145,11 @@
 				@config-SEQ {
 					description = "NAME.dtb";
 					fdt = "fdt-SEQ";
+#ifdef CONFIG_ARM64
 					fit,firmware = "atf-1", "u-boot";
+#else
+					fit,firmware = "op-tee", "u-boot";
+#endif
 					fit,loadables;
 				};
 			};
@@ -150,7 +182,7 @@
 			};
 		};
 
-#ifdef CONFIG_ARM64
+#if defined(CONFIG_ARM64)  || defined(CONFIG_SPL_OPTEE_IMAGE)
 		fit {
 			type = "blob";
 			filename = "u-boot.itb";
Signature · 1 line
2.41.0
author
#2 lore raw

PATCH 2/5 evb-rk3229_defconfig: Drop SPL_STACK_R_MALLOC_SIMPLE_LEN

In reply to Alex Bee

An OP-TEE FIT image will fail to extract in SPL because the malloc stack size is currently limited to 0x2000 for evb-rk3229 board.

In SPL we do not have to care about size limitations, since we are no longer bound to SRAM limits after DRAM initialization has been done in TPL.

Drop that definition, so that the default defined will be used, in order to successfully boot that image.

---
 configs/evb-rk3229_defconfig | 1 -
 1 file changed, 1 deletion(-)
configs/evb-rk3229_defconfig +0 -1
index cf73afeded..b818d11b69 100644
@@ -31,7 +31,6 @@ CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_NO_BSS_LIMIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
-CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
 CONFIG_SPL_OPTEE_IMAGE=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_GPT=y
Signature · 1 line
2.41.0
author
#3 lore raw

PATCH 3/5 rockchip: RK322x: select SPL_OPTEE_IMAGE

In reply to Alex Bee

For RK322x series ARM SoCs the OP-TEE is non-optional, as besides the TEE it also provides the PSCI implementation, which is expected to be available by upstream linux.

Select CONFIG_SPL_OPTEE_IMAGE if an FIT image is built.

---
 arch/arm/mach-rockchip/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/Kconfig +1 -0
index 9d6d20bf8e..9f12524aeb 100644
@@ -106,6 +106,7 @@ config ROCKCHIP_RK322X
 	imply ROCKCHIP_COMMON_BOARD
 	imply SPL_SERIAL
 	imply SPL_ROCKCHIP_COMMON_BOARD
+	select CONFIG_SPL_OPTEE_IMAGE if SPL_FIT
 	imply TPL_SERIAL
 	imply TPL_ROCKCHIP_COMMON_BOARD
 	select TPL_LIBCOMMON_SUPPORT
Signature · 1 line
2.41.0
author
#4 lore raw

PATCH 4/5 rockchip: evb_rk3229: Update/fix README

In reply to Alex Bee

This updates the evb_rk3229's README on howto create / use the FIT image created by binman.
Also fix some wrong paths and update filenames which have changed in recent upstream optee-os versions.

---
 board/rockchip/evb_rk3229/README | 72 +++++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 24 deletions(-)
board/rockchip/evb_rk3229/README +48 -24
index 9068225e27..e4c88bac06 100644
@@ -13,25 +13,23 @@ Compile the OP-TEE
 
   > cd optee_os
   > make clean
-  > make CROSS_COMPILE_ta_arm32=arm-none-eabi- PLATFORM=rockchip-rk322x
-  Get tee.bin in this step, copy it to U-Boot root dir:
-  > cp out/arm-plat-rockchip/core/tee-pager.bin ../u-boot/tee.bin
+  > make CROSS_COMPILE=arm-none-eabi- PLATFORM=rockchip-rk322x
+  Get tee-pager_v2.bin in this step, copy it to U-Boot root dir:
+  > cp out/arm-plat-rockchip/core/tee-pager_v2.bin ../u-boot/tee.bin
 
 Compile the U-Boot
 ==================
 
   > cd ../u-boot
-  > export CROSS_COMPILE=arm-linux-gnueabihf-
   > make evb-rk3229_defconfig
-  > make
-  > make u-boot.itb
+  > TEE=tee.bin CROSS_COMPILE=arm-linux-gnueabihf- make
 
-  Get tpl/u-boot-tpl.bin, spl/u-boot-spl.bin and u-boot.itb in this step.
+  Get u-boot-rockchip.bin in this step.
 
 Compile the rkdeveloptool
 =======================
   Follow instructions in latest README
-  > cd ../rkflashtool
+  > cd ../rkdeveloptool
   > autoreconf -i
   > ./configure
   > make
@@ -42,30 +40,56 @@ Compile the rkdeveloptool
 Both origin binaries and Tool are ready now, choose either option 1 or
 option 2 to deploy U-Boot.
 
-Package the image
-=================
-
-  > cd ../u-boot
-  > tools/mkimage -n rk322x -T rksd -d tpl/u-boot-spl.bin idbloader.img
-  > cat spl/u-boot-spl.bin >> idbloader.img
-
-  Get idbloader.img in this step.
-
 Flash the image to eMMC
 =======================
 Power on(or reset with RESET KEY) with MASKROM KEY preesed, and then:
   > cd ..
-  > rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
-  > rkdeveloptool wl 64 u-boot/idbloader.img
-  > rkdeveloptool wl 0x4000 u-boot/u-boot.itb
-  > rkdeveloptool rd
+  > rkdeveloptool/rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
+  > rkdeveloptool/rkdeveloptool wl 64 u-boot/u-boot-rockchip.bin
+  > rkdeveloptool/rkdeveloptool rd
 
 Flash the image to SD card
 ==========================
-  > dd if=u-boot/idbloader.img of=/dev/sdb seek=64
-  > dd if=u-boot/u-boot.itb of=/dev/sdb seek=16384
+  > dd if=u-boot/u-boot-rockchip.bin of=/dev/sdb seek=64
+
+You should be able to get U-Boot log message with OP-TEE boot info:
+
+U-Boot TPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51)
+Trying to boot from BOOTROM
+Returning to boot ROM...
+
+U-Boot SPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+Trying to boot from MMC1
+I/TC:
+I/TC: Non-secure external DT found
+I/TC: Switching console to device: /serial@11030000
+I/TC: OP-TEE version: 3.22.0-27-g893a762d1 (gcc version 10.3.1 20210621 (release) (15:10.3-2021.07-4)) #1 Sat Jul 15 12:14:36 UTC 2023 arm
+I/TC: WARNING: This OP-TEE configuration might be insecure!
+I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
+I/TC: Primary CPU initializing
+M/TC: Not protecting region 1: 0x68400000-0x68600000
+I/TC: Primary CPU switching to normal world boot
+
+
+U-Boot 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+
+Model: Rockchip RK3229 Evaluation board
+DRAM:  1 GiB (effective 992 MiB)
+Core:  113 devices, 16 uclasses, devicetree: separate
+MMC:   mmc@30000000: 1, mmc@30020000: 0
+Loading Environment from MMC... Card did not respond to voltage select! : -110
+*** Warning - No block device, using default environment
+
+In:    serial@11030000
+Out:   serial@11030000
+Err:   serial@11030000
+Model: Rockchip RK3229 Evaluation board
+Net:
+Warning: ethernet@30200000 (eth0) using random MAC address - 72:65:2b:f1:c5:0a
+eth0: ethernet@30200000
+Hit any key to stop autoboot:  0
+=>
 
-You should be able to get U-Boot log message with OP-TEE boot info.
 
 For more detail, please reference to:
 http://opensource.rock-chips.com/wiki_Boot_option
Signature · 1 line
2.41.0
#5 lore raw

Re: [PATCH v1 4/5] rockchip: evb_rk3229: Update/fix README

Quoted 15 lines · Alex Bee

This updates the evb_rk3229's README on howto create / use the FIT image created by binman.
Also fix some wrong paths and update filenames which have changed in recent upstream optee-os versions.

---
 board/rockchip/evb_rk3229/README | 72 +++++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 24 deletions(-)
board/rockchip/evb_rk3229/README +0 -0
index 9068225e27..e4c88bac06 100644

board/rockchip/evb_rk3229/README Compile the OP-TEE · line 18

Quoted 9 lines
board/rockchip/evb_rk3229/README +3 -3
@@ -13,25 +13,23 @@ Compile the OP-TEE
 
   > cd optee_os
   > make clean
-  > make CROSS_COMPILE_ta_arm32=arm-none-eabi- PLATFORM=rockchip-rk322x
-  Get tee.bin in this step, copy it to U-Boot root dir:
-  > cp out/arm-plat-rockchip/core/tee-pager.bin ../u-boot/tee.bin
+  > make CROSS_COMPILE=arm-none-eabi- PLATFORM=rockchip-rk322x
+  Get tee-pager_v2.bin in this step, copy it to U-Boot root dir:
+  > cp out/arm-plat-rockchip/core/tee-pager_v2.bin ../u-boot/tee.bin

Since OP-TEE 3.21.0, there is a tee-raw.bin file. I recommend using it instead of tee-pager_v2.bin. Technically they are identical when the OP-TEE "pager" feature is disabled, but the name makes more sense.

Signature · 1 line
Jerome
author
#6 lore raw

Re: [PATCH v1 4/5] rockchip: evb_rk3229: Update/fix README

Hi Jerome,

Am 17.07.23 um 15:42 schrieb Jerome Forissier:

Quoted 19 lines · Alex Bee
Quoted 16 lines

This updates the evb_rk3229's README on howto create / use the FIT image created by binman.
Also fix some wrong paths and update filenames which have changed in recent upstream optee-os versions.

---
  board/rockchip/evb_rk3229/README | 72 +++++++++++++++++++++-----------
  1 file changed, 48 insertions(+), 24 deletions(-)
board/rockchip/evb_rk3229/README +0 -0
index 9068225e27..e4c88bac06 100644
@@ -13,25 +13,23 @@ Compile the OP-TEE
 
Quoted 13 lines

board/rockchip/evb_rk3229/README Compile the OP-TEE · line 18

Quoted 8 lines
board/rockchip/evb_rk3229/README +3 -3
    > cd optee_os
    > make clean
-  > make CROSS_COMPILE_ta_arm32=arm-none-eabi- PLATFORM=rockchip-rk322x
-  Get tee.bin in this step, copy it to U-Boot root dir:
-  > cp out/arm-plat-rockchip/core/tee-pager.bin ../u-boot/tee.bin
+  > make CROSS_COMPILE=arm-none-eabi- PLATFORM=rockchip-rk322x
+  Get tee-pager_v2.bin in this step, copy it to U-Boot root dir:
+  > cp out/arm-plat-rockchip/core/tee-pager_v2.bin ../u-boot/tee.bin

Since OP-TEE 3.21.0, there is a tee-raw.bin file. I recommend using it instead of tee-pager_v2.bin. Technically they are identical when the OP-TEE "pager" feature is disabled, but the name makes more sense.

Thanks for the hint. I'll change that in v2.

Regards,
Alex

author
#7 lore raw

PATCH 5/5 optee: Support Rockchip OPTEE binaries

In reply to Alex Bee

Currently the only ARM Rockchip SoC which is supported by upstream optee-os is RK322x. For all other ARM SoCs a vendor-provided OP-TEE binary has to be used to have a TEE available. Those are using a calling convension different from upstream optee-os.

This introduces CONFIG_ROCKCHIP_OPTEE_BINARY which signals that any of those vendor binaries is used and changes the calling convension accordingly.

---
 arch/arm/mach-rockchip/Kconfig | 9 +++++++++
 common/spl/spl_optee.S         | 4 ++++
 2 files changed, 13 insertions(+)
arch/arm/mach-rockchip/Kconfig +9 -0
index 9f12524aeb..41a9c4fe95 100644
@@ -449,6 +449,15 @@ config ROCKCHIP_BOOT_MODE_REG
 	  The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h)
 	  according to the value from this register.
 
+config ROCKCHIP_OPTEE_BINARY
+	bool "Use a OP-TEE binary provided by Rockchip"
+	depends on SPL_FIT && SPL_OPTEE_IMAGE
+	default y if ROCKCHIP_RK3036 || ROCKCHIP_RK3128 || ROCKCHIP_RK3288
+	help
+	  This option enables the usage of vendor-provided OP-TEE binaries.
+
+	  Say Y if you are using OP-TEE binary provided by Rockchip.
+
 config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
 	bool "Disable device boot on power plug-in"
 	depends on PMIC_RK8XX
common/spl/spl_optee.S +4 -0
index a269904d38..ea41d8adb6 100644
@@ -7,6 +7,10 @@
 #include <asm/assembler.h>
 
 ENTRY(spl_optee_entry)
+#ifdef CONFIG_ROCKCHIP_OPTEE_BINARY
+	ldr r1, =CONFIG_TEXT_BASE
+#else
 	ldr lr, =CONFIG_TEXT_BASE
+#endif
 	mov pc, r3
 ENDPROC(spl_optee_entry)
Signature · 1 line
2.41.0
author
#8 lore raw

v2 cover rockchip: Support OP-TEE binaries in ARM FIT images

In reply to Alex Bee

This adds support for OP-TEE binaries to Rockchip's ARM FIT image generation by binman.

Currently there is an extra (and outdated) rockchip-optee.dtsi which can create an u-boot.itb which can also hold the OP-TEE binary. It has to be included manually in the respective SoC-specific device trees. But even if that is done, it won't be merged in rockchip-u-boot.bin, which aims to be platform-consistent.
The bootable FIT image must therefore currently be created manually.

This will be done automatically with this patch-set and a single u-boot-rockchip.bin file with an bootable FIT image containing all binaries will be generated.

Additionally this series adds a configuration option which has to be set if a vendor-provided OP-TEE binary is used. This is required as those use a different calling convention.
For RK3036, RK3128 and RK3288 SoCs this currently the only option to get an TEE, as no upstream implementation exists for them.
Those binaries can be found at [1]

There are also some adaptions for RK322x in order to successfully use that FIT image and some changes to the documenation.

This series has been tested on RK3229 (both vendor and upstream OP-TEE) and RK3288 (vendor implementation only).

[1] https://github.com/rockchip-linux/rkbin

Changes in v2:

1/5:
* whitespace fixes in rockchip-u-boot.dtsi
2/5:
* instead of dropping CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN, set it to the current default value
3/5:
* fix: select SPL_OPTEE_IMAGE instead of select CONFIG_SPL_OPTEE_IMAGE in Kconfig
4/5:
* refer to use "tee-raw.bin" instead of "tee-pager_v2.bin" in README (Jerome Forissier)
5/5:
* drop empty line in Kconfig help text
* fix subject "OPTEE" -> "OP-TEE"
* ROCKCHIP_OPTEE_BINARY should depend on SPL_OPTEE_IMAGE only, as the latter depends on SPL_FIT already
(via depends on SPL_LOAD_FIT || SPL_LOAD_FIT_FULL)

Alex Bee (5):
rockchip: Support OP-TEE for ARM in FIT images created by binman
configs: evb-rk3229: Increase SPL_STACK_R_MALLOC_SIMPLE_LEN
rockchip: RK322x: Select SPL_OPTEE_IMAGE
rockchip: evb_rk3229: Update/fix README
optee: Support Rockchip OP-TEE binaries

 arch/arm/dts/rk3288-u-boot.dtsi   |  1 -
 arch/arm/dts/rockchip-optee.dtsi  | 64 ---------------------------
 arch/arm/dts/rockchip-u-boot.dtsi | 38 ++++++++++++++--
 arch/arm/mach-rockchip/Kconfig    |  9 ++++
 board/rockchip/evb_rk3229/README  | 72 ++++++++++++++++++++-----------
 common/spl/spl_optee.S            |  4 ++
 configs/evb-rk3229_defconfig      |  2 +-
 7 files changed, 97 insertions(+), 93 deletions(-)
 delete mode 100644 arch/arm/dts/rockchip-optee.dtsi

base-commit: 890233ca5569e5787d8407596a12b9fca80952bf

Signature · 1 line
2.41.0
author
#9 lore raw

PATCH v2 1/5 rockchip: Support OP-TEE for ARM in FIT images created by binman

CONFIG_SPL_OPTEE_IMAGE option is used during DRAM size detection for Rockchip ARM platform to indicate that an OP-TEE binary was already loaded and a Trusted Execution Environment (TEE) is available in order to block/reserve a memory-region for it.

This adds a bunch of new #if's to u-boot-rockchip.dtsi to include the OP-TEE binary in the FIT image for ARM SOCs if CONFIG_SPL_OPTEE_IMAGE is selected.
That makes it a little harder to read, but I opted for that, because all the duplicates in an extra ARM-OP-TEE-specfic .dtsi would be the greater evil, IMHO. Besides it's more likley being "forgotten" to sync when changes in u-boot-rockchip.dtsi are made.

The no longer required rockchip-optee.dtsi and it's inclusions are dropped.

The hardcoded load address is common across all OP-TEE implemenations for Rockchip (vendor and upstream).

The OP-TEE-binary is non-optional if CONFIG_SPL_OPTEE_IMAGE is selected and there will be an error if the file does not exist and/or TEE= build option is missing.

---
 arch/arm/dts/rk3288-u-boot.dtsi   |  1 -
 arch/arm/dts/rockchip-optee.dtsi  | 64 -------------------------------
 arch/arm/dts/rockchip-u-boot.dtsi | 38 ++++++++++++++++--
 3 files changed, 35 insertions(+), 68 deletions(-)
 delete mode 100644 arch/arm/dts/rockchip-optee.dtsi
arch/arm/dts/rk3288-u-boot.dtsi +0 -1
index 1920698884..c4c5a2d225 100644
@@ -4,7 +4,6 @@
  */
 
 #include "rockchip-u-boot.dtsi"
-#include "rockchip-optee.dtsi"
 
 / {
 	aliases {
arch/arm/dts/rockchip-optee.dtsi deleted +0 -64

64 lines not on this page · raw message

arch/arm/dts/rockchip-u-boot.dtsi +35 -3
index 2878b80926..be2658e8ef 100644
@@ -33,9 +33,13 @@
 			};
 		};
 
-#if defined(CONFIG_SPL_FIT) && defined(CONFIG_ARM64)
+#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
 		fit: fit {
+#ifdef CONFIG_ARM64
 			description = "FIT image for U-Boot with bl31 (TF-A)";
+#else
+			description = "FIT image with OP-TEE";
+#endif
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
 			filename = "u-boot.itb";
@@ -44,10 +48,14 @@
 			offset = <CONFIG_SPL_PAD_TO>;
 			images {
 				u-boot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
 					type = "standalone";
 					os = "U-Boot";
+#ifdef CONFIG_ARM64
 					arch = "arm64";
+#else
+					arch = "arm";
+#endif
 					compression = "none";
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
@@ -60,6 +68,7 @@
 #endif
 				};
 
+#ifdef CONFIG_ARM64
 				@atf-SEQ {
 					fit,operation = "split-elf";
 					description = "ARM Trusted Firmware";
@@ -99,6 +108,25 @@
 					};
 #endif
 				};
+#else
+				op-tee {
+					description = "OP-TEE";
+					type = "tee";
+					arch = "arm";
+					os = "tee";
+					compression = "none";
+					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+					entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+
+					tee-os {
+					};
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+					hash {
+						algo = "sha256";
+					};
+#endif
+				};
+#endif
 
 				@fdt-SEQ {
 					description = "fdt-NAME";
@@ -117,7 +145,11 @@
 				@config-SEQ {
 					description = "NAME.dtb";
 					fdt = "fdt-SEQ";
+#ifdef CONFIG_ARM64
 					fit,firmware = "atf-1", "u-boot";
+#else
+					fit,firmware = "op-tee", "u-boot";
+#endif
 					fit,loadables;
 				};
 			};
@@ -150,7 +182,7 @@
 			};
 		};
 
-#ifdef CONFIG_ARM64
+#if defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE)
 		fit {
 			type = "blob";
 			filename = "u-boot.itb";
Signature · 1 line
2.41.0
Reviewed-by on v2 1/5
#10 lore raw

Re: [PATCH v2 1/5] rockchip: Support OP-TEE for ARM in FIT images created by binman

Quoted 15 lines · Alex Bee

CONFIG_SPL_OPTEE_IMAGE option is used during DRAM size detection for Rockchip ARM platform to indicate that an OP-TEE binary was already loaded and a Trusted Execution Environment (TEE) is available in order to block/reserve a memory-region for it.

This adds a bunch of new #if's to u-boot-rockchip.dtsi to include the OP-TEE binary in the FIT image for ARM SOCs if CONFIG_SPL_OPTEE_IMAGE is selected.
That makes it a little harder to read, but I opted for that, because all the duplicates in an extra ARM-OP-TEE-specfic .dtsi would be the greater evil, IMHO. Besides it's more likley being "forgotten" to sync when changes in u-boot-rockchip.dtsi are made.

The no longer required rockchip-optee.dtsi and it's inclusions are dropped.

Quoted 8 lines

The hardcoded load address is common across all OP-TEE implemenations for Rockchip (vendor and upstream).

The OP-TEE-binary is non-optional if CONFIG_SPL_OPTEE_IMAGE is selected and there will be an error if the file does not exist and/or TEE= build option is missing.

Thanks,
- Kever

Quoted 179 lines
---
  arch/arm/dts/rk3288-u-boot.dtsi   |  1 -
  arch/arm/dts/rockchip-optee.dtsi  | 64 -------------------------------
  arch/arm/dts/rockchip-u-boot.dtsi | 38 ++++++++++++++++--
  3 files changed, 35 insertions(+), 68 deletions(-)

delete mode 100644 arch/arm/dts/rockchip-optee.dtsi

arch/arm/dts/rk3288-u-boot.dtsi +0 -1
index 1920698884..c4c5a2d225 100644
@@ -4,7 +4,6 @@
   */
 
  #include "rockchip-u-boot.dtsi"
-#include "rockchip-optee.dtsi"
 
  / {
  	aliases {
arch/arm/dts/rockchip-optee.dtsi deleted +0 -64
deleted file mode 100644
index d84c10cf43..0000000000
@@ -1,64 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright 2020 Google LLC
- */
-
-#include <config.h>
-
-#if defined(CONFIG_HAS_ROM) && defined(CONFIG_FIT)
-&binman {
-	itb {
-		filename = "u-boot.itb";
-		fit {
-			fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
-			description = "FIT image with OP-TEE support";
-			#address-cells = <1>;
-
-			images {
-				uboot {
-					description = "U-Boot";
-					type = "standalone";
-					os = "U-Boot";
-					arch = "arm";
-					compression = "none";
-					load = <CONFIG_TEXT_BASE>;
-
-					u-boot-nodtb {
-					};
-				};
-				optee {
-					description = "OP-TEE";
-					type = "firmware";
-					arch = "arm";
-					os = "tee";
-					compression = "none";
-					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
-					entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
-
-					blob-ext {
-						filename = "tee.bin";
-					};
-				};
-				fdt {
-					description = CONFIG_SYS_BOARD;
-					type = "flat_dt";
-					compression = "none";
-
-					u-boot-dtb {
-					};
-				};
-			};
-
-			configurations {
-				default = "conf";
-				conf {
-					description = CONFIG_SYS_BOARD;
-					firmware = "optee";
-					loadables = "uboot";
-					fdt = "fdt";
-				};
-			};
-		};
-	};
-};
-#endif
arch/arm/dts/rockchip-u-boot.dtsi +35 -3
index 2878b80926..be2658e8ef 100644
@@ -33,9 +33,13 @@
  			};
  		};
 
-#if defined(CONFIG_SPL_FIT) && defined(CONFIG_ARM64)
+#if defined(CONFIG_SPL_FIT) && (defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE))
  		fit: fit {
+#ifdef CONFIG_ARM64
  			description = "FIT image for U-Boot with bl31 (TF-A)";
+#else
+			description = "FIT image with OP-TEE";
+#endif
  			#address-cells = <1>;
  			fit,fdt-list = "of-list";
  			filename = "u-boot.itb";
@@ -44,10 +48,14 @@
  			offset = <CONFIG_SPL_PAD_TO>;
  			images {
  				u-boot {
-					description = "U-Boot (64-bit)";
+					description = "U-Boot";
  					type = "standalone";
  					os = "U-Boot";
+#ifdef CONFIG_ARM64
  					arch = "arm64";
+#else
+					arch = "arm";
+#endif
  					compression = "none";
  					load = <CONFIG_TEXT_BASE>;
  					entry = <CONFIG_TEXT_BASE>;
@@ -60,6 +68,7 @@
  #endif
  				};
 
+#ifdef CONFIG_ARM64
  				@atf-SEQ {
  					fit,operation = "split-elf";
  					description = "ARM Trusted Firmware";
@@ -99,6 +108,25 @@
  					};
  #endif
  				};
+#else
+				op-tee {
+					description = "OP-TEE";
+					type = "tee";
+					arch = "arm";
+					os = "tee";
+					compression = "none";
+					load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+					entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+
+					tee-os {
+					};
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+					hash {
+						algo = "sha256";
+					};
+#endif
+				};
+#endif
 
  				@fdt-SEQ {
  					description = "fdt-NAME";
@@ -117,7 +145,11 @@
  				@config-SEQ {
  					description = "NAME.dtb";
  					fdt = "fdt-SEQ";
+#ifdef CONFIG_ARM64
  					fit,firmware = "atf-1", "u-boot";
+#else
+					fit,firmware = "op-tee", "u-boot";
+#endif
  					fit,loadables;
  				};
  			};
@@ -150,7 +182,7 @@
  			};
  		};
 
-#ifdef CONFIG_ARM64
+#if defined(CONFIG_ARM64) || defined(CONFIG_SPL_OPTEE_IMAGE)
  		fit {
  			type = "blob";
  			filename = "u-boot.itb";
author
#11 lore raw

PATCH v2 2/5 configs: evb-rk3229: Increase SPL_STACK_R_MALLOC_SIMPLE_LEN

In reply to Alex Bee

An OP-TEE FIT image will fail to extract in SPL because the malloc stack size is currently limited to 0x2000 for evb-rk3229 board.

In SPL we do not have to care about size limitations, since we are no longer bound to SRAM limits after DRAM initialization has been done in TPL.

Use the default value for CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN in order successfully unpack the FIT image.

---
 configs/evb-rk3229_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configs/evb-rk3229_defconfig +1 -1
index cf73afeded..73015f098c 100644
@@ -31,7 +31,7 @@ CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_NO_BSS_LIMIT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SPL_STACK_R=y
-CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000
 CONFIG_SPL_OPTEE_IMAGE=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_GPT=y
Signature · 1 line
2.41.0
Reviewed-by on v2 2/5
#12 lore raw

Re: [PATCH v2 2/5] configs: evb-rk3229: Increase SPL_STACK_R_MALLOC_SIMPLE_LEN

Quoted 10 lines · Alex Bee

An OP-TEE FIT image will fail to extract in SPL because the malloc stack size is currently limited to 0x2000 for evb-rk3229 board.

In SPL we do not have to care about size limitations, since we are no longer bound to SRAM limits after DRAM initialization has been done in TPL.

Use the default value for CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN in order successfully unpack the FIT image.

Thanks,
- Kever

Quoted 17 lines
---
  configs/evb-rk3229_defconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
configs/evb-rk3229_defconfig +1 -1
index cf73afeded..73015f098c 100644
@@ -31,7 +31,7 @@ CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_NO_BSS_LIMIT=y
  # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
  CONFIG_SPL_STACK_R=y
-CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000
  CONFIG_SPL_OPTEE_IMAGE=y
  CONFIG_SYS_BOOTM_LEN=0x4000000
  CONFIG_CMD_GPT=y
author
#13 lore raw

PATCH v2 3/5 rockchip: RK322x: Select SPL_OPTEE_IMAGE

In reply to Alex Bee

For RK322x series ARM SoCs the OP-TEE is non-optional, as besides the TEE it also provides the PSCI implementation, which is expected to be available by upstream linux.

Select CONFIG_SPL_OPTEE_IMAGE if an FIT image is built.

---
 arch/arm/mach-rockchip/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/Kconfig +1 -0
index 9d6d20bf8e..17dd43155d 100644
@@ -106,6 +106,7 @@ config ROCKCHIP_RK322X
 	imply ROCKCHIP_COMMON_BOARD
 	imply SPL_SERIAL
 	imply SPL_ROCKCHIP_COMMON_BOARD
+	select SPL_OPTEE_IMAGE if SPL_FIT
 	imply TPL_SERIAL
 	imply TPL_ROCKCHIP_COMMON_BOARD
 	select TPL_LIBCOMMON_SUPPORT
Signature · 1 line
2.41.0
Reviewed-by on v2 3/5
#14 lore raw

Re: [PATCH v2 3/5] rockchip: RK322x: Select SPL_OPTEE_IMAGE

Quoted 7 lines · Alex Bee

For RK322x series ARM SoCs the OP-TEE is non-optional, as besides the TEE it also provides the PSCI implementation, which is expected to be available by upstream linux.

Select CONFIG_SPL_OPTEE_IMAGE if an FIT image is built.

Thanks,
- Kever

Quoted 16 lines
---
  arch/arm/mach-rockchip/Kconfig | 1 +
  1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/Kconfig +1 -0
index 9d6d20bf8e..17dd43155d 100644
@@ -106,6 +106,7 @@ config ROCKCHIP_RK322X
  	imply ROCKCHIP_COMMON_BOARD
  	imply SPL_SERIAL
  	imply SPL_ROCKCHIP_COMMON_BOARD
+	select SPL_OPTEE_IMAGE if SPL_FIT
  	imply TPL_SERIAL
  	imply TPL_ROCKCHIP_COMMON_BOARD
  	select TPL_LIBCOMMON_SUPPORT
author
#15 lore raw

PATCH v2 4/5 rockchip: evb_rk3229: Update/fix README

In reply to Alex Bee

This updates the evb_rk3229's README on howto create / use the FIT image created by binman.
Also fix some wrong paths and update filenames which have changed in recent upstream optee-os versions.

---
 board/rockchip/evb_rk3229/README | 72 +++++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 24 deletions(-)
board/rockchip/evb_rk3229/README +48 -24
index 9068225e27..a8dcc40f09 100644
@@ -13,25 +13,23 @@ Compile the OP-TEE
 
   > cd optee_os
   > make clean
-  > make CROSS_COMPILE_ta_arm32=arm-none-eabi- PLATFORM=rockchip-rk322x
-  Get tee.bin in this step, copy it to U-Boot root dir:
-  > cp out/arm-plat-rockchip/core/tee-pager.bin ../u-boot/tee.bin
+  > make CROSS_COMPILE=arm-none-eabi- PLATFORM=rockchip-rk322x
+  Get tee-raw.bin in this step, copy it to U-Boot root dir:
+  > cp out/arm-plat-rockchip/core/tee-raw.bin ../u-boot/tee.bin
 
 Compile the U-Boot
 ==================
 
   > cd ../u-boot
-  > export CROSS_COMPILE=arm-linux-gnueabihf-
   > make evb-rk3229_defconfig
-  > make
-  > make u-boot.itb
+  > TEE=tee.bin CROSS_COMPILE=arm-linux-gnueabihf- make
 
-  Get tpl/u-boot-tpl.bin, spl/u-boot-spl.bin and u-boot.itb in this step.
+  Get u-boot-rockchip.bin in this step.
 
 Compile the rkdeveloptool
 =======================
   Follow instructions in latest README
-  > cd ../rkflashtool
+  > cd ../rkdeveloptool
   > autoreconf -i
   > ./configure
   > make
@@ -42,30 +40,56 @@ Compile the rkdeveloptool
 Both origin binaries and Tool are ready now, choose either option 1 or
 option 2 to deploy U-Boot.
 
-Package the image
-=================
-
-  > cd ../u-boot
-  > tools/mkimage -n rk322x -T rksd -d tpl/u-boot-spl.bin idbloader.img
-  > cat spl/u-boot-spl.bin >> idbloader.img
-
-  Get idbloader.img in this step.
-
 Flash the image to eMMC
 =======================
 Power on(or reset with RESET KEY) with MASKROM KEY preesed, and then:
   > cd ..
-  > rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
-  > rkdeveloptool wl 64 u-boot/idbloader.img
-  > rkdeveloptool wl 0x4000 u-boot/u-boot.itb
-  > rkdeveloptool rd
+  > rkdeveloptool/rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
+  > rkdeveloptool/rkdeveloptool wl 64 u-boot/u-boot-rockchip.bin
+  > rkdeveloptool/rkdeveloptool rd
 
 Flash the image to SD card
 ==========================
-  > dd if=u-boot/idbloader.img of=/dev/sdb seek=64
-  > dd if=u-boot/u-boot.itb of=/dev/sdb seek=16384
+  > dd if=u-boot/u-boot-rockchip.bin of=/dev/sdb seek=64
+
+You should be able to get U-Boot log message with OP-TEE boot info:
+
+U-Boot TPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51)
+Trying to boot from BOOTROM
+Returning to boot ROM...
+
+U-Boot SPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+Trying to boot from MMC1
+I/TC:
+I/TC: Non-secure external DT found
+I/TC: Switching console to device: /serial@11030000
+I/TC: OP-TEE version: 3.22.0-27-g893a762d1 (gcc version 10.3.1 20210621 (release) (15:10.3-2021.07-4)) #1 Sat Jul 15 12:14:36 UTC 2023 arm
+I/TC: WARNING: This OP-TEE configuration might be insecure!
+I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
+I/TC: Primary CPU initializing
+M/TC: Not protecting region 1: 0x68400000-0x68600000
+I/TC: Primary CPU switching to normal world boot
+
+
+U-Boot 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+
+Model: Rockchip RK3229 Evaluation board
+DRAM:  1 GiB (effective 992 MiB)
+Core:  113 devices, 16 uclasses, devicetree: separate
+MMC:   mmc@30000000: 1, mmc@30020000: 0
+Loading Environment from MMC... Card did not respond to voltage select! : -110
+*** Warning - No block device, using default environment
+
+In:    serial@11030000
+Out:   serial@11030000
+Err:   serial@11030000
+Model: Rockchip RK3229 Evaluation board
+Net:
+Warning: ethernet@30200000 (eth0) using random MAC address - 72:65:2b:f1:c5:0a
+eth0: ethernet@30200000
+Hit any key to stop autoboot:  0
+=>
 
-You should be able to get U-Boot log message with OP-TEE boot info.
 
 For more detail, please reference to:
 http://opensource.rock-chips.com/wiki_Boot_option
Signature · 1 line
2.41.0
Reviewed-by on v2 4/5
#16 lore raw

Re: [PATCH v2 4/5] rockchip: evb_rk3229: Update/fix README

Quoted 6 lines · Alex Bee

This updates the evb_rk3229's README on howto create / use the FIT image created by binman.
Also fix some wrong paths and update filenames which have changed in recent upstream optee-os versions.

Thanks,
- Kever

Quoted 113 lines
---
  board/rockchip/evb_rk3229/README | 72 +++++++++++++++++++++-----------
  1 file changed, 48 insertions(+), 24 deletions(-)
board/rockchip/evb_rk3229/README +48 -24
index 9068225e27..a8dcc40f09 100644
@@ -13,25 +13,23 @@ Compile the OP-TEE
 
    > cd optee_os
    > make clean
-  > make CROSS_COMPILE_ta_arm32=arm-none-eabi- PLATFORM=rockchip-rk322x
-  Get tee.bin in this step, copy it to U-Boot root dir:
-  > cp out/arm-plat-rockchip/core/tee-pager.bin ../u-boot/tee.bin
+  > make CROSS_COMPILE=arm-none-eabi- PLATFORM=rockchip-rk322x
+  Get tee-raw.bin in this step, copy it to U-Boot root dir:
+  > cp out/arm-plat-rockchip/core/tee-raw.bin ../u-boot/tee.bin
 
  Compile the U-Boot
  ==================
 
    > cd ../u-boot
-  > export CROSS_COMPILE=arm-linux-gnueabihf-
    > make evb-rk3229_defconfig
-  > make
-  > make u-boot.itb
+  > TEE=tee.bin CROSS_COMPILE=arm-linux-gnueabihf- make
 
-  Get tpl/u-boot-tpl.bin, spl/u-boot-spl.bin and u-boot.itb in this step.
+  Get u-boot-rockchip.bin in this step.
 
  Compile the rkdeveloptool
  =======================
    Follow instructions in latest README
-  > cd ../rkflashtool
+  > cd ../rkdeveloptool
    > autoreconf -i
    > ./configure
    > make
@@ -42,30 +40,56 @@ Compile the rkdeveloptool
  Both origin binaries and Tool are ready now, choose either option 1 or
  option 2 to deploy U-Boot.
 
-Package the image
-=================
-
-  > cd ../u-boot
-  > tools/mkimage -n rk322x -T rksd -d tpl/u-boot-spl.bin idbloader.img
-  > cat spl/u-boot-spl.bin >> idbloader.img
-
-  Get idbloader.img in this step.
-
  Flash the image to eMMC
  =======================
  Power on(or reset with RESET KEY) with MASKROM KEY preesed, and then:
    > cd ..
-  > rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
-  > rkdeveloptool wl 64 u-boot/idbloader.img
-  > rkdeveloptool wl 0x4000 u-boot/u-boot.itb
-  > rkdeveloptool rd
+  > rkdeveloptool/rkdeveloptool db rkbin/rk32/rk322x_loader_v1.04.232.bin
+  > rkdeveloptool/rkdeveloptool wl 64 u-boot/u-boot-rockchip.bin
+  > rkdeveloptool/rkdeveloptool rd
 
  Flash the image to SD card
  ==========================
-  > dd if=u-boot/idbloader.img of=/dev/sdb seek=64
-  > dd if=u-boot/u-boot.itb of=/dev/sdb seek=16384
+  > dd if=u-boot/u-boot-rockchip.bin of=/dev/sdb seek=64
+
+You should be able to get U-Boot log message with OP-TEE boot info:
+
+U-Boot TPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51)
+Trying to boot from BOOTROM
+Returning to boot ROM...
+
+U-Boot SPL 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+Trying to boot from MMC1
+I/TC:
+I/TC: Non-secure external DT found
+I/TC: Switching console to device: /serial@11030000
+I/TC: OP-TEE version: 3.22.0-27-g893a762d1 (gcc version 10.3.1 20210621 (release) (15:10.3-2021.07-4)) #1 Sat Jul 15 12:14:36 UTC 2023 arm
+I/TC: WARNING: This OP-TEE configuration might be insecure!
+I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
+I/TC: Primary CPU initializing
+M/TC: Not protecting region 1: 0x68400000-0x68600000
+I/TC: Primary CPU switching to normal world boot
+
+
+U-Boot 2023.07-00524-gf5346eba55-dirty (Jul 15 2023 - 14:22:51 +0200)
+
+Model: Rockchip RK3229 Evaluation board
+DRAM:  1 GiB (effective 992 MiB)
+Core:  113 devices, 16 uclasses, devicetree: separate
+MMC:   mmc@30000000: 1, mmc@30020000: 0
+Loading Environment from MMC... Card did not respond to voltage select! : -110
+*** Warning - No block device, using default environment
+
+In:    serial@11030000
+Out:   serial@11030000
+Err:   serial@11030000
+Model: Rockchip RK3229 Evaluation board
+Net:
+Warning: ethernet@30200000 (eth0) using random MAC address - 72:65:2b:f1:c5:0a
+eth0: ethernet@30200000
+Hit any key to stop autoboot:  0
+=>
 
-You should be able to get U-Boot log message with OP-TEE boot info.
 
  For more detail, please reference to:
  http://opensource.rock-chips.com/wiki_Boot_option
author
#17 lore raw

PATCH v2 5/5 optee: Support Rockchip OP-TEE binaries

In reply to Alex Bee

Currently the only ARM Rockchip SoC which is supported by upstream optee-os is RK322x. For all other ARM SoCs a vendor-provided OP-TEE binary has to be used to have a TEE available. Those are using a calling convension different from upstream optee-os.

This introduces CONFIG_ROCKCHIP_OPTEE_BINARY which signals that any of those vendor binaries is used and changes the calling convension accordingly.

---
 arch/arm/mach-rockchip/Kconfig | 8 ++++++++
 common/spl/spl_optee.S         | 4 ++++
 2 files changed, 12 insertions(+)
arch/arm/mach-rockchip/Kconfig +8 -0
index 17dd43155d..83d8a2a056 100644
@@ -449,6 +449,14 @@ config ROCKCHIP_BOOT_MODE_REG
 	  The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h)
 	  according to the value from this register.
 
+config ROCKCHIP_OPTEE_BINARY
+	bool "Use a OP-TEE binary provided by Rockchip"
+	depends on SPL_OPTEE_IMAGE
+	default y if ROCKCHIP_RK3036 || ROCKCHIP_RK3128 || ROCKCHIP_RK3288
+	help
+	  This option enables the usage of vendor-provided OP-TEE binaries.
+	  Say Y if you are using OP-TEE binary provided by Rockchip.
+
 config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
 	bool "Disable device boot on power plug-in"
 	depends on PMIC_RK8XX
common/spl/spl_optee.S +4 -0
index a269904d38..ea41d8adb6 100644
@@ -7,6 +7,10 @@
 #include <asm/assembler.h>
 
 ENTRY(spl_optee_entry)
+#ifdef CONFIG_ROCKCHIP_OPTEE_BINARY
+	ldr r1, =CONFIG_TEXT_BASE
+#else
 	ldr lr, =CONFIG_TEXT_BASE
+#endif
 	mov pc, r3
 ENDPROC(spl_optee_entry)
Signature · 1 line
2.41.0
#18 lore raw

Re: [PATCH v2 5/5] optee: Support Rockchip OP-TEE binaries

Hi Alex,

Quoted 20 lines · Alex Bee

Currently the only ARM Rockchip SoC which is supported by upstream optee-os is RK322x. For all other ARM SoCs a vendor-provided OP-TEE binary has to be used to have a TEE available. Those are using a calling convension different from upstream optee-os.

This introduces CONFIG_ROCKCHIP_OPTEE_BINARY which signals that any of those vendor binaries is used and changes the calling convension accordingly.

---
  arch/arm/mach-rockchip/Kconfig | 8 ++++++++
  common/spl/spl_optee.S         | 4 ++++
  2 files changed, 12 insertions(+)
arch/arm/mach-rockchip/Kconfig +0 -0
index 17dd43155d..83d8a2a056 100644

arch/arm/mach-rockchip/Kconfig config ROCKCHIP_BOOT_MODE_REG · line 455

Quoted 7 lines
arch/arm/mach-rockchip/Kconfig +4 -0
@@ -449,6 +449,14 @@ config ROCKCHIP_BOOT_MODE_REG
  	  The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h)
  	  according to the value from this register.
 
+config ROCKCHIP_OPTEE_BINARY
+	bool "Use a OP-TEE binary provided by Rockchip"
+	depends on SPL_OPTEE_IMAGE
+	default y if ROCKCHIP_RK3036 || ROCKCHIP_RK3128 || ROCKCHIP_RK3288

    This patch is not need for now.

    the  rk3036 works without OPTEE, and rk3288 is able to use ATF instead for OPTEE which upstreamed by Heiko.

Thanks,

- Kever

Quoted 22 lines
arch/arm/mach-rockchip/Kconfig +4 -0
+	help
+	  This option enables the usage of vendor-provided OP-TEE binaries.
+	  Say Y if you are using OP-TEE binary provided by Rockchip.
+
  config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
  	bool "Disable device boot on power plug-in"
  	depends on PMIC_RK8XX
common/spl/spl_optee.S +4 -0
index a269904d38..ea41d8adb6 100644
@@ -7,6 +7,10 @@
  #include <asm/assembler.h>
 
  ENTRY(spl_optee_entry)
+#ifdef CONFIG_ROCKCHIP_OPTEE_BINARY
+	ldr r1, =CONFIG_TEXT_BASE
+#else
  	ldr lr, =CONFIG_TEXT_BASE
+#endif
  	mov pc, r3
  ENDPROC(spl_optee_entry)
author
#19 lore raw

Re: [PATCH v2 5/5] optee: Support Rockchip OP-TEE binaries

Hi Kever,

Am 19.07.23 um 09:28 schrieb Kever Yang:

Quoted 33 lines

Hi Alex,

Quoted 21 lines · Alex Bee

Currently the only ARM Rockchip SoC which is supported by upstream optee-os is RK322x. For all other ARM SoCs a vendor-provided OP-TEE binary has to be used to have a TEE available. Those are using a calling convension different from upstream optee-os.

This introduces CONFIG_ROCKCHIP_OPTEE_BINARY which signals that any of those vendor binaries is used and changes the calling convension accordingly.

---
  arch/arm/mach-rockchip/Kconfig | 8 ++++++++
  common/spl/spl_optee.S         | 4 ++++

  2 files changed, 12 insertions(+)
arch/arm/mach-rockchip/Kconfig +0 -0
index 17dd43155d..83d8a2a056 100644
@@ -449,6 +449,14 @@ config ROCKCHIP_BOOT_MODE_REG
         The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h)
Quoted 5 lines

        according to the value from this register.
+config ROCKCHIP_OPTEE_BINARY
+    bool "Use a OP-TEE binary provided by Rockchip"
+    depends on SPL_OPTEE_IMAGE
+    default y if ROCKCHIP_RK3036 || ROCKCHIP_RK3128 || ROCKCHIP_RK3288

    This patch is not need for now.

Quoted 3 lines

    the  rk3036 works without OPTEE, and rk3288 is able to use ATF
instead for OPTEE which upstreamed by Heiko.

Thanks for your review.

I'm aware of Heiko's ATF BL32 implemenation for RK3288. But what about RK3128/RK3036? They might wwork w/o RK OPTEE-binaries in regards of SMP bringup, but still you have no TEE.

You're right: It's not strictly required to have support for RK OPTEE-binaries, but also it doesn't hurt and it's fully optional to use it for those SoCs. Besides RK's TEE-implementations provide some more services via SMCC calls (DVFS for DRAM, for instance) which are not supported (yet) by upstream variants. I don't like the requirement of this patch either, but unfortunately the TEE binaries RK provides are built with wrong/incompatible flags.

Regards,
Alex

Quoted 26 lines

Thanks,

- Kever

Quoted 21 lines

+    help
+      This option enables the usage of vendor-provided OP-TEE binaries. +      Say Y if you are using OP-TEE binary provided by Rockchip. +
  config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
      bool "Disable device boot on power plug-in"
      depends on PMIC_RK8XX

common/spl/spl_optee.S +3 -0
index a269904d38..ea41d8adb6 100644
@@ -7,6 +7,10 @@
   #include <asm/assembler.h>
   ENTRY(spl_optee_entry)
+#ifdef CONFIG_ROCKCHIP_OPTEE_BINARY
+    ldr r1, =CONFIG_TEXT_BASE
+#else

      ldr lr, =CONFIG_TEXT_BASE
+#endif
      mov pc, r3
  ENDPROC(spl_optee_entry)

#20 lore raw

Re: [PATCH v2 5/5] optee: Support Rockchip OP-TEE binaries

Quoted 36 lines · Alex Bee

Hi Kever,

Am 19.07.23 um 09:28 schrieb Kever Yang:

Quoted 33 lines

Hi Alex,

Quoted 21 lines · Alex Bee

Currently the only ARM Rockchip SoC which is supported by upstream optee-os is RK322x. For all other ARM SoCs a vendor-provided OP-TEE binary has to be used to have a TEE available. Those are using a calling convension different from upstream optee-os.

This introduces CONFIG_ROCKCHIP_OPTEE_BINARY which signals that any of those vendor binaries is used and changes the calling convension accordingly.

---
  arch/arm/mach-rockchip/Kconfig | 8 ++++++++
  common/spl/spl_optee.S         | 4 ++++

  2 files changed, 12 insertions(+)
arch/arm/mach-rockchip/Kconfig +0 -0
index 17dd43155d..83d8a2a056 100644
@@ -449,6 +449,14 @@ config ROCKCHIP_BOOT_MODE_REG
         The Soc will enter to different boot mode(defined in asm/arch-rockchip/boot_mode.h)
Quoted 5 lines

        according to the value from this register.
+config ROCKCHIP_OPTEE_BINARY
+    bool "Use a OP-TEE binary provided by Rockchip"
+    depends on SPL_OPTEE_IMAGE
+    default y if ROCKCHIP_RK3036 || ROCKCHIP_RK3128 || ROCKCHIP_RK3288

     This patch is not need for now.

Quoted 7 lines
Quoted 2 lines

     the  rk3036 works without OPTEE, and rk3288 is able to use ATF instead for OPTEE which upstreamed by Heiko.

Thanks for your review.

I'm aware of Heiko's ATF BL32 implemenation for RK3288. But what about RK3128/RK3036? They might wwork w/o RK OPTEE-binaries in regards of SMP bringup, but still you have no TEE.

You're right: It's not strictly required to have support for RK OPTEE-binaries, but also it doesn't hurt and it's fully optional to use it for those SoCs. Besides RK's TEE-implementations provide some more services via SMCC calls (DVFS for DRAM, for instance) which are not supported (yet) by upstream variants.

The mainline U-Boot is target to work with mainline kernel, so we don't need this patch for now.

Quoted 1 line

I don't like the requirement of this patch either, but unfortunately the TEE binaries RK provides are built with wrong/incompatible flags.

The better way is to push Rockchip TEE to use the same parameter with mainline OP-TEE, I will sync with rockchip OPTEE owner, and I would like this patch stay out of tree for now.

Thanks,

- Kever

Quoted 31 lines

Regards,
Alex

Quoted 27 lines

Thanks,

- Kever

Quoted 22 lines

+    help
+      This option enables the usage of vendor-provided OP-TEE binaries.
+      Say Y if you are using OP-TEE binary provided by Rockchip. +
  config ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
      bool "Disable device boot on power plug-in" depends on PMIC_RK8XX

common/spl/spl_optee.S +3 -0
index a269904d38..ea41d8adb6 100644
@@ -7,6 +7,10 @@
   #include <asm/assembler.h>
   ENTRY(spl_optee_entry)
+#ifdef CONFIG_ROCKCHIP_OPTEE_BINARY
+    ldr r1, =CONFIG_TEXT_BASE
+#else

      ldr lr, =CONFIG_TEXT_BASE
+#endif
      mov pc, r3
  ENDPROC(spl_optee_entry)