feat(espcoredump): Include boot time and unix time in header

This commit is contained in:
Nebojsa Cvetkovic 2024-05-09 17:35:52 -06:00
parent d4cd437ede
commit 523d526ebe
3 changed files with 16 additions and 2 deletions

View File

@ -66,8 +66,8 @@ extern "C" {
(((_maj_)&0xFF) << 8) | \
(((_min_)&0xFF) << 0) \
)
#define COREDUMP_VERSION_BIN 0
#define COREDUMP_VERSION_ELF 1
#define COREDUMP_VERSION_BIN 1
#define COREDUMP_VERSION_ELF 2
/* legacy bin coredumps (before IDF v4.1) has version set to 1 */
#define COREDUMP_VERSION_BIN_LEGACY COREDUMP_VERSION_MAKE(COREDUMP_VERSION_BIN, 1) // -> 0x0001
@ -146,6 +146,8 @@ typedef struct _core_dump_header_t {
uint32_t tcb_sz; /*!< Size of a TCB, in bytes */
uint32_t mem_segs_num; /*!< Number of memory segments */
uint32_t chip_rev; /*!< Chip revision */
uint64_t boot_time; /*!< Boot time, in microseconds */
uint64_t unix_time; /*!< Unix time, in microseconds */
} core_dump_header_t;
/**

View File

@ -185,6 +185,11 @@ static esp_err_t esp_core_dump_write_binary(void)
hdr.version = COREDUMP_VERSION_BIN_CURRENT;
hdr.tcb_sz = tcb_sz;
hdr.chip_rev = efuse_hal_chip_revision();
dump_hdr.boot_time = esp_timer_get_time();
struct timeval tv;
gettimeofday(&tv, NULL);
dump_hdr.unix_time = tv.tv_sec * 1000000 + tv.tv_usec;
err = esp_core_dump_write_data(&write_data, &hdr, sizeof(core_dump_header_t));
if (err != ESP_OK) {
ESP_COREDUMP_LOGE("Failed to write core dump header error=%d!", err);

View File

@ -17,6 +17,7 @@
#ifdef CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
#include <sys/param.h> // for the MIN macro
#include <sys/time.h>
#include "esp_app_desc.h"
#endif
@ -852,6 +853,12 @@ static esp_err_t esp_core_dump_write_elf(void)
dump_hdr.tcb_sz = 0; // unused in ELF format
dump_hdr.mem_segs_num = 0; // unused in ELF format
dump_hdr.chip_rev = efuse_hal_chip_revision();
dump_hdr.boot_time = esp_timer_get_time();
struct timeval tv;
gettimeofday(&tv, NULL);
dump_hdr.unix_time = tv.tv_sec * 1000000 + tv.tv_usec;
err = esp_core_dump_write_data(&self.write_data, &dump_hdr, sizeof(core_dump_header_t));
if (err != ESP_OK) {
ESP_COREDUMP_LOGE("Failed to write core dump header (%d)!", err);