Skip to content

Fix UBI volume names: resolve from mtdparts before ubi create#57

Merged
widgetii merged 1 commit intomasterfrom
fix/ubi-restore-vol-names
Apr 21, 2026
Merged

Fix UBI volume names: resolve from mtdparts before ubi create#57
widgetii merged 1 commit intomasterfrom
fix/ubi-restore-vol-names

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

The UBI volume name was resolved BEFORE ubi_partmap was populated from --mtdparts, so the first UBI partition always got the filename (mtd2) instead of the real partition name (rootfs). The kernel then couldn't find ubi0:rootfs and panicked with ENODEV (-19).

One-line fix: move vol_name = real_name to after mtdparts parsing.

Test result

Full 7-partition NAND restore on hi3516av200 with 4 UBI volumes — camera boots vendor firmware:

UBIFS: mounted UBI device 0, volume 0, name "rootfs", R/O mode ✓
UBIFS: mounted UBI device 4, volume 0, name "upgradefs" ✓
UBIFS: mounted UBI device 5, volume 0, name "appfs" ✓
UBIFS: mounted UBI device 6, volume 0, name "exdata" ✓
(none) login:   ✓

Command used:

defib restore -c hi3516av200 -i /tmp/restore_av200/ \
  -p /dev/uart-hi3516av200 \
  --uboot ~/git/u-boot-hi3519v101/u-boot-hi3516av200-universal.bin \
  --mtdparts "hinand:1M(boot),4M(kernel),8M(rootfs),16M(data),16M(upgradefs),64M(appfs),19M(exdata)" \
  --power-cycle

Test plan

  • 326 tests pass, lint + mypy clean
  • Full restore on hi3516av200 hardware: all partitions written, camera boots, UBIFS mounts

🤖 Generated with Claude Code

The vol_name was resolved BEFORE ubi_partmap was populated, so the
first UBI partition always used the filename ("mtd2") instead of the
partition name from mtdparts ("rootfs"). Kernel then couldn't find
"ubi0:rootfs" and panicked with ENODEV.

Move vol_name resolution to after mtdparts parsing, using real_name
from ubi_partmap.

Tested on hi3516av200: full 7-partition NAND restore with 4 UBI
volumes. Camera boots vendor firmware, UBIFS mounts all volumes:
  rootfs (mtd2): mounted R/O ✓
  upgradefs (mtd4): recovery completed, mounted ✓
  appfs (mtd5): recovery completed, mounted ✓
  exdata (mtd6): recovery completed, mounted ✓

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 894c2a6 into master Apr 21, 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