Skip to main content
JKim.2
Associate III
August 10, 2023
Question

OPTEE header parse error on STM32MP135F-DK

  • August 10, 2023
  • 15 replies
  • 15987 views

Hello,

 

I'm changing the DDR3 size from 512MB to 1GB on the STM32MP135F-DK board. The modifications were done as below. After that, I met the OPTEE header parse error. Compilation and updating software on board was conducted according to the ST wiki. ( https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package ) Please help me to solve this problem.

change from 0x20000000 to 0x40000000

  • stm32mp135f-dk.dts in Linux Kernel, U-Boot, TF-A, and OP-TEE
  • stm32mp135f-dk-fw-config.dts in TF-A
  • stm32mp13-ddr3-1x8Gb-1066-binF.dtsi in TF-A (DDR_ADDRMAP6 0x0F070707 ==> 0x07070707)
  • conf.mk in OP-TEE

Thanks.


NOTICE: CPU: STM32MP135F Rev.Y
NOTICE: Model: STMicroelectronics STM32MP135F-DK Discovery Board
NOTICE: Board: MB1635 Var1.0 Rev.E-02
INFO: PMIC version = 0x21
INFO: Reset reason (0x35):
INFO: TF-A simple example hello
INFO: Power-on Reset (rst_por)
INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe0000
INFO: FCONF: Reading firmware configuration information for: stm32mp_io
INFO: Using SDMMC
INFO: Instance 1
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.6-stm32mp1-r2.0(debug):()
NOTICE: BL2: Built : 07:56:58, Jul 28 2023
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-1066 bin F 1x8Gb 533MHz v1.53
INFO: Memory size = 0x40000000 (1024 MB)
INFO: BL2: Loading image id 1
INFO: Loading image id=1 at address 0x30006000
INFO: Image id=1 loaded: 0x30006000 - 0x30006246
INFO: FCONF: Reading FW_CONFIG firmware configuration file from: 0x30006000
INFO: FCONF: Reading firmware configuration information for: mce_config
INFO: FCONF: Reading firmware configuration information for: dyn_cfg
INFO: FCONF: Reading firmware configuration information for: stm32mp1_firewall
INFO: BL2: Loading image id 4
INFO: Loading image id=4 at address 0xde200000
INFO: Image id=4 loaded: 0xde200000 - 0xde20001c
INFO: OPTEE ep=0xde200000
INFO: OPTEE header info:
INFO: magic=0x4554504f
INFO: version=0x2
INFO: arch=0x0
INFO: flags=0x0
INFO: nb_images=0x1
WARNING: The load address in optee header 0xfe200000 - 0xfe2792e8 is not in reserved area: 0xde200000 - 0xe0000000.
ERROR: OPTEE header parse error.
PANIC at PC : 0x2ffe82b9

Exception mode=0x00000016 at: 0x2ffe82b9

 

This topic has been closed for replies.

15 replies

Olivier GALLIEN
Technical Moderator
September 7, 2023

Hi @JKim.2 ,

Sorry to come late in this thread. 

We will soon release a wiki page addressing modification to be done while changing DDR Size. 

It described reduction from 512 to 256MB but I'm sure it can be relevant for the opposite. 

OlivierGALLIEN_0-1694099783263.png

Please let me know if it help

Olivier 

Olivier GALLIEN In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
JKim.2
JKim.2Author
Associate III
September 8, 2023

Hi Olivier,

Thank you for the news. I'm looking forward to it.

Best Regards,

Jeff

debugging
Lead
September 10, 2023

Have  the same problem on a custom board. we had to change the memory to 0x400000 in OPTE DT to avoid OPTEE to stop compilation. If this was/is known issues, why is there no information ? Also, please advice a link to this the page of this picture ? Tried to Google some some the text in it,but can't find it. Was it recently added somewhere ?

In my case there is no 135f.dts file  (using STM32MP157AAA3), Modifying the .mk file it keep gets overwritten back to the original value at the build. (perhaps it uses it from the dts file)

Just found a WARNING message in the OPTEE wiki, but this warning is not in the TF-A WIKI 

https://wiki.st.com/stm32mpu/wiki/How_to_configure_OP-TEE

Enable TF-A configuration switch STM32MP1_OPTEE_IN_SYSRAM=1 for both TF-A BL2 and TF-A FIP images.

enable OP-TEE configuration switch CFG_STM32MP1_OPTEE_IN_SYSRAM=y

Question #1:

if this build switch is needed for TF-A for STM32MP15 why is it not in TF-A configuration wiki ?   Was this wiki just added recently ? Can't help wonder how to have noticed the big warning blocks.

Question #2

