Skip to content

osThreadNew ignores MPU #157

@kossnikita

Description

@kossnikita

Perhaps this is more of a usage question than a real issue.

I don't understand how to use the CMSIS OS2 wrapper when I have the MPU enabled. I selected the GCC_ARM_CM4_MPU port in FreeRTOS. I added the necessary sections to the linker script, and everything compiles and runs on the hardware.

The problem starts when I create a new task. I noticed that the task creation doesn't use the privileged/unprivileged mode selection.

  const osThreadAttr_t test_task_attr = {
      .name = "TestTask",
      .stack_size = 512,
      .priority = osPriorityNormal,
      .attr_bits = osThreadPrivileged,
  };
  osThreadNew(test_task, NULL, &test_task_attr);

if (attr->priority != osPriorityNone) {
prio = (UBaseType_t)attr->priority;
}
if ((prio < osPriorityIdle) || (prio > osPriorityISR) || ((attr->attr_bits & osThreadJoinable) == osThreadJoinable)) {
/* Invalid priority or unsupported osThreadJoinable attribute used */
return (NULL);
}

Because of this, the xTaskCreate call fails because the unprivileged mode is selected by default, which is not supported.

/* xTaskCreate() can only be used to create privileged tasks in MPU port. */
if( ( uxPriority & portPRIVILEGE_BIT ) != 0 )

Have I configured something incorrectly? Or is MPU support with CMSIS OS2 implemented differently?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions