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?
已解决! 转到解答。
The MPU can be configured to restrict access to memory regions, including flash.
Steps:
The MPU can be configured to restrict access to memory regions, including flash.
Steps:
Now,I want to set the address(0~0x77fff) unreadable.
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?