mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-12 10:13:29 +00:00
Report the crash log to mdash
This commit is contained in:
@@ -117,27 +117,6 @@ int main(void) {
|
||||
|
||||
MG_INFO(("Initialised. CPU clock: %lu MHz", SystemCoreClock / 1000000));
|
||||
|
||||
// Report the previous boot's crash backtrace, if any
|
||||
if (mg_health_reason() == MG_HEALTH_RESET_FAULT) {
|
||||
uint32_t *r = mg_health_record.backtrace;
|
||||
static char buf[512];
|
||||
size_t len = mg_snprintf(
|
||||
buf, sizeof(buf),
|
||||
"{\"image\":\"firmware.elf\",\"binary\":\"firmware.bin\","
|
||||
"\"regs\":{\"sp\":\"0x%08lx\",\"lr\":\"0x%08lx\","
|
||||
"\"pc\":\"0x%08lx\"},\"stack\":{\"addr\":\"0x%08lx\","
|
||||
"\"words\":[",
|
||||
(unsigned long) r[CRASH_SP], (unsigned long) r[CRASH_LR],
|
||||
(unsigned long) r[CRASH_PC], (unsigned long) r[CRASH_SP]);
|
||||
for (size_t i = CRASH_STACK; i < MG_HEALTH_BACKTRACE; i++) {
|
||||
len += mg_snprintf(buf + len, sizeof(buf) - len, "%s\"0x%08lx\"",
|
||||
i == CRASH_STACK ? "" : ",",
|
||||
(unsigned long) r[i]);
|
||||
}
|
||||
mg_snprintf(buf + len, sizeof(buf) - len, "]}}");
|
||||
MG_INFO(("Previous boot crash: %s", buf));
|
||||
}
|
||||
|
||||
struct mg_mgr mgr;
|
||||
mg_mgr_init(&mgr);
|
||||
mg_http_listen(&mgr, "http://0.0.0.0", http_ev_handler, NULL);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
// Crash report support. Health record lives in the .mg_health region, see link.ld
|
||||
#define MG_HEALTH_RAM __attribute__((section(".mg_health")))
|
||||
#define MG_HEALTH_BACKTRACE 1022 // fill the 4KB backup SRAM
|
||||
|
||||
// mdash.net device management service support
|
||||
#define MG_ENABLE_MDASH 1
|
||||
|
||||
Reference in New Issue
Block a user