Skip to content

novatek: add nt98566_ultimate SPI NAND defconfig, UBIFS packaging, and uImage sysupgrade witness - #2970

Merged
openipc-ai merged 3 commits into
OpenIPC:masterfrom
vlw:nt98566-spinand-ultimate
Nov 27, 2026
Merged

openipc-ai merged 3 commits into
OpenIPC:masterfrom
vlw:nt98566-spinand-ultimate

Conversation

@vlw

@vlw vlw commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds nt98566_ultimate_defconfig for Novatek NT98566 (NA51089) 128 MiB SPI NAND boards running OpenIPC U-Boot (openipc-novatek), UBIFS-with-/boot/uImage packaging, and legacy uImage SoC verification in sysupgrade.

Merge Order / Companion PRs

Commits

  1. novatek: add nt98566_ultimate_defconfig, SPI NAND kernel config, and CI entry — adds nt98566_ultimate_defconfig, Kconfig-ordered nt98566.nand.config (SPI NAND + HWECC, UBI/UBIFS, OF partitions, HW_RANDOM_NVT, no unused PWM), ubinize-nand.cfg (rootfs + autoresize rootfs_data), exfat-openipc + exfatprogs, and registers nt98566_ultimate in .github/scripts/ci-matrix.py (--self-test passes).
  2. build: package UBIFS-with-uImage NAND images for non-FIT U-Boots — enables OPENIPC_UBIFS_BOOT when ubinize-nand.cfg is present (embedding /boot/uImage inside rootfs.ubifs) and adds REPACK_NAND_UBIFS to ship uImage.nt98566, rootfs.ubifs.nt98566, and rootfs.ubi.nt98566 in openipc.nt98566-nand-ultimate.tgz.
  3. sysupgrade: accept legacy uImage SoC witness beside UBIFS rootfs — teaches verify_ubifs_rootfs to fall back to nor_split_soc on uImage.<soc> when no FIT is present (with matching & foreign SoC tests in test_sysupgrade.sh).

