Skip to content

nor: boot the split layout, FIT and squashfs in one firmware partition - #18

Merged
widgetii merged 3 commits into
openipc-hisiliconfrom
nor/fit-split
Oct 17, 2026
Merged

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

Conversation

@widgetii

@widgetii widgetii commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

This is opt-in through CONFIG_OPENIPC_NOR_FIT_SPLIT, enabled here for gk7205v200 and gk7205v300. The NOR offsets in openipc-common.h are unchanged, and a uImage at the kernel offset boots exactly as before.

A FIT at the NOR kernel offset means the split layout: firmware.bin, which is the hashed FIT followed by the squashfs at the next 64 KiB, written whole at 0x50000. In that case firmware_scan():

Changes:

  • Saved env: a saved root=/dev/mtdblock3 is rewritten in RAM to mtdblock4 under the split numbering, and to mtdblock3 for fixed slots.
  • Capability token: openipc_nor_fit=1 joins the command line on either layout. sysupgrade looks for it before writing a firmware.bin, and refuses without it.
  • bootm_size is set when a saved env lacks it.
  • Hash checking: the FIT's crc32 and sha1 are checked. misc_init_r() used to set verify=n after openipc_helper(), and envs saved by the old bootloaders carry verify=n too. The board now sets it first, and the FIT path unsets it in RAM.
  • Size: CONFIG_FIT and CONFIG_SHA1 for these boards bring the NOR images to 216–217 KB of 256 KB.

hi3516cv610 also boots a FIT from NOR, but its kernel has no mtdsplit, so the option stays off there.

Verified on hardware

GK7205V200 (8 MB NOR) and GK7205V300 (16 MB NOR), the latter with an env saved by u-boot-gk7205v200:

  • Split layout: Verifying Hash Integrity ... crc32+ sha1+ OK for the kernel and the DTB, the kernel splits firmware at the computed offsets, and boot reaches login.
  • Fixed slots: a fixed-slot uImage camera boots unchanged under the same image (root=/dev/mtdblock3 plus the token).
  • Upgrades: sysupgrade from fixed slots to split, split to split, and -n all work, with settings carried where they should be.

Review fix

  • TFTP update commands: on the split layout, kernsize, rootaddr and rootsize now name the fixed slots. So uk/ur/fwupd, which install a uImage and a squashfs, rebuild a consistent fixed-slot layout instead of writing at split offsets. loadkernel reads the slot, which holds the whole FIT.

Verified on GK7205V200 with U-Boot loaded into RAM:

  • the split boot still checks the FIT hashes;
  • ur then uk from TFTP turn a split camera into fixed slots, which boot.

With CONFIG_OPENIPC_NOR_FIT_SPLIT (on for gk7205v200 and gk7205v300 here),
a FIT at the NOR kernel offset means the split layout: firmware.bin, the
hashed FIT and then the squashfs at the next 64 KiB boundary, written
whole at 0x50000. firmware_scan() passes Linux
"256k(u-boot),64k(env),-(firmware)" and the kernel divides that
partition into kernel, rootfs and rootfs_data (mtdsplit). The read is
the FIT's own size, and nothing is clamped to a slot. A uImage keeps
today's fixed slots, unchanged.

- A saved bootargs spells out root=/dev/mtdblock3, which under the split
  numbering (u-boot, env, firmware, kernel, rootfs, rootfs_data) is the
  FIT. The token is rewritten in RAM: mtdblock4 for the split layout,
  mtdblock3 for fixed slots.
- openipc_nor_fit=1 joins the command line on either layout. sysupgrade
  reads it to know this bootloader boots the split layout before writing
  a firmware.bin for it.
- bootm_size is set when a saved env lacks it, so the relocated DTB
  stays in the kernel's lowmem.
- CONFIG_FIT and CONFIG_SHA1 for those boards; their NOR images grow from
  205 KB to 216-217 KB (256 KB boot partition).
- check_kernel/check_squashfs are __maybe_unused: NAND builds no longer
  call them.

hi3516cv610 also boots a FIT from NOR, but its kernel has no mtdsplit and
keeps fixed slots, so the option is off there.
misc_init_r() set verify=n after openipc_helper() had run, and cameras
upgraded from the old bootloader carry verify=n in their saved env as
well. So bootm loaded the FIT without checking its crc32 and sha1. For
gk7205v200 and gk7205v300 the board now sets it before
openipc_helper(), and firmware_scan() drops it (RAM only) when it boots
the split layout's FIT. A uImage keeps verify=n, as before.

Verified on a GK7205V200 with its env saved by u-boot-gk7205v200:
'Verifying Hash Integrity ... crc32+ sha1+ OK' for the kernel and the
DTB, then boot to login.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Boot split NOR FIT firmware while preserving fixed-slot images

✨ Enhancement 🐞 Bug fix ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Detect split NOR firmware from its FIT header while retaining fixed-slot uImage booting.
• Pass a single firmware partition to mtdsplit and adjust saved boot arguments in RAM.
• Enable FIT hash verification and opt in on GK7205V200 and GK7205V300.
Diagram

graph TD
  init["Board init"] --> scan["Firmware scan"] --> flash["SPI NOR"] --> detect{"FIT header?"} --> split["Split boot setup"] --> mtdsplit["Kernel mtdsplit"] --> boot["Linux boot"]
  detect --> fixed["Fixed-slot setup"] --> boot
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep fixed kernel and rootfs slots
  • ➕ Avoids a dependency on kernel mtdsplit and preserves the existing partition map.
  • ➖ Cannot boot the proposed single-partition firmware image without changing its packaging.
2. Calculate split partitions in U-Boot
  • ➕ Could avoid relying on kernel-side partition discovery.
  • ➖ Duplicates image-layout knowledge in the bootloader and kernel, increasing upgrade compatibility risk.

Recommendation: Use the opt-in FIT detection and kernel mtdsplit approach: it supports whole-image upgrades without changing fixed-slot uImage booting or NOR offsets. Keep the option limited to boards whose kernels provide mtdsplit.

Files changed (6) +113 / -4

Enhancement (1) +89 / -2
openipc.cSelect split or fixed NOR boot settings from the image +89/-2

Select split or fixed NOR boot settings from the image

• Detects a FIT at the kernel offset, sizes its read from the FIT header, and supplies a single firmware partition for kernel mtdsplit. Adjusts saved root arguments in RAM, adds the upgrade capability token, supplies a missing 'bootm_size', and enables FIT verification; uImages retain fixed-slot behavior. Marks kernel and squashfs checkers as potentially unused in NAND builds.

common/openipc.c

Bug fix (2) +6 / -2
board.cSet verification default before firmware scanning +3/-1

Set verification default before firmware scanning

• Moves 'verify=n' ahead of 'openipc_helper()' so FIT detection can unset it without a later board initialization step restoring it.

board/xmedia/xm72050200/board.c

board.cPreserve FIT verification decision during board initialization +3/-1

Preserve FIT verification decision during board initialization

• Sets 'verify=n' before 'openipc_helper()', allowing the split-FIT scan path to enable hash checking even with an older saved environment.

board/xmedia/xm72050300/board.c

Other (3) +18 / -0
KconfigAdd opt-in split NOR FIT capability +10/-0

Add opt-in split NOR FIT capability

• Introduces 'OPENIPC_NOR_FIT_SPLIT', dependent on FIT, for boards whose kernels can split a combined firmware partition.

common/Kconfig

xm72050200_configEnable split NOR FIT boot on GK7205V200 +4/-0

Enable split NOR FIT boot on GK7205V200

• Enables FIT, SHA1, and the split NOR layout option for this board configuration.

openipc/xm72050200_config

xm72050300_configEnable split NOR FIT boot on GK7205V300 +4/-0

Enable split NOR FIT boot on GK7205V300

• Enables FIT, SHA1, and the split NOR layout option for this board configuration.

openipc/xm72050300_config

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

qodo-free-for-open-source-projects Bot commented Oct 17, 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. Standard builds omit split firmware support 🐞 Bug ≡ Correctness
Description
The new options are added to xm72050200_config and xm72050300_config, but build_xmedia()
selects ${soc}_config for the advertised GK7205V200 and GK7205V300 targets. For those targets it
looks for gk7205v200_config and gk7205v300_config, neither of which exists, so this build path
never consumes the new flags or produces the intended split-capable images.
Code

openipc/xm72050200_config[R6-8]

+CONFIG_FIT=y
+CONFIG_SHA1=y
+CONFIG_OPENIPC_NOR_FIT_SPLIT=y
Evidence
The build dispatch passes the GK SoC name into a ${soc}_config selection, while the only files
setting the new symbol have xm-prefixed names.

build.sh[177-195]
build.sh[245-255]
openipc/xm72050200_config[5-8]
openipc/xm72050300_config[11-14]

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 GK7205 build dispatch does not select the configuration fragments that enable split NOR firmware support.
## Fix Focus Areas
- openipc/xm72050200_config[5-8]
- openipc/xm72050300_config[11-14]
- build.sh[245-255]
## Recommended Fix
Map the GK7205V200 and GK7205V300 build targets to their corresponding xm configuration fragments, and verify that both generated NOR configurations retain the new options.

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



Remediation recommended

2. Firmware updates can misplace the rootfs ✓ Resolved
Description
The FIT branch sets rootaddr to the detected squashfs offset, but the existing urwrite command
replaces it with the fixed-slot address 0x350000 when the rootfs file exceeds its size threshold.
Running U-Boot's fwupd command on an installed split image with such a rootfs erases and writes at
that legacy address before writing the FIT, leaving the rootfs outside the location the split image
expects.
Code

common/openipc.c[630]

+      env_set("rootaddr", str);
Evidence
The new scan supplies a layout-dependent rootaddr; the existing update sequence runs ur before
uk, and urwrite can replace that address with mtdsultimate's fixed value.

common/openipc.c[618-630]
include/configs/openipc-common.h[125-127]
include/configs/openipc-common.h[165-171]

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 legacy NOR rootfs update command can override the detected split-layout rootfs address during a U-Boot firmware update.
## Fix Focus Areas
- common/openipc.c[624-630]
- include/configs/openipc-common.h[167-171]
## Recommended Fix
Give split-layout updates a command that preserves the detected rootfs offset and erases only its appropriate range, or explicitly reject legacy separate-image updates on that layout.

ⓘ 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 see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread openipc/xm72050200_config
Comment on lines +6 to +8
CONFIG_FIT=y
CONFIG_SHA1=y
CONFIG_OPENIPC_NOR_FIT_SPLIT=y

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Standard builds omit split firmware support 🐞 Bug ≡ Correctness

The new options are added to xm72050200_config and xm72050300_config, but build_xmedia()
selects ${soc}_config for the advertised GK7205V200 and GK7205V300 targets. For those targets it
looks for gk7205v200_config and gk7205v300_config, neither of which exists, so this build path
never consumes the new flags or produces the intended split-capable images.
Agent Prompt
## Issue description
The GK7205 build dispatch does not select the configuration fragments that enable split NOR firmware support.
## Fix Focus Areas
- openipc/xm72050200_config[5-8]
- openipc/xm72050300_config[11-14]
- build.sh[245-255]
## Recommended Fix
Map the GK7205V200 and GK7205V300 build targets to their corresponding xm configuration fragments, and verify that both generated NOR configurations retain the new options.

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

Comment thread common/openipc.c
The FIT path set kernsize to the FIT and rootaddr to the squashfs
behind it. uk, ur and fwupd install a uImage and a squashfs, so on a
split camera they wrote fixed-slot images at split offsets: ur at
0x230000 with the default rootsize, uk over the FIT only. The next scan
found the rootfs at 0x230000, sized the kernel slot from it, and the
mtdparts it built did not match where the rootfs is.

kernsize, rootaddr and rootsize now name the fixed slots: kernel 2 MiB
and rootfs 5 MiB, or 3 and 10 MiB on 16 MiB parts when the FIT needs
3; urwrite still moves to the ultimate slots for a big rootfs, as
before. uk erases the whole kernel slot, so no head of the split
squashfs is left for the scan to find. loadkernel reads the slot, which
holds the whole FIT.

Verified on GK7205V200 (U-Boot loaded into RAM with defib): the split
layout still boots with the FIT hashes checked; ur then uk with
rootfs.squashfs and uImage from TFTP turn the split camera into fixed
slots, found at 0x50000 and 0x250000, and it boots to login.
@widgetii

Copy link
Copy Markdown
Member Author

Qodo #1 ("Standard builds omit split firmware support"): openipc/gk7205v200_config and openipc/gk7205v300_config are symlinks in git (mode 120000) to xm72050200_config and xm72050300_config, so build_xmedia gk7205v200 gk7205v200_config reads the edited fragments. The images I tested on hardware were built by build.sh gk7205v200 gk7205v300, and they check the FIT hashes at boot.

Qodo #2 (uk/ur on the split layout) was real. It's fixed in the latest commit, and verified on GK7205V200.

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

Copy link
Copy Markdown

Qodo #1 ("Standard builds omit split firmware support"): openipc/gk7205v200_config and openipc/gk7205v300_config are symlinks in git (mode 120000) to xm72050200_config and xm72050300_config, so build_xmedia gk7205v200 gk7205v200_config reads the edited fragments. The images I tested on hardware were built by build.sh gk7205v200 gk7205v300, and they check the FIT hashes at boot.

Qodo #2 (uk/ur on the split layout) was real. It's fixed in the latest commit, and verified on GK7205V200.

Your clarification invalidates the basis for finding 1: if openipc/gk7205v200_config and openipc/gk7205v300_config are Git symlinks to the edited xm* fragments, then build_xmedia resolves the new options correctly. The finding was based on checking only the fragment filenames, not their symlink targets.

For finding 2, the reported issue is addressed in your latest commit and has been verified on GK7205V200. I can’t independently inspect that commit from the supplied diff, but the described verification confirms the intended update-path fix.

@widgetii
widgetii merged commit 7e52056 into openipc-hisilicon Oct 17, 2026
72 checks passed
widgetii added a commit that referenced this pull request Oct 17, 2026
Same as gk7205v200 and gk7205v300 (#18): CONFIG_FIT, CONFIG_SHA1 and
CONFIG_OPENIPC_NOR_FIT_SPLIT in their fragments, and verify=n set before
openipc_helper() so firmware_scan() can drop it for a FIT. Their kernels
come from the same OpenIPC/linux goke-gk7205v200 branch, which carries
mtdsplit, and OpenIPC/firmware already enables it for both.

NOR images: gk7202v300 222 KB, gk7605v100 216 KB (256 KB boot
partition).

Build-tested only: no gk7202v300 or gk7605v100 board was run.
widgetii added a commit to OpenIPC/wiki that referenced this pull request Oct 17, 2026
…0 family (#605)

A new page for the split NOR layout on GK7205V200, GK7205V300, GK7202V300
and GK7605V100 (OpenIPC/linux#96, OpenIPC/u-boot#18 and #19,
OpenIPC/firmware#2617 and #2621):
- what the layout is, and how mtdsplit divides it at boot;
- what it needs: the u-boot-<soc>-nor.bin bootloader and the -split
  package;
- how to tell which layout a camera runs;
- moving a camera over: the bootloader, then sysupgrade -k -r;
- how sysupgrade carries the settings, -n, and what it refuses;
- writing the image from U-Boot, and going back to fixed slots.

The console lines quoted are from the lab GK7205V200 and GK7205V300.
Linked from the README, install-goke and sysupgrade.
widgetii added a commit to OpenIPC/website that referenced this pull request Oct 17, 2026
…yout (#482)

* Wizard: the GK7205V200 family on OpenIPC/u-boot, and the split NOR layout

GK7202V300, GK7205V200, GK7205V210, GK7205V300 and GK7605V100 now install
OpenIPC/u-boot's u-boot-<soc>-nor.bin (OpenIPC/u-boot#18, #19), published
in latest, in place of the -universal.bin of the retired u-boot-gk7205v200
repository. That bootloader scans the NOR layout at boot, so these SoCs
take the #477 install: each image written at its offset, no uknor/urnor
macros, no sf lock.

The same bootloader boots the split NOR layout (OpenIPC/linux#96,
OpenIPC/firmware#2617, #2621): one firmware.bin -- a hashed FIT, then the
squashfs at the next 64 KiB -- at 0x50000, which the kernel divides into
kernel, rootfs and rootfs_data at boot. Their firmware publishes it as
openipc.<board>-nor-<edition>-split.tgz beside the fixed-slot package.
The catalogue marks these SoCs nor_split; where the -split package is
published for the board and edition, the Linux step writes that one
image at 0x50000 and erases to the end of the chip in the same guarded
line (0x7b0000 on 8 MB, 0xfb0000 on 16 MB), and the page links the
-split package. Where it is not, the two-image install stays. The full
image and the backup/restore steps are unchanged: the bootloader boots
the fixed slots the full image carries.

The fixture index gains the four published u-boot-<soc>-nor.bin, so the
availability reference stands; boards.json and the documents golden are
regenerated for the five SoCs. TestSplitNORInstall covers the split
lines, gk7205v210 through its gk7205v200 build, the SD path, and the
fall-back when no -split package is published.

The split install was verified on the lab GK7205V200 (8 MB) and GK7205V300
(16 MB) with these bootloaders and the 2026-10-17 nightly's images, by
the same U-Boot write: boots with the FIT hashes checked and kernel,
rootfs and rootfs_data where the image puts them.

* Wizard: the GK7205V200 family's NAND bootloader is OpenIPC/u-boot's -nand.bin

Review of the previous commit: Bootloader("nand") falls back to
uboot_filename, so moving these SoCs to u-boot-<soc>-nor.bin handed that
NOR build to NAND installs and NAND full images.

OpenIPC/u-boot publishes a NAND build for each of them too,
u-boot-<soc>-nand.bin in latest, and that build is the UBI-only layout
(768k boot, 256k env, the rest one UBI device), the same as u-boot-xmedia's.
So the catalogue names it as uboot_nand_filename, which is what moves a
SoC's NAND installs onto that layout; defib (OpenIPC/defib#154) installs
these SoCs on NAND the same way. The retired -universal.bin, and its split
NAND layout, is not offered for them again.

The fixture index gains the four published -nand.bin. boards.json carries
them; the gk7202v300 NAND row of the image reference is dropped, since it
is the split NAND layout this SoC no longer installs (hi3516av100's row
still covers that layout). The documents golden is regenerated.
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