Skip to content

hi3516cv300: build the NAND image again, the uImage inside the UBIFS rootfs - #3006

Merged
openipc-ai merged 1 commit into
masterfrom
hi3516cv300-nand-ubifs
Nov 29, 2026
Merged

openipc-ai merged 1 commit into
masterfrom
hi3516cv300-nand-ubifs

Conversation

@openipc-ai

@openipc-ai openipc-ai commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#3005: no hi3516cv300 SPI NAND release can be booted with the U-Boot we publish for it.

This puts the UBI symbols back in hi3516cv300_ultimate_defconfig and adds board/hi3516cv300/ubinize-nand.cfg. With a ubinize-nand.cfg and no nand-fit.its, the existing packaging from #2970 (nt98566) applies:

  • external.mk puts the uImage into the UBIFS as /boot/uImage;
  • repack ships uImage, rootfs.ubifs and rootfs.ubi;
  • sysupgrade takes the uImage as the SoC witness.

There is no FIT because the cv300 uImage already carries its DTB (CONFIG_ARM_APPENDED_DTB=y), and it is the same kernel the NOR image boots. The kernel config already has HIFMC100_SPI_NAND, MTD_UBI, UBIFS_FS and MTD_CMDLINE_PARTS.

hi3516ev100 shares board/hi3516cv300/ but builds no UBI, so the /boot hook and the NAND repack never run for it.

Hardware tested on

Not on a camera. There is no hi3516cv300 board with SPI NAND in the lab, and the #3005 reporter's Dahua DH-IPC-HMW7230 (W25N01GV) would be the first real one.

What was run instead is a qemu-bench digital twin: the hi3516cv300 machine with a W25N01GV SPI NAND (nand-jedec=0xEFAA21, 64-byte OOB). Its flash is laid out the way an install writes it:

Offset Contents
0x000000 the published u-boot-hi3516cv300-nand.bin from latest
0x0C0000 blank env
0x100000 rootfs.ubi

It booted from flash through that U-Boot, with no -kernel and no -initrd. The emulated SoC is only as good as the model, so this does not stand in for a camera: SPI NAND timing, real bad blocks and the sensor are not exercised.

Evidence

rootfs.ubi comes from a local make BOARD=hi3516cv300_ultimate of this branch (3700fb4). That build produced the same three files with the same size lines as the CI job:

- firmware.bin: [8704KB/15808KB]
- uImage: [1668KB/2048KB read by the bootloader]
- rootfs.ubi: [16256KB/24576KB]

openipc.hi3516cv300-nand-ultimate.tgz:
  uImage.hi3516cv300  rootfs.ubifs.hi3516cv300  rootfs.ubi.hi3516cv300  (+ .md5sum)

Before: the same U-Boot, given the rootfs.ubi from the Oct 3 pre-#2537 openipc.hi3516cv300-nand-ultimate.tgz, the one #3005 paired it with. U-Boot finds no kernel and falls through to TFTP, as reported:

Checking UBI firmware...
ubi0: attached mtd3 (name "ubi", size 127 MiB)
Read 64 bytes from volume rootfs to 87ad0e28
Unmounting UBIFS volume rootfs!
Firmware is absent/corrupt (no /boot/fitImage or /boot/uImage)
...
TFTP from server 192.168.1.107; our IP address is 192.168.1.10
Filename 'rootfs.ubifs.hi3516cv300'.

After: this branch's rootfs.ubi:

Checking UBI firmware...
ubi0: volume 1 ("rootfs_data") re-sized from 17 to 833 LEBs
ubi0: attached mtd3 (name "ubi", size 127 MiB)
Hit Ctrl-C to stop autoboot:  1
Loading file '/boot/fitImage' to addr 0x82000000...
** File not found /boot/fitImage **
Loading file '/boot/uImage' to addr 0x82000000...
Done
## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-3.18.20-hi3516cv300
   Data Size:    1708329 Bytes = 1.6 MiB
Starting kernel ...
[    0.000000] Kernel command line: mem=32M console=ttyAMA0,115200 panic=20 init=/init root=ubi0:rootfs rootfstype=ubifs ubi.mtd=2,2048 mtdparts=hinand:768k(boot),256k(env),-(ubi)
[    7.112091] UBIFS: mounted UBI device 0, volume 0, name "rootfs", R/O mode
[    7.113731] VFS: Mounted root (ubifs filesystem) readonly on device 0:12.
[    7.222874] UBIFS: default file-system created
[    7.236409] UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
...
Starting majestic: OK

Welcome to OpenIPC
openipc-hi3516cv300 login:

Selector:

