Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST boards: Fix sleep tracing #13034

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rtos/source/TARGET_CORTEX/mbed_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void mbed_init(void)

void mbed_start(void)
{
mbed_rtos_init_singleton_mutex();
mbed_toolchain_init();
mbed_tfm_init();
mbed_main();
Expand Down
8 changes: 8 additions & 0 deletions rtos/source/TARGET_CORTEX/mbed_boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ void mbed_tfm_init(void);
*/
void mbed_main(void);

/**
* Create and Initialize a Singleton Mutex object.
*
* Precondition(s):
* - The RTOS has been started by a call to mbed_rtos_start
*/
void mbed_rtos_init_singleton_mutex(void);

/**@}*/
/**@}*/

Expand Down
18 changes: 11 additions & 7 deletions rtos/source/TARGET_CORTEX/mbed_rtos_rtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mbed_rtos_storage_thread_t _main_obj __attribute__((section(".bss.os.thread.cb")

osMutexId_t singleton_mutex_id;
mbed_rtos_storage_mutex_t singleton_mutex_obj;
osMutexAttr_t singleton_mutex_attr;

void mbed_rtos_init()
{
Expand All @@ -47,11 +46,6 @@ void mbed_rtos_init()

MBED_NORETURN void mbed_rtos_start()
{
singleton_mutex_attr.name = "singleton_mutex";
singleton_mutex_attr.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust;
singleton_mutex_attr.cb_size = sizeof(singleton_mutex_obj);
singleton_mutex_attr.cb_mem = &singleton_mutex_obj;

_main_thread_attr.stack_mem = _main_stack;
_main_thread_attr.stack_size = sizeof(_main_stack);
_main_thread_attr.cb_size = sizeof(_main_obj);
Expand All @@ -68,7 +62,6 @@ MBED_NORETURN void mbed_rtos_start()
tfm_ns_lock_init();
#endif // defined(TARGET_TFM) && defined(COMPONENT_NSPE)

singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
osThreadId_t result = osThreadNew((osThreadFunc_t)mbed_start, NULL, &_main_thread_attr);
if ((void *)result == NULL) {
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Pre main thread not created", &_main_thread_attr);
Expand All @@ -77,3 +70,14 @@ MBED_NORETURN void mbed_rtos_start()
osKernelStart();
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Failed to start RTOS");
}

void mbed_rtos_init_singleton_mutex(void)
{
const osMutexAttr_t singleton_mutex_attr = {
.name = "singleton_mutex",
.attr_bits = osMutexRecursive | osMutexPrioInherit | osMutexRobust,
.cb_size = sizeof(singleton_mutex_obj),
.cb_mem = &singleton_mutex_obj
};
singleton_mutex_id = osMutexNew(&singleton_mutex_attr);
}