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

capture-live

Read memory from a running chip through J-Link or the UART DEBUG IP

Chip memory, .jlink script

Per-region *.bin plus metadata (the directory itself is a crash package)

export-coredump

Read the persisted coredump partition, or package an existing coredump file

Coredump partition / coredump.bin

Parsed crash package

readcore

Convert a crash package into a GDB-compatible core ELF

Crash package + firmware ELF

coredump.elf

analyze

Analyze a crash package or core ELF offline

Crash package / core ELF + firmware ELF

analysis.json

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 savebin line in the .jlink script (for example hcpu_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 uart uses 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

*.bin

Captured memory for each region

sdk_manifest.json

Full SDK metadata, including segments, current_registers, legacy, and attachment info; tools read this file first

manifest.json

AssertDump-compatible metadata (items/files); sdk.py rewrites this file when generating the compatible directory

attachments/

Copies of --elf and --log

hcpu.axf, log.txt

Firmware image and log used by AssertDump/Trace32 (copy of --elf; log.txt comes from capture.log for capture-live --transport jlink, or from --log for export-coredump)

coredump.bin, segments/, ramlogs/

Produced only by export-coredump

capture.jlink, capture.log

Produced only by capture-live --transport jlink

coredump.elf

GDB core file generated by readcore

Note: manifest.json and sdk_manifest.json have different roles. The full metadata lives in sdk_manifest.json; validate_package() prefers it and only falls back to manifest.json when it is absent (for example, a package without the compatible directory).

3. Prerequisites

  • The SDK environment is initialized (./export.ps1 on Windows, source ./export.sh on Linux/macOS) and sdk.py is available; the environment already includes pyserial, pyelftools, and arm-none-eabi-gdb from 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 jlink requires the J-Link software (JLink.exe on Windows, JLinkExe elsewhere); use --jlink to 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

--transport

Connection

Dependency

Chip support

Current-register source

jlink (default)

J-Link probe over USB, or the SifliUsartServer IP service

J-Link software

All series

J-Link log

uart

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

--transport

jlink (default) or uart

--chip

Required; chip series such as SF32LB52 or SF32LB56X; still required even when --script is given

--output

Required; output directory. Prefer an empty directory or clean old files first

--probe

Required for uart; serial port (/dev/ttyUSB0, /dev/cu.*, COM5) or a probe-rs selector (VID:PID-index:COM5)

--jlink

J-Link executable path; platform default is used when omitted

--jlink-ip

Connect to J-Link/usart_server over IP, for example 127.0.0.1:19025

--core

hcpu or lcpu; filters regions by file name and removes core-switch commands

--script

Custom .jlink script, overriding the automatic region selection

--chip-model

Exact part number (for example LB525 or SF32LB57BUN3N6), used to look up a script in tools/AssertDump/AssertDump.ini; cannot be combined with --psram-size

--include-psram

Use the part-specific PSRAM script; must be combined with --chip-model, otherwise the command fails

--psram-size

Select a PSRAM script by capacity, for example 8MB; cannot be combined with --chip-model

--elf

Firmware ELF; copied into attachments/ and used for offline analysis

--log

Serial/debug log; copied into the package and used by analyze as a register fallback

--json

Print the manifest JSON instead of the output path; progress still goes to stderr

--probe-rs is currently accepted for compatibility but is not used; a non-default value prints a warning to stderr.

.jlink script selection priority:

  1. The script passed with --script;

  2. --chip-model + --include-psram: the script mapped to that part in AssertDump.ini;

  3. --chip-model without --include-psram: <chip>_psramless.jlink;

  4. --psram-size: <chip>_psram_<size>.jlink;

  5. 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 named sf32lb58x_psram_<size>_<size>.jlink), so --psram-size only works with single-capacity scripts and fails with AssertDump script not found on 58X; use a part number or --script instead.

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 *.bin per savebin entry in the .jlink script (for example hcpu_ram.bin, psram.bin);

  • sdk_manifest.json: full SDK metadata including segments, current_registers, current_register_source, and warnings;

  • manifest.json: AssertDump-compatible metadata;

  • hcpu.axf: copy of --elf when provided;

  • capture.jlink and capture.log: generated script and J-Link log for the jlink transport (capture.log is also copied as log.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 name mindump).

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.json files shipped with the SDK do not carry these tags by default. Reusing one directly fails with PTAB 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

--chip + --ptab, or --chip + --address/--size

Read through sftool or J-Link

