I do not allow reading flash memory through code.

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

I do not allow reading flash memory through code.

ソリューションへジャンプ
454件の閲覧回数
pangyun
Contributor II

I design by S32k144.

I do not allow reading flash memory through code.

for example:

uint32_t address = 0x0;

uint32_t data = *(uint32_t *)address;

After setting,this operation will be illegal and the read data can not be the real.

But I do not know how to realize it, do you have any solutions?

 

タグ(1)
0 件の賞賛
返信
1 解決策
433件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

The MPU can be configured to restrict access to memory regions, including flash.

  • Steps:

    1. Enable the MPU.
    2. Define a region covering the flash area.
    3. Set access permissions to no access or execute-only.

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
434件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

The MPU can be configured to restrict access to memory regions, including flash.

  • Steps:

    1. Enable the MPU.
    2. Define a region covering the flash area.
    3. Set access permissions to no access or execute-only.
0 件の賞賛
返信
348件の閲覧回数
pangyun
Contributor II

Now,I want to set the address(0~0x77fff) unreadable.

pangyun_0-1750754639157.pngpangyun_1-1750754666963.pngpangyun_2-1750754682557.pngpangyun_3-1750754698829.pngpangyun_4-1750754715209.png

s32k144   debug flash

code 1:

#define ADDRESS_PROTECT 0x0000U

(void)MPU_EnableRegion(&mpu_pal_config_1_Instance, 2U, true);

  test = *((uint32_t *)ADDRESS_PROTECT);

Like this, It can be OK.

code 2:

(void)MPU_EnableRegion(&mpu_pal_config_1_Instance, 2U, false);

  //test = *((uint32_t *)ADDRESS_PROTECT);

it is always in "void HardFault_Handler(void)", I can't understand this, because I don't read any address,It should be normal,but it's not,why?

 

 

0 件の賞賛
返信