Skip to content

nor: the split layout is a uImage + squashfs, and the kernel is told nothing - #20

Merged
widgetii merged 2 commits into
openipc-hisiliconfrom
nor/split-uimage
Oct 18, 2026
Merged

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

Conversation

@widgetii

Copy link
Copy Markdown
Member

The split NOR layout was a FIT followed by the squashfs, which only a
FIT-capable U-Boot boots, and the kernel learned its partitions and root
from the mtdparts and root= this bootloader passed. Both move to the
kernel (OpenIPC/linux): the gk7205v200 family's device tree carries the
layout, mtdsplit divides a uImage followed by the squashfs, and the root
the split finds is taken whatever root= says. So any U-Boot that can
bootm a uImage at 0x50000 boots the layout -- the factory XM one
included -- and this one only has to stop telling the kernel otherwise.

  • The split layout is recognised as a uImage at the kernel offset with
    the scan's squashfs at the next 64 KiB block after it; fixed slots put
    the squashfs at the slot boundary.
  • On it, mtdparts=, root= and openipc_nor_fit= are dropped from bootargs
    (RAM only), and verify is unset so bootm checks the uImage CRC.
    kernsize/rootaddr/rootsize keep naming the fixed slots for uk/ur.
  • CONFIG_OPENIPC_NOR_FIT_SPLIT becomes CONFIG_OPENIPC_NOR_SPLIT, with no
    FIT dependency; CONFIG_SHA1 leaves the four fragments. NOR images
    210-211 KB (gk7205v200/v300), down from 222.

FIT split images are no longer recognised: none were released outside
the 2026-10-17 nightly.

Tested in QEMU (qemu-hisilicon gk7205v200): the split image boots with
"mem=32M console=ttyAMA0,115200 panic=20 rootfstype=squashfs init=/init"
and "Verifying Checksum ... OK"; the fixed-slot package keeps its
mtdparts and root=/dev/mtdblock3.

On hardware: flashed on a GK7205V300 (16 MB NOR), it boots the split
uImage with "Verifying Checksum ... OK" and the same clean command line;
the kernel splits firmware from its device tree, overlay rw, majestic up.

Kernel side: OpenIPC/linux#97 (merged). Firmware side: OpenIPC/firmware#2623 (merged).

…nothing

The split NOR layout was a FIT followed by the squashfs, which only a
FIT-capable U-Boot boots, and the kernel learned its partitions and root
from the mtdparts and root= this bootloader passed. Both move to the
kernel (OpenIPC/linux): the gk7205v200 family's device tree carries the
layout, mtdsplit divides a uImage followed by the squashfs, and the root
the split finds is taken whatever root= says. So any U-Boot that can
bootm a uImage at 0x50000 boots the layout -- the factory XM one
included -- and this one only has to stop telling the kernel otherwise.

- The split layout is recognised as a uImage at the kernel offset with
  the scan's squashfs at the next 64 KiB block after it; fixed slots put
  the squashfs at the slot boundary.
- On it, mtdparts=, root= and openipc_nor_fit= are dropped from bootargs
  (RAM only), and verify is unset so bootm checks the uImage CRC.
  kernsize/rootaddr/rootsize keep naming the fixed slots for uk/ur.
- CONFIG_OPENIPC_NOR_FIT_SPLIT becomes CONFIG_OPENIPC_NOR_SPLIT, with no
  FIT dependency; CONFIG_SHA1 leaves the four fragments. NOR images
  210-211 KB (gk7205v200/v300), down from 222.

FIT split images are no longer recognised: none were released outside
the 2026-10-17 nightly.

Tested in QEMU (qemu-hisilicon gk7205v200): the split image boots with
"mem=32M console=ttyAMA0,115200 panic=20 rootfstype=squashfs init=/init"
and "Verifying Checksum ... OK"; the fixed-slot package keeps its
mtdparts and root=/dev/mtdblock3.

On hardware: flashed on a GK7205V300 (16 MB NOR), it boots the split
uImage with "Verifying Checksum ... OK" and the same clean command line;
the kernel splits firmware from its device tree, overlay rw, majestic up.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Boot split NOR firmware as uImage with kernel-managed partitions

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Recognize split NOR firmware by its uImage and adjacent squashfs, enabling boot with
 uImage-capable U-Boot.
• Remove legacy partition and root arguments for split boots; retain fixed-slot upgrade settings and
 checksum verification.
• Enable the new layout on four boards without FIT or SHA1 dependencies.
Diagram

graph TD
  CFG["Board configs"] --> SCAN["NOR flash scan"] --> LAYOUT{"Split layout?"}
  LAYOUT -->|yes| SPLIT["Strip legacy args"] --> BOOT["Boot uImage"] --> LINUX["Linux rootfs"]
  LAYOUT -->|no| FIXED["Keep fixed slots"] --> BOOT
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep FIT and upgrade bootloaders
  • ➕ Retains FIT-based kernel and device-tree hash verification.
  • ➖ Excludes factory U-Boot implementations that can boot a uImage but not FIT.
  • ➖ Requires a bootloader replacement to use split firmware.

Recommendation: Prefer the uImage approach because compatibility with factory U-Boot is the central goal. Relying on the kernel's device tree for split partitions also avoids passing a layout that may be stale in saved boot arguments; review the FIT compatibility tradeoff explicitly.

Files changed (6) +116 / -116

