Skip to content

Commit 2941c8d

Browse files
author
Cruz Monrreal
authored
Merge pull request #9296 from SenRamakri/sen_RemovePrintfCrashReport
Remove printf completely and fix the optimization check
2 parents 7c4668c + d0b9503 commit 2941c8d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

TESTS/host_tests/crash_reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_steps(self):
6060
wait_after_reset = wait_after_reset if wait_after_reset is not None else DEFAULT_CYCLE_PERIOD
6161

6262
#Wait 2 seconds for system to init
63-
time.sleep(2.0)
63+
time.sleep(7.0)
6464
#self.send_kv(MSG_KEY_SYNC, MSG_VALUE_DUMMY)
6565
self.send_kv(MSG_KEY_DEVICE_ERROR, MSG_VALUE_DUMMY)
6666
time.sleep(5.0)

TESTS/mbed_platform/crash_reporting/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ void test_crash_reporting()
5353

5454
// Report readiness
5555
greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY);
56+
printf("\nMessage sent: %s\n", MSG_KEY_DEVICE_READY);
5657

5758
static char _key[MSG_KEY_LEN + 1] = { };
5859
static char _value[MSG_VALUE_LEN + 1] = { };
5960

61+
printf("\nWaiting for crash inject error message: %s\n", MSG_KEY_DEVICE_ERROR);
6062
greentea_parse_kv(_key, _value, MSG_KEY_LEN, MSG_VALUE_LEN);
63+
printf("\nCrash inject error message received\n");
64+
6165
if (strcmp(_key, MSG_KEY_DEVICE_ERROR) == 0) {
66+
printf("\nForcing error\n");
6267
MBED_ERROR1(MBED_ERROR_OUT_OF_MEMORY, "Executing crash reporting test.", 0xDEADBAD);
6368
TEST_ASSERT_MESSAGE(0, "crash_reporting() error call failed.");
6469
}
@@ -67,7 +72,7 @@ void test_crash_reporting()
6772

6873
int main(void)
6974
{
70-
GREENTEA_SETUP(30, "crash_reporting");
75+
GREENTEA_SETUP(40, "crash_reporting");
7176
test_crash_reporting();
7277
GREENTEA_TESTSUITE_RESULT(0);
7378

platform/mbed_error.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,16 @@ mbed_error_status_t mbed_error_initialize(void)
211211
//Read report_error_ctx and check if CRC is correct, and with valid status code
212212
if ((report_error_ctx->crc_error_ctx == crc_val) && (report_error_ctx->is_error_processed == 0)) {
213213
is_reboot_error_valid = true;
214-
//Report the error info
215-
#ifndef NDEBUG
216-
printf("\n== The system has been rebooted due to a fatal error. ==\n");
217-
#endif
218214

219215
//Call the mbed_error_reboot_callback, this enables applications to do some handling before we do the handling
220216
mbed_error_reboot_callback(report_error_ctx);
221217

222218
//We let the callback reset the error info, so check if its still valid and do the rest only if its still valid.
223-
if (report_error_ctx->error_reboot_count < 0) {
219+
if (report_error_ctx->error_reboot_count > 0) {
224220

225221
//Enforce max-reboot only if auto reboot is enabled
226222
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED
227223
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
228-
//We have rebooted more than enough, hold the system here.
229-
#ifndef NDEBUG
230-
printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
231-
#endif
232224
mbed_halt_system();
233225
}
234226
#endif
@@ -300,6 +292,13 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
300292
core_util_critical_section_exit();
301293
//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
302294
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0)
295+
#ifndef NDEBUG
296+
mbed_error_printf("\n= System will be rebooted due to a fatal error =\n");
297+
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
298+
//We have rebooted more than enough, hold the system here.
299+
mbed_error_printf("= Reboot count(=%ld) reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count);
300+
}
301+
#endif
303302
system_reset();//do a system reset to get the system rebooted
304303
#endif
305304
#endif

0 commit comments

Comments
 (0)