Skip to content

install --nand leaves 0 UBI user volumes (rootfs panic); raw 'nand write' of rootfs.ubi fixes it #124

Description

@widgetii

Summary

defib install --nand (non-V500 path) reports success, but the resulting UBI has zero user volumes — the kernel attaches ubi0 (all PEBs good) yet root=ubi0:rootfs fails with VFS: Cannot open root device "ubi0:rootfs" ... error -19 → kernel panic. Writing rootfs.ubi raw with nand write (OpenIPC's own urnand method) produces a correct, bootable UBI.

Environment

  • defib a39e0e2 (master)
  • Target: hi3516ev300, 128 MiB SPI-NAND (W25N01GV), board Rostelecom IPC8232SWC-WE
  • Firmware: openipc.hi3516ev300-nand-ultimate.tgz (contains uImage.hi3516ev300 + rootfs.ubi.hi3516ev300, a full ubinize image, 16121856 bytes)

Repro

defib install -c hi3516ev300 --firmware openipc.hi3516ev300-nand-ultimate.tgz \
  --nand -p /dev/ttyUSB4 --nic eth0 --host-ip <a> --device-ip <b> --output json

{"event": "done", "success": true}

Observed (first boot after install)

ubi0: attaching mtd3
ubi0: attached mtd3 (name "ubi", size 118 MiB)
ubi0: good PEBs: 944, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128   <-- no rootfs volume
...
VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -19
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Code path

src/defib/cli/app.py, non-V500 NAND rootfs branch (~L2867–2888):

await _cmd(f"nand erase 0x{r_off:x} 0x{r_sz:x}", ...)
await _cmd("setenv mtdids nand0=hinand", ...)
await _cmd("setenv mtdparts mtdparts=hinand:1024k(boot),1024k(env),8192k(kernel),-(ubi)", ...)
await _cmd("ubi part ubi", ...)
await _cmd("ubi create rootfs", ...)
await _cmd(f"ubi write 0x{ram_addr:x} rootfs 0x{len(ubifs_data):x}", ...)

This formats a fresh UBI (ubi part ubi), creates a rootfs volume and ubi writes the (extracted) UBIFS into it. In practice this left ubi0 with 0 user volumes on reattach by the kernel — the volume table did not persist as expected from the u-boot ubi create/ubi write session.

Fix that works

Write the shipped rootfs.ubi raw to the ubi partition (exactly what OpenIPC's urnand env macro does), instead of ubi part/ubi create/ubi write:

tftpboot 0x42000000 rootfs.ubi.hi3516ev300
nand erase 0xA00000 0x7600000
nand write 0x42000000 0xA00000 0xf60000      # full 16121856-byte image

After this the kernel attaches ubi0 with user volume: 2 (rootfs + rootfs_data) and UBIFS mounts cleanly; the camera boots OpenIPC and streams.

rootfs.ubi from the OpenIPC release is a complete ubinize image (with volume table) designed for a raw nand write on chips with 0 bad blocks — the ubi write-into-a-created-volume approach does not reproduce it here.

Side note

For a fully bootable result on this board I also had to add ubi.mtd=3,2048 back to bootargs (OpenIPC firstboot regenerates bootargs and drops it) and set fw_setenv sensor sp2305 — but those are OpenIPC firmware-side, not defib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions