Skip to content

nor: split layout on the hi3516ev200 family - #48

Merged
widgetii merged 3 commits into
openipc-hisiliconfrom
nor/split-ev200
Oct 21, 2026
Merged

widgetii merged 3 commits into
openipc-hisiliconfrom
nor/split-ev200

Conversation

@widgetii

Copy link
Copy Markdown
Member

CONFIG_OPENIPC_NOR_SPLIT for hi3516ev200, hi3516ev300, hi3518ev300 and hi3516dv200, now that their kernel finds the split layout from its device tree (OpenIPC/linux#131, merged on hisilicon-hi3516ev200). 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 SD recovery take firmware.bin.<soc>. Fixed-slot cameras boot as before: a squashfs at the 2 or 3 MiB slot boundary is still fixed slots. The NAND builds compile the split code out and are unchanged.

NOR images: u-boot-hi3516ev300-nor.bin 209413 bytes, u-boot-hi3516ev200-nor.bin 208693, hi3518ev300 208661, hi3516dv200 202129, all inside the 256K boot area; the NAND images build as before.

Tested in qemu-hisilicon:

  • hi3516ev200 (8 and 16 MB) and hi3518ev300 split firmware.bin: Found RootFS at 0x00210000 / 0x00230000, root-less command line, the kernel's split, root on 31:4, login prompt;
  • the fixed-slot packages: Found RootFS at 0x00250000 / 0x00350000, fixed-slot mtdparts, root on 31:3;
  • hi3516ev300's published fixed package (a uImage padded to the full 2 MiB slot) is still taken as fixed slots, so ev300 cameras are unchanged. Its firmware keeps the kernel splitters off for now (see hi3516ev200 family: the split NOR layout, from the device tree linux#131).

Not run on hardware.

CONFIG_OPENIPC_NOR_SPLIT for hi3516ev200, hi3516ev300, hi3518ev300 and
hi3516dv200, now that their kernel (OpenIPC/linux hisilicon-hi3516ev200)
finds the split layout from its device tree. The scan then 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 SD recovery take
firmware.bin.<soc>. Fixed-slot cameras boot as before: a squashfs at the
2 or 3 MiB slot boundary is still fixed slots. The NAND builds compile the
split code out and are unchanged.

NOR images: u-boot-hi3516ev300-nor.bin 209413 bytes,
u-boot-hi3516ev200-nor.bin 208693, inside the 256K boot area; the NAND
images build as before.

Tested in qemu-hisilicon: hi3516ev200 (8 and 16 MB) and hi3518ev300 split
firmware.bin -> "Found RootFS at 0x00210000" / "0x00230000", root-less
command line, the kernel's split; the fixed-slot packages -> "Found
RootFS at 0x00250000" / "0x00350000", fixed-slot mtdparts, root on 31:3.
hi3516ev300's published fixed package (a uImage padded to the full 2 MiB
slot) is still taken as fixed slots. Not run on hardware.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 21, 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. Fixed-slot cameras can lose their root ✓ Resolved
Description
nor_split_bootargs() removes root= and mtdparts= from the in-memory environment, but
openipc_helper() can subsequently persist that environment with env_save(). After a split image
is replaced by a fixed-slot image, the fixed-layout branch does not restore those boot arguments,
leaving a kernel that needs the fixed partitions unable to mount its root filesystem.
Code

openipc/hi3516ev200_config[9]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
The new config activates the split-only bootargs removal. Both the default-environment save and
altbootcmd migration occur after the scan, while the fixed branch sets mtdparts but does not put
root= back into bootargs.

openipc/hi3516ev200_config[7-9]
common/openipc.c[633-674]
common/openipc.c[850-858]
common/openipc.c[861-905]
common/openipc.c[982-1005]
include/configs/openipc-common.h[196-196]

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 NOR allows a stripped bootargs value to be saved, breaking a subsequent fixed-slot boot.
## Fix Focus Areas
- common/openipc.c[641-674]
- common/openipc.c[850-859]
- common/openipc.c[982-1005]
## Recommended Fix
Ensure default-environment persistence and altbootcmd migration cannot save split-only bootargs, and restore the required root and partition arguments when detecting a fixed layout after a split boot.

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


