HAL_ChibiOS: fetch crash_dump stored in flash

This commit is contained in:
bugobliterator 2021-10-23 12:04:35 +05:30 committed by Andrew Tridgell
parent f9f47cbeeb
commit 29568a23ae
2 changed files with 25 additions and 0 deletions

View File

@ -698,3 +698,22 @@ void Util::log_stack_info(void)
last_tp = tp;
#endif
}
#if defined(HAL_CRASH_DUMP_FLASHPAGE)
void Util::last_crash_dump(ExpandingString &str) const
{
// get dump size
uint32_t size = stm32_crash_dump_size();
char* dump_start = (char*)stm32_flash_getpageaddr(HAL_CRASH_DUMP_FLASHPAGE);
if (!(dump_start[0] == 0x63 && dump_start[1] == 0x43)) {
// there's no valid Crash Dump
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "No Crash Detected!");
return;
}
if (size == 0xFFFFFFFF) {
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "Crash Dump incomplete, dumping what we got!");
size = stm32_flash_getpagesize(HAL_CRASH_DUMP_FLASHPAGE);
}
str.append(dump_start, size);
}
#endif

View File

@ -135,4 +135,10 @@ private:
// log info on stack usage
void log_stack_info(void) override;
#if defined(HAL_CRASH_DUMP_FLASHPAGE)
// get last crash dump
void last_crash_dump(ExpandingString &str) const override;
#endif
};