I had an issue with the migration from 8.0.0 to 8.2.1. I copied all relevant files over and the built the new image (I had to remove a cast from FreeRTOSConfig.h for configMAX_PRIORITIES). When I ran the system, I had an assertion on line 3466 in tasks.c:
if( pxMutexHolder != NULL )
{
/* A task can only have an inherited priority if it holds the mutex.
If the mutex is held by a task then it cannot be given from an
interrupt, and if a mutex is given by the holding task then it must
be the running state task. */
configASSERT( pxTCB == pxCurrentTCB );
This works fine on the 8.0.0, but this assert check is not made, so maybe something bad is happening and not being trapped? Anyway, I had to pull back to 8.0.0 until I can get an indication as to the problem.
Some optimisations were made to giving semaphores from interrupts. Previously the semaphore give from ISR macro used the queue send from ISR function - now it has its own function which allows it to be slimmer (parts of the function relevant only to a queue do not have to be executed). That did however mean that mutexes can no longer be given from interrupts if a priority has been inherited - as you have found.
It may be possible to call xQueueSendFromISR() to give a mutex from an interrupt, instead of xSemaphoreGiveFromISR() (you may need to cast the SemaphoreHandle_t to a QueueHandle_t when passing in the parameter to avoid compiler warnings). It is on our todo list to look at this to see if it is safe, and if not, make it safe. You could try it.
I just encountered this problem again on a different processor and project; I am not sure what you are suggesting for a solution. If I follow the call stack back, the call to xSemaphoreGive(calibrationMutex); is made, but as you can see this is not from an ISR. Isn’t this a critical error in the v8.2.1, seeing that I have encountered it twice now…?
I have a gatekeeper task which takes the mutex, which allows the gk queue to fill with additional requests. The GK task signals an event_group which pumps a state machine. When the state machine has concluded, it calls a function to give the mutex, which allows the next request in the queue to run. This scheme works well with 8.0.0 but fails with 8.2.1
That sounds like a better use for a semaphore than a mutex. The big feature of the mutex over a semaphore is that it will boost the priority of the task holding it to avoid priority inversion if needed. It sounds like the task that took the mutex (the Gate Keeper) isn’t the task responsible for the processing so the priority boost doesn’t do anything.
I am also not sure from your description who else is trying to acquire the mutex to provide the exclusion.