Wrong timing in sys_arch.c in function sys_arch_mbox_fetch (LwIP)
Hallo,
I try to use LwIP with freertos. The sw was generated via CubeMX.
I have problems to get it running. So I did some investigations. I found some strange behavior of the overall timing.
DHCP retrys when failling getting the IP-address. But the time between retrys are very long.
The reason for this behavior seams to be a failure in
"STM32CubeFX/Middlewares/Third_Party/LwIP/system/OS/sys_arch.c, Release v1.16.0! in function "sys_arch_mbox_fetch".
It is the line 184
....
#else
status = osMessageQueueGet(*mbox, msg, 0, timeout);
if (status == osOK)
....
As mentioned in the description of the function the value timeout is [ms]. The caller of "sys_arch_mbox_fetch" uses [ms] as it seams to me.
But osMessageQueueGet expects [kernel-ticks] (CMSIS-RTOS2, RTOS V2).
As long as kernel-ticks has a length of 1ms everything works as expected. I thing CubeMx generates the default value 1ms.
But I changed the kernel-tick to 10ms; so the waiting time is 10 times of timeout.
A proposal for correction:
uint32_t const TickLength_ms = 1000 / osKernelGetTickFreq();
status = osMessageQueueGet( *mbox, msg, 0, timeout / TickLength_ms );
Thanks,
Detlef
