Giovanni wrote:You need to give me specifics about your setup if you want a meaningful answer. The heap allocator is working on all demos.
Giovanni
Oh I'm sure it's not a ChibiOS defect but something in my setup. The test that triggers the NULL return is in chmemcore.c:
Code: Select all
/* Considering also the case where there is numeric overflow.*/
if ((prev < ch_memcore.basemem) || (prev > ch_memcore.topmem)) {
return NULL;
}
In my case prev is 0x20004f60 and both ch_memcore.basemem and ch_memcore.topmem are 0x20004f78 so clearly that will always fail.
In the linker map __heap_base__ is 0x20004f78 and __heap_end__ is 0x2000500 so the linker is allocating very little to the heap, although it should be enough for this semaphore.
Looking at the various allocated memory, bss is 18,204 and data is 88 and this is an STM32F103CB so should have 20K of RAM ie 20,480 which implies over 2k should be left but I'm assuming the bss number already includes the linker allocation for the heap?
But that's where I get stuck - the implication from the docs is that it should allocate all of the available space to the heap but there is only 0x8c allocated so I'm guessing the issue is that there isn't enough RAM but can't figure out where to start looking for where it has gone and whether it's always going to show 'full' when using the default heap as that will soak up any spare?