mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* IMX8M and Optee support
@ 2023-10-18  8:11 Hans Christian Lønstad
  2023-10-18  9:06 ` Ahmad Fatoum
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-18  8:11 UTC (permalink / raw)
  To: Barebox List

Just reaching out to ask whether anyone has successfully integrated Optee on the IMX8M(P) platform.
Our trials results in a crash when the ATF (NXP 2.8) does the handover to Optee (exit EL3).

In ATF it appears that BL32 is expected to load at 0x56000000 on IMX8MP while Barebox actually loads
The Optee bin blob just below top of memory.
(Patching Barebox to the expected ATF BL32_BASE does not resolve the issue)

Any help would be appreciated

Hans Christian Lønstad



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18  8:11 IMX8M and Optee support Hans Christian Lønstad
@ 2023-10-18  9:06 ` Ahmad Fatoum
  2023-10-18 11:29   ` Hans Christian Lønstad
  0 siblings, 1 reply; 10+ messages in thread
From: Ahmad Fatoum @ 2023-10-18  9:06 UTC (permalink / raw)
  To: Hans Christian Lønstad, Barebox List

Hello Hans,

On 18.10.23 10:11, Hans Christian Lønstad wrote:
> Just reaching out to ask whether anyone has successfully integrated Optee on the IMX8M(P) platform.
> Our trials results in a crash when the ATF (NXP 2.8) does the handover to Optee (exit EL3).
> 
> In ATF it appears that BL32 is expected to load at 0x56000000 on IMX8MP while Barebox actually loads
> The Optee bin blob just below top of memory.
> (Patching Barebox to the expected ATF BL32_BASE does not resolve the issue)
> 
> Any help would be appreciated

I am using OP-TEE in an i.MX8MN project successfully. The hardcoding of addresses
is indeed unfortunate and it needs manual adjustment depending on the size
of available RAM.

The common configuration is to reserve secure memory at the end of DRAM as not
to split the RAM in half. You should thus change the BL32 address used in TF-A
in alignment with barebox CONFIG_OPTEE_SIZE, which is always relative to the end
of RAM.

Let me know how it goes.

Cheers,
Ahmad

> 
> Hans Christian Lønstad
> 
> 

-- 
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 |




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18  9:06 ` Ahmad Fatoum
@ 2023-10-18 11:29   ` Hans Christian Lønstad
  2023-10-18 12:31     ` Hans Christian Lønstad
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-18 11:29 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.

ATF compiled with:
make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j

Optee compiled with:

CFG_DDR_SIZE ?= UL(0x80000000)
CFG_UART_BASE ?= UART2_BASE
CFG_TZDRAM_START ?= 0xBE000000
undefine CFG_NS_ENTRY_ADDR

Barebox compiled with:
CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y 

This produces the following on boot:
—————————————————><--------------

Uart initialized
Run level 3
Init power
Init DDR
Handover to ATF
imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
                                                                   NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
INFO:    GICv3 with legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    Maximum SPI INTID supported: 191
INFO:    BL31: Initializing runtime services
INFO:    bl31_plat_get_next_image_ep_info: want image 0
INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
INFO:    BL31: Initializing BL32
INFO:    bl31_plat_get_next_image_ep_info: want image 0
INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>

————————><————

I´m not sure why it asks for the same image twice and if this implies anything …

Hans

