Skip to content

Commit 0449825

Browse files
authored
Merge pull request #13034 from hugueskamba/hk_fix_sleep_tracing
ST boards: Fix sleep tracing
2 parents b21d5e8 + 5d94fd4 commit 0449825

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

rtos/source/TARGET_CORTEX/mbed_boot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void mbed_init(void)
9494

9595
void mbed_start(void)
9696
{
97+
mbed_rtos_init_singleton_mutex();
9798
mbed_toolchain_init();
9899
mbed_tfm_init();
99100
mbed_main();

rtos/source/TARGET_CORTEX/mbed_boot.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ void mbed_tfm_init(void);
177177
*/
178178
void mbed_main(void);
179179

180+
/**
181+
* Create and Initialize a Singleton Mutex object.
182+
*
183+
* Precondition(s):
184+
* - The RTOS has been started by a call to mbed_rtos_start
185+
*/
186+
void mbed_rtos_init_singleton_mutex(void);
187+
180188
/**@}*/
181189
/**@}*/
182190

rtos/source/TARGET_CORTEX/mbed_rtos_rtx.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ mbed_rtos_storage_thread_t _main_obj __attribute__((section(".bss.os.thread.cb")
3838

3939
osMutexId_t singleton_mutex_id;
4040
mbed_rtos_storage_mutex_t singleton_mutex_obj;
41-
osMutexAttr_t singleton_mutex_attr;
4241

4342
void mbed_rtos_init()
4443
{
@@ -47,11 +46,6 @@ void mbed_rtos_init()
4746

4847
MBED_NORETURN void mbed_rtos_start()
4948
{
50-
singleton_mutex_attr.name = "singleton_mutex";
51-
singleton_mutex_attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
52-
singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj);
53-
singleton_mutex_attr.cb_mem = &singleton_mutex_obj;
54-
5549
_main_thread_attr.stack_mem = _main_stack;
5650
_main_thread_attr.stack_size = sizeof(_main_stack);
5751
_main_thread_attr.cb_size = sizeof(_main_obj);
@@ -68,7 +62,6 @@ MBED_NORETURN void mbed_rtos_start()
6862
tfm_ns_lock_init();
6963
#endif // defined(TARGET_TFM) && defined(COMPONENT_NSPE)
7064

71-
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
7265
osThreadId_t result = osThreadNew((osThreadFunc_t)mbed_start, NULL, &_main_thread_attr);
7366
if ((void *)result == NULL) {
7467
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Pre main thread not created", &_main_thread_attr);
@@ -77,3 +70,14 @@ MBED_NORETURN void mbed_rtos_start()
7770
osKernelStart();
7871
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Failed to start RTOS");
7972
}
73+
74+
void mbed_rtos_init_singleton_mutex(void)
75+
{
76+
const osMutexAttr_t singleton_mutex_attr = {
77+
.name = "singleton_mutex",
78+
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
79+
.cb_size = sizeof(singleton_mutex_obj),
80+
.cb_mem = &singleton_mutex_obj
81+
};
82+
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
83+
}

0 commit comments

Comments
 (0)