Hi,
On 2/6/26 11:02 AM, Marco Felsch wrote:
>> On 2/4/26 9:01 PM, Marco Felsch wrote:
>>> Add support to store a FDT within the scratch area. The user needs to
>>> query the location and size via imx_scratch_get_fdt() which can be used
>>> afterwards to write the actual FDT into it.
>>>
>>> Signed-off-by: Marco Felsch <[email protected]>
>>> +config SCRATCH_FDT_SIZE
>>> + hex
>>> + default 0x0
>>> + prompt "Scratch FDT size"
>>> + help
>>> + The size of the scratch area used as destination to load and optional
>>> + decompress the barebox builtin DTB into it. Can be 0x0 if early FDT
>>> + support is not requied.
>>> +
>>> + If specified, SCRATCH_FDT_SIZE <= SCRATCH_SIZE must be ensured.
>>> +
>>> + This option should match the OP-TEE's CFG_DTB_MAX_SIZE configuration
>>> + if used by OP-TEE.
>>
>> AFAIU, this is a workaround because OP-TEE doesn't accept outside
>> information about how big the DTB buffer is, just its base address.
>
> This is correct for the bl_params case. In case of transfer-lists the
> size could be detected by OP-TEE OS.
>
>> In that case, this should go to security/Kconfig and be named something
>> like PBL_OPTEE_DTB_MAX_SIZE. There's no need to ask every user that
>> configures barebox about this.
>
> This would bind the FDT support to OP-TEE but the FDT could be used by
> other boot binaries as well.In the speak of ARM, it could be used by
> the TF-A. In the speak of RISC-V, it could be used by opensbi. Therefore
> I made it generic.
>
> I wanted to avoid multiple Kconfig options to configure the scatch space
> for:
> - OP-TEE FDT
> - OpenSBI FDT
> - TF-A FDT
>
> I'm currently unsure if dropping the OP-TEE note from the help message
> helps. But I have no hard feelings about PBL_OPTEE_DTB_MAX_SIZE either.
How about:
struct imx_scratch_space {
union {
u8 __b[CONFIG_SCRATCH_SIZE];
struct {
u32 bootrom_log[128];
u32 reserved[128];
struct optee_header optee_hdr;
u8 fdt[] __aligned(8);
};
};
};
static_assert(sizeof(struct imx_scratch_space)
- offsetof(struct imx_scratch_space, fdt)
<= PBL_OPTEE_DTB_MAX_SIZE);
The benefits I see:
- Just one argument to tune (CONFIG_SCRATCH_SIZE) like we already use
for Rockchip
- We still have a dedicated option that can be kept in-sync with the
exact option value in OP-TEE to find problems at compile-time
- Only those who actually use OP-TEE will be asked about
PBL_OPTEE_DTB_MAX_SIZE
Would this work for you?
Cheers,
Ahmad
>
> Regards,
> Marco
>
>
>>
>>
>> Cheers,
>> Ahmad
>>
>> --
>> 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 |
>>
>>
>
--
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 |