2. Oversized updates erase working firmware ✓ Resolved
Description
The split fwwrite command erases the entire firmware area before checking whether ${filesize}
fits in it. If a downloaded image exceeds the remaining flash capacity, the erase succeeds but `sf
write` rejects the out-of-bounds write, leaving the camera without its previous kernel and rootfs.
Code

openipc/hi3518ev300_config[14]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
Enabling this config selects the whole-area erase and firmware-file update. The scan sets fwsize to
the capacity through the chip's end; the erase uses that valid size, whereas the subsequent write is
checked against filesize and flash bounds.

openipc/hi3518ev300_config[12-14]
include/configs/openipc-common.h[203-214]
common/openipc.c[766-784]
cmd/sf.c[288-304]
cmd/sf.c[327-350]

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

## Issue description
A split firmware download larger than the available flash erases the installed firmware before its write fails.
## Fix Focus Areas
- include/configs/openipc-common.h[203-210]
- common/openipc.c[766-784]
## Recommended Fix
Check that the downloaded filesize is nonzero and no greater than the probed capacity from kernaddr before running sf erase. Abort the update without changing flash when the check fails.

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



Remediation recommended

3. Card-only split recovery skips firmware ✓ Resolved
Description
firmware_recovery() searches an SD card for script.txt or *.img files, not the firmware.bin.
file selected by the newly enabled split update command. A camera with a failed split image and only
that firmware file on its card cannot recover automatically; the boot-failure command uses the
default TFTP source unless someone has separately changed it.
Code

openipc/hi3516ev300_config[14]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
The new configuration makes firmware.bin.<soc> the split update filename, but the startup recovery
path filters the SD directory to *.img and never invokes the update command or switches its source
to MMC.

openipc/hi3516ev300_config[11-14]
include/configs/openipc-common.h[124-127]
include/configs/openipc-common.h[173-183]
include/configs/openipc-common.h[203-210]
common/openipc.c[499-529]
common/openipc.c[577-626]
common/openipc.c[994-997]

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

## Issue description
Automatic SD recovery does not recognize the split firmware file that this configuration enables for updates.
## Fix Focus Areas
- common/openipc.c[499-529]
- common/openipc.c[577-626]
- include/configs/openipc-common.h[173-183]
- include/configs/openipc-common.h[203-210]
## Recommended Fix
Add an automatic NOR recovery path for firmware.bin.<soc> that validates its size and writes it at the firmware offset. Keep the existing wrapped *.img recovery path available.

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


4. Saved cameras skip split updates ✓ Resolved
Description
Selecting CONFIG_OPENIPC_NOR_SPLIT changes the compiled default fwupd command to fetch
firmware.bin., but firmware_scan() only overrides fwwrite and fwsize in an existing
environment. Cameras retaining the previous saved fwupd=run ur; run uk instead keep requesting
separate rootfs and kernel files, so supplying the new firmware file alone does not update them.
Code

openipc/hi3516dv200_config[14]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
The previous and new fwupd defaults differ, but defaults are saved only for a blank environment. The
scan overrides only fwwrite and fwsize, and the sole migration shown handles altbootcmd.

openipc/hi3516dv200_config[12-14]
include/configs/openipc-common.h[203-214]
common/openipc.c[766-784]
common/openipc.c[975-1005]

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

## Issue description
Existing saved environments retain the fixed-slot update command after split support is enabled.
## Fix Focus Areas
- common/openipc.c[766-784]
- common/openipc.c[975-1005]
- include/configs/openipc-common.h[203-214]
## Recommended Fix
Recognize the exact legacy fwupd value in saved environments and replace it with the split-aware command, also supplying fwfile when absent. Preserve user-edited update commands.

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


5. Firmware updates erase camera settings 🐞 Bug ≡ Correctness
Description
With split mode enabled, firmware_scan() replaces fwwrite with a command that erases from
kernaddr through the end of the flash rather than only the written image. When fwupd finds
firmware.bin., that erase also covers the space after the firmware used for rootfs_data, whereas
the fixed-slot update commands and SD image recovery limit their erases.
Code

openipc/hi3516ev200_config[9]

+CONFIG_OPENIPC_NOR_SPLIT=y
Evidence
The split scan explicitly sets fwsize to flash size minus the firmware start, and fwupd uses that
size for its erase. The fixed partition map names the trailing area rootfs_data, and the code
identifies it as holding settings; the earlier fixed-slot commands and card recovery erase bounded
image or slot ranges.

openipc/hi3516ev200_config[7-9]
common/openipc.c[766-784]
common/openipc.c[789-801]
common/openipc.c[895-897]
common/openipc.c[485-494]
include/configs/openipc-common.h[203-224]

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 activated full-firmware update erases writable settings beyond the downloaded image.
## Fix Focus Areas
- common/openipc.c[766-784]
- include/configs/openipc-common.h[203-224]
- common/openipc.c[486-495]
## Recommended Fix
Limit the firmware erase to the image's aligned length while handling any genuinely stale overlay area separately. Preserve rootfs_data where the update does not need to replace it.

ⓘ 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 start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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

Copy link
Copy Markdown

PR Summary by Qodo

Enable split NOR layout on the hi3516ev200 family

✨ Enhancement ⚙️ Configuration changes 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Enable existing split NOR support for four hi3516ev200-family targets whose kernels recognize the
 layout.
• Preserve fixed-slot boot behavior and leave NAND builds unchanged.
• Document the expanded set of supported boards.
Diagram

graph TD
  TARGETS["Four NOR targets"] --> SCAN["NOR layout scan"] --> LAYOUT{"Split layout?"} -->|yes| SPLIT["Split boot"] --> DT["Kernel DT split"]
  LAYOUT -->|no| FIXED["Fixed-slot boot"]
Loading
High-Level Assessment

Enabling the existing, NOR-only split-layout path per target is appropriate. It avoids duplicating detection logic and retains the established fixed-slot fallback; changing the shared boot implementation is unnecessary for this scope.

Files changed (5) +18 / -1

Documentation (1) +2 / -1
KconfigDocument hi3516ev200-family split NOR support +2/-1

Document hi3516ev200-family split NOR support

• Adds the hi3516ev200 family to the help text listing boards whose kernels understand the split layout.

common/Kconfig

Other (4) +16 / -0
hi3516dv200_configEnable split NOR support for hi3516dv200 +4/-0

Enable split NOR support for hi3516dv200

• Sets CONFIG_OPENIPC_NOR_SPLIT and notes that the kernel partitions firmware using its device tree.

openipc/hi3516dv200_config

hi3516ev200_configEnable split NOR support for hi3516ev200 +4/-0

Enable split NOR support for hi3516ev200

• Sets CONFIG_OPENIPC_NOR_SPLIT and documents the kernel's device-tree-based firmware split.

openipc/hi3516ev200_config

hi3516ev300_configEnable split NOR support for hi3516ev300 +4/-0

Enable split NOR support for hi3516ev300

• Sets CONFIG_OPENIPC_NOR_SPLIT and documents the expected kernel partitioning. The existing scan still classifies fixed-slot images as fixed slots.

openipc/hi3516ev300_config

hi3518ev300_configEnable split NOR support for hi3518ev300 +4/-0

Enable split NOR support for hi3518ev300

• Sets CONFIG_OPENIPC_NOR_SPLIT and notes that the kernel divides the firmware partition from its device tree.

openipc/hi3518ev300_config

@widgetii

Copy link
Copy Markdown
Member Author

/review

Comment thread openipc/hi3516ev200_config
Comment thread openipc/hi3518ev300_config
Comment thread openipc/hi3516ev300_config
Comment thread openipc/hi3516dv200_config
Comment thread openipc/hi3516ev200_config
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4e08fc6

From review, for every split board:
- openipc_helper() saved the default environment, and
  altbootcmd_migrate() the whole environment, after firmware_scan(),
  so a split boot could persist its RAM-only bootargs without root= and
  mtdparts=; a fixed-slot image written later then had no root. Both
  saves now come before the scan, whose settings stay for this boot.
- fwwrite erases the firmware area only for a file that is not empty and
  fits ${fwsize}: an oversized download no longer erases what it cannot
  replace. One command string serves the default environment and the
  scan's RAM override.
- A saved fwupd that is exactly the pre-split "run ur; run uk" takes the
  firmware file first (in RAM; an edited one is left alone), and fwfile
  is supplied when absent.

