I do not allow reading flash memory through code.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I do not allow reading flash memory through code.

Jump to solution
452 Views
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?

 

Tags (1)
0 Kudos
Reply
1 Solution
431 Views
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.

View solution in original post

0 Kudos
Reply
2 Replies
432 Views
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 Kudos
Reply
346 Views
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 Kudos
Reply