Commit 1704a668 authored by Alessandro Rubini's avatar Alessandro Rubini

main: check for stack overflow

We are always pretty near to the end of RAM, so now that we
have a reserved stack area, we can also check if it overlows.
When it happens, let's print a message forever, so a user who
comes and see what's up will see it eventually.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 8eb4c296
......@@ -59,6 +59,9 @@ SECTIONS
_ebss = .;
} > ram
/* End of RAM for checking stack overflows */
PROVIDE(_endram = ORIGIN(stack));
/* First location in stack is highest address in STACK */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
}
......
......@@ -149,10 +149,22 @@ static void ui_update()
}
extern uint32_t _endram;
#define ENDRAM_MAGIC 0xbadc0ffe
void check_stack(void)
{
while (_endram != ENDRAM_MAGIC) {
mprintf("Stack overflow!\n");
timer_delay(1000);
}
}
int main(void)
{
wrc_extra_debug = 1;
wrc_ui_mode = UI_SHELL_MODE;
_endram = ENDRAM_MAGIC;
wrc_initialize();
shell_init();
......@@ -190,5 +202,6 @@ int main(void)
ui_update();
wrc_ptp_update();
spll_update_aux_clocks();
check_stack();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment