cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube - bug in cmsisOS api regarding FreeRTOS

basile
Associate II
Posted on February 02, 2015 at 10:30

STM32Cube provides project code generation for FreeRTOS along with a wrapper dedicated to use of the CMSIS-OS API.

Nevertheless, it seems that this wrapper is brocken regarding the FreeRTOS API function ''

vTaskDelayUntil()

'' wich is wrapped to ''

osDelayUntil()

'' according to the following code from cmsis_os.c:

/**

* @brief  Delay a task until a specified time

* @param   PreviousWakeTime   Pointer to a variable that holds the time at which the

*          task was last unblocked.

* @param   millisec    time delay value

* @retval  status code that indicates the execution status of the function.

*/

osStatus osDelayUntil (uint32_t PreviousWakeTime, uint32_t millisec)

{

&sharpif INCLUDE_vTaskDelayUntil

  portTickType ticks = (millisec / portTICK_RATE_MS);

  portTickType previouswake = (portTickType) PreviousWakeTime;

  vTaskDelayUntil(&previouswake, ticks ? ticks : 1);

 

  return osOK;

&sharpelse

  (void) millisec;

  (void) PreviousWakeTime;

 

  return osErrorResource;

&sharpendif

}

In the freeRTOS API, the first argument of this function is a pointer to a variable that holds the time at which the task was last unblocked and this variable is automatically updated within vTaskDelayUntil(). Nevertheless, as you can note, the wrapper don't use a pointer anymore. That is, the local variable couldn't be updated anymore and the function is unusable.

Of course, it is easy to fix by ourself, but the file cmsis_os.c from STM32Cube should be updated.

I'm not sure that it is the right place for reporting it, but I don't know where to do so...

Many thanks in advance for your help.

Best regards,

BaDuf

#freertos #cubemx #cmsis #os
7 REPLIES 7
afbagautdinov
Associate
Posted on February 16, 2015 at 20:21

Its realy bug. Work like this

osStatus osDelayUntil (uint32_t * const PreviousWakeTime, uint32_t millisec)

{

#if INCLUDE_vTaskDelayUntil

  portTickType ticks = (millisec / portTICK_RATE_MS);

  portTickType* previouswake = (portTickType*) PreviousWakeTime; 

  vTaskDelayUntil(previouswake, ticks ? ticks : 1);

  

  return osOK;

#else

  (void) millisec;

  (void) PreviousWakeTime;

  

  return osErrorResource;

#endif

}

basile
Associate II
Posted on February 26, 2015 at 11:04

In order to expect a futur fix for this bug, which team is the maintainer of the cmsis wrapper for freeRTOS ?

Indeed, I've also reported this bug on FreeRTOS bug tracker, but they are not responsible of this wrapper.

As a consequence, is it ST who provide this for CubeMX or do we need to report it elsewhere ?

Thanks in advance.

Posted on February 27, 2015 at 16:13

Hidufay.basile,

The fix proposed by bagautdinov.anton is OK, and it will be implemented in next release like below:

/**
* @brief Delay a task until a specified time
* @param PreviousWakeTime Pointer to a variable that holds the time at which the 
* task was last unblocked. PreviousWakeTime must be initialised with the current time
* prior to its first use (PreviousWakeTime = osKernelSysTick() )
* @param millisec time delay value
* @retval status code that indicates the execution status of the function.
*/
osStatus osDelayUntil (uint32_t *PreviousWakeTime, uint32_t millisec)
{
#if INCLUDE_vTaskDelayUntil
TickType_t ticks = (millisec / portTICK_PERIOD_MS);
vTaskDelayUntil((TickType_t *) PreviousWakeTime, ticks ? ticks : 1);
return osOK;
#else
(void) millisec;
(void) PreviousWakeTime;
return osErrorResource;
#endif
}

Keep an eye out for the next update! Best regards, Heisenberg.
martin239955_stm1
Associate II
Posted on June 08, 2015 at 17:09

Hi Heisenberg

I'm using STM32CubeMX version 4.8.0 with the Firmware Package STM32F3 Version 1.1.1 and it seems that this bug still exists in the cmsis_os.c file.

Could you confirm this?

Kind regards

Martin

basile
Associate II
Posted on June 12, 2015 at 15:14

Hi all,

Thank you for the reply and the suggested fix.

I've just tried with CubeMX v4.8 and STM32F4 package v1.6.0, the issue is still there. As noticed by Cami.

When do you plan to release a fixed version ?

King Regards,

Basile

Posted on October 20, 2015 at 11:37

Hello,

I have updated Cube MX to the latest version some time a go my osDelayUntil routines stopped working. The software is getting stuck inside it. Previously I used to run this in the loop to make a 1 ms delay:

startTick = xTaskGetTickCount();<

br

>osDelayUntil(startTick, 1);

Now it doesnt work and the program is getting stuck. Has something changed in the osDelayUntil usage? Please help I am stuck with not working project :(.

Posted on October 26, 2015 at 12:07

Hi guys,

The bug is already fixed forSTM32CubeF4 v1.9.0, STM32CubeF2 v1.2.0, STM32CubeF0 v1.4.0, STM32CubeF7 v1.2.0, STM32CubeL1 v1.4.0, STM32CubeL4 v1.0.0,STM32CubeF1 v1.2.0and STM32CubeL0 v1.3.0. For STM32CubeF3, the fix will be released in version 1.4.0. The workaround is:

osStatus osDelayUntil (uint32_t *PreviousWakeTime, uint32_t millisec)
{
#if INCLUDE_vTaskDelayUntil
TickType_t ticks = (millisec / portTICK_PERIOD_MS);
vTaskDelayUntil((TickType_t *) PreviousWakeTime, ticks ? ticks : 1);
return osOK;
#else
(void) millisec;
(void) PreviousWakeTime;
return osErrorResource;
#endif
}

We are sorry for inconvenience may bring. -Shahrzad-