> 18. okt. 2023 kl. 11:06 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
> 
> Hello Hans,
> 
> On 18.10.23 10:11, Hans Christian Lønstad wrote:
>> Just reaching out to ask whether anyone has successfully integrated Optee on the IMX8M(P) platform.
>> Our trials results in a crash when the ATF (NXP 2.8) does the handover to Optee (exit EL3).
>> 
>> In ATF it appears that BL32 is expected to load at 0x56000000 on IMX8MP while Barebox actually loads
>> The Optee bin blob just below top of memory.
>> (Patching Barebox to the expected ATF BL32_BASE does not resolve the issue)
>> 
>> Any help would be appreciated
> 
> I am using OP-TEE in an i.MX8MN project successfully. The hardcoding of addresses
> is indeed unfortunate and it needs manual adjustment depending on the size
> of available RAM.
> 
> The common configuration is to reserve secure memory at the end of DRAM as not
> to split the RAM in half. You should thus change the BL32 address used in TF-A
> in alignment with barebox CONFIG_OPTEE_SIZE, which is always relative to the end
> of RAM.
> 
> Let me know how it goes.
> 
> Cheers,
> Ahmad
> 
>> 
>> Hans Christian Lønstad
>> 
>> 
> 
> -- 
> 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 |
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 11:29   ` Hans Christian Lønstad
@ 2023-10-18 12:31     ` Hans Christian Lønstad
  2023-10-18 13:04       ` Ahmad Fatoum
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-18 12:31 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?

The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?


Hans





> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
> 
> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
> 
> ATF compiled with:
> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
> 
> Optee compiled with:
> 
> CFG_DDR_SIZE ?= UL(0x80000000)
> CFG_UART_BASE ?= UART2_BASE
> CFG_TZDRAM_START ?= 0xBE000000
> undefine CFG_NS_ENTRY_ADDR
> 
> Barebox compiled with:
> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y 
> 
> This produces the following on boot:
> —————————————————><--------------
> 
> Uart initialized
> Run level 3
> Init power
> Init DDR
> Handover to ATF
> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>                                                                   NOTICE:  Do not release JR0 to NS as it can be used by HAB
> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
> INFO:    GICv3 with legacy support detected.
> INFO:    ARM GICv3 driver initialized in EL3
> INFO:    Maximum SPI INTID supported: 191
> INFO:    BL31: Initializing runtime services
> INFO:    bl31_plat_get_next_image_ep_info: want image 0
> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
> INFO:    BL31: Initializing BL32
> INFO:    bl31_plat_get_next_image_ep_info: want image 0
> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
> 
> ————————><————
> 
> I´m not sure why it asks for the same image twice and if this implies anything …
> 
> Hans
> 
>> 18. okt. 2023 kl. 11:06 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>> 
>> Hello Hans,
>> 
>> On 18.10.23 10:11, Hans Christian Lønstad wrote:
>>> Just reaching out to ask whether anyone has successfully integrated Optee on the IMX8M(P) platform.
>>> Our trials results in a crash when the ATF (NXP 2.8) does the handover to Optee (exit EL3).
>>> 
>>> In ATF it appears that BL32 is expected to load at 0x56000000 on IMX8MP while Barebox actually loads
>>> The Optee bin blob just below top of memory.
>>> (Patching Barebox to the expected ATF BL32_BASE does not resolve the issue)
>>> 
>>> Any help would be appreciated
>> 
>> I am using OP-TEE in an i.MX8MN project successfully. The hardcoding of addresses
>> is indeed unfortunate and it needs manual adjustment depending on the size
>> of available RAM.
>> 
>> The common configuration is to reserve secure memory at the end of DRAM as not
>> to split the RAM in half. You should thus change the BL32 address used in TF-A
>> in alignment with barebox CONFIG_OPTEE_SIZE, which is always relative to the end
>> of RAM.
>> 
>> Let me know how it goes.
>> 
>> Cheers,
>> Ahmad
>> 
>>> 
>>> Hans Christian Lønstad
>>> 
>>> 
>> 
>> -- 
>> 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 |
>> 
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 12:31     ` Hans Christian Lønstad
@ 2023-10-18 13:04       ` Ahmad Fatoum
  2023-10-18 14:06         ` Hans Christian Lønstad
  0 siblings, 1 reply; 10+ messages in thread
From: Ahmad Fatoum @ 2023-10-18 13:04 UTC (permalink / raw)
  To: Hans Christian Lønstad; +Cc: Barebox List

Hello,

On 18.10.23 14:31, Hans Christian Lønstad wrote:
> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
> 
> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?

