cancel
Showing results for 
Search instead for 
Did you mean: 

Cube Firmware Error in osPoolAlloc function in cmsis_os.c

afortunato
Associate
Posted on July 14, 2015 at 00:42

In the latest version of the STM32CubeF4 package (and the last few I've used), there seems to be an error in the CMSIS OS wrapper for FreeRTOS. I imagine this is in the other Cube packages as well, though I haven't looked. In the memory pool allocation function (osPoolAlloc() in cmsis_os.c), we traverse the list of free memory blocks with the following code:

for (i = 0; i < pool_id->pool_sz; i++) {

    index = pool_id->currentIndex + i;

    if (index >= pool_id->pool_sz) {

      index = 0;

    }

This should read something like:

 

for (i = 0; i < pool_id->pool_sz; i++) {

    index = pool_id->currentIndex + i;

    if (index >= pool_id->pool_sz) {

    index = index - pool_id->pool_sz;

    }

To properly traverse the list of blocks in a circular manner. Otherwise, depending on how fast you allocate and release items from the pool, you can run into cases where allocations fail even though the pool has plenty of free space.
1 REPLY 1
rmawatson
Associate II
Posted on November 11, 2015 at 19:28

*bump*

just came across this as well and found this post.