Hello,
We are using the S32K144 with the FuSa RTS and noticed that the device isn't equipped with a standard ARM MPU.
The RTS Blinky example is configuring the MPU to use zones but it won't work because registers are different.
Can someone point us in the right direction or maybe provide some sample code?
static const ARM_MPU_Region_t mpu_table[ZONES_NUM][MPU_REGIONS];
extern void stop_on_error(uint32_t cond);
/* Update MPU settings for newly activating Zone */
void osZoneSetup_Callback (uint32_t zone) {
stop_on_error(zone >= ZONES_NUM);
ARM_MPU_Disable();
ARM_MPU_Load(mpu_table[zone], MPU_REGIONS);
ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk);
}
/* MPU table specifying MPU regions for all Zones */
static const ARM_MPU_Region_t mpu_table[ZONES_NUM][MPU_REGIONS] = {
/* Zone 'ZONE_CTRL' */
{
// FLASH (0x00000000..0x00020000)
{ .RBAR = ARM_MPU_RBAR(0U, 0x00000000), .RASR = ARM_MPU_RASR_EX(0U, ARM_MPU_AP_RO, ARM_MPU_ACCESS_NORMAL(ARM_MPU_CACHEP_NOCACHE, ARM_MPU_CACHEP_NOCACHE, 1U), 0x00U, ARM_MPU_REGION_SIZE_128KB) },
// RAM_SHARED, RAM_EVR (0x20000000..0x20001FFF)
{ .RBAR = ARM_MPU_RBAR(1U, 0x20000000), .RASR = ARM_MPU_RASR_EX(1U, ARM_MPU_AP_FULL, ARM_MPU_ACCESS_NORMAL(ARM_MPU_CACHEP_NOCACHE, ARM_MPU_CACHEP_NOCACHE, 1U), 0x00U, ARM_MPU_REGION_SIZE_8KB) },
// RAM_CTRL (0x20002000..0x20003FFF)
{ .RBAR = ARM_MPU_RBAR(2U, 0x20002000), .RASR = ARM_MPU_RASR_EX(1U, ARM_MPU_AP_FULL, ARM_MPU_ACCESS_NORMAL(ARM_MPU_CACHEP_NOCACHE, ARM_MPU_CACHEP_NOCACHE, 0U), 0x00U, ARM_MPU_REGION_SIZE_8KB) },
{ .RBAR = ARM_MPU_RBAR(3U, 0U), .RASR = 0U },
{ .RBAR = ARM_MPU_RBAR(4U, 0U), .RASR = 0U },
{ .RBAR = ARM_MPU_RBAR(5U, 0U), .RASR = 0U },
{ .RBAR = ARM_MPU_RBAR(6U, 0U), .RASR = 0U },
{ .RBAR = ARM_MPU_RBAR(7U, 0U), .RASR = 0U }
},
Regards Peter
Hi @Peter-DK
I answered something similar here:
https://community.nxp.com/t5/S32-Design-Studio/FreeRTOS-MPU-for-S32K144/m-p/1065873
We have an example for this system MPU in the SDK:
c:\NXP\S32DS.3.4\S32DS\software\S32SDK_S32K1XX_RTM_4.0.3\examples\S32K144\driver_examples\system\mpu_memory_protection\
Second option is to write own code without SDK but unfortunately we do not have such example. But it’s only configuration of individual descriptors, so it should not be difficult.
Regards,
Lukas
Hi @lukaszadrapa,
Thank you for answering. I've looked at the example and I can't really understand it.
A bit more help, details and explanation would be appreciated.
Regards Peter
Hi @Peter-DK
simple example written in C will be better, I guess. Take a look at this one:
It's for another device but the principle is still the same. See the main function and MPU_Init. It's just about configuration of start address, end address and user rights of individual descriptors. Then there's a test to check the behavior when the access rights are violated. And one note - all the memory resources need to be covered by MPU descriptors once the MPU is enabled. Access to an area which is not covered by descriptors is considered as access violation.
I do not have this directly for S32K1 devices but I believe this will clear it up.
Regards,
Lukas