I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
haven't come around to update them. I know that barebox works fine with newer TF-A
versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
a device tree, this may indeed be the culprit.

>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>
>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>
>> ATF compiled with:
>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>
>> Optee compiled with:
>>
>> CFG_DDR_SIZE ?= UL(0x80000000)
>> CFG_UART_BASE ?= UART2_BASE
>> CFG_TZDRAM_START ?= 0xBE000000
>> undefine CFG_NS_ENTRY_ADDR
>>
>> Barebox compiled with:
>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y 

barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().

>>
>> This produces the following on boot:
>> —————————————————><--------------
>>
>> Uart initialized
>> Run level 3
>> Init power
>> Init DDR
>> Handover to ATF
>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>                                                                   NOTICE:  Do not release JR0 to NS as it can be used by HAB
>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>> INFO:    GICv3 with legacy support detected.
>> INFO:    ARM GICv3 driver initialized in EL3
>> INFO:    Maximum SPI INTID supported: 191
>> INFO:    BL31: Initializing runtime services
>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>> INFO:    BL31: Initializing BL32
>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>

Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.

>> I´m not sure why it asks for the same image twice and if this implies anything …

No idea..

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 |




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 13:04       ` Ahmad Fatoum
@ 2023-10-18 14:06         ` Hans Christian Lønstad
  2023-10-18 14:36           ` Ahmad Fatoum
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-18 14:06 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

The ATF for imx8 is quite convoluted requiring fixed memory locations for images and device trees. The ATF itself supports transferring parameters
Using 4 unsigned long arguments. These are unfortunately zeroed out by a misconfiguration for IMX8:

RESET_TO_BL31 := 1
and not at the same time setting
RESET_TO_BL31_WITH_PARAMS := 1

As demoed below this can be made to work.
———><——

Uart initialized
Run level 3
Init power
Init DDR
Handover to ATF
imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
                                                                   CAAM early init successful
imx8m_atf_start_bl31: Callout BL31 with 1, 2, 3, 4
NOTICE:  Do not release JR0 to NS as it can be used by HAB
INFO:    bl31_early_platform_setup2: args are 0x00000001, 0x00000002, 0x00000003, 0x00000004
NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
NOTICE:  BL31: Built : 15:49:38, Oct 18 2023

——><——

The "best" approach is likely to patch ATFs imx8mX_bl31_setup.c replacing preprocessor values with values
handed over from Barebox. Adding these parameters will be compatible with unpatched ATFs anyway.

Hans


> 18. okt. 2023 kl. 15:04 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
> 
> Hello,
> 
> On 18.10.23 14:31, Hans Christian Lønstad wrote:
>> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
>> 
>> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?
> 
> I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
> haven't come around to update them. I know that barebox works fine with newer TF-A
> versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
> but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
> a device tree, this may indeed be the culprit.
> 
>>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>> 
>>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>> 
>>> ATF compiled with:
>>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>> 
>>> Optee compiled with:
>>> 
>>> CFG_DDR_SIZE ?= UL(0x80000000)
>>> CFG_UART_BASE ?= UART2_BASE
>>> CFG_TZDRAM_START ?= 0xBE000000
>>> undefine CFG_NS_ENTRY_ADDR
>>> 
>>> Barebox compiled with:
>>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y
> 
> barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().
> 
>>> 
>>> This produces the following on boot:
>>> —————————————————><--------------
>>> 
>>> Uart initialized
>>> Run level 3
>>> Init power
>>> Init DDR
>>> Handover to ATF
>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>                                                                  NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>>> INFO:    GICv3 with legacy support detected.
>>> INFO:    ARM GICv3 driver initialized in EL3
>>> INFO:    Maximum SPI INTID supported: 191
>>> INFO:    BL31: Initializing runtime services
>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>>> INFO:    BL31: Initializing BL32
>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
> 
> Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.
> 
>>> I´m not sure why it asks for the same image twice and if this implies anything …
> 
> No idea..
> 
> 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 |
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 14:06         ` Hans Christian Lønstad
@ 2023-10-18 14:36           ` Ahmad Fatoum
  2023-10-19  6:23             ` Hans Christian Lønstad
  2023-10-19  6:25             ` Hans Christian Lønstad
  0 siblings, 2 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2023-10-18 14:36 UTC (permalink / raw)
  To: Hans Christian Lønstad; +Cc: Barebox List

Hello Hans,

On 18.10.23 16:06, Hans Christian Lønstad wrote:
> The ATF for imx8 is quite convoluted requiring fixed memory locations for images and device trees. The ATF itself supports transferring parameters
> Using 4 unsigned long arguments. These are unfortunately zeroed out by a misconfiguration for IMX8:
> 
> RESET_TO_BL31 := 1
> and not at the same time setting
> RESET_TO_BL31_WITH_PARAMS := 1
> 
> As demoed below this can be made to work.
> ———><——
> 
> Uart initialized
> Run level 3
> Init power
> Init DDR
> Handover to ATF
> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>                                                                    CAAM early init successful
> imx8m_atf_start_bl31: Callout BL31 with 1, 2, 3, 4
> NOTICE:  Do not release JR0 to NS as it can be used by HAB
> INFO:    bl31_early_platform_setup2: args are 0x00000001, 0x00000002, 0x00000003, 0x00000004
> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
> NOTICE:  BL31: Built : 15:49:38, Oct 18 2023
> 
> ——><——
> 
> The "best" approach is likely to patch ATFs imx8mX_bl31_setup.c replacing preprocessor values with values
> handed over from Barebox. Adding these parameters will be compatible with unpatched ATFs anyway.

There's void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
		        uintptr_t bl33_entry, uintptr_t fdt_addr)

which is used for RK3568/RK3588 platforms. AFAIU, future SoCs will likely
use a linked list of hand over blocks to transfer this same information.

Any of these two approaches would be better than what we have now on i.MX.

I am still not sure how this relates to OP-TEE hanging. Can you configure
your OP-TEE to not expect a FDT?

Cheers,
Ahmad

> 
> Hans
> 
> 
>> 18. okt. 2023 kl. 15:04 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>>
>> Hello,
>>
>> On 18.10.23 14:31, Hans Christian Lønstad wrote:
>>> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
>>>
>>> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?
>>
>> I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
>> haven't come around to update them. I know that barebox works fine with newer TF-A
>> versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
>> but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
>> a device tree, this may indeed be the culprit.
>>
>>>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>>>
>>>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>>>
>>>> ATF compiled with:
>>>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>>>
>>>> Optee compiled with:
>>>>
>>>> CFG_DDR_SIZE ?= UL(0x80000000)
>>>> CFG_UART_BASE ?= UART2_BASE
>>>> CFG_TZDRAM_START ?= 0xBE000000
>>>> undefine CFG_NS_ENTRY_ADDR
>>>>
>>>> Barebox compiled with:
>>>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y
>>
>> barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().
>>
>>>>
>>>> This produces the following on boot:
>>>> —————————————————><--------------
>>>>
>>>> Uart initialized
>>>> Run level 3
>>>> Init power
>>>> Init DDR
>>>> Handover to ATF
>>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>                                                                  NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>>>> INFO:    GICv3 with legacy support detected.
>>>> INFO:    ARM GICv3 driver initialized in EL3
>>>> INFO:    Maximum SPI INTID supported: 191
>>>> INFO:    BL31: Initializing runtime services
>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>>>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>>>> INFO:    BL31: Initializing BL32
>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>>>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
>>
>> Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.
>>
>>>> I´m not sure why it asks for the same image twice and if this implies anything …
>>
>> No idea..
>>
>> 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 |




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 14:36           ` Ahmad Fatoum
@ 2023-10-19  6:23             ` Hans Christian Lønstad
  2023-10-19  6:25             ` Hans Christian Lønstad
  1 sibling, 0 replies; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-19  6:23 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

