cancel
Showing results for 
Search instead for 
Did you mean: 

OPTEE header parse error on STM32MP135F-DK

JKim.2
Associate III

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

 

36 REPLIES 36

@debugging, your board is DDR config of MP15 DK board. So (on V5 release) if you run optee in DDR, the MP15 DK board memory mapping should fit with your board without any changing.

debugging
Senior III

@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

Hello Bernard,

 

Both the original files for 4Gb and the modified files for 8Gb are attached and diff comparisons are as follows.

 

Best Regards,

Jeff

ubuntu@ubuntu:~$ ls stm32mp13*
stm32mp131.dtsi stm32mp135f-dk-fw-config.dts stm32mp13-ddr3-1x8Gb-1066-binF.dtsi stm32mp13-ssp-bl2.dtsi
stm32mp133.dtsi stm32mp135f-dk-fw-config.dts.original stm32mp13-ddr.dtsi stm32mp13xa.dtsi
stm32mp135.dtsi stm32mp13-bl2.dtsi stm32mp13-fw-config.dtsi stm32mp13xc.dtsi
stm32mp135f-dk.dts stm32mp13-ddr3-1x2Gb-1066-binF.dtsi stm32mp13-fw-config-mem-encrypt.dtsi stm32mp13xd.dtsi
stm32mp135f-dk.dts.original stm32mp13-ddr3-1x4Gb-1066-binF.dtsi stm32mp13-pinctrl.dtsi stm32mp13xf.dtsi
ubuntu@ubuntu:~$ diff stm32mp135f-dk.dts.original stm32mp135f-dk.dts
12c12
< #include "stm32mp13-ddr3-1x4Gb-1066-binF.dtsi"
---
> #include "stm32mp13-ddr3-1x8Gb-1066-binF.dtsi"
32c32
< reg = <0xc0000000 0x20000000>;
---
> reg = <0xc0000000 0x40000000>;
33a34,49
>
> reserved-memory {
> #address-cells = <1>;
> #size-cells = <1>;
> ranges;
>
> optee_framebuffer@fd000000 {
> reg = <0xfd000000 0x1000000>;
> no-map;
> };
>
> optee@fe000000 {
> reg = <0xfe000000 0x2000000>;
> no-map;
> };
> };
ubuntu@ubuntu:~$ diff stm32mp135f-dk-fw-config.dts.original stm32mp135f-dk-fw-config.dts
6c6
< #define DDR_SIZE 0x20000000 /* 512MB */
---
> #define DDR_SIZE 0x40000000 /* 1GB */
ubuntu@ubuntu:~$ grep 8Gb stm32mp13*
stm32mp135f-dk.dts:#include "stm32mp13-ddr3-1x8Gb-1066-binF.dtsi"
stm32mp13-ddr3-1x8Gb-1066-binF.dtsi:#define DDR_MEM_NAME "DDR3-1066 bin F 1x8Gb 533MHz v1.53"

debugging
Senior III

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

 

@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
Senior III

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

@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
Senior III

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.

 

@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

debugging
Senior III

The tos_fw in dtb is 0xFE200000 but TF-A fw in the error messages expects 0xDE00000. I think that's is very weird. With this do you still get the same error. P.S: It seems you run OP-TEE in DDR, not with paging. since there is no BL-32 Extra 2 entry in the header file. and also use use fdtdump <fw-config.dtb> insteado grep, the output wlll be easier to read.

Here are my dumps using OPTEE is SYSRAM, when you do not use SRAM for OPTEE in should load  ID#8 (BL32 extra 1) in 0xDE000000 (in my example) and skip ID#9.

Just my two cents. Hope ST can  give you a hand as well. (as well with my troubles...)

NOTICE: DEBUG: parse optee image #0
NOTICE: DEBUG: header->optee_image_list[num].image_id=0x0
NOTICE: DEBUG: OPTEE_PAGER_IMAGE_ID=0
NOTICE: DEBUG: OPTEE_PAGED_IMAGE_ID=1
NOTICE: DEBUG: init_load_addr=0x2ffc0000
NOTICE: DEBUG: init_size=0x12768
NOTICE: DEBUG: image_info->image_base=0x2ffc0000
NOTICE: DEBUG: image_info->image_max_size=0x22000
NOTICE: DEBUG: parse optee image #1
NOTICE: DEBUG: header->optee_image_list[num].image_id=0x1
NOTICE: DEBUG: OPTEE_PAGER_IMAGE_ID=0
NOTICE: DEBUG: OPTEE_PAGED_IMAGE_ID=1
NOTICE: DEBUG: parse_optee_imageNOTICE: DEBUG: init_load_addr=0xde000000
NOTICE: DEBUG: init_size=0x54000
NOTICE: DEBUG: image_info->image_base=0xde000000
NOTICE: DEBUG: image_info->image_max_size=0x2000000
INFO: BL2: Loading image id 8
INFO: Loading image id=8 at address 0x2ffc0000
INFO: Image id=8 loaded: 0x2ffc0000 - 0x2ffd2768
INFO: BL2: Loading image id 9
INFO: Loading image id=9 at address 0xde000000
INFO: Image id=9 loaded: 0xde000000 - 0xde054000
INFO: BL2: Loading image id 2
INFO: Loading image id=2 at address 0xc0500000
INFO: Image id=2 loaded: 0xc0500000 - 0xc051ecf0
INFO: BL2: Skip loading image id 16
INFO: BL2: Loading image id 5
INFO: Loading image id=5 at address 0xc0100000
INFO: Image id=5 loaded: 0xc0100000 - 0xc01ffa14
NOTICE: BL2: Booting BL32
INFO: Entry point address = 0x2ffc0000
INFO: SPSR = 0x1d3