CFG_STM32MP1_OPTEE_IN_SYSRAM=y . set this to y in build/conf.mk but it always changes back to "n" it seems the build/.conf get generates at build time, but from which file  ? Where to set this option to "y", in which file ?  and This should contain a typo as well, it should be CFG_STM32MP1_OPTEE_IN_SYSRAM ?= y , correct ?

Question #3

Why does CubeMX not generate the correct values in the DT ? for the memory and reservation?

Question 4:

Added the reservation in the DTS, but OPTEE errors with that it cannot parse the line:

st,protreg = <TZC_REGION_S_RDWR 0>;

Copied the section from :

https://github.com/STMicroelectronics/optee_os/blob/3.16.0-stm32mp/core/arch/arm/dts/stm32mp135f-dk.dts

.dts:45.18-19 syntax error
FATAL ERROR: Unable to parse input tree

Found the reason because it needed the defintion in #include <dt-bindings/soc/stm32mp-tzc400-macro.h> Why was that not mentioned ?

Question 5:

It seems that OPTEE build does not generate the correct header information, it it did there would not be an error from OPTEE to find the OPTEE data, correct ? For this, changed the entry point in optee-header_v2.bin manually to the one that OPTEE seems to expect as listed in the error. For example change two bytes FE00 to DE00. but this causes another error. How to calculate the correct value in the header ?

ERROR: Parse optee image failed.
ERROR: OPTEE header parse error.

 

 

 

----

I don't like the wiki's that keep changing on the fly.  Why not publish a PDF/book of the wiki and update when there is a change ? Quite old skool, but its so much better for version changes and tracking !

NOTICE: DEBUG: stm32mp1_arch_security_setup
NOTICE: DEBUG: print_reset_reason
INFO: Reset reason (0x14):
INFO: Pad Reset from NRST
NOTICE: DEBUG: stm32mp1_syscfg_enable_io_compensation_finish
NOTICE: DEBUG: fconf_populate
INFO: FCONF: Reading TB_FW firmware configuration file from: 0x2ffe2000
INFO: FCONF: Reading firmware configuration information for: stm32mp_io
NOTICE: DEBUG: stm32_skip_boot_device_after_standby
NOTICE: DEBUG: stm32mp_io_setup
INFO: Using SDMMC
INFO: Instance 1
INFO: Boot used partition fsbl1
NOTICE: BL2: v2.8-stm32mp1-r1.0(debug):()
NOTICE: BL2: Built : 06:37:24, Sep 10 2023
INFO: BL2: Doing platform setup
INFO: RAM: DDR3-DDR3L 16bits 533000kHz
INFO: Memory size = 0x20000000 (512 MB)
INFO: BL2: Loading image id 1
INFO: Loading image id=1 at address 0x2ffff000
INFO: Image id=1 loaded: 0x2ffff000 - 0x2ffff1ea
INFO: FCONF: Reading FW_CONFIG firmware configuration file from: 0x2ffff000
INFO: FCONF: Reading firmware configuration information for: dyn_cfg
INFO: FCONF: Reading firmware configuration information for: stm32mp1_firewall
INFO: BL2: Loading image id 4
INFO: Loading image id=4 at address 0xde000000
INFO: Image id=4 loaded: 0xde000000 - 0xde00001c
INFO: OPTEE ep=0xde000000
INFO: OPTEE header info:
INFO: magic=0x4554504f
INFO: version=0x2
INFO: arch=0x0
INFO: flags=0x0
INFO: nb_images=0x1
WARNING: The load address in optee header 0xfe000000 - 0xfe03dbb8 is not in reserved area: 0xde000000 - 0xe0000000.
ERROR: OPTEE header parse error.
PANIC at PC : 0x2ffecfa5

debugging
Lead
September 14, 2023
debugging
Lead
September 19, 2023

I ran in the not in reserved area issue again.  Always compiled with DEBUG=1. After removing that an all other DEBUG command line options for OPTEE and TF-A, finally BL32 Extra 1 (id 8) and 2 (id 9) were loaded.

Both TF-A and OPTEE need STM32MP1_OPTEE_IN_SYSRAM=1 on the  build command line and OPTEE CFG_STM32MP1_OPTEE_IN_SYSRAM=y CHANGED (not added) in the optee conf.mk file .

This solution worked for me. YMMV. (hope did not confuse anyone else).

debugging
Lead
September 20, 2023

@Bernard PUEL   what are the values mentioned in the WIKI but now  for an STM32MP157AAA3 with 512MB ?

debugging
Lead
September 20, 2023

@bernard. The WIKI is for STM32MP135 changing 512MB to 256MB , The WIKI explains how to configure the DT for OPTEE and U-boot. But there isn't a WIKI to explain how to configure the DT on an STM32MP157 board with 512MB.  Looked at the The DK/EV1 board DTS files do not have these DT entries for optee  The custom board I have is 512MB STM32MP157AAA3 , and wish to know  what the DT entries for optee in the DT should be. This is the related post and the logs are included.. https://community.st.com/t5/stm32-mpus-products/stm32mp15-eco-5-0-0-stm32mp157aaa3-non-secure-privileged-write/td-p/591438  Thanks for advise.

P.S the link you provided links for me to an  ECO 4 WIKI. The one for ECO 5  released last week (Sep 12) is https://wiki.st.com/stm32mpu/wiki/How_to_configure_a_256MB_DDR_mapping_from_STM32_MPU_Distribution_Package

debugging
Lead
September 22, 2023

@Bernard PUEL  Do you mean running OP-TEE unsecure in DDR ? My aim is to run it secure in SYSRAM with paging in with DDR. In was stated by ST that  since ECO 5.0 the  default was changed to insecure DDR from SYSRAM in previous ECO system but can be moved back to secure SYSRAM. (using the make build options and changes to the conf.mk file)  See the post here: https://community.st.com/t5/stm32-mpus-products/stm32mp15-eco-5-0-0-stm32mp157aaa3-non-secure-privileged-write/td-p/591438

debugging
Lead
September 22, 2023

@JKim.2  Hi JKim, allow me to make a comment in your thread.  if I compile OP-TEE with DEBUG=1 I get ysimiar error as your WARNING: The load address in optee header 0x2ffc0000 - 0x2ffe6fc0 is not in reserved area: 0x2ffc0000 - 0x2ffe2000. ERROR: OPTEE header parse error. When I remove it, it boots onward to the u-boot sign on. It took me days to figure that out. I just tested this again just now.  Try to remove any DEBUG settings on make file command.

 

JKim.2
JKim.2Author
Associate III
September 22, 2023

@debugging Hi, Thank you for your idea. I didn't use DEBUG option on make command for OPTEE. ( How to cross-compile with the Developer Package - stm32mpu ) TF-A uses ELF_DEBUG option. ( How to cross-compile with the Developer Package - stm32mpu ) Am I misunderstanding your comment?

debugging
Lead
September 23, 2023

@JKim.2m,

My understanding, so far, is that there is a difference between running OP-TEE in SYSRAM or in DDR. Because I have problem to get it run in SYSRAM (no help received so far) I changed my config to try to run in DDR and got similar error as you. that surprised me a lot

After hours,  I found the TF-A fw-config.dtsi file always defaulted to OPTEE in SYSRAM  no matter OPTEE_IN_SYSRAM is "1" or not provided. T Finally I found the only way to get the OPTEE entry address in the dtb to  DDR is on the make command line:

STM32MP1_OPTEE_IN_SYSRAM=0

Then i got : a DDR address instead of a SYSRAM entry address like 0x2ffc0000, Use fdtdump <fw-config.dtb> file

tos_fw {
load-address = <0x00000002 0xde000000>;
max-size = <0x01e00000>;
id = <0x00000004>;
};

and I think  that address should be the same as in the optee_header.bin file  (hexdump -C optee_header.bin)

@Bernard PUEL  or ST folks may know more or could comment if I am wrong. But that is what I found and I believe this is not (well) documented.

JKim.2
JKim.2Author
Associate III
September 26, 2023

@debugging Hi, I tried "optee-os-stm32mp-3.16.0-stm32mp-r2$ make -f $PWD/../Makefile.sdk all CFG_EMBED_DTB_SOURCE_FILE="stm32mp135f-dk" STM32MP1_OPTEE_IN_SYSRAM=0" at optee compilation but the result is not changed.

debugging
Lead
September 26, 2023

Sorry to hear that. Can you compare the entry address optee_header_v2.bin (hexdump -C) with what is in  tos_fw entry in fw-config.dtb file (fdtdump) ? AFAIK, if those mismatch you get the error.

 

JKim.2
JKim.2Author
Associate III
September 27, 2023

@debugging Hi, The dump results are as follows. Is it different with your imagination?

ubuntu@ubuntu:~$ cat tee-header_v2_bin_dump.asc
00000000 4f 50 54 45 02 00 00 00 01 00 00 00 00 00 00 00 |OPTE............|
00000010 00 00 20 fe 00 00 00 00 e8 92 07 00 |.. .........|
0000001c
ubuntu@ubuntu:~$ grep -A 10 tos_fw stm32mp135f-dk-fw-config-optee-dtb-dump.asc
tos_fw {
// 0114: tag: 0x00000003 (FDT_PROP)
// 021f: string: load-address
// 0120: value
load-address = <0x00000000 0xfe200000>;
// 0128: tag: 0x00000003 (FDT_PROP)
// 022c: string: max-size
// 0134: value
max-size = <0x01e00000>;
// 0138: tag: 0x00000003 (FDT_PROP)
// 0235: string: id