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

Hello Bernard,

According to the initial bootlog, I set reserved-memory for optee as below. However, I still see an error with TZC permission failure. Please review the bootlog.

 

optee-os-stm32mp-3.16.0-stm32mp-r2/core/arch/arm/dts/stm32mp135f-dk.dts
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

optee_framebuffer: optee-framebuffer@fd000000 {
/* Secure framebuffer memory */
reg = <0xfd000000 0x1000000>;
st,protreg = <TZC_REGION_S_RDWR 0>;
};
};

u-boot-stm32mp-v2021.10-stm32mp-r2/arch/arm/dts/stm32mp135f-dk.dts
linux-5.15.67/arch/arm/boot/dts/stm32mp135f-dk.dts
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;

optee_framebuffer@fd000000 {
reg = <0xfd000000 0x1000000>;
no-map;
};

optee@fe000000 {
reg = <0xfe000000 0x2000000>;
no-map;
};
};

Best Regards,

Jeff

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 (0x234):
INFO: TF-A simple example hello
INFO: IWDG2 Reset (rst_iwdg2)
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
INFO: BL2: Loading image id 8
INFO: Loading image id=8 at address 0xde200000
INFO: Image id=8 loaded: 0xde200000 - 0xde2792e8
INFO: BL2: Loading image id 2
INFO: Loading image id=2 at address 0xc0400000
INFO: Image id=2 loaded: 0xc0400000 - 0xc040f750
INFO: BL2: Skip loading image id 16
INFO: BL2: Loading image id 5
INFO: Loading image id=5 at address 0xc0000000
INFO: Image id=5 loaded: 0xc0000000 - 0xc00e453c
NOTICE: BL2: Booting BL32
INFO: Entry point address = 0xde200000
INFO: SPSR = 0x1d3
I/TC: Early console on UART#4
I/TC:
I/TC: Non-secure external DT found
I/TC: Embedded DTB found
I/TC: OP-TEE version: 3.16.0-dev (gcc version 11.3.0 (GCC)) #1 Fri 28 Jan 2022 02:28:18 PM UTC arm
I/TC: WARNING: This OP-TEE configuration might be insecure!
I/TC: WARNING: Please check https://optee.readthedocs.io/en/latest/architecture/porting_guidelines.html
I/TC: Primary CPU initializing
I/TC: WARNING: All debug access are allowed
I/TC: Platform stm32mp1: flavor PLATFORM_FLAVOR - DT stm32mp135f-dk.dts
I/TC: DTB enables console (non-secure)
I/TC: Primary CPU switching to normal world boot
optee optee: OP-TEE: revision 3.16 (d0b742d1)


U-Boot 2021.10-stm32mp-r2 (Sep 19 2023 - 01:29:51 -0700)

CPU: STM32MP135F Rev.Y
Model: STMicroelectronics STM32MP135F-DK Discovery Board
Board: stm32mp1 in trusted mode (st,stm32mp135f-dk)
U-Boot simple example
Board: MB1635 Var1.0 Rev.E-02
DRAM: E/TC:0 tzc_it_handler:72 TZC permission failure
E/TC:0 dump_fail_filter:417 Overrun violation on filter 0
E/TC:0 dump_fail_filter:420 Permission violation on filter 0
E/TC:0 dump_fail_filter:425 Violation @0xfabfffb0, non-secure privileged read, AXI ID 4a0
E/TC:0 Panic at core/arch/arm/plat-stm32mp1/plat_tzc400.c:77 <tzc_it_handler>
E/TC:0 TEE load address @ 0xde200000
E/TC:0 Call stack:
E/TC:0 0xde203cb5
E/TC:0 0xde21bc31
E/TC:0 0xde207b09
E/TC:0 0xde21b2f1
E/TC:0 0xde238c2b
E/TC:0 0xde200340

