From cc5969b1ec221c647253e9fcb96e7a9a6fad3adf Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 8 Jan 2019 15:00:56 -0600 Subject: [PATCH 1/4] Remove printf completely and fix the optimization check --- platform/mbed_error.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/platform/mbed_error.c b/platform/mbed_error.c index 97134e232c5..01e6e06ebab 100644 --- a/platform/mbed_error.c +++ b/platform/mbed_error.c @@ -211,24 +211,16 @@ mbed_error_status_t mbed_error_initialize(void) //Read report_error_ctx and check if CRC is correct, and with valid status code if ((report_error_ctx->crc_error_ctx == crc_val) && (report_error_ctx->is_error_processed == 0)) { is_reboot_error_valid = true; - //Report the error info -#ifndef NDEBUG - printf("\n== The system has been rebooted due to a fatal error. ==\n"); -#endif //Call the mbed_error_reboot_callback, this enables applications to do some handling before we do the handling mbed_error_reboot_callback(report_error_ctx); //We let the callback reset the error info, so check if its still valid and do the rest only if its still valid. - if (report_error_ctx->error_reboot_count < 0) { + if (report_error_ctx->error_reboot_count > 0) { //Enforce max-reboot only if auto reboot is enabled #if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) { - //We have rebooted more than enough, hold the system here. -#ifndef NDEBUG - printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count); -#endif mbed_halt_system(); } #endif @@ -300,6 +292,11 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat core_util_critical_section_exit(); //We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception #if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0) + mbed_error_printf("\n= System will be rebooted due to a fatal error =\n"); + if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) { + //We have rebooted more than enough, hold the system here. + mbed_error_printf("= Reboot count(=%ld) reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count); + } system_reset();//do a system reset to get the system rebooted #endif #endif From 62d6eb56733bfeadb4e3ea29db52b575aefe41fe Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Fri, 11 Jan 2019 17:18:40 -0600 Subject: [PATCH 2/4] Increase the timeout for the host side script and the test --- TESTS/host_tests/crash_reporting.py | 2 +- TESTS/mbed_platform/crash_reporting/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TESTS/host_tests/crash_reporting.py b/TESTS/host_tests/crash_reporting.py index bc4a7170784..a5055973891 100644 --- a/TESTS/host_tests/crash_reporting.py +++ b/TESTS/host_tests/crash_reporting.py @@ -60,7 +60,7 @@ def test_steps(self): wait_after_reset = wait_after_reset if wait_after_reset is not None else DEFAULT_CYCLE_PERIOD #Wait 2 seconds for system to init - time.sleep(2.0) + time.sleep(7.0) #self.send_kv(MSG_KEY_SYNC, MSG_VALUE_DUMMY) self.send_kv(MSG_KEY_DEVICE_ERROR, MSG_VALUE_DUMMY) time.sleep(5.0) diff --git a/TESTS/mbed_platform/crash_reporting/main.cpp b/TESTS/mbed_platform/crash_reporting/main.cpp index dab00237de1..b8488f99223 100644 --- a/TESTS/mbed_platform/crash_reporting/main.cpp +++ b/TESTS/mbed_platform/crash_reporting/main.cpp @@ -67,7 +67,7 @@ void test_crash_reporting() int main(void) { - GREENTEA_SETUP(30, "crash_reporting"); + GREENTEA_SETUP(40, "crash_reporting"); test_crash_reporting(); GREENTEA_TESTSUITE_RESULT(0); From 815066f8530f7b4715b03e98ab34f1b60aa89338 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Tue, 22 Jan 2019 16:37:13 -0600 Subject: [PATCH 3/4] Add debug prints to triage the test timeouts --- TESTS/mbed_platform/crash_reporting/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TESTS/mbed_platform/crash_reporting/main.cpp b/TESTS/mbed_platform/crash_reporting/main.cpp index b8488f99223..d971099c854 100644 --- a/TESTS/mbed_platform/crash_reporting/main.cpp +++ b/TESTS/mbed_platform/crash_reporting/main.cpp @@ -53,12 +53,17 @@ void test_crash_reporting() // Report readiness greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY); + printf("\nMessage sent: %s\n", MSG_KEY_DEVICE_READY); static char _key[MSG_KEY_LEN + 1] = { }; static char _value[MSG_VALUE_LEN + 1] = { }; + printf("\nWaiting for crash inject error message: %s\n", MSG_KEY_DEVICE_ERROR); greentea_parse_kv(_key, _value, MSG_KEY_LEN, MSG_VALUE_LEN); + printf("\nCrash inject error message received\n"); + if (strcmp(_key, MSG_KEY_DEVICE_ERROR) == 0) { + printf("\nForcing error\n"); MBED_ERROR1(MBED_ERROR_OUT_OF_MEMORY, "Executing crash reporting test.", 0xDEADBAD); TEST_ASSERT_MESSAGE(0, "crash_reporting() error call failed."); } From d0b95031c5629fbd29dd804dc2b472702ddedd18 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Wed, 23 Jan 2019 17:33:10 -0600 Subject: [PATCH 4/4] Print crash report reboot messages only for non-release builds --- platform/mbed_error.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/mbed_error.c b/platform/mbed_error.c index 01e6e06ebab..11b584b11ab 100644 --- a/platform/mbed_error.c +++ b/platform/mbed_error.c @@ -292,11 +292,13 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat core_util_critical_section_exit(); //We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception #if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0) +#ifndef NDEBUG mbed_error_printf("\n= System will be rebooted due to a fatal error =\n"); if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) { //We have rebooted more than enough, hold the system here. mbed_error_printf("= Reboot count(=%ld) reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count); } +#endif system_reset();//do a system reset to get the system rebooted #endif #endif