crash-dump Command-Line Tool
crash-dump is the sdk.py command group for capturing, packaging, and analyzing crash context. It is intended for environments without the Trace32/AssertDump GUI, such as CI, Linux/macOS development machines, and remote debugging. Contexts captured this way can still be opened with Trace32/AssertDump, and can also be analyzed offline on a PC.
sdk.py crash-dump --help
sdk.py crash-dump <command> --help
1. Command Overview
Command |
Purpose |
Input |
Main output |
|---|---|---|---|
|
Read memory from a running chip through J-Link or the UART DEBUG IP |
Chip memory, |
Per-region |
|
Read the persisted coredump partition, or package an existing coredump file |
Coredump partition / |
Parsed crash package |
|
Convert a crash package into a GDB-compatible core ELF |
Crash package + firmware ELF |
|
|
Analyze a crash package or core ELF offline |
Crash package / core ELF + firmware ELF |
|
Typical flow:
capture-live ─┐
├─> crash package ─> readcore ─> coredump.elf ─> analyze ─> analysis.json
export-coredump ┘ └─────────> analyze (directly on the package)
Packages produced by capture-live and export-coredump can be passed directly to analyze. readcore is only needed when the context must be opened with GDB or a third-party tool.
Terms used in this document:
Crash package: the directory holding the captured memory and metadata; it is the exchange format between the commands in this tool chain.
Region: one memory block defined by a
savebinline in the.jlinkscript (for examplehcpu_ram.bin).AssertDump / Trace32: PC-side GUI tools for inspecting a crash context; both can open a crash package directory directly.
UART DEBUG IP: the serial debug protocol built into SiFli chips;
--transport uartuses it to read and write memory.saved_stack_frame: the register frame saved by the firmware’s fault handler, used to reconstruct the instant the exception occurred.
2. Crash Package Layout
The output directory of both capture commands is a crash package. Common contents:
File/directory |
Description |
|---|---|
|
Captured memory for each region |
|
Full SDK metadata, including |
|
AssertDump-compatible metadata ( |
|
Copies of |
|
Firmware image and log used by AssertDump/Trace32 (copy of |
|
Produced only by |
|
Produced only by |
|
GDB core file generated by |
Note:
manifest.jsonandsdk_manifest.jsonhave different roles. The full metadata lives insdk_manifest.json;validate_package()prefers it and only falls back tomanifest.jsonwhen it is absent (for example, a package without the compatible directory).
3. Prerequisites
The SDK environment is initialized (
./export.ps1on Windows,source ./export.shon Linux/macOS) andsdk.pyis available; the environment already includes pyserial, pyelftools, andarm-none-eabi-gdbfrom the GCC toolchain, so no extra installation is needed;An ELF/AXF that exactly matches the crashed firmware (
build_<board>/main.elf), otherwise symbols and addresses will be wrong;--transport jlinkrequires the J-Link software (JLink.exeon Windows,JLinkExeelsewhere); use--jlinkto specify a full path;The examples use relative paths and assume the project directory (the directory containing
build_<board>) as the working directory. When running elsewhere, use absolute paths;<SDK_ROOT>denotes the SDK root.
4. capture-live
4.1 Transports
|
Connection |
Dependency |
Chip support |
Current-register source |
|---|---|---|---|---|
|
J-Link probe over USB, or the SifliUsartServer IP service |
J-Link software |
All series |
J-Link log |
|
Direct serial connection using the SiFli UART DEBUG IP protocol |
pyserial |
SF32LB52X / SF32LB56X only |
Read through UART-DAP |
The uart transport does not require J-Link hardware, AssertDump.exe, or uart_server, so it suits pure USB-serial setups on Windows, macOS, and Linux. It still uses the .jlink scripts under tools/AssertDump/ to define which regions are captured.
4.2 Options
Option |
Description |
|---|---|
|
|
|
Required; chip series such as |
|
Required; output directory. Prefer an empty directory or clean old files first |
|
Required for |
|
J-Link executable path; platform default is used when omitted |
|
Connect to J-Link/usart_server over IP, for example |
|
|
|
Custom |
|
Exact part number (for example |
|
Use the part-specific PSRAM script; must be combined with |
|
Select a PSRAM script by capacity, for example |
|
Firmware ELF; copied into |
|
Serial/debug log; copied into the package and used by |
|
Print the manifest JSON instead of the output path; progress still goes to stderr |
--probe-rsis currently accepted for compatibility but is not used; a non-default value prints a warning to stderr.
.jlink script selection priority:
The script passed with
--script;--chip-model+--include-psram: the script mapped to that part inAssertDump.ini;--chip-modelwithout--include-psram:<chip>_psramless.jlink;--psram-size:<chip>_psram_<size>.jlink;None of the above:
<chip>_psramless.jlink.
The priority list applies only to combinations that pass option validation: --include-psram alone (without --chip-model) fails before script selection, and --script cannot be combined with --chip-model, --psram-size, or --include-psram.
--chip-model and --psram-size cannot be combined (the command fails). Drop --chip-model when selecting a capacity manually.
58X note: the default is
sf32lb58x_psramless.jlink, which captures RAM only. To include PSRAM, use--chip-model <part> --include-psram. 58X has a dual-bank PSRAM layout (scripts are namedsf32lb58x_psram_<size>_<size>.jlink), so--psram-sizeonly works with single-capacity scripts and fails withAssertDump script not foundon 58X; use a part number or--scriptinstead.
4.3 Examples
UART (Windows):
sdk.py crash-dump capture-live \
--transport uart \
--probe COM5 \
--chip SF32LB52 \
--chip-model LB525 \
--include-psram \
--output ./live-crash \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf
UART (Linux):
sdk.py crash-dump capture-live \
--transport uart \
--probe /dev/ttyUSB0 \
--chip SF32LB52 \
--chip-model LB525 \
--output ./live-crash \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf
J-Link over USB:
sdk.py crash-dump capture-live \
--transport jlink \
--chip SF32LB57 \
--chip-model SF32LB575UCNN6 \
--core hcpu \
--output ./live-crash \
--elf build_dpi-hdk_lb575ucnn6_a128_qspi_hcpu/main.elf
J-Link over IP (SifliUsartServer):
sdk.py crash-dump capture-live \
--transport jlink \
--jlink-ip 127.0.0.1:19025 \
--chip SF32LB52 \
--output ./live-crash \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf
J-Link (58X; a part number and --include-psram are needed to capture PSRAM):
sdk.py crash-dump capture-live \
--transport jlink \
--chip SF32LB58 \
--chip-model LB583 \
--include-psram \
--output ./live-crash \
--elf build_ec-lb583_hcpu/main.elf
Alternatively, pass an explicit script on 58X:
sdk.py crash-dump capture-live \
--transport jlink \
--chip SF32LB58 \
--script <SDK_ROOT>/tools/AssertDump/sf32lb58x_psram_8MB_8MB.jlink \
--output ./live-crash \
--elf build_ec-lb583_hcpu/main.elf
4.4 Output
One
*.binpersavebinentry in the.jlinkscript (for examplehcpu_ram.bin,psram.bin);sdk_manifest.json: full SDK metadata includingsegments,current_registers,current_register_source, andwarnings;manifest.json: AssertDump-compatible metadata;hcpu.axf: copy of--elfwhen provided;capture.jlinkandcapture.log: generated script and J-Link log for thejlinktransport (capture.logis also copied aslog.txt);The output directory can be used directly as a Trace32/AssertDump context directory.
The output directory is itself a crash package and can be passed directly to readcore --package and analyze --package.
5. export-coredump
Use this when the firmware has persisted the crash context into a coredump partition, or to convert an existing coredump.bin into a crash package.
5.1 Enabling the coredump partition
Firmware side (middleware/coredump/Kconfig, configurable in menuconfig):
Enable
Core Dump for Offline Debugging(USING_COREDUMP=y);Select the
Partition Backend;The partition name defaults to
coredump;Optionally enable
Enable minidump, which needs a separate partition (default namemindump).
Partition table side: tag the corresponding ptab region:
{
"offset": "0x00BA0000",
"max_size": "0x00100000",
"tags": ["COREDUMP_REGION"]
},
{
"offset": "0x00B20000",
"max_size": "0x00080000",
"tags": ["COREDUMP_MIN_REGION"]
}
--ptab accepts only the legacy JSON list format (base + offset + max_size + tags); ptab.yaml is not supported. A complete, working template is example/system/coredump/project/sf32lb52-lcd_n16r8_hcpu/ptab.json, where the full region is 0x12BA0000 / 0x100000 and the minimum region is 0x12B20000 / 0x80000.
FAL partition table: the firmware locates the partition by name with fal_partition_find(), so custom_mem_map.h in the project (or the board-level file of the same name) must also map the partition names to those regions (adjust the flash device name to your configuration):
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WORD, "mindump", NOR_FLASH2_DEV_NAME, COREDUMP_MIN_REGION_OFFSET, COREDUMP_MIN_REGION_SIZE, 0}, \
{FAL_PART_MAGIC_WORD, "coredump", NOR_FLASH2_DEV_NAME, COREDUMP_REGION_OFFSET, COREDUMP_REGION_SIZE, 0}, \
}
The names must match COREDUMP_PARTITION_NAME / COREDUMP_MINIDUMP_PART_NAME in menuconfig. See example/system/coredump/project/sf32lb52-lcd_n16r8_hcpu/custom_mem_map.h for a complete example.
The
customer/boards/**/ptab.jsonfiles shipped with the SDK do not carry these tags by default. Reusing one directly fails withPTAB tag not found: COREDUMP_REGION; add the tags as shown above, or use--address/--size.
5.2 Two Input Modes
Input |
Required options |
Notes |
|---|---|---|
Coredump partition on flash |
|
Read through |
Existing coredump file |
|
Chip model and timestamp come from the file header; read options such as |
The coredump header has the form <52X|55X|56X|57X|58X>_<timestamp> (24 bytes). A mismatched header reports invalid coredump header.
--kind selects the partition-table region and only takes effect in --ptab mode:
full(default):COREDUMP_REGION;minimum:COREDUMP_MIN_REGION.
5.3 Options
Option |
Description |
|---|---|
|
Required; output directory. Prefer an empty directory or clean old files first |
|
Existing coredump file |
|
|
|
Chip series; not needed in |
|
Legacy ptab.json (JSON list format) used to locate the coredump region |
|
Specify the coredump region directly; mutually exclusive with |
|
|
|
Memory type for |
|
Required for |
|
Serial baud rate; default |
|
|
|
J-Link executable path |
|
Only used to define regions when rebuilding the AssertDump-compatible directory (same selection rules as section 4.2; 58X needs a part number + |
|
Attach the firmware ELF and log |
|
Print the manifest JSON |
5.4 Examples
Read by partition table (UART + sftool):
sdk.py crash-dump export-coredump \
--transport uart \
--chip SF32LB52 \
--ptab <SDK_ROOT>/example/system/coredump/project/sf32lb52-lcd_n16r8_hcpu/ptab.json \
--port COM5 \
--output ./coredump-pkg
Read by address/size (J-Link; addresses taken from the template above):
sdk.py crash-dump export-coredump \
--transport jlink \
--chip SF32LB52 \
--address 0x12BA0000 \
--size 0x100000 \
--output ./coredump-pkg
Read the minidump (only in --ptab mode):
sdk.py crash-dump export-coredump \
--chip SF32LB52 \
--ptab <SDK_ROOT>/example/system/coredump/project/sf32lb52-lcd_n16r8_hcpu/ptab.json \
--kind minimum \
--port COM5 \
--output ./coredump-pkg
Package an existing file:
sdk.py crash-dump export-coredump \
--input ./coredump.bin \
--output ./coredump-pkg \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf
5.5 Output
coredump.bin: the raw coredump;segments/<index>-0x<address>.bin: memory segments split from the coredump blocks;ramlogs/minimum.bin,ramlogs/remaining.bin: firmware RAM logs when present in the dump;sdk_manifest.json: full metadata containingraw,segments,ramlogs,chip, andwarnings;manifest.json: AssertDump-compatible metadata;AssertDump-compatible directory:
*.binfiles reconstructed fromsegmentsaccording to the.jlinkscript regions, plussdk_manifest.json, andhcpu.axf/log.txtwhen--elf/--logis given; regions not covered by the coredump are listed inlegacy.missinginsdk_manifest.json.
6. readcore
Converts a crash package into a GDB-compatible core ELF.
sdk.py crash-dump readcore \
--package ./live-crash \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf \
--output ./live-crash/coredump.elf
Option |
Description |
|---|---|
|
Required; output directory of |
|
Firmware ELF; may be omitted when the package already has an attached ELF; when both exist, their SHA-256 must match |
|
Output path; defaults to |
The generated ELF creates a PT_LOAD segment for each memory region and carries registers in a PT_NOTE. Registers are taken, in order, from registers in the package’s sdk_manifest.json (the current registers for capture-live packages), the packaged J-Link log, and the saved_stack_frame symbol.
arm-none-eabi-gdb build_sf32lb52-lcd_n16r8_hcpu/main.elf \
-ex "core-file ./live-crash/coredump.elf" \
-ex "bt"
7. analyze
sdk.py crash-dump analyze --package ./live-crash --engine python
sdk.py crash-dump analyze \
--core ./live-crash/coredump.elf \
--elf build_sf32lb52-lcd_n16r8_hcpu/main.elf
Option |
Description |
|---|---|
|
Crash package directory |
|
Core ELF; |
|
Firmware ELF; may be omitted in |
|
|
|
Output path; defaults to |
|
Print the analysis JSON to stdout; the analysis file is still written |
Engine behavior:
python: uses only pyelftools and the package data;gdb: in--packagemode, generatescoredump.elfviareadcorefirst if it is missing;auto: tries GDB only whencoredump.elfalready exists in the package; otherwise it uses Python directly. If GDB partially fails, it falls back to Python and keepsgdb_partial.
Two kinds of registers appear in the result and mean different things:
current_registers/current_register_source: the current CPU registers read by the debugger at capture time, useful for determining where the chip is stopped;saved_registers/saved_register_source: the registers at the exception instant, decoded from the firmwaresaved_stack_frame; ifsaved_stack_pointerorerror_reasonlooks invalid, trust the current registers instead.
The result also includes symbols for pc/lr, scb, error_reason, stack_pointer, and stack_candidates.
8. Troubleshooting
Symptom |
Cause and fix |
|---|---|
|
No |
|
The ELF does not match the firmware used at capture time; both |
|
Relative paths resolve against the current directory; run from the project directory or use absolute paths |
|
The serial port is mandatory for |
|
|
|
|
|
The required |
|
|
|
Install the J-Link software or pass |
|
The GCC toolchain environment is not exported, or use |
|
Partition mode is missing the chip series or the region information |
|
|
|
Drop |
|
|
|
A custom script already defines the capture range; script-selection options cannot be added |
|
|
|
The partition table has no coredump tag; see section 5.1, or use |
|
The |
|
The |