Notes on Review Points

  • Why SPI NAND-only (!MTD_SPINOR): In Novatek's kernel (drivers/mtd/spiflash/Kconfig:27), config MTD_SPINOR has depends on (MTD) && (!MTD_SPINAND). A single NT98566 kernel cannot enable both SPI NOR and SPI NAND simultaneously, so shipping a NOR image from a MTD_SPINAND=y build would not boot on SPI NOR (nt98566_lite_defconfig covers SPI NOR).
  • Why /boot/uImage instead of nand-fit.its: OpenIPC/u-boot (openipc-novatek) is built with CONFIG_LEGACY_IMAGE_FORMAT=y (no CONFIG_FIT) and passes the loader's DTB via ${fdtaddr} (ubifsload ${baseaddr} /boot/uImage; bootm ${baseaddr}). The alternative you suggested (teaching verify_ubifs_rootfs to read the SoC from uImage.<soc> + test_sysupgrade.sh coverage) is implemented here.
  • RNG description corrected: nvt-rng uses default quality = 0 (per novatek: nt9856x: add Fudan FM25S01A SPI NAND and enable nvt-rng on NA51089 linux#330).

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

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

Copy link
Copy Markdown

PR Summary by Qodo

Add NT98566 SPI NAND boot support and hardware RNG

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Recognize FM25S01A SPI NAND so NT98566 boards can access their 128 MiB flash.
• Enable Novatek hardware RNG to avoid entropy-related delays during boot.
• Add an ultimate build profile with NAND, UBI/UBIFS, and supporting packages.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: novatek_nand_firmware.
  • The defconfig, UBI layout, kernel configuration, UBIFS boot hook and archive rule jointly produce one deployable NAND firmware artifact for the bounded Novatek NAND integration.
  • The changed witness selection directly governs whether a UBIFS firmware package proceeds to the NAND upgrade; it is a separate operational outcome within the same bounded NAND firmware integration as artifact generation.
Sources

Makefile[247-249]

else ifneq ($(wildcard $(PWD)/br-ext-chip-$(subst ",,$(BR2_OPENIPC_SOC_VENDOR))/board/$(subst ",,$(BR2_OPENIPC_SOC_FAMILY))/ubinize-nand.cfg),)
	@$(call CHECK_SIZE,rootfs.ubi,24576)
	@$(call REPACK_NAND_UBIFS)
Behavioral complexity 🟡 Medium 🧩 Compatibility cases, Interacting branches

  • Before, NAND packaging used the existing generic or FIT-specific path.
  • After, a layout predicate selects a third archive contract and the rootfs hook chooses FIT versus uImage.
  • New correctness conditions are that the selected board layout, embedded kernel name, model-suffixed witness, checksums and archive contents remain mutually consistent across NOR+NAND builds and legacy versus FIT boot formats.
Sources

Makefile[247-249]

else ifneq ($(wildcard $(PWD)/br-ext-chip-$(subst ",,$(BR2_OPENIPC_SOC_VENDOR))/board/$(subst ",,$(BR2_OPENIPC_SOC_FAMILY))/ubinize-nand.cfg),)
	@$(call CHECK_SIZE,rootfs.ubi,24576)
	@$(call REPACK_NAND_UBIFS)

Makefile[455-464]

NAND_UBIFS_IMAGES = uImage rootfs.ubifs rootfs.ubi
define REPACK_NAND_UBIFS
	cd $(TARGET)/images && for f in $(NAND_UBIFS_IMAGES); do \
		if [ -f $$f ]; then cp -f $$f $$f.$(BR2_OPENIPC_SOC_MODEL); fi && \
		test -f $$f.$(BR2_OPENIPC_SOC_MODEL) && \
		md5sum $$f.$(BR2_OPENIPC_SOC_MODEL) > $$f.$(BR2_OPENIPC_SOC_MODEL).md5sum || exit 1; done
	# Checksums first, as in REPACK_FIRMWARE.
	cd $(TARGET)/images && tar -czf openipc.$(BR2_OPENIPC_SOC_MODEL)-nand-$(BR2_OPENIPC_VARIANT).tgz \
		$(foreach f,$(NAND_UBIFS_IMAGES),$(f).$(BR2_OPENIPC_SOC_MODEL).md5sum) \
		$(foreach f,$(NAND_UBIFS_IMAGES),$(f).$(BR2_OPENIPC_SOC_MODEL))
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the changed build composition or archive contract is wrong, the affected NAND release can be unusable or refused by upgrade tooling; rebuilding the artifact is supported, and no device-side write is implied by the build alone.
  • Rebuild and republish the affected firmware artifact.
  • A device already running older firmware is unaffected unless the faulty artifact is activated.
Sources

Makefile[247-249]

else ifneq ($(wildcard $(PWD)/br-ext-chip-$(subst ",,$(BR2_OPENIPC_SOC_VENDOR))/board/$(subst ",,$(BR2_OPENIPC_SOC_FAMILY))/ubinize-nand.cfg),)
	@$(call CHECK_SIZE,rootfs.ubi,24576)
	@$(call REPACK_NAND_UBIFS)

Makefile[455-464]

NAND_UBIFS_IMAGES = uImage rootfs.ubifs rootfs.ubi
define REPACK_NAND_UBIFS
	cd $(TARGET)/images && for f in $(NAND_UBIFS_IMAGES); do \
		if [ -f $$f ]; then cp -f $$f $$f.$(BR2_OPENIPC_SOC_MODEL); fi && \
		test -f $$f.$(BR2_OPENIPC_SOC_MODEL) && \
		md5sum $$f.$(BR2_OPENIPC_SOC_MODEL) > $$f.$(BR2_OPENIPC_SOC_MODEL).md5sum || exit 1; done
	# Checksums first, as in REPACK_FIRMWARE.
	cd $(TARGET)/images && tar -czf openipc.$(BR2_OPENIPC_SOC_MODEL)-nand-$(BR2_OPENIPC_VARIANT).tgz \
		$(foreach f,$(NAND_UBIFS_IMAGES),$(f).$(BR2_OPENIPC_SOC_MODEL).md5sum) \
		$(foreach f,$(NAND_UBIFS_IMAGES),$(f).$(BR2_OPENIPC_SOC_MODEL))
Assessed commit 050162e
Diagram

graph TD
  Build["Ultimate defconfig"] --> Kernel["NA51089 kernel"] --> NAND["SPI NAND driver"] --> Flash[("FM25S01A flash")] --> UBI["UBI / UBIFS"]
  Kernel --> RNG["Novatek HWRNG"] --> CRNG["Kernel CRNG"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Derive NAND configuration from the generic kernel config
  • ➕ Keeps board-wide kernel settings synchronized
  • ➕ Makes NAND-specific changes easier to review
  • ➖ Requires fragment application or config-generation wiring beyond the existing custom-config path

Recommendation: Keep the complete NAND configuration for compatibility with the existing Buildroot custom-config approach. Because it substantially duplicates the generic NT98566 configuration, consider generating it from a small NAND-specific fragment if the build workflow can reliably reproduce the result.

Files changed (4) +2781 / -0

Enhancement (2) +35 / -0
0001-spinand-add-fudan-fm25s01a.patchRecognize FM25S01A in the Novatek SPI NAND table +14/-0

Recognize FM25S01A in the Novatek SPI NAND table

• Adds the Fudan FM25S01A device ID and geometry to the vendor SPI NAND driver so the kernel can identify the board's flash.

br-ext-chip-novatek/board/nt9856x/kernel/patches/0001-spinand-add-fudan-fm25s01a.patch

0002-hwrng-enable-nvt-rng-for-na51089.patchEnable and credit Novatek RNG on NA51089 +21/-0

Enable and credit Novatek RNG on NA51089

• Allows the existing RNG driver on NA51089 and sets its reported quality to 1000 so its output can initialize the kernel CRNG promptly.

br-ext-chip-novatek/board/nt9856x/kernel/patches/0002-hwrng-enable-nvt-rng-for-na51089.patch

Other (2) +2746 / -0
nt98566.nand.configConfigure the NT98566 NAND kernel +2673/-0

Configure the NT98566 NAND kernel

• Adds a complete Linux 4.19.91 configuration with Novatek SPI NAND and hardware ECC, UBI/UBIFS, device-tree partitions, hardware RNG, and PWM enabled.

br-ext-chip-novatek/board/nt9856x/nt98566.nand.config

nt98566_ultimate_defconfigAdd an ultimate profile for 128 MiB NAND boards +73/-0

Add an ultimate profile for 128 MiB NAND boards

• Adds a Buildroot profile that applies the kernel patches, selects the NAND kernel configuration, declares 128 MiB flash, and includes UBI utilities and ultimate-variant application packages.

br-ext-chip-novatek/configs/nt98566_ultimate_defconfig

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. NAND builds ship no UBI root filesystem ✓ Resolved
Description
nt98566_ultimate_defconfig selects CPIO and SquashFS but never enables Buildroot's UBI filesystem
target, despite selecting a kernel with UBI and UBIFS support. The packaging rule therefore skips
NAND image generation and produces a NOR-style package without the intended rootfs.ubi or
rootfs.ubifs for a 128 MiB SPI NAND board.

2. NAND upgrades lack the images they need ✓ Resolved
Description
nt98566_ultimate_defconfig adds a NAND kernel configuration, but its board family has no
nand-fit.its, so enabling UBI image generation would still take the legacy uImage and
rootfs.ubi packaging branch. A camera using the current kernel-in-rootfs UBIFS layout expects
fitImage and rootfs.ubifs in its upgrade package; the alternative separate-kernel-volume layout
is explicitly refused by sysupgrade.


Remediation recommended

3. ExFAT cards cannot mount on this image ✓ Resolved
Description
nt98566_ultimate_defconfig installs exfatprogs, but the NAND kernel configuration has no exFAT
filesystem driver and the defconfig does not select the repository's out-of-tree exFAT module
package. The tools can check or format a card, but a camera built from this configuration cannot
mount that card as exFAT.

4. Kernel updates retain a local patch burden 🐞 Bug ⚙ Maintainability
Description
0001-spinand-add-fudan-fm25s01a.patch and the RNG patch modify the OpenIPC/linux kernel through
firmware-local patches, without an identified pull request to that owning repository or a removal
point. A subsequent kernel revision must carry and revalidate both changes locally rather than
taking the flash and RNG support from the kernel source it fetches.
Code

br-ext-chip-novatek/board/nt9856x/kernel/patches/0001-spinand-add-fudan-fm25s01a.patch[R8-11]

++	// Fudan Micro
++	{"FM25S01A 1GiB 3.3V",
++		{ .id = {0xA1, 0xE4} },
++		SZ_2K, SZ_128, SZ_128K, 0, 2, 64 },
Evidence
The new defconfig fetches its kernel from OpenIPC/linux yet applies both new firmware-local driver
patches. The supplied PR context identifies a companion U-Boot pull request, not an owning-kernel
pull request or a patch retirement plan.

br-ext-chip-novatek/configs/nt98566_ultimate_defconfig[20-25]
br-ext-chip-novatek/board/nt9856x/kernel/patches/0001-spinand-add-fudan-fm25s01a.patch[1-14]
br-ext-chip-novatek/board/nt9856x/kernel/patches/0002-hwrng-enable-nvt-rng-for-na51089.patch[1-21]

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 new flash and RNG support is maintained as firmware-local patches against an OpenIPC-owned kernel, with no identified upstream kernel change or patch retirement point.
## Fix Focus Areas
- br-ext-chip-novatek/board/nt9856x/kernel/patches/0001-spinand-add-fudan-fm25s01a.patch[8-11]
- br-ext-chip-novatek/board/nt9856x/kernel/patches/0002-hwrng-enable-nvt-rng-for-na51089.patch[5-18]
- br-ext-chip-novatek/configs/nt98566_ultimate_defconfig[20-25]
## Recommended Fix
Submit the minimal driver changes to OpenIPC/linux and identify that pull request here. If the local patches bridge a kernel release, document the kernel-version bump at which they will be removed.

ⓘ 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 commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai openipc-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the full NAND bring-up. The approach, a UBIFS rootfs with the kernel inside it booted by openipc-novatek U-Boot, matches what that U-Boot looks for (/boot/fitImage or /boot/uImage). Several things block the merge.

Changes requested

  1. Register the board with CI. python3 .github/scripts/ci-matrix.py --self-test currently fails with: nt98566_ultimate has a defconfig but nothing builds it; add it to ALL_BOARDS, or to UNBUILT_BOARDS with the reason if that is deliberate. Add it to ALL_BOARDS.

  2. Drop board/nt9856x/kernel/patches/ and BR2_LINUX_KERNEL_PATCH. Kernel changes belong in OpenIPC/linux, and you've opened OpenIPC/linux#330 for that. The "bridge until OPENIPC_KERNEL is bumped" plan doesn't work here because there is no pin to bump: OPENIPC_KERNEL is novatek-nt9856x, and the defconfig downloads that branch's tarball. As soon as #330 merges, this board stops building. I checked: applying 0001-spinand-add-fudan-fm25s01a.patch the way Buildroot does (patch -p1 -t -N) to #330's spinand.c gives Reversed (or previously applied) patch detected! Skipping patch. with exit 1, which apply-patches.sh turns into Patch failed!. The patch also needs fuzz 2 against today's branch. Land #330 first (it needs one ECC change, see that PR), then remove the patches here.

  3. ultimate has to keep the NOR package, or this needs a different home. All 30 *_ultimate_defconfigs in the tree set BR2_TARGET_ROOTFS_SQUASHFS=y, and the 7 with NAND ship the NAND image in addition (e.g. hi3516ev300_ultimate: one kernel config, FLASH_SIZE="16", squashfs and UBI). This defconfig drops squashfs and builds the kernel with # CONFIG_MTD_SPINOR is not set, which would make nt98566 the only SoC whose ultimate has no NOR image. Please keep SPI NOR in the kernel and build both rootfs types (FLASH_SIZE="16"), as the other NOR+NAND ultimates do. Watch the kernel cap while doing it: today's nt98566_lite uImage is about 1.86 MiB against the 2048 KB NOR limit.

  4. sysupgrade cannot verify a local archive of this package. On the ubifs layout, verify_ubifs_rootfs takes the SoC from the FIT beside rootfs.ubifs (fit_soc "$(kernel_image)", which is /tmp/fitImage.<soc>). This package has no FIT, so a --url upgrade passes on the artifact name, but an upgrade from a local archive dies with Cannot verify the SoC of a UBIFS rootfs: no FIT kernel beside it names one unless the user passes --force_soc. A device-profile camera dies on the platform check either way. The tree's existing route avoids all of this: ship board/nt9856x/nand-fit.its (see hi3516ev200's). rootfs_script.sh builds the FIT, OPENIPC_UBIFS_BOOT puts it in /boot, and REPACK_NAND_FIT packages it. That also removes the need for the new REPACK_NAND_UBIFS branch in the Makefile and the external.mk change. Right now those two key on any family that has a ubinize-nand.cfg and no FIT, an implicit trigger that only nt9856x hits today. If a FIT doesn't fit Novatek's appended-DTB kernel, say why. The alternative is then to teach verify_ubifs_rootfs to read the SoC from the uImage.<soc> name field, with a case in test_sysupgrade.sh.

  5. Keep the kernel config to what the NAND board needs, and correct the description. CONFIG_PWM, CONFIG_PWM_SYSFS and CONFIG_PWM_NA51055 have nothing to do with SPI NAND, and nothing in the image uses them: drop them, or name the consumer. For the RNG, the description still says "rng.quality = 1000 so crng initializes immediately" and "/dev/hwrng fast crng init". That assignment was removed after review, and with quality 0 the 4.19 hwrng core credits no entropy, so the claim no longer holds. Please update the text. I checked the RNG itself on a lab NT98566 and it works (details on linux#330), so keeping CONFIG_HW_RANDOM_NVT is fine once #330 provides the dependency. Also move the CONFIG_UBIFS_* block from the end of nt98566.nand.config into Kconfig order, i.e. regenerate the file rather than appending to it.

  6. Paste the hardware evidence. Please include the actual output from the Dahua board: the make size lines, the boot dmesg (spinand identify, UBI attach, rootfs mount), cat /proc/mtd, ubinfo -a, df, and one sysupgrade run from this package onto the installed camera.

  7. Squash the history. Commit 4 says "drop unused exfatprogs", commit 5 adds it back, and commit 6 is a review fixup. Rebase into logical commits (kernel config plus defconfig, packaging) with messages that describe the final state.

@vlw vlw changed the title novatek: nt98566: add FM25S01A SPI NAND, enable HWRNG, and add ultimate SPI NAND defconfig novatek: add nt98566_ultimate SPI NAND defconfig, UBIFS packaging, and uImage sysupgrade witness Nov 27, 2026
@vlw
vlw force-pushed the nt98566-spinand-ultimate branch from b217887 to 6c6a433 Compare November 27, 2026 13:52
@vlw

vlw commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all review items and squashed into 3 clean commits (b9ae53f, 844d213, 6c6a433):

  1. CI matrix: Registered nt98566_ultimate in .github/scripts/ci-matrix.py (ALL_BOARDS); python3 .github/scripts/ci-matrix.py --self-test passes (138 boards, 180 packages, 81 cases).
  2. Removed local kernel patches: Dropped board/nt9856x/kernel/patches/ and BR2_LINUX_KERNEL_PATCH; this PR now depends on novatek: nt9856x: add Fudan FM25S01A SPI NAND and enable nvt-rng on NA51089 linux#330 landing first.
  3. SPI NOR vs SPI NAND mutual exclusion: In Novatek's drivers/mtd/spiflash/Kconfig:27, MTD_SPINOR has depends on (MTD) && (!MTD_SPINAND) — a single NT98566 kernel cannot enable both drivers at once, so nt98566_ultimate stays SPI NAND-only (nt98566_lite covers SPI NOR).
  4. sysupgrade local archive verification without FIT: openipc-novatek U-Boot has CONFIG_LEGACY_IMAGE_FORMAT=y (no CONFIG_FIT) and boots /boot/uImage with the loader's DTB at ${fdtaddr}. Implemented the alternative you suggested: verify_ubifs_rootfs now falls back to nor_split_soc() on uImage.<soc> beside rootfs.ubifs, with matching and foreign SoC test cases added to .github/scripts/test_sysupgrade.sh.
  5. Kernel config cleanup: Dropped CONFIG_PWM*, regenerated nt98566.nand.config in Kconfig order via olddefconfig, and corrected the RNG description.
  6. Hardware evidence from Dahua DH-IPC-HFW2449SP-S-IL (NT98566 / NA51089, 128 MB DDR3, Fudan FM25S01A 128 MiB SPI NAND, SC430AI):

Build output (BOARD=nt98566_ultimate make)

ubinize: volume size was not specified in section "rootfs", assume minimum to fit image ".../rootfs.ubifs" 13967360 bytes (13.3 MiB)
- rootfs.ubi: [14336KB/24576KB]
uImage.nt98566          2060920 bytes (Linux-4.19.91-nt98566)
rootfs.ubifs.nt98566   13967360 bytes
rootfs.ubi.nt98566     14680064 bytes

Boot dmesg, /proc/mtd, ubinfo -a, df -h

# dmesg | grep -iE "nand|mtd|ubi|rng|exfat"
Kernel command line: mem=48M console=ttyS0,115200 panic=20 init=/init root=ubi0:rootfs rootfstype=ubifs ubi.mtd=2,2048 mtdparts=spi_nand.0:2816k(boot),256k(env),-(ubi)
nvt_rng f0680000.rng: Register nvt_rng_probe successfully
nand: device found, Manufacturer ID: 0xa1, Chip ID: 0xe4
nand: Unknown FM25S01A 1Gbit 3.3V
nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
spi_nand f0400000.nand: 4-bit mode @ 40000000 Hz
3 cmdlinepart partitions found on MTD device spi_nand.0
Creating 3 MTD partitions on "spi_nand.0":
0x000000300000-0x000008000000 : "ubi"
ubi0: attaching mtd2
ubi0: scanning is finished
ubi0: attached mtd2 (name "ubi", size 125 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 999, bad PEBs: 1, corrupted PEBs: 0
ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 0
ubi0: available PEBs: 0, total reserved PEBs: 999, PEBs reserved for bad PEB handling: 19
UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs", R/O mode
VFS: Mounted root (ubifs filesystem) readonly on device 0:13.
UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
exfat: loading out-of-tree module taints kernel.

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 002c0000 00020000 "boot"
mtd1: 00040000 00020000 "env"
mtd2: 07d00000 00020000 "ubi"

# ubinfo -a
UBI version:                    1
Count of UBI devices:           1
ubi0: 2 volumes (rootfs: 110 LEBs / 13.3 MiB, rootfs_data: 866 LEBs / 104.8 MiB)
Logical eraseblock size:        126976 bytes, 124.0 KiB
Total LEBs: 999, bad PEBs: 1, reserved PEBs: 19, max erase counter: 2

# df -h
Filesystem                Size      Used Available Use% Mounted on
ubi0:rootfs              10.4M     10.4M         0 100% /rom
ubi0:rootfs_data         95.1M     88.0K     90.3M   0% /overlay
overlay                  95.1M     88.0K     90.3M   0% /

Live sysupgrade from local archive (without --force_soc)

# sysupgrade -z --archive=/overlay/openipc.nt98566-nand-ultimate.tgz
OpenIPC System Updater v1.0.86
Vendor	novatek
SoC	nt98566
Model	nt98566
Kernel	13:44:42 2026-11-27
RootFS	local+build, 2026-11-27
The kernel lives inside the rootfs on this camera: writing the rootfs.
...
Local archive unpacked
Unmounting SD card
UBIFS rootfs; its SoC and version cannot be read without mounting it.
SoC from the uImage kernel beside it: nt98566
SoC OK
Moving the flash phase into RAM
RAM left to flash from: 5644 KB
Handing PID 1 over to the RAM root.

Camera rebooted cleanly back into Linux nt98566-sc430ai 4.19.91 #8 with sysupgrade --history recording the upgrade (2026-11-27T13:50:47Z).

@openipc-ai openipc-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, most of the first round is done. From that round, 1 (CI registration), 2 (local patches dropped), 4 (uImage SoC witness, with tests), 6 (evidence, including a local-archive sysupgrade without --force_soc) and 7 (squash) are resolved. On 3 you're right: drivers/mtd/spiflash/Kconfig has MTD_SPINOR ... depends on (MTD) && (!MTD_SPINAND), so one kernel can't serve both flashes, and a NAND-only ultimate is the only option on this SoC. I'm withdrawing that item.

The sysupgrade change looks right to me. It still takes the FIT first, falls back only to a real legacy header (27051956), reads the SoC with the same nor_split_soc the split NOR path uses, and the two new cases cover the matching and the foreign SoC.

Still to change

  1. Rebase on master. .github/scripts/ci-matrix.py conflicts (the majestic count in the self-test moved again). While the PR conflicts, GitHub creates no pull_request runs, so this head has no CI at all.
  2. nt98566.nand.config lost the thermal sensor. Compared with master's nt98566.generic.config, the regenerated file turns off CONFIG_THERMAL, CONFIG_THERMAL_OF, CONFIG_THERMAL_GOV_STEP_WISE, CONFIG_IIO and CONFIG_NVT_ADC. Those came in with #2950 and give nt98566 its thermal_zone0, which the temperature readout uses. Running olddefconfig against a kernel tree without those symbols drops them silently. Please rebuild the file from the current nt98566.generic.config so the only differences are the NAND/UBI/UBIFS, MTD_OF_PARTS and HW_RANDOM_NVT lines.
  3. Port #2971 into the same file. Master's nt98566.generic.config no longer requires a signed regulatory.db (CONFIG_CFG80211_REQUIRE_SIGNED_REGDB off, CONFIG_CFG80211_CERTIFICATION_ONUS=y, CONFIG_SYSTEM_DATA_VERIFICATION and CONFIG_SYSTEM_TRUSTED_KEYRING off), so the kernel build no longer needs host OpenSSL. nt98566.nand.config still has the old values. Item 2's rebuild covers this if you start from today's master.
  4. Update the ubinize-nand.cfg comment after the rebase. #2972 (now on master) adds 4 MiB of headroom to the rootfs volume. external.mk writes the vol_size into a copy of the board's ubinize-nand.cfg inside the same ifneq your wildcard extends, so nt9856x picks it up automatically. Your file's comment ("No vol_size on rootfs: the volume is sized to its image") will then be wrong. Word it the way hi3516ev200/ubinize-nand.cfg now does, and check ubinfo -a on the board shows the rootfs volume 4 MiB above the image.

OpenIPC/linux#330 is approved. Merge order: #330, then this PR.

@vlw
vlw force-pushed the nt98566-spinand-ultimate branch from 6c6a433 to fca77b0 Compare November 27, 2026 14:01
vlw added 3 commits November 27, 2026 17:16
…CI entry

Add nt98566_ultimate_defconfig, Kconfig-ordered nt98566.nand.config
(SPI NAND + HWECC, UBI/UBIFS, OF partitions, HW_RANDOM_NVT),
ubinize-nand.cfg (rootfs + autoresize rootfs_data), exfat-openipc +
exfatprogs, and register nt98566_ultimate in ci-matrix.py.

Note: Novatek's drivers/mtd/spiflash/Kconfig defines MTD_SPINOR with
'depends on (MTD) && (!MTD_SPINAND)', so a single NT98566 kernel cannot
enable both SPI NOR and SPI NAND simultaneously; nt98566_ultimate is
therefore SPI NAND only (nt98566_lite continues to cover SPI NOR).
Depends on OpenIPC/linux#330 (FM25S01A + nvt-rng Kconfig) and
OpenIPC/u-boot#211.

Tested on Dahua DH-IPC-HFW2449SP-S-IL (Novatek NT98566 / NA51089,
128 MB DDR3, Fudan FM25S01A 128 MiB SPI NAND ID 0xA1 0xE4, SC430AI).
Trigger OPENIPC_UBIFS_BOOT when board/<family>/ubinize-nand.cfg exists
(not only when nand-fit.its exists) so /boot/uImage is embedded inside
rootfs.ubifs for OpenIPC/u-boot openipc-novatek (CONFIG_LEGACY_IMAGE_FORMAT=y,
no CONFIG_FIT, ubifsload /boot/uImage + loader DTB via ${fdtaddr}).
Add REPACK_NAND_UBIFS in Makefile to package uImage.<soc>,
rootfs.ubifs.<soc>, and rootfs.ubi.<soc> into the -nand- archive.

Tested on Dahua DH-IPC-HFW2449SP-S-IL (Novatek NT98566 / NA51089,
128 MB DDR3, Fudan FM25S01A 128 MiB SPI NAND, SC430AI).
When verifying a UBIFS rootfs from a local archive on boards whose
U-Boot boots /boot/uImage rather than a FIT (e.g. openipc-novatek),
fall back to checking the legacy uImage.<soc> beside rootfs.ubifs
using nor_split_soc() if no FIT is present. Add matching and foreign
SoC test cases in test_sysupgrade.sh.

Tested live on Dahua DH-IPC-HFW2449SP-S-IL (NT98566) via
'sysupgrade --archive=/overlay/openipc.nt98566-nand-ultimate.tgz'
without --force_soc.
@vlw
vlw force-pushed the nt98566-spinand-ultimate branch from fca77b0 to 050162e Compare November 27, 2026 14:17
@vlw

vlw commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest master (8f4f51a) and pushed 050162e addressing all remaining items:

  1. Rebased onto master & resolved .github/scripts/ci-matrix.py (114 → 115); python3 .github/scripts/ci-matrix.py --self-test passes (142 boards, 182 packages, 81 cases).
  2. Rebuilt br-ext-chip-novatek/board/nt9856x/nt98566.nand.config from master's nt98566.generic.config against origin/novatek-nt9856x (e75a4165c): preserves thermal/ADC (CONFIG_THERMAL, CONFIG_THERMAL_OF, CONFIG_THERMAL_GOV_STEP_WISE, CONFIG_IIO, CONFIG_NVT_ADC) and nt9856x: don't require a signed regulatory.db, so the kernel no longer needs host OpenSSL #2971 (no signed regulatory.db / host OpenSSL), differing from nt98566.generic.config only in SPI NAND + UBI/UBIFS + HW_RANDOM_NVT.
  3. Updated br-ext-chip-novatek/board/nt9856x/ubinize-nand.cfg comment to match hi3516ev200/ubinize-nand.cfg after NAND: 4 MiB of headroom in the rootfs volume, so a grown image keeps the settings #2972. BOARD=nt98566_ultimate make all generates output/build/openipc-ubinize-nand.cfg with vol_size=18161664 (image 13967360 + 4194304 headroom).
  4. Verified on live NT98566 SPI NAND hardware (Dahua DH-IPC-HFW2449SP-S-IL, Fudan FM25S01A):
    • sysupgrade archive check passes without --force_soc: SoC from the uImage kernel beside it: nt98566 → SoC OK.
    • Upgraded live via RAM-pivot (Settings carried over), ubinfo -a confirms ubi0:rootfs resized to 144 LEBs (18284544 bytes, 17.4 MiB) and ubi0:rootfs_data to 832 LEBs (105644032 bytes, 100.7 MiB).
    • /sys/class/thermal/thermal_zone0/temp reports 49.
    • mtd0/mtd1/mtd2 all report ecc_strength=1 bitflip_threshold=1.

@openipc-ai openipc-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 3 at 050162e: all requested changes are in.

  • The local kernel patches are gone. FM25S01A and the NA51089 RNG now come from OpenIPC/linux (linux#330, merged), so Qodo's finding 4 is stale.
  • nt98566.nand.config differs from master's nt98566.generic.config only in MTD/UBI/UBIFS/HW_RANDOM, and keeps the thermal and regdb options.
  • The ubinize-nand.cfg comment matches the #2972 rootfs headroom.
  • verify_ubifs_rootfs has a uImage SoC-witness fallback, covered by both new test_sysupgrade.sh cases.
  • CI is green, including Firmware (nt98566_ultimate).

@openipc-ai
openipc-ai merged commit 11d097c into OpenIPC:master Nov 27, 2026
169 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.

2 participants