Skip to content

Add ipctool backup format support to defib restore#60

Merged
widgetii merged 1 commit intomasterfrom
feature/ipctool-backup-restore
Apr 22, 2026
Merged

Add ipctool backup format support to defib restore#60
widgetii merged 1 commit intomasterfrom
feature/ipctool-backup-restore

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

defib restore now accepts ipctool backup files directly — no extraction step needed.

# One command to restore from ipctool backup:
defib restore -c hi3516av200 -i backup.bin \
  --uboot u-boot.bin -p /dev/ttyUSB0 --power-cycle

How it works

  • Auto-detects ipctool format from ---\n YAML prefix
  • Extracts mtdparts from embedded YAML (no --mtdparts needed)
  • Extracts partition data blocks (YAML + null + [4-byte len + data]*)
  • UBI partitions auto-detected from UBIFS magic and written via ubi write

Also fixes

  • mtdparts parser for -(name) fill-remainder syntax (last partition)

Test result

Full round-trip on hi3516av200 (128MB SPI NAND):

  1. ipctool backup on live camera → test-backup.bin (110MB, 7 partitions)
  2. defib restore -i test-backup.bin → all 7 partitions written
  3. Cold boot → all 6 UBIFS volumes mount, vendor firmware runs
UBIFS: mounted "rootfs"    ✓
UBIFS: mounted "data"      ✓
UBIFS: mounted "upgradefs" ✓
UBIFS: mounted "appfs"     ✓
UBIFS: mounted "exdata"    ✓
(none) login:              ✓
Sony IMX385 → OK           ✓

Test plan

  • 326 tests pass, lint + mypy clean
  • Restore from ipctool backup file on real hardware
  • All UBIFS volumes mount after cold boot
  • Vendor firmware fully operational

🤖 Generated with Claude Code

defib restore now accepts ipctool backup files (.bin with YAML header)
directly. Auto-detects the format from the "---\n" YAML prefix, extracts
partition layout (mtdparts) and UBI metadata from embedded YAML, and
extracts data blocks — no manual extraction step needed.

Usage:
  defib restore -c hi3516av200 -i backup.bin \
    --uboot u-boot.bin --power-cycle

Also fix mtdparts parser for "-(name)" fill-remainder syntax.

Tested end-to-end: ipctool backup on live camera → defib restore from
.bin file → cold boot with all 7 partitions and 6 UBIFS volumes mounted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit c2c99da into master Apr 22, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant