From 88d0b163b52803a38e9c316f1ccaf43b4ffd3818 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 7 Dec 2018 10:12:51 -0800 Subject: [PATCH] common:board_crashdump must end in reset! Upstream changes defer the board reset based on the vaule of CONFIG_BOARD_RESET_ON_ASSERT 0 (or not defined) Do not reset on assert >= 1 reset if assertion is in an interrupt handler or the idle task >= 2 on any asertion. up_assert is called from up_hardfault or an asertion failure. Part 1 of up_assert will call out to the board_crashdump Part 2 on return from board_crashdump will then perform the reset. board_crashdump needs a chunk of ram to save the complete context in. It uses &_sdata which is the lowest memory and it will corrupt that memeory. We can therfore can not allow return to the OS, as it could depend on that area of RAM. So all boards need to do a reset at the end of board_crashdump --- src/drivers/boards/common/board_crashdump.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/drivers/boards/common/board_crashdump.c b/src/drivers/boards/common/board_crashdump.c index afde200ce7..20628820c2 100644 --- a/src/drivers/boards/common/board_crashdump.c +++ b/src/drivers/boards/common/board_crashdump.c @@ -336,9 +336,15 @@ __EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint #endif /* BOARD_CRASHDUMP_RESET_ONLY */ -#if defined(CONFIG_BOARD_RESET_ON_CRASH) - board_reset(0); -#endif + /* All boards need to do a reset here! + * + * Since we needed a chunk of ram to save the complete + * context in and have corrupted it. We can not allow + * the OS to run again. We used &_sdata which is the lowest memory + * and it could be used by the OS. + */ + + board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); } #endif /* CONFIG_BOARD_CRASHDUMP */