Note that Optee is not build using position independence, so one will need to set CFG_TZDRAM_START to
the Barebox (endmem-OPTEE_SIZE) location.

This inconvenience makes the use of passed parameters less relevant given a compile time
resolution is required.

Hans

> 18. okt. 2023 kl. 16:36 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
> 
> Hello Hans,
> 
> On 18.10.23 16:06, Hans Christian Lønstad wrote:
>> The ATF for imx8 is quite convoluted requiring fixed memory locations for images and device trees. The ATF itself supports transferring parameters
>> Using 4 unsigned long arguments. These are unfortunately zeroed out by a misconfiguration for IMX8:
>> 
>> RESET_TO_BL31 := 1
>> and not at the same time setting
>> RESET_TO_BL31_WITH_PARAMS := 1
>> 
>> As demoed below this can be made to work.
>> ———><——
>> 
>> Uart initialized
>> Run level 3
>> Init power
>> Init DDR
>> Handover to ATF
>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>                                                                   CAAM early init successful
>> imx8m_atf_start_bl31: Callout BL31 with 1, 2, 3, 4
>> NOTICE:  Do not release JR0 to NS as it can be used by HAB
>> INFO:    bl31_early_platform_setup2: args are 0x00000001, 0x00000002, 0x00000003, 0x00000004
>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>> NOTICE:  BL31: Built : 15:49:38, Oct 18 2023
>> 
>> ——><——
>> 
>> The "best" approach is likely to patch ATFs imx8mX_bl31_setup.c replacing preprocessor values with values
>> handed over from Barebox. Adding these parameters will be compatible with unpatched ATFs anyway.
> 
> There's void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
>         uintptr_t bl33_entry, uintptr_t fdt_addr)
> 
> which is used for RK3568/RK3588 platforms. AFAIU, future SoCs will likely
> use a linked list of hand over blocks to transfer this same information.
> 
> Any of these two approaches would be better than what we have now on i.MX.
> 
> I am still not sure how this relates to OP-TEE hanging. Can you configure
> your OP-TEE to not expect a FDT?
> 
> Cheers,
> Ahmad
> 
>> 
>> Hans
>> 
>> 
>>> 18. okt. 2023 kl. 15:04 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>>> 
>>> Hello,
>>> 
>>> On 18.10.23 14:31, Hans Christian Lønstad wrote:
>>>> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
>>>> 
>>>> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?
>>> 
>>> I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
>>> haven't come around to update them. I know that barebox works fine with newer TF-A
>>> versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
>>> but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
>>> a device tree, this may indeed be the culprit.
>>> 
>>>>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>>>> 
>>>>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>>>> 
>>>>> ATF compiled with:
>>>>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>>>> 
>>>>> Optee compiled with:
>>>>> 
>>>>> CFG_DDR_SIZE ?= UL(0x80000000)
>>>>> CFG_UART_BASE ?= UART2_BASE
>>>>> CFG_TZDRAM_START ?= 0xBE000000
>>>>> undefine CFG_NS_ENTRY_ADDR
>>>>> 
>>>>> Barebox compiled with:
>>>>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y
>>> 
>>> barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().
>>> 
>>>>> 
>>>>> This produces the following on boot:
>>>>> —————————————————><--------------
>>>>> 
>>>>> Uart initialized
>>>>> Run level 3
>>>>> Init power
>>>>> Init DDR
>>>>> Handover to ATF
>>>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>>                                                                 NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>>>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>>>>> INFO:    GICv3 with legacy support detected.
>>>>> INFO:    ARM GICv3 driver initialized in EL3
>>>>> INFO:    Maximum SPI INTID supported: 191
>>>>> INFO:    BL31: Initializing runtime services
>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>>>>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>>>>> INFO:    BL31: Initializing BL32
>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>>>>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
>>> 
>>> Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.
>>> 
>>>>> I´m not sure why it asks for the same image twice and if this implies anything …
>>> 
>>> No idea..
>>> 
>>> 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 |



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-18 14:36           ` Ahmad Fatoum
  2023-10-19  6:23             ` Hans Christian Lønstad
