I do not allow reading flash memory through code.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

I do not allow reading flash memory through code.

跳至解决方案
434 次查看
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 解答
413 次查看
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 回复数
414 次查看
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 项奖励
回复
328 次查看
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 项奖励
回复