This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to trigger a Mailbox Overflow?

Hello everyone!

Well, the topic is what I want, here are the reasons why I want to know this:

In my actual project I get dropped somehow in the RTX Error function osError. I've checked the registers, searched for the Thread who caused the error and double checked my MessageQueues and MemoryPools. But the Thread ID I get is none of my user Threads and the register values are not very useful.

So I've started to read why a mailbox overflow could happen. Mostly there is not enought memory in the message queue to put a new message into, and for some reasons the message is placed in the queue anyway and the mailbox overflow error is set.

Till now, I couldn't find any of these special reasons, why the messages were placed into the queue...

Here is some code example where I place messages in the Queue (using a function):

bool Place_DataStruct_in_Queue(Data_Struct theData)
{
        // local variables
        Data_Struct * pData = 0;
        osStatus Status = osOK;

        // get a new memory block from pool
        pData = (Data_Struct *)osPoolCAlloc(MemPool_Data);

        // check pointer value (0 in case of no memory)
        if(pData)
        {
                // memory reserved, fill data
                pData->a = theData.a;
                pData->b = theData.b;
                pData->c = theData.c;

                // send into queue
                Status = osMessagePut(MsgQueue_Data, (uint32_t)pData, 0);

                // check status
                if(Status != osOK)
                {
                        // can't add message, free reserved memory from pool
                        osPoolFree(MemPool_Data, pData);
                        return False;
                }
                else
                {
                        // message successful added
                        return True;
                }
        }
        else
        {
                // no more memory in pool
                return False;
        }
}

I'm not sure if the problem is somewhere deeper, but both, memory allocating and message put functions should be threadsafe right?

I want to find out, what I have to make in the pool or queue to trigger this mailbox overflow error. Is there some special function?

Thanks

Alain

Parents
  • In case someone is looking for an answer to this:

    In the above problem I've used the CMSIS RTOS V1 library. In there, a overflow of the timer callback queue is also triggering a mailbox overflow. When adapting the whole application to CMSIS RTOS V2 (full-adaption), the correct error "Timer callback overflow" is occuring.

    An increase of the timer callback queue items didn't solve the problem.

    In both cases the problem was an unhandled USART Overrun interrupt who "blocked" the Timer Thread from processing the timer callback queue messages.

    On the used STM32F2 microcontroller the ORE interrupt is also activated when enabling the RXNE interrupt. If the ORE interrupt is processed (and not ignored) no timer callback overflow, or as initially meant mailbox overflow is happening.

    So to trigger the mailbox / timer callback overflow, you just simply have to ignore pending interrupts who are stopping the Timer Thread from processing the timer queue messages.

    Happy coding

    Alain

Reply
  • In case someone is looking for an answer to this:

    In the above problem I've used the CMSIS RTOS V1 library. In there, a overflow of the timer callback queue is also triggering a mailbox overflow. When adapting the whole application to CMSIS RTOS V2 (full-adaption), the correct error "Timer callback overflow" is occuring.

    An increase of the timer callback queue items didn't solve the problem.

    In both cases the problem was an unhandled USART Overrun interrupt who "blocked" the Timer Thread from processing the timer callback queue messages.

    On the used STM32F2 microcontroller the ORE interrupt is also activated when enabling the RXNE interrupt. If the ORE interrupt is processed (and not ignored) no timer callback overflow, or as initially meant mailbox overflow is happening.

    So to trigger the mailbox / timer callback overflow, you just simply have to ignore pending interrupts who are stopping the Timer Thread from processing the timer queue messages.

    Happy coding

    Alain

Children
No data