chibios-code-r17689-branches-stable_21.11.x
Hi all!
I tried to run the demo HAL-STM32F407-DISCOVERY and found that it gets stuck upon the second call to osalThreadSleepMilliseconds(500) in main. The very first call works OK.
Code: Select all
while (true) {
chnWriteTimeout(&SD2, (uint8_t *)"Hello World!\r\n", 14, TIME_INFINITE);
palSetPad(GPIOD, GPIOD_LED3); /* Orange. */
osalThreadSleepMilliseconds(500);
palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
osalThreadSleepMilliseconds(500);
}Debugging into, i foud that the program circles in void vtSetI(virtual_timer_t *vtp,....
A quick check of the same demo using branch ChibiOS_20.3.4 shows it working as expected.
A diff of osal.c of both branches shows one single difference in function msg_t osalThreadSuspendS(thread_reference_t *trp)
In chibios_stable-21.11.x (not working):
Code: Select all
msg_t osalThreadSuspendS(thread_reference_t *trp) {
static thread_t self = {MSG_WAIT};
osalDbgCheck(trp != NULL);
*trp = &self;
while (self.message == MSG_WAIT) {
osalSysUnlock();
/* A state-changing interrupt could occur here and cause the loop to
terminate, an hook macro is executed while waiting.*/
OSAL_IDLE_HOOK();
osalSysLock();
}
return self.message;
}In ChibiOS_20.3.4 (working OK):
Code: Select all
msg_t osalThreadSuspendS(thread_reference_t *trp) {
thread_t self = {MSG_WAIT};
osalDbgCheck(trp != NULL);
*trp = &self;
while (self.message == MSG_WAIT) {
osalSysUnlock();
/* A state-changing interrupt could occur here and cause the loop to
terminate, an hook macro is executed while waiting.*/
OSAL_IDLE_HOOK();
osalSysLock();
}
return self.message;
}So declaring thread_t self = {MSG_WAIT} static seems to be the problem.
Removing static from the declaration makes the demo run OK in trunk.
Best regards,
Wolf