Hello Kim, the bl2 will load optee and u-boot will also relocate itself inside the DDR (so need to take care about where is optee secure memory (secure and/or encrypted). So you need to check alignment of the optee reserved memory in the 3 dts. 

Then from this article: https://wiki.st.com/stm32mpu-ecosystem-v4/wiki/How_to_configure_a_256MB_DDR_mapping_from_STM32_MPU_Distribution_Package#DDR_configuration

 

Did you check in the 3 component you have coherent update on your side ? (Moving from 512MB to 1GB -> DDR Base address and Start address have to be updated but reserved memory size should be the same).

 

debugging
Lead

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

Hello Bernard,

I changed my dts files according to the wiki posting but I'm increasing the size. I didn't change the base address. I changed the size from 0x20000000 to 0x40000000 for 1GB. Please see the error message in my initial post. ("The load address in optee header 0xfe200000 - 0xfe2792e8 is not in reserved area: 0xde200000 - 0xe0000000.") Due to this, I had to change reserved-memory for optee. The modified reserved-memory is shared in previous post. Do you see any wrong modifications?

Best Regards,

Jeff

@jeff, sorry if i was not clear.

Your optee device tree is correct. But this should be also aligned with both tf-a bl2 (that will jump to optee) and u-boot that will relocate itself at the end of the DDR (just where optee is located).

 

On your trace above, you can see:

INFO: OPTEE ep=0xde200000

 

Entry point for OPTEE is not correct. This should be 0xfe20000. So that means your DDR settings in bl2 are not correct for your 1GB memory (still with 512MB one). OPTEE secure (and encrypted) memory starts from the end of the memory (so directly dependent from your memory size). This is well explain in wiki tf-a modifications for 256 MB.

 

The main root cause of your issue may come from the ddr settings file coming from Cube MX DDR settings code generation or from the dts mentioned in wiki article.

 

Also be aware that u-boot DDR size is not taken from the same definitions (dts or define) compared to optee or tf-a but directly from the DDR controler. So ddr settings coming from Cube MX DDR tool is very important:

This one for ex (for 256 MB): #define DDR_ADDRMAP6 0x0F0F0707.

 

So in summary for tf-a:

- check with cube MX, you have generated the right DDR setting register list and you are using this file in tf-a (like stm32mp13-ddr3-2x4Gb-1066-binF.dtsi)

- Check in tf-a dts optee memory start address calculation from stm32mp135f-xxx-fw-config.dts

 

 

@debugging, Sorry I don't understand your question. On MP15 we have 2 public boards (DK (512MB) and EV1 (1GB) DDR). On MP13 we have only one DK board (512MB) and the article use case is to use only the first 256 MB of the MP13 DK baords.

 

But of course, internally we are testing with many other boards on MP1 with different DDR types and sizes. 

debugging
Lead

@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

Hello Bernard,

 

I generated dts files by Cube MX with 1GB DDR size setting. It is attached. It doesn't care about the reserved memory at all. 

As you suggested, I tried to align the four (TF-A, U-boot, optee, Linux) dts files as below. It was not successful and its bootlog is as follows.

 

FILE: optee-os-stm32mp-3.16.0-stm32mp-r2/core/arch/arm/dts/stm32mp135f-dk.dts
        reserved-memory {
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;
 
                optee_framebuffer: optee-framebuffer@fd000000 {
                        /* Secure framebuffer memory */
                        reg = <0xfd000000 0x1000000>;
                        st,protreg = <TZC_REGION_S_RDWR 0>;
                };
optee: optee@fe000000 {
                        reg = <0xfe000000 0x2000000>;
                        no-map;
                };
        };
 
FILE: tf-a-stm32mp-v2.6-stm32mp-r2/fdts/stm32mp135f-dk.dts
FILE: u-boot-stm32mp-v2021.10-stm32mp-r2/arch/arm/dts/stm32mp135f-dk.dts
FILE: linux-5.15.67/arch/arm/boot/dts/stm32mp135f-dk.dts
        reserved-memory {
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;
 
                optee_framebuffer@fd000000 {
                        reg = <0xfd000000 0x1000000>;
                        no-map;
                };
                optee@fe000000 {
                        reg = <0xfe000000 0x2000000>;
                        no-map;
                };
        };

 

Best Regards,

Jeff

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 0xfe200000
INFO: Image id=4 loaded: 0xfe200000 - 0xfe20001c
INFO: OPTEE ep=0xfe200000
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 0xde200000 - 0xde2792e8 is not in reserved area: 0xfe200000 - 0.
ERROR: OPTEE header parse error.
PANIC at PC : 0x2ffe82b9

Exception mode=0x00000016 at: 0x2ffe82b9

"INFO: OPTEE ep=0xfe200000" is good news. Now the issue comes from the FIP. So maybe you have a build issue and your FIP is not updated or your "xxxfw-config.dts" is not aligned. Can share it for sanity check if required.