Hi,
we are evaluating some strategies about where to place rtos in a system based on trustzone (e.g. cortex m33).
- rtos running in non-secure zone
- rtos running in secure-zone
- double rtos (1 instance running in non-secure zone and 1 instance running in secure zone)
We managed to implement all three solutions (PROS/CONS for each case, but I don’t want to focus on these) using FreeRTOS, but we stumbled upon a problem using solution 3). I’ll try to describe it.
TEST scenario:
- boot in secure zone and do basic configuration (also set to ‘1’ AIRCR.PRIS, so non secure zone will run always with lower priority). Also create a NSC function void dummy (void) { vTaskDelay (1) }
- configure freertos (using secure zone banked interrupts systick / pendsv / svc), create a single task (blocking on vTaskDelay (forever)) and start kernel
- in secure domain freertos idle task hook tick, call non_secure_init routine (it will never return, so idle task acts as the entrypoint to non secure domain
- in non secure domain, configure a separate freertos kernel (using non secure domain systick / pendsv / svc interrupts) and start it.
At this point, the situation is:
SECURE DOMAIN
- 1 task waiting forever / 1 task in “execution” (idle task, blocked on non_secure_init routine since it will never return)
NON SECURE DOMAIN
- 1 task in execution (idle task)
So, non secure domain is in execution (exception done for secure/non secure domain switch due RTOSs tick handler ISRs)
- at this point, in non secure domain idle task tick hook, call NSC function, which (as said before), will call vTaskDelay (1)
- secure domain switch is done due to NSC function, which will be executed in idle task context
- configAssert will be triggered because of taskSELECT_HIGHEST_PRIORITY_TASK, since there are no ready task in secure domain rtos
Obviously this is an architecture lack (double rtos / blocking NSC function / etc etc), but my question is:
couldn’t FreeRTOS kernel function taskSELECT_HIGHEST_PRIORITY_TASK just wait for a task to become ready, instead of triggering configASSERT( uxTopPriority )?
I hope I was able to explain good enough the test scenario.
Best regards,
Alessandro