Existing coredump file

--input <file>

Chip model and timestamp come from the file header; read options such as --transport, --port, --address, --size, and --ptab are ignored

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

--output

Required; output directory. Prefer an empty directory or clean old files first

--input

Existing coredump file

--transport

uart (default, uses sftool read_flash) or jlink (uses savebin)

--chip

Chip series; not needed in --input mode

--ptab

Legacy ptab.json (JSON list format) used to locate the coredump region

--address, --size

Specify the coredump region directly; mutually exclusive with --ptab

--kind

full (default) or minimum; only used with --ptab

--memory

Memory type for sftool; default nor

--port

Required for uart; serial port, COM5 on Windows

--baud

Serial baud rate; default 1000000

--sftool

sftool executable path; default sftool

--jlink

J-Link executable path

--script, --psram-size, --chip-model, --include-psram

Only used to define regions when rebuilding the AssertDump-compatible directory (same selection rules as section 4.2; 58X needs a part number + --include-psram to cover PSRAM regions)

--elf, --log

Attach the firmware ELF and log

--json

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 containing raw, segments, ramlogs, chip, and warnings;

  • manifest.json: AssertDump-compatible metadata;

  • AssertDump-compatible directory: *.bin files reconstructed from segments according to the .jlink script regions, plus sdk_manifest.json, and hcpu.axf/log.txt when --elf/--log is given; regions not covered by the coredump are listed in legacy.missing in sdk_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

--package

Required; output directory of capture-live or export-coredump

--elf

Firmware ELF; may be omitted when the package already has an attached ELF; when both exist, their SHA-256 must match

--output

Output path; defaults to <package>/coredump.elf

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

--package

Crash package directory

--core

Core ELF; --elf is required as well; this mode always uses GDB and ignores --engine

--elf

Firmware ELF; may be omitted in --package mode when the package has an attached ELF

--engine

python (default, pyelftools only), gdb (GDB only), or auto (try GDB first, then fall back to Python and merge partial results)

--output

Output path; defaults to analysis.json in the package directory (or next to the core ELF)

--json

Print the analysis JSON to stdout; the analysis file is still written

Engine behavior:

  • python: uses only pyelftools and the package data;

  • gdb: in --package mode, generates coredump.elf via readcore first if it is missing;

  • auto: tries GDB only when coredump.elf already exists in the package; otherwise it uses Python directly. If GDB partially fails, it falls back to Python and keeps gdb_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 firmware saved_stack_frame; if saved_stack_pointer or error_reason looks 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

--elf is required when the package has no attached ELF

No --elf was passed at capture time and the package has no attachment; pass --elf to readcore/analyze

ELF sha256 does not match the crash package

The ELF does not match the firmware used at capture time; both readcore and analyze --package verify it

Invalid value for '--elf': Path ... does not exist

Relative paths resolve against the current directory; run from the project directory or use absolute paths

--probe is required for --transport uart

The serial port is mandatory for uart

Cannot extract serial port from probe spec

--probe is not in /dev/... or COMx form

UART live capture only supports SF32LB52X and SF32LB56X

uart capture only supports 52X/56X; use --transport jlink for other chips

AssertDump script not found

The required .jlink script is missing; check tools/AssertDump/. 58X has a dual-bank PSRAM layout; use --chip-model + --include-psram, or --script

AssertDump chip model not found

--chip-model is not listed in AssertDump.ini

JLinkExe/JLink.exe not found

Install the J-Link software or pass --jlink

arm-none-eabi-gdb was not found

The GCC toolchain environment is not exported, or use --engine python

--chip and either --ptab or both --address/--size are required

Partition mode is missing the chip series or the region information

--port is required for UART coredump export

export-coredump --transport uart requires a serial port

--chip-model and --psram-size are mutually exclusive

Drop --chip-model when selecting a capacity manually

--include-psram requires --chip-model

--include-psram is only valid together with a part number

--script cannot be combined with --chip-model, --psram-size, or --include-psram

A custom script already defines the capture range; script-selection options cannot be added

legacy PTAB must be a JSON list

--ptab accepts only the legacy JSON list format; ptab.yaml is not supported

PTAB tag not found: COREDUMP_REGION

The partition table has no coredump tag; see section 5.1, or use --address/--size

invalid coredump header

The --input file was not produced by the firmware, or its header is corrupted

missing output file warning in the manifest

The .jlink regions do not match the captured files, for example a wrong PSRAM size