Add UBI/UBIFS-aware backup and restore for NAND cameras#142
Merged
Conversation
On NAND cameras with UBI/UBIFS, raw MTD dumps include physical block mappings that are chip-specific and cannot be safely restored. This adds UBI volume-level backup and restore using kernel sysfs and ioctls. Detection: scan /sys/class/ubi/ to find UBI devices attached to MTD partitions and enumerate their volumes with data_bytes and names. Backup: read UBI volumes from /dev/ubiN_V instead of raw /dev/mtdblockN for UBI-managed partitions. Each volume becomes a separate data block. YAML output: add dump_type, ubi_device, and ubi_volumes array with per-volume vol_id, vol_name, data_bytes, and sha1. Restore: UBI-aware path using ioctls (UBI_IOCDET, UBI_IOCATT, UBI_IOCMKVOL, UBI_IOCVOLUP) to detach, erase, reattach, create volumes, and write data. Raw MTD partitions use existing path. Tested on HI3516AV200 with 128MB SPI NAND and 5 UBI volumes. Closes #141 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cross-compile for both ARM and MIPS targets on PRs to catch build errors before merge. Uses the same OpenIPC toolchains as the release workflows but skips packaging, uploads, and notifications. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The OpenIPC ARM musl toolchain has a broken <mtd/ubi-user.h> where __packed is not defined, causing build failures. Replace the include with minimal inlined struct and ioctl definitions guarded by ifndef UBI_IOC_MAGIC. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #141
/sys/class/ubi/sysfs/dev/ubiN_V) instead of raw MTD for UBI-managed partitions, storing actual volume data (no UBI headers)dump_type,ubi_device, andubi_volumesarray to YAML output with per-volumevol_id,vol_name,data_bytes, andsha1UBI_IOCDET,UBI_IOCATT,UBI_IOCMKVOL,UBI_IOCVOLUP) — no dependency on userspace UBI toolsYAML output example (HI3516AV200)
Test plan
dump_type: ubifsandubi_volumesfor all UBI partitions🤖 Generated with Claude Code