mirror of https://github.com/ARMmbed/mbed-os.git
Removing support for printing error-report after reboot and other minor fixes
parent
423b52e1c3
commit
f59b99d889
|
@ -59,6 +59,8 @@ class CrashReportingTest(BaseHostTest):
|
|||
wait_after_reset = self.get_config_item('forced_reset_timeout')
|
||||
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)
|
||||
#self.send_kv(MSG_KEY_SYNC, MSG_VALUE_DUMMY)
|
||||
self.send_kv(MSG_KEY_DEVICE_ERROR, MSG_VALUE_DUMMY)
|
||||
time.sleep(5.0)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#include "mbed.h"
|
||||
#include "mbed_error.h"
|
||||
#include "mbed_crash_data_offsets.h"
|
||||
#include "greentea-client/test_env.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
|
@ -29,33 +30,38 @@
|
|||
#define MSG_KEY_DEVICE_READY "crash_reporting_ready"
|
||||
#define MSG_KEY_DEVICE_ERROR "crash_reporting_inject_error"
|
||||
|
||||
static mbed_error_ctx saved_error_ctx = {0};
|
||||
|
||||
void mbed_error_reboot_callback(mbed_error_ctx *error_context)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_OUT_OF_MEMORY, error_context->error_status);
|
||||
TEST_ASSERT_EQUAL_UINT(1, error_context->error_reboot_count);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT((uint32_t)error_context, ERROR_CONTEXT_LOCATION);
|
||||
memcpy(&saved_error_ctx, error_context, sizeof(mbed_error_ctx));
|
||||
mbed_reset_reboot_error_info();
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_OUT_OF_MEMORY, saved_error_ctx.error_status);
|
||||
TEST_ASSERT_EQUAL_UINT(1, saved_error_ctx.error_reboot_count);
|
||||
|
||||
//Send the ready msg to host to indicate test pass
|
||||
greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY);
|
||||
}
|
||||
|
||||
void test_crash_reporting()
|
||||
{
|
||||
//Clear any previous status
|
||||
mbed_reset_reboot_error_info();
|
||||
|
||||
// Report readiness
|
||||
greentea_send_kv(MSG_KEY_DEVICE_READY, MSG_VALUE_DUMMY);
|
||||
|
||||
static char _key[MSG_KEY_LEN + 1] = { };
|
||||
static char _value[MSG_VALUE_LEN + 1] = { };
|
||||
|
||||
printf("\nWaiting for inject error\n");
|
||||
greentea_parse_kv(_key, _value, MSG_KEY_LEN, MSG_VALUE_LEN);
|
||||
printf("\nGot inject error\n");
|
||||
if (strcmp(_key, MSG_KEY_DEVICE_ERROR) == 0) {
|
||||
printf("\nErroring...\n");
|
||||
MBED_ERROR1(MBED_ERROR_OUT_OF_MEMORY, "Executing crash reporting test.", 0xDEADBAD);
|
||||
TEST_ASSERT_MESSAGE(0, "crash_reporting() error call failed.");
|
||||
}
|
||||
printf("\nWaiting for inject error");
|
||||
TEST_ASSERT_MESSAGE(0, "Unexpected message received.");
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
#include <inttypes.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ERROR_REPORT(ctx, error_msg, error_filename, error_line, print_thread_info) print_error_report(ctx, error_msg, error_filename, error_line, print_thread_info)
|
||||
static void print_error_report(const mbed_error_ctx *ctx, const char *, const char *error_filename, int error_line, bool print_thread_info);
|
||||
#define ERROR_REPORT(ctx, error_msg, error_filename, error_line) print_error_report(ctx, error_msg, error_filename, error_line)
|
||||
static void print_error_report(const mbed_error_ctx *ctx, const char *, const char *error_filename, int error_line);
|
||||
#else
|
||||
#define ERROR_REPORT(ctx, error_msg, error_filename, error_line, print_thread_info) ((void) 0)
|
||||
#define ERROR_REPORT(ctx, error_msg, error_filename, error_line) ((void) 0)
|
||||
#endif
|
||||
|
||||
static core_util_atomic_flag error_in_progress = CORE_UTIL_ATOMIC_FLAG_INIT;
|
||||
|
@ -71,8 +71,8 @@ static unsigned int compute_crc32(const void *data, int datalen)
|
|||
const unsigned int polynomial = 0x04C11DB7; /* divisor is 32bit */
|
||||
unsigned int crc = 0; /* CRC value is 32bit */
|
||||
unsigned char *buf = (unsigned char *)data;//use a temp variable to make code readable and to avoid typecasting issues.
|
||||
|
||||
for (; datalen>0; datalen-- ) {
|
||||
|
||||
for (; datalen > 0; datalen--) {
|
||||
unsigned char b = *buf++;
|
||||
crc ^= (unsigned int)(b << 24); /* move byte into upper 8bit */
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
@ -115,7 +115,7 @@ WEAK MBED_NORETURN void error(const char *format, ...)
|
|||
// Prevent recursion if error is called again during store+print attempt
|
||||
if (!core_util_atomic_flag_test_and_set(&error_in_progress)) {
|
||||
handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0, MBED_CALLER_ADDR());
|
||||
ERROR_REPORT(&last_error_ctx, "Fatal Run-time error", NULL, 0, true);
|
||||
ERROR_REPORT(&last_error_ctx, "Fatal Run-time error", NULL, 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
va_list arg;
|
||||
|
@ -202,32 +202,34 @@ mbed_error_status_t mbed_error_initialize(void)
|
|||
{
|
||||
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
|
||||
uint32_t crc_val = 0;
|
||||
|
||||
|
||||
//Just check if we have valid value for error_status, if error_status is positive(which is not valid), no need to check crc
|
||||
if (report_error_ctx->error_status < 0) {
|
||||
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
|
||||
//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;
|
||||
#if MBED_CONF_PLATFORM_REBOOT_CRASH_REPORT_ENABLED && !defined(NDEBUG)
|
||||
//Report the error info
|
||||
mbed_error_printf("\n== Your last reboot was triggered by an error, below is the error information ==");
|
||||
ERROR_REPORT(report_error_ctx, "System rebooted due to fatal error", MBED_FILENAME, __LINE__, false);
|
||||
#endif
|
||||
printf("\n== The system has been rebooted due to a fatal error. ==\n");
|
||||
|
||||
//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);
|
||||
|
||||
//Enforce max-reboot only if auto reboot is enabled
|
||||
|
||||
//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) {
|
||||
|
||||
//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.
|
||||
mbed_error_printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
|
||||
mbed_halt_system();
|
||||
}
|
||||
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
|
||||
//We have rebooted more than enough, hold the system here.
|
||||
printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
|
||||
mbed_halt_system();
|
||||
}
|
||||
#endif
|
||||
report_error_ctx->is_error_processed = 1;//Set the flag that we already processed this error
|
||||
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
|
||||
report_error_ctx->crc_error_ctx = crc_val;
|
||||
report_error_ctx->is_error_processed = 1;//Set the flag that we already processed this error
|
||||
crc_val = compute_crc32(report_error_ctx, offsetof(mbed_error_ctx, crc_error_ctx));
|
||||
report_error_ctx->crc_error_ctx = crc_val;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -270,7 +272,7 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
|
|||
(void) handle_error(error_status, error_value, filename, line_number, MBED_CALLER_ADDR());
|
||||
|
||||
//On fatal errors print the error context/report
|
||||
ERROR_REPORT(&last_error_ctx, error_msg, filename, line_number, true);
|
||||
ERROR_REPORT(&last_error_ctx, error_msg, filename, line_number);
|
||||
}
|
||||
|
||||
#if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED
|
||||
|
@ -447,7 +449,7 @@ static void print_threads_info(const osRtxThread_t *threads)
|
|||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg, const char *error_filename, int error_line, bool print_thread_info)
|
||||
static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg, const char *error_filename, int error_line)
|
||||
{
|
||||
int error_code = MBED_GET_ERROR_CODE(ctx->error_status);
|
||||
int error_module = MBED_GET_ERROR_MODULE(ctx->error_status);
|
||||
|
@ -520,19 +522,17 @@ static void print_error_report(const mbed_error_ctx *ctx, const char *error_msg,
|
|||
#endif
|
||||
|
||||
#if MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO && defined(MBED_CONF_RTOS_PRESENT)
|
||||
if (print_thread_info) {
|
||||
mbed_error_printf("\nNext:");
|
||||
print_thread(osRtxInfo.thread.run.next);
|
||||
mbed_error_printf("\nNext:");
|
||||
print_thread(osRtxInfo.thread.run.next);
|
||||
|
||||
mbed_error_printf("\nReady:");
|
||||
print_threads_info(osRtxInfo.thread.ready.thread_list);
|
||||
mbed_error_printf("\nReady:");
|
||||
print_threads_info(osRtxInfo.thread.ready.thread_list);
|
||||
|
||||
mbed_error_printf("\nWait:");
|
||||
print_threads_info(osRtxInfo.thread.wait_list);
|
||||
mbed_error_printf("\nWait:");
|
||||
print_threads_info(osRtxInfo.thread.wait_list);
|
||||
|
||||
mbed_error_printf("\nDelay:");
|
||||
print_threads_info(osRtxInfo.thread.delay_list);
|
||||
}
|
||||
mbed_error_printf("\nDelay:");
|
||||
print_threads_info(osRtxInfo.thread.delay_list);
|
||||
#endif
|
||||
mbed_error_printf(MBED_CONF_PLATFORM_ERROR_DECODE_HTTP_URL_STR, ctx->error_status);
|
||||
mbed_error_printf("\n-- MbedOS Error Info --\n");
|
||||
|
|
|
@ -951,8 +951,7 @@ void mbed_error_reboot_callback(mbed_error_ctx *error_context);
|
|||
|
||||
/**
|
||||
* Initialize error handling system, this is called by the mbed-os boot sequence. This is not required to be called by Application unless the boot sequence is overridden by the system implementation.
|
||||
* NOTE: This function also prints the error report to serial terminal if MBED_CONF_PLATFORM_REBOOT_CRASH_REPORT_ENABLED is enabled.
|
||||
* If MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled and if the current reboot count exceeds MBED_CONF_PLATFORM_ERROR_REBOOT_MAX the system will halt when this function is called,
|
||||
* NOTE: If MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled and if the current reboot count exceeds MBED_CONF_PLATFORM_ERROR_REBOOT_MAX the system will halt when this function is called,
|
||||
* and in such cases the caller will not get the control back. Also note that calling this function may trigger mbed_error_reboot_callback() if application side overides mbed_error_reboot_callback().
|
||||
* @return MBED_SUCCESS on success.
|
||||
*
|
||||
|
|
|
@ -114,10 +114,6 @@
|
|||
"help": "Enables crash context capture when the system enters a fatal error/crash.",
|
||||
"value": false
|
||||
},
|
||||
"reboot-crash-report-enabled": {
|
||||
"help": "Enables crash context capture when the system enters a fatal error/crash.",
|
||||
"value": false
|
||||
},
|
||||
"error-reboot-max": {
|
||||
"help": "Maximum number of auto reboots permitted when an error happens.",
|
||||
"value": 1
|
||||
|
@ -139,67 +135,54 @@
|
|||
},
|
||||
"DISCO_L475VG_IOT01A": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"K64F": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"K66F": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_F429ZI": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_F746ZG": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_F767ZI": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_F439ZI": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"UBLOX_EVK_ODIN_W2": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"UBLOX_C030_U201": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUMAKER_PFM_M487": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NRF52840_DK": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_L476RG": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
},
|
||||
"NUCLEO_F411RE": {
|
||||
"crash-capture-enabled": true,
|
||||
"reboot-crash-report-enabled": true,
|
||||
"fatal-error-auto-reboot-enabled": true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue