@@ -38,7 +38,6 @@ mbed_rtos_storage_thread_t _main_obj __attribute__((section(".bss.os.thread.cb")
3838
3939osMutexId_t singleton_mutex_id ;
4040mbed_rtos_storage_mutex_t singleton_mutex_obj ;
41- osMutexAttr_t singleton_mutex_attr ;
4241
4342void mbed_rtos_init ()
4443{
@@ -47,11 +46,6 @@ void mbed_rtos_init()
4746
4847MBED_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