STM32F Cortex M4 MPU Crash

nmithun wrote on Tuesday, April 10, 2018:

Hi,

We have been trying to use ARM_CM4F_MPU port in one of our application. Freertos version is 10.0.0.

An unprivileged task always Mem Faults when trying to use a kernel API though mpu_wrappers is elevating the privilege of during kernel execution.

When Task calls vTaskDelay(), it crashes inside portYIELD_WITHIN_API() though I can see it gets executed when CPU state is in Privilege mode. nPRIV in CONTROL Register is 0 when this yield is called.

Any pointers on what could cause this?

Regards

rtel wrote on Tuesday, April 10, 2018:

Was this a project you put together yourself, or a project we provided?
If a project you put together yourself then did you update the linker
script (or constants, depending on the compiler you are using) so the
memory bounds of the privileged data sections are defined correctly?

nmithun wrote on Tuesday, April 10, 2018:

This project was put together ourselves.

On entry to this task, we are accessing a couple of variables in SRAM whose region is defined as NON PRIVILEGE READ_WRITE. We are able to read write on this region. After this we are using vTaskDelay() inside which it Mem Faults when it calls portYIELD_WITHIN_API().

Even if the variables are disabed and only vTaskDelay() is called on entry inside this task, it faults.

void ProcessMainTask(void *arg) //Non Privilege Task
{
g_NonPrivMemArray[0] = 1;
while(1)
{
vTaskDelay(10);
}
}

It assigns g_NonPrivMemArray[0] with 1, then tries to delay and crashes.

nmithun wrote on Tuesday, April 10, 2018:

Also, if I use the same application code with Freertos 9.0.0 version avaiable in STMCube it does not crash here.

There is not change in application at all. Just replaced RTOS from 10.0.0 to 9.0.0 provided in STMCube.

rtel wrote on Tuesday, April 10, 2018:

Does STM32 Cube contain the MPU version of FreeRTOS? I thought it only
contained the non-MPU version.

nmithun wrote on Wednesday, April 11, 2018:

Yes it contains an MPU version also. But it has version 9.0.0 of Freertos. We initially ported 10.0.0 into our application and all our tests have been on this version.

So we are hesitant to go back to 9.0.0 as we will have to redo all our tests.