In common/abstractions/cmsis_os/cmsis_os.h, we have the code:
/**
* @brief Access a Memory Pool definition.
*/
#define osPool(name) &os_pool_def_##name
/**
* @brief Define a Message Queue.
*/
#if defined(osObjectsExternal)
#define osMessageQDef(name, queue_sz, type) \
extern const osMessageQDef_t os_messageQ_def_##name
#else
#define osMessageQDef(name, queue_sz, type) \
static const msg_t os_messageQ_buf_##name[queue_sz]; \
static mailbox_t os_messageQ_obj_##name; \
const osMessageQDef_t os_messageQ_def_##name = { \
(queue_sz), \
sizeof (type), \
(mailbox_t*)&os_messageQ_obj_##name, \
(void *)&os_messageQ_buf_##name[0] \
}
#endif
Here the buffer is defined as static const msg_t. Since the buffer is const, adding messages to the message queue does not work.
Problem occurs when In oslib/src/chmboxes.c, function chMBPostTimeoutS(), the buffer being pointed to by the write-pointer gets written and the pointer gets incremented:
*mbp->wrptr++ = msg;
However, the write operation is not successful since the buffer is const.