Skip to content

Commit e79ae2f

Browse files
committed
ST boards: Fix sleep tracing
Prevent singleton lock if the RTOS is not yet ready. lp_ticker is used during the RTOS initialization process. ST lp_ticker implementation calls sleep functions which in turn attempts to print to the console when sleep tracing is enabled. Console initialization attempts to lock the singleton mutex.
1 parent 9a8c9e2 commit e79ae2f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

rtos/source/TARGET_CORTEX/mbed_boot.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@
6464
#include "mbed_error.h"
6565
#include "mbed_mpu_mgmt.h"
6666

67+
#ifdef MBED_CONF_RTOS_PRESENT
68+
#include "cmsis_os2.h"
69+
#endif
70+
71+
#ifdef MBED_CONF_RTOS_PRESENT
72+
extern osMutexId_t singleton_mutex_id;
73+
extern osMutexAttr_t singleton_mutex_attr;
74+
#endif
75+
6776
int main(void);
6877
static void mbed_cpy_nvic(void);
6978

@@ -94,6 +103,9 @@ void mbed_init(void)
94103

95104
void mbed_start(void)
96105
{
106+
#ifdef MBED_CONF_RTOS_PRESENT
107+
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
108+
#endif // MBED_CONF_RTOS_PRESENT
97109
mbed_toolchain_init();
98110
mbed_tfm_init();
99111
mbed_main();

rtos/source/TARGET_CORTEX/mbed_rtos_rtx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ MBED_NORETURN void mbed_rtos_start()
6868
tfm_ns_lock_init();
6969
#endif // defined(TARGET_TFM) && defined(COMPONENT_NSPE)
7070

71-
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
7271
osThreadId_t result = osThreadNew((osThreadFunc_t)mbed_start, NULL, &_main_thread_attr);
7372
if ((void *)result == NULL) {
7473
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Pre main thread not created", &_main_thread_attr);

0 commit comments

Comments
 (0)