Skip to content

nor: split layout on the gk7205v500 family - #52

Merged
widgetii merged 2 commits into
openipc-hisiliconfrom
nor/split-v500
Oct 22, 2026
Merged

widgetii merged 2 commits into
openipc-hisiliconfrom
nor/split-v500

Conversation

@widgetii

Copy link
Copy Markdown
Member

CONFIG_OPENIPC_NOR_SPLIT for gk7205v500, gk7205v510 and gk7205v530 (xm720xxx_config, which build.sh uses for all three, and xm72050500_config), now that their kernel finds the split layout from its device tree (OpenIPC/linux#137, merged on goke-gk7205v500). The scan takes a uImage at 0x50000 with the squashfs at the next 64 KiB as the split image and boots it with a root-less command line; fwupd and recovery take firmware.bin.<soc>. Fixed-slot cameras boot as before. The NAND builds compile the split code out.

misc_init_r() on xm720xxx and xm72050500 set verify=n after openipc_helper(), undoing the scan's clearing of it for a split image, so bootm never checked the uImage CRC. It is now set before the scan, as #48 did for the boards that had the same order.

NOR images: u-boot-gk7205v500/v510/v530-nor.bin 225792 bytes each (rebased on #51), inside the 256K boot area; NAND images build as before.

Tested in qemu-hisilicon with a gk7205v500_lite build:

  • gk7205v500 8 MB and gk7205v510/v530 16 MB, the split firmware.bin: Found RootFS at 0x00240000, Verifying Checksum ... OK, root-less command line, the kernel's split, root on 31:4, login;
  • the fixed-slot uImage + rootfs: Found RootFS at 0x00250000, fixed mtdparts, root on 31:3.

Not run on hardware.

CONFIG_OPENIPC_NOR_SPLIT for gk7205v500, gk7205v510 and gk7205v530
(xm720xxx_config, which build.sh uses for all three, and
xm72050500_config), now that their kernel (OpenIPC/linux
goke-gk7205v500) finds the split layout from its device tree. The scan
takes a uImage at 0x50000 with the squashfs at the next 64 KiB as the
split image and boots it with a root-less command line; fwupd and
recovery take firmware.bin.<soc>. Fixed-slot cameras boot as before.
The NAND builds compile the split code out.

misc_init_r() on xm720xxx and xm72050500 set verify=n after
openipc_helper(), undoing the scan's clearing of it for a split image so
bootm never checked the uImage CRC; it is set before the scan, as #48
did for the boards that had it then.

NOR images: u-boot-gk7205v500/v510/v530-nor.bin 225792 bytes each,
inside the 256K boot area; NAND images build as before.

Tested in qemu-hisilicon with a gk7205v500_lite build: gk7205v500 8 MB
and gk7205v510/v530 16 MB, the split firmware.bin -> "Found RootFS at
0x00240000", "Verifying Checksum ... OK", root-less command line, the
kernel's split, root on 31:4, login; the fixed-slot uImage + rootfs ->
"Found RootFS at 0x00250000", fixed mtdparts, root on 31:3. Not run on
hardware.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Enable split NOR boot on the gk7205v500 family

✨ Enhancement 🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Enable split NOR layout detection for gk7205v500, v510, and v530 while retaining fixed-slot
 booting.
• Set verify=n before scanning so split images retain uImage CRC verification.
• Keep split support out of NAND builds; QEMU boot tests passed, but hardware remains untested.
Diagram

graph TD
  Init["Board init"] --> Scan["NOR scan"] --> Match{"Split image?"}
  Match -->|Yes| Split["Split bootargs"] --> CRC["CRC bootm"] --> DT["Kernel DT split"]
  Match -->|No| Fixed["Fixed slots"] --> Root["Legacy root"]
Loading
High-Level Assessment

Reusing the existing opt-in split-layout scanner is preferable to adding family-specific detection. Setting verify before the helper preserves fixed-slot behavior while allowing the scanner to enable CRC checks for split images. Hardware validation remains worthwhile.

Files changed (5) +13 / -3

Bug fix (2) +4 / -2
board.cPreserve split-image CRC checks during board initialization +2/-1

Preserve split-image CRC checks during board initialization

• Moves 'verify=n' before 'openipc_helper()', so a detected split image can clear it before boot. Fixed-slot images retain the previous setting.

board/xmedia/xm72050500/board.c

board.cPreserve split-image CRC checks on xm720xxx boards +2/-1

Preserve split-image CRC checks on xm720xxx boards

• Sets 'verify=n' before the firmware scan rather than afterward. This prevents board initialization from undoing CRC verification selected for a split image.

board/xmedia/xm720xxx/board.c

Documentation (1) +1 / -1
KconfigDocument gk7205v500 split-layout support +1/-1

Document gk7205v500 split-layout support

• Adds the gk7205v500 family to the help text for the existing split NOR option.

common/Kconfig

Other (2) +8 / -0
xm72050500_configEnable split NOR support for xm72050500 +4/-0

Enable split NOR support for xm72050500

• Enables the existing split-layout option and documents its dependency on the kernel's device-tree partition handling.

openipc/xm72050500_config

xm720xxx_configEnable split NOR support for the shared gk7205v500-family build +4/-0

Enable split NOR support for the shared gk7205v500-family build

• Enables the existing split-layout option in the configuration used by 'build.sh' for gk7205v500, v510, and v530. The option's NAND-specific code remains compiled out in NAND builds.

openipc/xm720xxx_config

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

qodo-free-for-open-source-projects Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Fixed-slot updates erase saved data 🐞 Bug ≡ Correctness
Description
Enabling the split update command makes fwupd prefer firmware.bin. whenever it is available,
even when the scan found a fixed-slot image. On a fixed-slot camera, fwwrite then erases from
kernaddr to the end of flash, including the rootfs_data partition that the previous
kernel-and-rootfs update left intact.
Code

openipc/xm720xxx_config[14]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
The new option selects a command that fetches the firmware file first; the scan installs it
independently of the detected layout and sets its erase length to the remainder of the chip. The
fixed-slot partition map places rootfs_data after the kernel and rootfs slots, whereas the legacy
update writes only those slots.

common/openipc.c[766-791]
include/configs/openipc-common.h[130-135]
include/configs/openipc-common.h[206-229]
include/configs/openipc-common.h[238-244]

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

## Issue description
Enabling split updates makes a fixed-slot camera use the whole-flash firmware writer whenever a firmware file is available, erasing its rootfs_data partition.
## Fix Focus Areas
- openipc/xm720xxx_config[12-14]
- common/openipc.c[766-791]
- include/configs/openipc-common.h[206-224]
## Recommended Fix
Select the whole-firmware update only when the detected layout is split. Keep the kernel-and-rootfs update path for fixed-slot installations, including when a firmware file exists.

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



Remediation recommended

2. Damaged kernels halt without recovery 🐞 Bug ☼ Reliability
Description
The moved verify=n lets the split scan clear that setting for bootm, but nor_split_layout()
accepts a uImage without checking its data CRC and clears bootfail. If the image has a valid
header and a damaged payload, bootm rejects it while fwrecovery sees no failure flag; the
boot-limit fallback retries the same image and can leave the camera at the prompt.
Code

board/xmedia/xm720xxx/board.c[146]

+	env_set("verify", "n");
Evidence
The scan's split test checks magic and image size, then clears bootfail. Bootm rejects a bad data
CRC when verify is enabled, but the recovery and fallback commands depend on bootfail or attempt the
same kernel again.

common/openipc.c[681-698]
common/openipc.c[862-869]
boot/bootm.c[844-854]
include/configs/openipc-common.h[150-185]

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

## Issue description
Split-image checksum verification can reject a damaged kernel after the scan has cleared bootfail, so neither normal boot nor the boot-limit fallback initiates recovery.
## Fix Focus Areas
- board/xmedia/xm720xxx/board.c[145-147]
- common/openipc.c[681-698]
- common/openipc.c[862-869]
- include/configs/openipc-common.h[178-185]
## Recommended Fix
Check split-image integrity before clearing bootfail, or arrange for a bootm checksum failure to set a recovery signal that the subsequent boot and boot-limit path honor.

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


3. Recovery scripts skip checksum checks ✓ Resolved
Description
misc_init_r() now sets verify=n before openipc_helper() runs recovery, so source skips the
data-CRC check for a uImage-wrapped script.txt. On an SD card or USB recovery attempt with a
damaged wrapped script, commands can execute despite the checksum mismatch; previously this setting
was applied after recovery returned.
Code

board/xmedia/xm720xxx/board.c[146]

+	env_set("verify", "n");
Evidence
The helper invokes recovery before the scan. Recovery passes a uImage-wrapped script to source,
whose legacy-image path checks its data CRC only when the verify environment setting is true.

common/openipc.c[1019-1038]
common/openipc.c[534-569]
cmd/source.c[60-86]

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

## Issue description
Moving verify=n ahead of the helper disables the data-CRC check for wrapped recovery scripts, not just for the firmware scan.
## Fix Focus Areas
- board/xmedia/xm720xxx/board.c[145-147]
- board/xmedia/xm72050500/board.c[146-148]
- common/openipc.c[1019-1038]
## Recommended Fix
Keep verification enabled while firmware_recovery runs, then set verify=n immediately before firmware_scan so its split branch can clear the setting for bootm.

ⓘ 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 ask Qodo to dismiss a finding you disagree with, with your reason on record

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread openipc/xm720xxx_config
Comment thread board/xmedia/xm720xxx/board.c
Comment thread board/xmedia/xm720xxx/board.c
From review: boards set verify=n before openipc_helper() so the split
scan can clear it for bootm (#48, and this PR for xm720xxx/xm72050500),
and recovery then ran with verify=n: source skipped the data CRC of a
uImage-wrapped script.txt. openipc_helper() now drops verify while
firmware_recovery() runs and puts it back for the boot, on every board.

QEMU (gk7205v500, 8 MB, split image): 'Verifying Checksum ... OK' before
the kernel, split, root on 31:4, login; hi3516ev300 builds.
@widgetii
widgetii merged commit 4c314e3 into openipc-hisilicon Oct 22, 2026
116 of 118 checks passed
@widgetii
widgetii deleted the nor/split-v500 branch October 22, 2026 13:06
widgetii added a commit to OpenIPC/defib that referenced this pull request Oct 23, 2026
The gk7205v500 firmware now ships the split NOR package beside the
fixed-slot one (OpenIPC/firmware#2658). Its kernel (OpenIPC/linux#137)
and NOR U-Boot (OpenIPC/u-boot#52) both know the layout.

- `gk7205v500` joins `NOR_SPLIT_SOCS`, so `install` writes
`firmware.bin.gk7205v500` at 0x50000 and erases the rest of the chip.
- `FIRMWARE_PACKAGE_BOARD` maps gk7205v510/v530 to `gk7205v500`, the one
build the family installs, as NAND already does (`_UBI_NAND_BOARD`).
Each keeps its own `-nor` U-Boot. A fixed-slot package named for the
chip itself is still accepted.
- V500 boot-ROM recovery (`HiSiliconV500`) and the agent's donor are
unchanged.

Local: `pytest` (1084 passed), `ruff`, `mypy` clean.

Not run on hardware. The firmware side was checked in qemu-hisilicon
(see OpenIPC/firmware#2658): split boot under the new and the published
U-Boot, the overlay kept across a power cycle, and U-Boot recovery from
a fixed-slot install to the split image. qemu-hisilicon does not emulate
the V500 boot ROM, so `defib install` itself was not run against it.
widgetii added a commit to OpenIPC/website that referenced this pull request Oct 23, 2026
gk7205v500 ships the split NOR package beside the fixed-slot one since
OpenIPC/firmware#2658, on a kernel (OpenIPC/linux#137) and a -nor U-Boot
(OpenIPC/u-boot#52) that scan the layout. nor_split on gk7205v500,
gk7205v510 and gk7205v530 lets the wizard give the split install where
the -split package is published, as on the gk7205v200 family.

gk7205v510 installs the gk7205v500 build on NOR too, as defib does since
OpenIPC/defib#163 and as gk7205v530 already did here. Its own
openipc.gk7205v510-nor-lite.tgz dates from 2026-10-02 and has no
defconfig behind it any more. Without the move, deleting that stale
asset from the release would leave v510 with no NOR download. v510 keeps
its own -nor and -nand U-Boot. nand_board, which only v510 used, has no
user now; the field stays.

Tests: the fixture index loses the v510 package and gains the two
gk7205v500 -split packages (sizes and digests from the latest release).
boards.json moves v510 to the gk7205v500 build. The nand_board wizard
test becomes TestV510InstallsTheV500Build: v510's NOR and NAND
installs use the gk7205v500 build, and NOR uses the split
firmware.bin.gk7205v500. The golden is regenerated for the three V500
SoCs. go test ./... (uncached) passes.
widgetii added a commit to OpenIPC/wiki that referenced this pull request Oct 23, 2026
* nor-split: the Hi3516EV200 family, Hi3516EV300 split-only

- nor-split-layout: Hi3516EV200, Hi3518EV300 and Hi3516DV200 ship the
  split package beside the fixed-slot one (OpenIPC/firmware#2655, on
  OpenIPC/linux#131 and OpenIPC/u-boot#48); Hi3516EV300 lite and
  ultimate ship the split package only, its kernel filling the 2 MiB
  kernel slot (neo keeps fixed slots). Going back to fixed slots lists
  them accordingly.
- sysupgrade: `sysupgrade -k -r` installs the split layout on them.

Checked in qemu-hisilicon (hi3516ev200, hi3518ev300, hi3516ev300; 8 and
16 MB). Not run on hardware.

* nor-split: the GK7205V500 family

GK7205V500 ships the split package beside the fixed-slot one
(OpenIPC/firmware#2658, on OpenIPC/linux#137 and OpenIPC/u-boot#52).
GK7205V510 and GK7205V530 install that one gk7205v500 build, as defib
(OpenIPC/defib#163) and the site's installer do. Each keeps its own
u-boot-<soc>-nor.bin. sysupgrade -k -r takes the split package on them
too, and they go back to fixed slots the same way.

Checked in qemu-hisilicon (gk7205v500 8 and 16 MB, gk7205v510/v530
16 MB). Not run on hardware.

* sysupgrade: the split list is for NOR cameras, and Hi3516EV300 lite and ultimate

From review: the list of SoCs whose sysupgrade -k -r installs the split
package now says it is about NOR flash, and points NAND cameras to their
own layout page. Hi3516EV300 is listed for lite and ultimate only: neo
keeps fixed slots, as the layout page says.
widgetii added a commit that referenced this pull request Oct 24, 2026
* nor: split layout on gk7201v200

CONFIG_OPENIPC_NOR_SPLIT for xm72010200_config, which gk7201v200_config
names, now that its kernel (OpenIPC/linux goke-gk7205v500, ARCH_XM72050200)
finds the split layout from its device tree. misc_init_r() sets verify=n
before openipc_helper(), as #52 did for xm720xxx and xm72050500, so a
split image's uImage CRC is checked by bootm.

NOR image: u-boot-gk7201v200-nor.bin 213729 bytes, inside the 256K boot
area; the NAND build compiles the split code out.

Tested in qemu-hisilicon (gk7201v200, 8 MB) with a gk7201v200_lite build
on this kernel (uImage 1836K, squashfs 4956K, firmware.bin 6848K):
- split firmware.bin, new U-Boot: "Found RootFS at 0x00220000", "sfc: split
  NOR layout, device tree partitions", rootfs_data from 0x700000, root on
  31:4, login; a second boot on the same flash reads the seed the first
  saved in the overlay;
- the same image under the published u-boot-gk7201v200-nor.bin:
  "root=/dev/mtdblock3 ignored, the flash names its own root", root on 31:4;
- the fixed-slot package: 6 cmdlinepart partitions, root on 31:3, login;
- recovery: from fixed slots, and from a split image with one kernel byte
  flipped ("kernel at 0x50000 fails its CRC"), fwupd over TFTP writes
  firmware.bin.gk7201v200 (byte-identical on flash) and the next boot
  reaches login on 31:4.
Not run on hardware.

* nor: split layout on the hi3516cv200 family

CONFIG_OPENIPC_NOR_SPLIT for hi3516cv200 and hi3518ev200 (hi3518ev201
boots the hi3518ev200 image), whose kernel (OpenIPC/linux
hisilicon-hi3516cv200) finds the split layout from its device tree.
misc_init_r() sets verify=n before openipc_helper(), so the scan can
clear it for a split image and bootm checks the uImage CRC.

NOR images: u-boot-hi3516cv200-nor.bin 140376 bytes,
u-boot-hi3518ev200-nor.bin 140488 bytes.
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