During migrating my project to RTOSv2 and RTX5, I recognize that after a few minutes my program hangs and the messages appear at the RTX_RTOS window:
Expression: 'QML[j + QCB[i].ml_idx].addr' E303: Access out of bounds - <readlist 'QML[44]'> - actual index:=45 I find the source of the hard fault is the "memcpy" function.
CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_msgqueue.c
/// Put a Message into a Queue or timeout if Queue is full. osStatus_t osMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { EvrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); if (IS_IRQ_MODE() || IS_IRQ_MASKED()) { return isrRtxMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); } else { return __svcMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout); } } ... /// Put a Message into a Queue or timeout if Queue is full. /// \note API identical to osMessageQueuePut __STATIC_INLINE osStatus_t isrRtxMessageQueuePut (osMessageQueueId_t mq_id, const void *msg_ptr, uint8_t msg_prio, uint32_t timeout) { os_message_queue_t *mq = (os_message_queue_t *)mq_id; os_message_t *msg; const void **ptr; ... // Try to allocate memory msg = osRtxMemoryPoolAlloc(&mq->mp_info); if (msg != NULL) { // Copy Message memcpy((uint8_t *)msg + sizeof(os_message_t), msg_ptr, mq->msg_size); ... return osOK; }
Does anyone have any ideas?