mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
coredump: added the chip_rev field into the coredump header
This commit is contained in:
parent
02a9be9292
commit
ba51b09cb2
@ -66,9 +66,9 @@ extern "C" {
|
||||
|
||||
/* 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
|
||||
#define COREDUMP_VERSION_BIN_CURRENT COREDUMP_VERSION_MAKE(COREDUMP_VERSION_BIN, 2) // -> 0x0002
|
||||
#define COREDUMP_VERSION_ELF_CRC32 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 0) // -> 0x0100
|
||||
#define COREDUMP_VERSION_ELF_SHA256 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 1) // -> 0x0101
|
||||
#define COREDUMP_VERSION_BIN_CURRENT COREDUMP_VERSION_MAKE(COREDUMP_VERSION_BIN, 3) // -> 0x0003
|
||||
#define COREDUMP_VERSION_ELF_CRC32 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 2) // -> 0x0102
|
||||
#define COREDUMP_VERSION_ELF_SHA256 COREDUMP_VERSION_MAKE(COREDUMP_VERSION_ELF, 3) // -> 0x0103
|
||||
#define COREDUMP_CURR_TASK_MARKER 0xDEADBEEF
|
||||
#define COREDUMP_CURR_TASK_NOT_FOUND -1
|
||||
|
||||
@ -143,6 +143,7 @@ typedef struct _core_dump_header_t
|
||||
uint32_t tasks_num; /*!< Number of tasks */
|
||||
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 */
|
||||
} core_dump_header_t;
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "core_dump_binary.h"
|
||||
#include "esp_core_dump_port.h"
|
||||
#include "esp_core_dump_common.h"
|
||||
#include "hal/efuse_hal.h"
|
||||
|
||||
#if CONFIG_ESP_COREDUMP_DATA_FORMAT_BIN
|
||||
|
||||
@ -175,6 +176,7 @@ esp_err_t esp_core_dump_write_binary(core_dump_write_config_t *write_cfg)
|
||||
hdr.data_len = data_len;
|
||||
hdr.version = COREDUMP_VERSION_BIN_CURRENT;
|
||||
hdr.tcb_sz = tcb_sz;
|
||||
hdr.chip_rev = efuse_hal_chip_revision();
|
||||
err = write_cfg->write(write_cfg->priv, &hdr, sizeof(core_dump_header_t));
|
||||
if (err != ESP_OK) {
|
||||
ESP_COREDUMP_LOGE("Failed to write core dump header error=%d!", err);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "esp_core_dump_port.h"
|
||||
#include "esp_core_dump_port_impl.h"
|
||||
#include "esp_core_dump_common.h"
|
||||
#include "hal/efuse_hal.h"
|
||||
|
||||
#ifdef CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF
|
||||
#include "esp_app_desc.h"
|
||||
@ -608,6 +609,7 @@ esp_err_t esp_core_dump_write_elf(core_dump_write_config_t *write_cfg)
|
||||
dump_hdr.tasks_num = 0; // unused in ELF format
|
||||
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();
|
||||
err = write_cfg->write(write_cfg->priv,
|
||||
(void*)&dump_hdr,
|
||||
sizeof(core_dump_header_t));
|
||||
|
@ -3,8 +3,6 @@ components/efuse/efuse_table_gen.py
|
||||
components/efuse/test_efuse_host/efuse_tests.py
|
||||
components/esp_local_ctrl/python/esp_local_ctrl_pb2.py
|
||||
components/esp_netif/test_apps/component_ut_test.py
|
||||
components/espcoredump/corefile/gdb.py
|
||||
components/espcoredump/test/test_espcoredump.py
|
||||
components/lwip/weekend_test/net_suite_test.py
|
||||
components/mbedtls/esp_crt_bundle/gen_crt_bundle.py
|
||||
components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/test_gen_crt_bundle.py
|
||||
|
@ -12,7 +12,7 @@ import time
|
||||
from base64 import b64decode
|
||||
from textwrap import indent
|
||||
from threading import Thread
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from click import INT
|
||||
from click.core import Context
|
||||
@ -70,6 +70,18 @@ def get_openocd_arguments(target: str) -> str:
|
||||
return str(OPENOCD_TAGET_CONFIG.get(target, default_args))
|
||||
|
||||
|
||||
def chip_rev_to_int(chip_rev: Optional[str]) -> Union[int, None]:
|
||||
# The chip rev will be derived from the elf file if none are returned.
|
||||
# The chip rev must be supplied for coredump files generated with idf versions less than 5.1 in order to load
|
||||
# rom elf file.
|
||||
if not chip_rev or not all(c.isdigit() or c == '.' for c in chip_rev):
|
||||
return None
|
||||
if '.' not in chip_rev:
|
||||
chip_rev += '.0'
|
||||
major, minor = map(int, chip_rev.split('.'))
|
||||
return major * 100 + minor
|
||||
|
||||
|
||||
def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
OPENOCD_OUT_FILE = 'openocd_out.txt'
|
||||
GDBGUI_OUT_FILE = 'gdbgui_out.txt'
|
||||
@ -137,6 +149,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
args: PropertyDict,
|
||||
gdb_timeout_sec: int = None,
|
||||
core: str = None,
|
||||
chip_rev: str = None,
|
||||
save_core: str = None) -> CoreDump:
|
||||
|
||||
ensure_build_directory(args, ctx.info_name)
|
||||
@ -146,6 +159,20 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
coredump_to_flash = coredump_to_flash_config.rstrip().endswith('y') if coredump_to_flash_config else False
|
||||
|
||||
prog = os.path.join(project_desc['build_dir'], project_desc['app_elf'])
|
||||
args.port = args.port or get_default_serial_port()
|
||||
|
||||
espcoredump_kwargs = dict()
|
||||
|
||||
espcoredump_kwargs['port'] = args.port
|
||||
espcoredump_kwargs['baud'] = args.baud
|
||||
espcoredump_kwargs['gdb_timeout_sec'] = gdb_timeout_sec
|
||||
espcoredump_kwargs['chip_rev'] = chip_rev_to_int(chip_rev)
|
||||
|
||||
# for reproducible builds
|
||||
extra_gdbinit_file = project_desc.get('debug_prefix_map_gdbinit', None)
|
||||
|
||||
if extra_gdbinit_file:
|
||||
espcoredump_kwargs['extra_gdbinit_file'] = extra_gdbinit_file
|
||||
|
||||
espcoredump_kwargs: Dict[str, Any] = dict()
|
||||
core_format = None
|
||||
@ -527,8 +554,10 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
args: PropertyDict,
|
||||
gdb_timeout_sec: int,
|
||||
core: str = None,
|
||||
chip_rev: str = None,
|
||||
save_core: str = None) -> None:
|
||||
espcoredump = _get_espcoredump_instance(ctx=ctx, args=args, gdb_timeout_sec=gdb_timeout_sec, core=core,
|
||||
chip_rev=chip_rev,
|
||||
save_core=save_core)
|
||||
|
||||
espcoredump.info_corefile()
|
||||
@ -537,8 +566,9 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
ctx: Context,
|
||||
args: PropertyDict,
|
||||
core: str = None,
|
||||
chip_rev: str = None,
|
||||
save_core: str = None) -> None:
|
||||
espcoredump = _get_espcoredump_instance(ctx=ctx, args=args, core=core, save_core=save_core)
|
||||
espcoredump = _get_espcoredump_instance(ctx=ctx, args=args, core=core, chip_rev=chip_rev, save_core=save_core)
|
||||
|
||||
espcoredump.dbg_corefile()
|
||||
|
||||
@ -547,6 +577,12 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
||||
'names': ['--core', '-c'],
|
||||
'help': 'Path to core dump file (if skipped core dump will be read from flash)',
|
||||
},
|
||||
{
|
||||
'names': ['--chip-rev'],
|
||||
'help': 'Specify the chip revision (e.g., 0.1). If provided, the corresponding ROM ELF file will be used '
|
||||
'for decoding the core dump, improving stack traces. This is only needed for core dumps from IDF '
|
||||
'<v5.1. Newer versions already contain chip revision information.',
|
||||
},
|
||||
{
|
||||
'names': ['--save-core', '-s'],
|
||||
'help': 'Save core to file. Otherwise temporary core file will be deleted.',
|
||||
|
Loading…
x
Reference in New Issue
Block a user