STM32U5, FreeRTOS 11.2, CMSIS 2.1.3, taskEXIT_CRITICAL does not reset mask

Symptoms: Custom hardware board, STM32U575 processor, CMSIS 2.

DMA2D, DMA, SPI, I2C interrupts not working. Timers mostly work. Processor basepri is set to 0x80 but not set back.

Tracing:

with the processor registers displayed, step through the code starting at the osKernelInitialize() call. In MX_FREERTOS_Init(), the main task is created.

This calls taskENTER_CRITICAL(), which increased base_pri to 0x80, effectively disabling most interrupts.

Task is then created successfully.

taskEXIT_CRITICAL is called which fails (not with error, but simply does not reset the mask).

taskEXIT_CRITICAL is linked to:


void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */
{
    configASSERT( ulCriticalNesting );
    ulCriticalNesting--;

    if( ulCriticalNesting == 0 )
    {
        portENABLE_INTERRUPTS();
    }
}

where the critical nesting is NOT zero, it’s the default value:

/**
 * @brief Each task maintains its own interrupt status in the critical nesting
 * variable.
 */
PRIVILEGED_DATA static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL;


which will never hit zero for any practical definition of “never”

Is this supposed to be like this? What got missed?

See this part of the FAQ Before the FAQ... - FreeRTOS™ - interrupts will be re-enabled when the scheduler starts.