I’m running on FreeRTOS Kernel V10.0.1 - the NXP Port for the RT1052 -
Using code based on their power_mode_switch_ca demo, in my implementation, on startup (before the task scheduler is started), xSemaphoreCreateMutex() is called and usually works just fine, but intermittently it fails configAssert( pxQueue) in xQueueGenericSend()
The assert shows the mutex handle is null. Do you check the mutex is created before trying to use it? If it is created, and then the assert fails, something else must be writing over the mutex handle, although that seems unlikely as it would have to write zero over the handle for that assert to fail.
So asserting when i’m trying to create the Mutex, before anything tries to use it… which is why i’m a little unsure of how to debug & looking for some ideas.
Seems you‘re doing a couple of things in main…
Take care that the main stack size (usually configured in the linker script) is sufficient.
Also avoid using variables defined in main because later on the main stack is re-used as ISR stack for a number of MCUs and those variables might get corrupted.
Another approach would be to move some task related code into a task where you can manage the stack size more flexible and where the stack is dedicated to this task.
thanks @hs2 and @aggarg,
right after seeing @aggarg’s post - i ran thru a few more times to try and hit this assertion and instead of asserting, the next time thru I got the below fault.
While code’s running from flash (via NXP’s XIP mode) - at this point flash is initialized, and the real kicker is the fact that the code works more often than not.
the new queue (pxNewQueue) is stored at location 0x2020_0098 - which is on the device’s internal OCRAM.
I suppose I’ll try @hs2’s idea - run this xSemaphoreCreateMutex from a task instead of main, see if I am able to still replicate.