$ python3 .github/scripts/ci-matrix.py --self-test
ci-matrix: self-test ok (143 boards, 183 packages, 81 cases)
$ git diff --name-only origin/master | python3 .github/scripts/ci-matrix.py --stdin
  hi3516cv300_lite hi3516cv300_neo hi3516cv300_ultimate hi3516ev100_lite

Not covered, on the twin or anywhere else:

  • sysupgrade from this package on a running NAND camera;
  • U-Boot's run ur / fwupd path;
  • a chip with factory bad blocks.

Scope

  • No kernel patches under general/package/all-patches/linux/ (those go to OpenIPC/linux)
  • No files specific to a single retail camera model (those go to OpenIPC/builder)
  • No probing or bring-up tooling (that goes to OpenIPC/ipctool)
  • Nothing under general/overlay/ or in a shared load_<vendor> script hardcodes a value specific to my board
  • Package sources come from an OpenIPC repository, and any version bump keeps at least the specificity of the pin it replaces (a new package should pin a full 40-character SHA)
  • No LD_PRELOAD, and no binaries that cannot be rebuilt from source
  • New code is selected by a defconfig, so CI actually builds it

Refs #3005

…rootfs

#2537 stopped building hi3516cv300 NAND images because no bootloader could
boot the kernel-in-UBIFS layout. OpenIPC/u-boot#28 has since added
u-boot-hi3516cv300-nand.bin, which loads /boot/fitImage or else /boot/uImage
from ubi0:rootfs, but nothing here was re-enabled, so the only cv300 NAND
package in the latest release was the pre-#2537 one that U-Boot cannot boot
(#3005).

The NOR uImage carries its DTB (CONFIG_ARM_APPENDED_DTB), so no FIT is needed:
ubinize-nand.cfg alone selects the uImage-in-UBIFS packaging nt98566 uses.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Restore hi3516cv300 SPI NAND images with a UBIFS-embedded kernel

🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

AI Description

• Re-enable hi3516cv300 NAND images compatible with the published NAND U-Boot.
• Place the existing DTB-appended uImage in UBIFS, avoiding a separate kernel volume or FIT.
• Define rootfs and overlay UBI volumes; hardware boot validation remains outstanding.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed defconfig selects the NAND filesystem pipeline, the board configuration defines the rootfs/rootfs_data contract, external.mk places the kernel in the UBIFS target tree, and Makefile repacks the resulting NAND artifacts.
  • These are coordinated steps of one firmware-delivery behavior, not independent technical capabilities.
Sources

br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[39-45]

# SPI NAND: one UBI partition after boot and env, the UBIFS rootfs carrying
# /boot/uImage, as u-boot-hi3516cv300-nand.bin boots it (#3005).
BR2_TARGET_ROOTFS_UBI=y
BR2_TARGET_ROOTFS_UBI_SUBSIZE=2048
BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y
BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/ubinize-nand.cfg"
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x1f000
Behavioral complexity 🟡 Medium 🧩 Compatibility cases, Interacting branches

  • Before: the ultimate configuration generated the existing NOR split firmware path without a NAND UBI artifact.
  • After: it additionally selects UBIFS/UBI, injects uImage into the target tree, creates rootfs and rootfs_data volumes, and takes a NAND-specific repackaging branch.
  • New correctness condition: the Buildroot output, custom volume layout, kernel placement, U-Boot naming contract, and upgrade artifact selection must agree while the existing NOR output remains valid.
  • The branch distinction and cross-stage ordering are introduced by this change; the underlying UBI helpers are reused rather than newly implemented.
Sources

br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[39-45]

# SPI NAND: one UBI partition after boot and env, the UBIFS rootfs carrying
# /boot/uImage, as u-boot-hi3516cv300-nand.bin boots it (#3005).
BR2_TARGET_ROOTFS_UBI=y
BR2_TARGET_ROOTFS_UBI_SUBSIZE=2048
BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y
BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/ubinize-nand.cfg"
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x1f000

br-ext-chip-hisilicon/board/hi3516cv300/ubinize-nand.cfg[12-27]

[rootfs]
mode=ubi
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_alignment=1
image=BR2_ROOTFS_UBIFS_PATH

[rootfs_data]
mode=ubi
vol_id=1
vol_type=dynamic
vol_name=rootfs_data
vol_alignment=1
vol_size=2MiB
vol_flags=autoresize
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the changed NAND layout or generated artifact is incompatible with the expected boot/update contract, a freshly installed or updated camera may fail to boot its rootfs.
  • Reverting source stops future bad artifacts but does not repair an already written NAND image; reinstallation or reflashing is required.
  • The repository does not show external U-Boot implementation, so exact boot failure modes remain an assumption.
  • Reverting restores future builds, but deployed NAND contents require a supported reflash, reinstall, or manual recovery operation; no automatic repair path is established here.
Sources

br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[39-45]

# SPI NAND: one UBI partition after boot and env, the UBIFS rootfs carrying
# /boot/uImage, as u-boot-hi3516cv300-nand.bin boots it (#3005).
BR2_TARGET_ROOTFS_UBI=y
BR2_TARGET_ROOTFS_UBI_SUBSIZE=2048
BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y
BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE="$(EXTERNAL_VENDOR)/board/$(OPENIPC_SOC_FAMILY)/ubinize-nand.cfg"
BR2_TARGET_ROOTFS_UBIFS_LEBSIZE=0x1f000

br-ext-chip-hisilicon/board/hi3516cv300/ubinize-nand.cfg[12-27]

[rootfs]
mode=ubi
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_alignment=1
image=BR2_ROOTFS_UBIFS_PATH

[rootfs_data]
mode=ubi
vol_id=1
vol_type=dynamic
vol_name=rootfs_data
vol_alignment=1
vol_size=2MiB
vol_flags=autoresize
Assessed commit 3700fb4
Diagram

graph TD
  A["cv300 defconfig"] --> B["UBIFS boot hook"] --> C["UBIFS rootfs"] --> D["UBI image"] --> E["NAND U-Boot"]
  A --> F["NAND volume config"] --> D
  E -->|"loads /boot/uImage"| C
Loading
High-Level Assessment

Reusing the existing uImage-in-UBIFS packaging path is the simplest fit for the published bootloader. A FIT or separate kernel volume would add a format or layout that this change does not need; the remaining priority is validating the resulting image on NAND hardware.

Files changed (2) +34 / -0

Bug fix (1) +7 / -0
hi3516cv300_ultimate_defconfigEnable UBI packaging for the ultimate NAND image +7/-0

Enable UBI packaging for the ultimate NAND image

• Enables UBI, selects the new volume configuration, and sets NAND subpage and UBIFS eraseblock sizes. These settings activate the existing path that embeds the DTB-appended uImage at /boot/uImage.

br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig

Other (1) +27 / -0
ubinize-nand.cfgDefine the hi3516cv300 NAND UBI volume layout +27/-0

Define the hi3516cv300 NAND UBI volume layout

• Adds a rootfs volume backed by the generated UBIFS image and an autoresizing rootfs_data volume. Leaves the rootfs size to the existing build hook, which adds headroom.

br-ext-chip-hisilicon/board/hi3516cv300/ubinize-nand.cfg

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Untested NAND image re-enabled for release 📘 Rule violation ≡ Correctness
Description
The defconfig change re-enables the UBI rootfs packaging for hi3516cv300_ultimate, so CI now
produces a SPI NAND image with uImage inside the UBIFS rootfs that boots on real cameras. The PR
description states it was "Not run on a camera" and that the U-Boot and image pair "has not booted
on hardware either", with only a selector run and a self-test offered as evidence. Because the
change alters what the firmware does on a camera (which boot layout is built and shipped), this is
the case the gate names, and the lack of board output is not offset by the CI build, which only
proves the image compiles.
Code

br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[R39-42]

+# SPI NAND: one UBI partition after boot and env, the UBIFS rootfs carrying
+# /boot/uImage, as u-boot-hi3516cv300-nand.bin boots it (#3005).
+BR2_TARGET_ROOTFS_UBI=y
+BR2_TARGET_ROOTFS_UBI_SUBSIZE=2048
Evidence
The defconfig adds the UBI rootfs selection that makes the NAND image ship again, while the PR
description's hardware section says the change was not run on a camera and offers only selector and
self-test output as evidence.

Rule 3: Hardware evidence is present and honest
br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[39-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR re-enables the hi3516cv300 SPI NAND UBI image (`BR2_TARGET_ROOTFS_UBI=y` and the custom `ubinize-nand.cfg` in the ultimate defconfig) but the PR description says it was not run on a camera and offers only a selector run and a self-test. The change alters what the firmware does on a camera, so the evidence must include board output.
## Fix Focus Areas
- br-ext-chip-hisilicon/configs/hi3516cv300_ultimate_defconfig[39-46]
- br-ext-chip-hisilicon/board/hi3516cv300/ubinize-nand.cfg[1-27]
## Recommended Fix
Before merge, boot the built `openipc.hi3516cv300-nand-ultimate.tgz` (uImage, rootfs.ubifs, rootfs.ubi) on a hi3516cv300 with SPI NAND, using the paired U-Boot, and paste the boot log and `ubinfo`/`mount` output into the PR description, replacing the 'Not run on a camera' statement. If no board is available, state that plainly and mark the change as not verified on hardware rather than implying the layout is tested.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit d5aec81 into master Nov 29, 2026
33 of 34 checks passed
@openipc-ai
openipc-ai deleted the hi3516cv300-nand-ubifs branch November 29, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant