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

[Feature]: Main Task OS Sanity Check (#1838) #5

Open
wants to merge 1 commit into
base: v1_1_x_release
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions kernel/os/src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ OS_TASK_STACK_DEFINE(g_idle_task_stack, OS_IDLE_STACK_SIZE);

uint32_t g_os_idle_ctr;

static struct os_task os_main_task;
OS_TASK_STACK_DEFINE(os_main_stack, OS_MAIN_STACK_SIZE);
struct os_task g_os_main_task;
OS_TASK_STACK_DEFINE(g_os_main_stack, OS_MAIN_STACK_SIZE);

/*
* Double the interval timer to allow proper timer check-in.
*/
#define OS_MAIN_TASK_TIMER_TICKS \
os_time_ms_to_ticks32(MYNEWT_VAL(OS_MAIN_TASK_SANITY_ITVL_MS)) * 2

#if MYNEWT_VAL(OS_WATCHDOG_MONITOR)

Expand Down Expand Up @@ -227,11 +233,13 @@ os_init(int (*main_fn)(int argc, char **arg))
assert(err == OS_OK);

if (main_fn) {
err = os_task_init(&os_main_task, "main", os_main, main_fn,
OS_MAIN_TASK_PRIO, OS_WAIT_FOREVER, os_main_stack,
OS_STACK_ALIGN(OS_MAIN_STACK_SIZE));
err = os_task_init(&g_os_main_task, "main", os_main, main_fn,
OS_MAIN_TASK_PRIO,
(OS_MAIN_TASK_TIMER_TICKS == 0) ? OS_WAIT_FOREVER : OS_MAIN_TASK_TIMER_TICKS,
g_os_main_stack, OS_STACK_ALIGN(OS_MAIN_STACK_SIZE));
assert(err == 0);
}

/* Call bsp related OS initializations */
hal_bsp_init();

Expand Down
5 changes: 5 additions & 0 deletions kernel/os/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ syscfg.defs:
description: >
If set, assert callback gets called inside __assert_func()
value: 0
OS_MAIN_TASK_SANITY_ITVL_MS:
description: >
Interval for sanity check on main task. Setting a 0 will disable
sanity check on main task. Value is in milliseconds.
value: 0

syscfg.vals.OS_DEBUG_MODE:
OS_CRASH_STACKTRACE: 1
Expand Down