Checked in qemu-hisilicon (hi3516ev200, 8 MB, this U-Boot):
- first boot of a split image on a blank env: saved bootargs keep
  "root=/dev/mtdblock3 ... mtdparts=${mtdparts}", the boot's own command
  line is root-less, root on 31:4; a fixed-slot image then written under
  that env: "Found RootFS at 0x00250000", 6 cmdlinepart partitions, root
  on 31:3, login;
- setenv fwupd 'run ur; run uk'; saveenv; reset: fwupd reads the split
  command again; filesize 0x1000000 against fwsize 0x7b0000 and filesize
  0: "nothing written", the squashfs at 0x250000 untouched.
hi3516cv300 and gk7205v200 build too.
From review: a build that saved its environment after the scan could
already have stored a split boot's bootargs without root= and mtdparts=.
On fixed slots, when both are missing, the scan appends
"root=/dev/mtdblock3 mtdparts=${mtdparts}" for this boot; a command line
naming either is the owner's and is left alone.

Checked in qemu-hisilicon (hi3516ev200, fixed slots): bootargs saved as
"mem=${osmem} console=ttyAMA0,115200 panic=20 rootfstype=squashfs
init=/init", reset: the kernel gets root=/dev/mtdblock3 and the fixed
mtdparts, 6 cmdlinepart partitions, root on 31:3, login.
@widgetii
widgetii merged commit baa1506 into openipc-hisilicon Oct 21, 2026
74 checks passed
@widgetii
widgetii deleted the nor/split-ev200 branch October 21, 2026 13:16
widgetii added a commit to OpenIPC/defib that referenced this pull request Oct 21, 2026
…dv200 (#160)

Their firmware now ships the split NOR package beside the fixed-slot one
(OpenIPC/firmware#2655, on OpenIPC/linux#131), and their OpenIPC/u-boot
NOR build scans for it (OpenIPC/u-boot#48), so they join
`NOR_SPLIT_SOCS`: one `firmware.bin.<soc>` at 0x50000, the rest of the
chip erased. They already take `u-boot-<soc>-nor.bin`
(`PER_FLASH_TYPE_UBOOT`).

hi3516ev300 stays on fixed slots: its uImage (2009K with the split
options) fills the 2 MiB slot, over the 1983K a fixed-slot package
beside a split one may use, so its firmware ships no split package. A
test keeps it out even though its profile is an alias of hi3516ev200.

The split package appears with the next nightly. Until the U-Boot
publish workflow runs again, the published `u-boot-<soc>-nor.bin`
predates #48: the split image still boots under it (the kernel ignores
its fixed mtdparts, checked in QEMU), but its scan and `fwupd` for the
split image come with the republished build.

Not run on hardware; the firmware side was checked in qemu-hisilicon
(hi3516ev200, hi3518ev300; 8 and 16 MB). `pytest tests/
--ignore=tests/fuzz`: 1084 passed. ruff and mypy are clean.
widgetii added a commit to OpenIPC/defib that referenced this pull request Oct 22, 2026
hi3516ev300's firmware now ships only the split NOR package, like
hi3516cv6xx (OpenIPC/firmware#2656): its uImage (2008K with the split
options) fills the 2 MiB slot, so a fixed-slot package cannot ship
beside a split one. hi3518ev300 went split-only in the same PR; it is
already in `NOR_SPLIT_SOCS` (#160).

- hi3516ev300 joins `NOR_SPLIT_SOCS`, so `install` writes
`firmware.bin.hi3516ev300` at 0x50000 and erases the rest of the chip;
its U-Boot is the published `u-boot-hi3516ev300-nor.bin` (split mode
since OpenIPC/u-boot#48).
- The refusal test that used hi3516ev300 as a chip without the split
layout now uses hi3518ev200. CLAUDE.md lists it.

The split package appears with the next nightly. Not run on hardware;
the firmware side was checked in qemu-hisilicon (8 MB lite, 16 MB
ultimate: root on the split rootfs, overlay kept across a reboot).
`pytest tests/ --ignore=tests/fuzz`: 1084 passed. ruff and mypy are
clean.
widgetii added a commit that referenced this pull request Oct 22, 2026
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 added a commit that referenced this pull request Oct 22, 2026
* nor: split layout on the gk7205v500 family

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.

* openipc: recovery checks what it runs, whatever verify the board set

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 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.
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