@ 2023-10-19  6:25             ` Hans Christian Lønstad
  2024-01-22 15:48               ` Ahmad Fatoum
  1 sibling, 1 reply; 10+ messages in thread
From: Hans Christian Lønstad @ 2023-10-19  6:25 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

Optee using ATF 2.8 works when a header is stripped of the tee.bin file (use tee-raw.bin)

Hans

> 18. okt. 2023 kl. 16:36 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
> 
> Hello Hans,
> 
> On 18.10.23 16:06, Hans Christian Lønstad wrote:
>> The ATF for imx8 is quite convoluted requiring fixed memory locations for images and device trees. The ATF itself supports transferring parameters
>> Using 4 unsigned long arguments. These are unfortunately zeroed out by a misconfiguration for IMX8:
>> 
>> RESET_TO_BL31 := 1
>> and not at the same time setting
>> RESET_TO_BL31_WITH_PARAMS := 1
>> 
>> As demoed below this can be made to work.
>> ———><——
>> 
>> Uart initialized
>> Run level 3
>> Init power
>> Init DDR
>> Handover to ATF
>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>                                                                   CAAM early init successful
>> imx8m_atf_start_bl31: Callout BL31 with 1, 2, 3, 4
>> NOTICE:  Do not release JR0 to NS as it can be used by HAB
>> INFO:    bl31_early_platform_setup2: args are 0x00000001, 0x00000002, 0x00000003, 0x00000004
>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>> NOTICE:  BL31: Built : 15:49:38, Oct 18 2023
>> 
>> ——><——
>> 
>> The "best" approach is likely to patch ATFs imx8mX_bl31_setup.c replacing preprocessor values with values
>> handed over from Barebox. Adding these parameters will be compatible with unpatched ATFs anyway.
> 
> There's void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
>         uintptr_t bl33_entry, uintptr_t fdt_addr)
> 
> which is used for RK3568/RK3588 platforms. AFAIU, future SoCs will likely
> use a linked list of hand over blocks to transfer this same information.
> 
> Any of these two approaches would be better than what we have now on i.MX.
> 
> I am still not sure how this relates to OP-TEE hanging. Can you configure
> your OP-TEE to not expect a FDT?
> 
> Cheers,
> Ahmad
> 
>> 
>> Hans
>> 
>> 
>>> 18. okt. 2023 kl. 15:04 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>>> 
>>> Hello,
>>> 
>>> On 18.10.23 14:31, Hans Christian Lønstad wrote:
>>>> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
>>>> 
>>>> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?
>>> 
>>> I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
>>> haven't come around to update them. I know that barebox works fine with newer TF-A
>>> versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
>>> but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
>>> a device tree, this may indeed be the culprit.
>>> 
>>>>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>>>> 
>>>>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>>>> 
>>>>> ATF compiled with:
>>>>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>>>> 
>>>>> Optee compiled with:
>>>>> 
>>>>> CFG_DDR_SIZE ?= UL(0x80000000)
>>>>> CFG_UART_BASE ?= UART2_BASE
>>>>> CFG_TZDRAM_START ?= 0xBE000000
>>>>> undefine CFG_NS_ENTRY_ADDR
>>>>> 
>>>>> Barebox compiled with:
>>>>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y
>>> 
>>> barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().
>>> 
>>>>> 
>>>>> This produces the following on boot:
>>>>> —————————————————><--------------
>>>>> 
>>>>> Uart initialized
>>>>> Run level 3
>>>>> Init power
>>>>> Init DDR
>>>>> Handover to ATF
>>>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>>                                                                 NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>>>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>>>>> INFO:    GICv3 with legacy support detected.
>>>>> INFO:    ARM GICv3 driver initialized in EL3
>>>>> INFO:    Maximum SPI INTID supported: 191
>>>>> INFO:    BL31: Initializing runtime services
>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>>>>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>>>>> INFO:    BL31: Initializing BL32
>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>>>>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
>>> 
>>> Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.
>>> 
>>>>> I´m not sure why it asks for the same image twice and if this implies anything …
>>> 
>>> No idea..
>>> 
>>> 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 |



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: IMX8M and Optee support
  2023-10-19  6:25             ` Hans Christian Lønstad
@ 2024-01-22 15:48               ` Ahmad Fatoum
  0 siblings, 0 replies; 10+ messages in thread
