2018-08-08 06:11 AM
Hi There,
I've made some tests with the FreeRTOS MPU demo project using the STM32F429 Discovery Board.
While most of the code snippets, that should be uncommented to test, resulted in an exception as expected, the test after portSWITCH_TO_USER_MODE didn't raise an exception.
I've made some tests and modifications and finally realized, that after the call to portSWITCH_TO_USER_MODE a little bit of time is required until the restriction will work.
Following code snippet from the TestMemoryRegions function:
/* Now set the task into user mode. */
portSWITCH_TO_USER_MODE();
/* The following loop is only for wasting time. Without this part of code the access to the
* privileged array is possible without an exception
*/
for( x = 0; x < 1; x++ )
{
ReadWriteArray[ x ] = 'a';
if( ReadWriteArray[ x ] != 'a' )
{
/* Something unexpected happened. Delete this task so the error is
apparent (no output will be displayed). */
vTaskDelete( NULL );
}
}
/* Accessing the privileged only array will now cause a fault. Uncomment
the following line to test. */
/* PrivilegedOnlyAccessArray[ 0 ] = 'a'; */
Can someone please explain this behavior?
Thanks