Enhancement (1) +95 / -91
openipc.cDetect split uImage firmware and clean its boot environment +95/-91

Detect split uImage firmware and clean its boot environment

• Recognizes split firmware when the scanned squashfs follows the uImage at the next 64 KiB boundary. For split boots, removes legacy boot arguments, enables uImage CRC verification, and keeps fixed-slot addresses for upgrade commands; the fixed-layout path no longer rewrites root arguments.

common/openipc.c

Other (5) +21 / -25
KconfigDefine uImage-based split NOR support +9/-9

Define uImage-based split NOR support

• Replaces the FIT-specific option with CONFIG_OPENIPC_NOR_SPLIT and removes its FIT dependency. Documents kernel-managed partitions and the requirement for a compatible board kernel.

common/Kconfig

xm72020300_configEnable uImage split NOR on xm72020300 +3/-4

Enable uImage split NOR on xm72020300

• Selects CONFIG_OPENIPC_NOR_SPLIT instead of FIT-specific split support and removes FIT and SHA1 selections.

openipc/xm72020300_config

xm72050200_configEnable uImage split NOR on xm72050200 +3/-4

Enable uImage split NOR on xm72050200

• Selects CONFIG_OPENIPC_NOR_SPLIT instead of FIT-specific split support and removes FIT and SHA1 selections.

openipc/xm72050200_config

xm72050300_configEnable uImage split NOR on xm72050300 +3/-4

Enable uImage split NOR on xm72050300

• Selects CONFIG_OPENIPC_NOR_SPLIT instead of FIT-specific split support and removes FIT and SHA1 selections.

openipc/xm72050300_config

xm76050100_configEnable uImage split NOR on xm76050100 +3/-4

Enable uImage split NOR on xm76050100

• Selects CONFIG_OPENIPC_NOR_SPLIT instead of FIT-specific split support and removes FIT and SHA1 selections.

openipc/xm76050100_config

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

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Some fixed-slot cameras lose their root ✓ Resolved
Description
nor_split_layout() treats a fixed-slot image as split when its uImage ends within the final 64 KiB
of the kernel slot, because the aligned image length then equals the slot size. On these images, the
split branch removes the fixed layout’s root= and mtdparts= arguments even though the squashfs
is at the normal fixed-slot boundary.
Code

common/openipc.c[554]

+  return rootfs_off == kernel_off + ALIGN(image_get_image_size(&hdr), 0x10000);
Evidence
The fixed layouts put the rootfs 2 MiB or 3 MiB after the kernel. A uImage length in the last 64 KiB
of either slot rounds up to exactly that offset, satisfying the new split test; that branch then
deletes the default arguments identifying the fixed root and partitions.

common/openipc.c[546-555]
common/openipc.c[509-535]
common/openipc.c[631-678]
include/configs/openipc-common.h[169-169]
include/configs/openipc-common.h[183-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
A fixed-slot uImage that fills all but the final 64 KiB of its kernel slot satisfies the new split-layout test. The split branch then removes the root and partition arguments required by that fixed layout.
## Fix Focus Areas
- common/openipc.c[546-555]
- common/openipc.c[631-678]
## Recommended Fix
Do not infer a split layout solely from equality between the aligned uImage length and a fixed-slot rootfs offset. Add a reliable distinguishing check before stripping boot arguments, and test uImages ending in the last 64 KiB of both supported fixed kernel slots.

ⓘ 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 move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread common/openipc.c
…Image size

A fixed-slot uImage ending in the 2 MiB slot's last 64 KiB block puts
the squashfs at the slot boundary right after it, the split shape. The
split branch then dropped mtdparts= and root=, which a kernel from
before the split layout needs to find its root. A squashfs at
kernel_off + 2 MiB or 3 MiB now keeps the fixed-slot path; a split image
of that size boots all the same, as the kernel splits it from its
device tree and ignores both.

Tested in QEMU (qemu-hisilicon gk7205v200) with the uImage padded to
2000K: the 2026-10-17 nightly's fixed-slot package (pre-split kernel)
gets mtdparts and root=/dev/mtdblock3 and mounts its root; the new
kernel in the same shape splits from the DT; a normal split image still
boots with the clean command line and "Verifying Checksum ... OK".
@widgetii
widgetii merged commit 5547c2a into openipc-hisilicon Oct 18, 2026
72 checks passed
widgetii added a commit to OpenIPC/defib that referenced this pull request Oct 18, 2026
OpenIPC moves the split NOR layout's firmware.bin from a FIT to the
legacy
uImage followed by the squashfs at the next 64 KiB block, and the kernel
now finds the layout's partitions and root in its own device tree,
whatever the bootloader passes. Any U-Boot that bootm's a uImage at
0x50000 boots it, the factory XM U-Boot included, which has no FIT.

- split_image_end() reads the uImage header (data size at bytes 12..15)
  instead of a FIT's totalsize; the shape checks are otherwise the same.
- The warning on a plan without the uboot stage goes: the U-Boot already
  on the flash boots the image whichever it is.
- README and the firmware table say uImage.

Tests: the split fixture is a uImage; a FIT now fails the shape check.

Matches OpenIPC/linux#97, OpenIPC/firmware#2623 and OpenIPC/u-boot#20
(all merged). The format was verified on hardware with sysupgrade and in
QEMU; `defib install` of the uImage split image itself has not been run
on a camera.
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