From: Ahmad Fatoum @ 2024-01-22 15:48 UTC (permalink / raw)
  To: Hans Christian Lønstad; +Cc: Barebox List

On 19.10.23 08:25, Hans Christian Lønstad wrote:
> Optee using ATF 2.8 works when a header is stripped of the tee.bin file (use tee-raw.bin)

FTR: With Marco's recent OP-TEE changes that are sitting in next, barebox accepts
OP-TEE with a header too and will use it to dynamically determine the OP-TEE base
instead of hardcoding it to be at the end of RAM.

> 
> Hans
> 
>> 18. okt. 2023 kl. 16:36 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>>
>> Hello Hans,
>>
>> On 18.10.23 16:06, Hans Christian Lønstad wrote:
>>> The ATF for imx8 is quite convoluted requiring fixed memory locations for images and device trees. The ATF itself supports transferring parameters
>>> Using 4 unsigned long arguments. These are unfortunately zeroed out by a misconfiguration for IMX8:
>>>
>>> RESET_TO_BL31 := 1
>>> and not at the same time setting
>>> RESET_TO_BL31_WITH_PARAMS := 1
>>>
>>> As demoed below this can be made to work.
>>> ———><——
>>>
>>> Uart initialized
>>> Run level 3
>>> Init power
>>> Init DDR
>>> Handover to ATF
>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>                                                                   CAAM early init successful
>>> imx8m_atf_start_bl31: Callout BL31 with 1, 2, 3, 4
>>> NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>> INFO:    bl31_early_platform_setup2: args are 0x00000001, 0x00000002, 0x00000003, 0x00000004
>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>> NOTICE:  BL31: Built : 15:49:38, Oct 18 2023
>>>
>>> ——><——
>>>
>>> The "best" approach is likely to patch ATFs imx8mX_bl31_setup.c replacing preprocessor values with values
>>> handed over from Barebox. Adding these parameters will be compatible with unpatched ATFs anyway.
>>
>> There's void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
>>         uintptr_t bl33_entry, uintptr_t fdt_addr)
>>
>> which is used for RK3568/RK3588 platforms. AFAIU, future SoCs will likely
>> use a linked list of hand over blocks to transfer this same information.
>>
>> Any of these two approaches would be better than what we have now on i.MX.
>>
>> I am still not sure how this relates to OP-TEE hanging. Can you configure
>> your OP-TEE to not expect a FDT?
>>
>> Cheers,
>> Ahmad
>>
>>>
>>> Hans
>>>
>>>
>>>> 18. okt. 2023 kl. 15:04 skrev Ahmad Fatoum <a.fatoum@pengutronix.de>:
>>>>
>>>> Hello,
>>>>
>>>> On 18.10.23 14:31, Hans Christian Lønstad wrote:
>>>>> I may have gotten this wrong, but should not the device tree be passed over to ATF which again pass it over to Optee?
>>>>>
>>>>> The bl31() wrapper in imx8m_atf_start_bl31 should do this using register call parameters?
>>>>
>>>> I am using a quite antiquated imx-atf v2.4 and optee-os-3.2.0.imx in my setup and
>>>> haven't come around to update them. I know that barebox works fine with newer TF-A
>>>> versions (especially after https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/16370),
>>>> but I haven't tested a newer OP-TEE, so if your OP-TEE configuration/version expects
>>>> a device tree, this may indeed be the culprit.
>>>>
>>>>>> 18. okt. 2023 kl. 13:29 skrev Hans Christian Lønstad <hcl@datarespons.no>:
>>>>>>
>>>>>> We have a 2GB IMX8MP system using 32MB OPTEEE_SIZE, so expect to find Optee blob at 0xBE000000.
>>>>>>
>>>>>> ATF compiled with:
>>>>>> make PLAT=imx8mp BL32_BASE=0xBE000000 IMX_BOOT_UART_BASE=0x30890000 SPD=opteed DEBUG=1 -j
>>>>>>
>>>>>> Optee compiled with:
>>>>>>
>>>>>> CFG_DDR_SIZE ?= UL(0x80000000)
>>>>>> CFG_UART_BASE ?= UART2_BASE
>>>>>> CFG_TZDRAM_START ?= 0xBE000000
>>>>>> undefine CFG_NS_ENTRY_ADDR
>>>>>>
>>>>>> Barebox compiled with:
>>>>>> CONFIG_HAVE_OPTEE=y CONFIG_OPTEE_SIZE=0x02000000 # CONFIG_BOOTM_OPTEE is not set CONFIG_PBL_OPTEE=y CONFIG_FIRMWARE_IMX8MP_OPTEE=y
>>>>
>>>> barebox configuration looks ok assuming board code calls imx8mp_load_and_start_image_via_tfa().
>>>>
>>>>>>
>>>>>> This produces the following on boot:
>>>>>> —————————————————><--------------
>>>>>>
>>>>>> Uart initialized
>>>>>> Run level 3
>>>>>> Init power
>>>>>> Init DDR
>>>>>> Handover to ATF
>>>>>> imx8mp_load_and_start_image_via_tfa: Expect OPTEE at 0xbe000000
>>>>>> CH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>>> IH e2a7175151fe3e842116990e62c864334e1bb030ca146b749d8e6b0c02481357
>>>>>>                                                                 NOTICE:  Do not release JR0 to NS as it can be used by HAB
>>>>>> NOTICE:  BL31: v2.8(debug):lf-6.1.36-2.1.0-0-g1a3beeab6-dirty
>>>>>> NOTICE:  BL31: Built : 13:14:09, Oct 18 2023
>>>>>> INFO:    GICv3 with legacy support detected.
>>>>>> INFO:    ARM GICv3 driver initialized in EL3
>>>>>> INFO:    Maximum SPI INTID supported: 191
>>>>>> INFO:    BL31: Initializing runtime services
>>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>>> INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
>>>>>> WARNING: BL31: cortex_a53: CPU workaround for 1530924 was missing!
>>>>>> INFO:    BL31: Initializing BL32
>>>>>> INFO:    bl31_plat_get_next_image_ep_info: want image 0
>>>>>> INFO:    bl31_plat_get_next_image_ep_info: bl32 PC is 0xbe000000
>>>>>> INFO:    opteed_init: 176 - calling <opteed_synchronous_sp_entry>
>>>>>> INFO:    opteed_synchronous_sp_entry: 79 - calling <opteed_enter_sp>
>>>>
>>>> Try compiling op-tee with CFG_TEE_CORE_LOG_LEVEL=4 and see how far it gets.
>>>>
>>>>>> I´m not sure why it asks for the same image twice and if this implies anything …
>>>>
>>>> No idea..
>>>>
>>>> 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 |
> 
> 

-- 
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 |




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-01-22 15:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18  8:11 IMX8M and Optee support Hans Christian Lønstad
2023-10-18  9:06 ` Ahmad Fatoum
2023-10-18 11:29   ` Hans Christian Lønstad
2023-10-18 12:31     ` Hans Christian Lønstad
2023-10-18 13:04       ` Ahmad Fatoum
2023-10-18 14:06         ` Hans Christian Lønstad
2023-10-18 14:36           ` Ahmad Fatoum
2023-10-19  6:23             ` Hans Christian Lønstad
2023-10-19  6:25             ` Hans Christian Lønstad
2024-01-22 15:48               ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox