That is not true. An unprivileged task only has access to its own stack by default. You need to grant explicit access to any other memory region that your unprivileged task needs to access. We use MPU regions to grant these access and therefore, these memory regions needs to satisfy MPU constraints.
As I mentioned before, the smallest MPU region size is 32 bytes. You cannot grant an unprivileged task access to just one byte (i.e. uint8_t). Here is an example to grant your unprivileged task access to a 32 byte array:
/* We will grant our unprivileged task access to the unprivAccessibleMemory
* array. Therefore, this memory region must satisfy all the MPU constraints:
* 1. The size of a MPU region is a power of 2.
* 2. Smallest supported region size is 32 bytes.
* 3. Start address of a region must be aligned to an integer multiple of the
* region size. For example, if the region size is 4 KB(0x1000), the starting
* address must be N x 0x1000, where N is an integer.
*/
#define ARRAY_SIZE 32
static uint8_t unprivAccessibleMemory[ ARRAY_SIZE ] __attribute__( ( aligned( ARRAY_SIZE ) ) );
/* We use an MPU region to grant unprivileged task access to its stack, therefore,
* stack memory must satisfy MPU constraints. */
static StackType_t UnprivTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( configMINIMAL_STACK_SIZE * sizeof( StackType_t ) ) ) );
/* Grant unprivileged task Read-Write access to unprivAccessibleMemory. */
TaskParameters_t UnprivTaskParameters =
{
.pvTaskCode = UnprivTask,
.pcName = "Unpriv",
.usStackDepth = configMINIMAL_STACK_SIZE,
.pvParameters = NULL,
.uxPriority = tskIDLE_PRIORITY,
.puxStackBuffer = UnprivTaskStack,
.xRegions = {
{ unprivAccessibleMemory, ARRAY_SIZE, portMPU_REGION_READ_WRITE | portMPU_REGION_EXECUTE_NEVER },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
}
};
xTaskCreateRestricted( &( UnprivTaskParameters ), NULL );