When encryption is enabled, static std::map cause BEE read violation on i.MX RT1052

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

When encryption is enabled, static std::map cause BEE read violation on i.MX RT1052

1,241件の閲覧回数
cup-a-coffee
Contributor I

In our code, we have constant map object like below:

static const std::map<const uint32_t, const uint32_t> map =
{
{1, 1},
{2, 2}
};

It is initialized by __libc_init_array() before calling main()
When MCU initializes the std::map, a hard fault occurs. At this time, the BEE state was 0x8104

However, when I disable the BEE, MCU works fine with std::map.

 

Questions

  1. Why does this cause a hard fault with a non-zero BEE state when encryption is enabled?
  2. How can I use this std::map + enabled encryption + prevent the hard fault with non-zero BEE state?

 

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

908件の閲覧回数
adde_ado
Contributor III

Hi,

We are experiencing the same issue that you have explained in yor post and I wonder if you have find any solution.

 

Best regards,

Adde

0 件の賞賛
返信

1,227件の閲覧回数
jeremyzhou
NXP Employee
NXP Employee

Hi @cup-a-coffee ,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
According to your statement, it seems like the definition of the above map object causes a hard fault when enabling the XIP encryption mode for RT1050, but it works well on a normal boot of RT1050, is my understanding right?
If yes, I was wondering if you can illustrate the steps of replicating the phenomenon, further, upload the related demo code.Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信

100件の閲覧回数
gvisser
Contributor II

I have the same problem.

We also create a struct using cpp.
The compiler generates a

 

 

ldmia

 

 

instruction to load the constant values from flash.
Which are then used to initialize the struct.

This in combination with an enabled BEE causes a hard fault.

We where able to recreate the problem with two ASM instructions.

 

 

__asm __volatile ("\
    		ldr r5,=0x7001fb68 \n\
    		ldmia r5!, {r0, r1, r2, r3}");

 

 

 

In our case we use the IMX1064.

Side note:
We have used a number of values for R5.
0x7001fb60
0x7001fb64
0x7001fb68 <- this value cause problems.
0x7001fb6C
The others do not cause problems.

 

タグ(2)
0 件の賞賛
返信

87件の閲覧回数
gvisser
Contributor II

We have found the solution:

https://www.nxp.com/docs/en/errata/IMXRT1064CE_B.pdf
ERR050164 says the BEE does not like unaligned access.

The ResetISR will call __libc_init_array before main.
In the default project main has a function BOARD_ConfigMPU which will enable the cache.
However objects which are static const will be initialized in __libc_init_array.
Which is before the cache is enabled.
Thus is it possible for the code to access the storage with a address which is not 16-bytes aligned.

The solution is to enable the cache before the object is initialized.
So enable the cache in ResetISR before __libc_init_array.

0 件の賞賛
返信