You are right chPoolInit is not needed and you do need to load the pool.
Here is a simple test sketch for mailboxes with a memory pool that suggests they work. It is a minimal test with the main task posting and fetching mail.
#include <ChibiOS_AVR.h>
//------------------------------------------------------------------------------
// mailbox size and memory pool object count
const size_t MB_COUNT = 6;
// type for a memory pool object
struct PoolObject_t {
int var1;
int var2;
};
// array of memory pool objects
PoolObject_t PoolObject[MB_COUNT];
// memory pool structure
MEMORYPOOL_DECL(memPool, MB_COUNT, 0);
//------------------------------------------------------------------------------
// slots for mailbox messages
msg_t letter[MB_COUNT];
// mailbox structure
MAILBOX_DECL(mail, &letter, MB_COUNT);
//------------------------------------------------------------------------------
void setup() {
// initialize heap/stack memory and start ChibiOS
chBegin(chSetup);
while(1);
}
//------------------------------------------------------------------------------
void chSetup() {
Serial.begin(9600);
// fill pool with PoolObject array
for (int i = 0; i < MB_COUNT; i++) {
chPoolFree(&memPool, &PoolObject[i]);
}
// put messages in mailbox
for (int i = 0; i < MB_COUNT; i++) {
PoolObject_t* p = (PoolObject_t*)chPoolAlloc(&memPool);
if (!p) {
Serial.println("null chPoolAlloc");
while(1);
}
p->var1 = i;
p->var2 = 2*i;
msg_t s = chMBPost(&mail, (msg_t)p, TIME_IMMEDIATE);
if (s != RDY_OK) {
Serial.println("chMBPost failed");
while(1);
}
}
// fetch and check messages
for (int i = 0; i < MB_COUNT; i++) {
PoolObject_t *p;
msg_t s = chMBFetch(&mail, (msg_t*)&p, TIME_IMMEDIATE);
if (s != RDY_OK) {
Serial.println("chMBFetch failed");
while(1);
}
if (p->var1 != i || p->var2 != 2*i) {
Serial.println("bad content");
while(1);
}
// put memory back into pool
chPoolFree(&memPool, p);
}
// see if memory is in pool
for ( int i = 0; i < MB_COUNT; i++) {
if (!chPoolAlloc(&memPool)) {
Serial.println("free problem");
while(1);
}
}
// should be exhausted now
if (chPoolAlloc(&memPool)) {
Serial.println("excess pool object");
while(1);
}
Serial.println("OK");
}
//------------------------------------------------------------------------------
void loop() {}