Re: RK3588 optee question

Alexander Shiyan <[email protected]>
Newsgroups org.infradead.lists.barebox
Message-ID <CAP1tNvRw3xWZCs3KUFMH7=9f7s8Op8-5hQUCFiFE8LY+mcp+VQ@mail.gmail.com>
Hello Sascha.

After enabling CONFIG_ARCH_ROCKCHIP_ATF_PASS_FDT=y the following build
errors occur:

CC [P]  arch/arm/mach-rockchip/rk3588.pbl.o
In file included from include/linux/array_size.h:6,
from include/linux/kernel.h:6,
from /home/ARM64/barebox/arch/arm/include/asm/barebox-arm.h:17,
from include/mach/rockchip/bootrom.h:9,
from arch/arm/mach-rockchip/bootrom.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/rockchip.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/rk3568.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:170:
arch/arm/mach-rockchip/rockchip.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:170:
arch/arm/mach-rockchip/bootrom.o] Error 1
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:170:
arch/arm/mach-rockchip/rk3568.o] Error 1
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/rk3588.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/bbu.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:170:
arch/arm/mach-rockchip/rk3588.o] Error 1
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:170:
arch/arm/mach-rockchip/bbu.o] Error 1
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/atf.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:167:
arch/arm/mach-rockchip/atf.pbl.o] Error 1
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/rk3568.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/param.h:7,
from include/console.h:10,
from include/stdio.h:6,
from include/common.h:10,
from arch/arm/mach-rockchip/rk3588.c:2:
include/linux/build_bug.h:100:41: error: static assertion failed:
"sizeof(structrockchip_scratch_space) <= CONFIG_SCRATCH_SIZE"
100 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
|                                         ^~~~~~~~~~~~~~
include/linux/build_bug.h:99:34: note: in expansion of macro ‘__static_assert’
99 | #define static_assert(expr, ...) __static_assert(expr,
##__VA_ARGS__, #expr)
|                                  ^~~~~~~~~~~~~~~
include/mach/rockchip/bootrom.h:25:1: note: in expansion of macro
‘static_assert’
25 | static_assert(sizeof(struct rockchip_scratch_space) <=
CONFIG_SCRATCH_SIZE);
| ^~~~~~~~~~~~~
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:167:
arch/arm/mach-rockchip/rk3568.pbl.o] Error 1
make[1]: *** [/home/ARM64/barebox/scripts/Makefile.build:167:
arch/arm/mach-rockchip/rk3588.pbl.o] Error 1
make: *** [Makefile:1142: arch/arm/mach-rockchip] Error 2
make: *** Waiting for unfinished jobs....
AR      drivers/of/built-in.a
AR      drivers/built-in.a

So, to avoid this, can we define default for CONFIG_SCRATCH_SIZE as
CONFIG_ARCH_ROCKCHIP_ATF_FDT_SIZE if this option is used?

Finally, at least for RK3568 (cannot test RK3588 right now), the init
errors are gone:
...
arm-scmi firmware:scmi.of: SCMI Protocol v2.0 'rockchip:' Firmware version 0x0
optee: smc_abi: probing for conduit method.
optee: smc_abi: revision 4.10 (5c827bf3bc358e9a)
psci psci.of: detected version 1.1
...

The rksecure now works like this:
barebox@Diasom DS-RK3568-SOM-EVB:/ rksecure -i
NOTICE: optee: optee: No supplicant or RPC handler for command 0x0
ERROR: rk-secure: TA 5cfa57f6-1a4c-407f-94a7-a56c8c47019d: error 0xffff0009
Failed to read secure boot info
rksecure: Invalid argument

ср, 12 авг. 2026 г. в 09:25, Sascha Hauer <[email protected]>:
>
> On 2026-08-11 14:51, Alexander Shiyan wrote:
> > Hello All.
> >
> > BL31 = rockchip bl31 from rkbin
> > BL32 = tee.bin builded from https://github.com/OP-TEE/optee_os.git
> >
> > DDR cb12b99cc23 hcy 25/10/17-18:57:13,fwver: v1.21
> > ...
> > NOTICE:  BL31: v2.3():v2.3-964-g8319968f5:derrick.huang, fwver: v1.54
> > NOTICE:  BL31: Built : 17:20:23, Dec 26 2025
> > ...
> > INFO:    BL31: Initialising Exception Handling Framework
> > INFO:    BL31: Initializing runtime services
> > INFO:    BL31: Initializing BL32
> > INFO:    BL31: Preparing for EL3 exit to normal world
> > INFO:    Entry point address = 0xb00000
> > INFO:    SPSR = 0x3c9
> >
> > barebox 2026.07.0-00839-g50ae8812b950-dirty #144 Tue Aug 11 14:39:36 MSK 2026
> >
> > Board: Diasom DS-RK3588-BTB-EVB
> > rockchip-dmc memory-controller.of: Detected memory size: 0x100000000
> > netconsole: registered as netconsole-1
> > fan53555-regulator rk86020: FAN53555 Option[10] Rev[1] Detected!
> > vdd2_ddr: Bringing 500000uV into 1100000-1100000uV
> > vddq_ddr: Bringing 500000uV into 600000-600000uV
> > rockchip_saradc [email protected]: registered as aiodev0
> > BTB revision: 3
> > EVB revision: 2
> > EVB HAT Addon detected.
> > arm-scmi firmware:scmi.of: SCMI Protocol v2.0 'rockchip:' Firmware version 0x0
> > optee: smc_abi: probing for conduit method.
> > optee: smc_abi: revision 4.10 (71196403f6f9f642)
> > ERROR: optee: smc_abi: driver requires OP-TEE dynamic shared memory support
>
> In OP-TEE this goes down to:
>
> #if defined(CFG_CORE_DYN_SHM)
>           dyn_shm_en = core_mmu_nsec_ddr_is_defined();
>           if (dyn_shm_en)
>                   args->a1 |= OPTEE_SMC_SEC_CAP_DYNAMIC_SHM;
> #endif
>
> So either you have compiled OP-TEE without CFG_CORE_DYN_SHM enabled
> (unlikely, it's the default), or core_mmu_nsec_ddr_is_defined() fails
> which means OP-TEE doesn't know where your memory is. OP-TEE gets this
> information from the device tree. Do you pass a device tree to OP-TEE?
> barebox only does it when CONFIG_ARCH_ROCKCHIP_ATF_PASS_FDT is enabled
> which currently is not the default as there are some Rockchip TF-A
> binaries shipped by Rockchip which do not handle a fdt being passed.
>
> Looking at your TF-A version you might have one of these, so you likely
> have to update your TF-A to an upstream one.
>
> Side note: Look at bl31_entry(). if it gets a fdt_addr that will be
> passed to both TF-A and OP-TEE. You *could* try passing NULL as fdt to
> atf_entry() to pass the fdt only to OP-TEE and not to TF-A, but I
> wouldn't encourage that.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.