Repository navigation
gk7205v200: kernel and rootfs in one NOR partition, split at boot - #2617
Conversation
The fixed slots -- kernel 2 MiB at 0x50000, rootfs 5 MiB after it -- each
cap their image on their own, so slack in one is lost to the other and
every build is a round of trimming. On the gk7205v200 family the kernel
now splits one "firmware" partition at boot (mtdsplit, OpenIPC/linux):
the FIT at its start, the squashfs at the next 64 KiB, rootfs_data from
the squashfs end. Only the sum has to fit the chip.
Build: the kernel enables MTD_SPLIT_FIRMWARE, the FIT and squashfs
parsers and MTD_ROOTFS_ROOT_DEV; legacy fixed-slot command lines are
left unsplit. post-image.sh packs firmware.bin, a crc32+sha1 FIT (zImage
and the board DTB, nor-fit.its, described "OpenIPC <soc>") then the
squashfs.
Packages: the plain openipc.<soc>-nor-<variant>.tgz stays the fixed-slot
uImage and rootfs, gated as before -- every camera in the field upgrades
from it with its own sysupgrade, and the openipc.org installer reads it.
firmware.bin goes into openipc.<soc>-nor-<variant>-split.tgz, a name no
older sysupgrade looks for, gated against the chip less boot, env and a
256 KiB overlay. The space win arrives when the plain package is retired.
sysupgrade: a bootloader that boots the layout says so with
openipc_nor_fit=1 (OpenIPC/u-boot, CONFIG_OPENIPC_NOR_FIT_SPLIT), and
the default URL then names the -split package. firmware.bin goes down
through mtdblock at 0x50000, over the "firmware" partition or, from
fixed slots, across kernel, rootfs and rootfs_data. The overlay moves
with the squashfs end, so its contents travel as a blob ("OPENIPC-OVL1",
12-digit length, gzipped tar) written where the new rootfs_data starts;
-n writes a blob of length 0. dd runs with conv=fsync: from fixed slots
the mounted root holds "rootfs" open, mtdblock keeps its last block
cached until a flush, and a plain sync does not send one -- the blob was
lost at the reboot without it (GK7205V300). Both writes are then read
back through the MTD character device. Refused before anything is
written: a split image on a bootloader without the token, another SoC's
image, one that leaves no block for settings, and a separate kernel and
rootfs on a camera already on the split layout.
/init restores the blob before it mounts rootfs_data: erase the
partition, mount it, untar, unmount. Length 0 only erases.
Tests: test_sysupgrade.sh covers the split write, the overlay offset,
-n, the move from fixed slots, the refusals, the read-back and the
default URL; test_init_overlay.sh runs the carry-over itself.
Verified on GK7205V200 (8 MB) and GK7205V300 (16 MB) NOR with OpenIPC
U-Boot built with CONFIG_OPENIPC_NOR_FIT_SPLIT: FIT hashes checked at
boot, /proc/mtd split as computed; upgrades to a bigger and a smaller
image, from fixed slots, and split to split carry claim, keys and a
marker file, using the sysupgrade inside the image; -n comes up on
defaults; the new kernel as a uImage boots the fixed-slot layout
unchanged; the plain package on a split camera and a split image on a
token-less bootloader are refused with nothing written and no reboot.
PR Summary by QodoAdd split-NOR firmware packaging and upgrades for Goke cameras
AI Description
Diagram
High-Level Assessment
Files changed (15)
|
Code Review by Qodo
1. Hardware verification lacks measured output
|
From review of the split-layout upgrade:
sysupgrade
- The FIT's SoC, bytes past the squashfs, and settings too big for what
the image leaves are now refused before the RAM pivot, where a refusal
still costs no reboot. The writer keeps its own checks.
- A camera on the split layout takes only a split firmware.bin: any
other combined image used to fall through to a whole-partition write
over "firmware".
- --channel/--build resolve the plain package from the manifest; a
camera whose bootloader boots the layout now fetches the -split one
beside it, as the default URL already did. The manifest itself keeps
listing only the plain package, which older cameras install from.
/init
- The carry-over runs only after flash_aliased says the chip is what the
kernel thinks, and is skipped on an aliased one.
- Nothing is erased until the archive is read whole and lists clean. A
short read or no RAM keeps the blob for the next boot and boots on a
RAM overlay; a damaged archive is reported and left to the usual
mount. Every failure goes to the console and /dev/kmsg.
CI: the -split package made `find openipc*nor*` return two paths, so
the NOR upload step skipped; the plain package is picked by name.
Verified on GK7205V200 and GK7205V300 with the images built from this
tree, using the sysupgrade inside them: fixed slots to split and split
to split carry settings ("Settings restored."), -n comes up on
defaults ("Clearing settings after an upgrade...").
Their kernels already carry mtdsplit and the split options (the gk7205v200 family's config fragments, #2617), but only the gk7205v200 and gk7205v300 defconfigs ran post-image.sh, so these two produced no firmware.bin and no -split package. They now do, beside the unchanged plain package. OpenIPC/u-boot#19 enables the layout in their bootloaders; until a camera runs one, sysupgrade keeps it on the plain package. Local builds: gk7202v300_lite firmware.bin 7040KB/7616KB, gk7605v100_lite 7040KB/7616KB; each FIT is described "OpenIPC <soc>". Build-tested only: no gk7202v300 or gk7605v100 camera was run.
…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.
…family (#154) gk7202v300, gk7205v200, gk7205v300 and gk7605v100 now boot OpenIPC/u-boot (`openipc-hisilicon`), published per flash type as `u-boot-<soc>-nor.bin` and `-nand.bin`. Their firmware also ships the split NOR layout (OpenIPC/firmware#2617, #2621) as `openipc.<board>-nor-<variant>-split.tgz`: one `firmware.bin` written at 0x50000, which the kernel divides into kernel, rootfs and rootfs_data at boot (OpenIPC/linux#96). ### What changes - **U-Boot:** the four SoCs join `PER_FLASH_TYPE_UBOOT`, so `burn`, `install` and `restore` fetch `-nor.bin`/`-nand.bin`. Before this they fetched the old `-universal.bin` from the retired u-boot-gk7205v200 repo. - **Environment:** that U-Boot works out the NOR layout at every boot and sets mtdparts and the root device itself. It has no `bootcmdnor`, so the env stage's `setenv bootcmd ${bootcmdnor}` would have left these cameras without a bootcmd. On these SoCs the env stage now loads the defaults (`env default -a`) and carries `ethaddr` and `totalmem` across. - `totalmem` is the DRAM size U-Boot measured. Without the saved value, Linux assumes 64 MB. - **Split package:** `install` recognises it by its contents. - The image is checked for its shape (FIT, then a squashfs at the next 64 KiB, nothing after it) and for the board it names. - The rootfs stage writes it at 0x50000 and erases to the end of the chip. The kernel and rootfs-data stages have nothing of their own to do. - The size check is the image end plus one block of overlay against the detected chip. - Refused: another SoC, NAND, a stock-U-Boot migration, and `--wipe-rootfs-data` without the rootfs stage. A plan without the uboot stage gets a warning. - **Flash size:** this U-Boot's `sf probe 0` prints nothing at the prompt. Before this, the size fell back to 8 MiB, so a 16 MB board would have been laid out as 8 MB. When the probe gives no size, 16-byte `sf read`s just below 32, 16 and 8 MiB ask the chip: `sf read` refuses offsets past the end. - **`sf lock`:** its `sf` has no lock subcommand. The console's echo of `sf lock 0` above the usage table was taken for a table entry, which made the unlock a hard failure. Only lines from `Usage:` on count now. ### Tests - `tests/test_install_nor_split.py` drives `run_install` against a fake NOR console that keeps every byte of an 8 MiB chip. It answers `sf probe`/`sf lock` as this U-Boot does and refuses out-of-range reads. It covers the split and fixed-slot packages, the package checks and the refusals. - New helper tests cover the size reads and the `sf lock` echo. `test_firmware.py` is updated for the new U-Boot names. - The full suite passes, and so do ruff and mypy. ### Verified on hardware `defib install` with the split packages built from OpenIPC/firmware master, and the published U-Boot (`g7e52056f`): - **GK7205V200 (8 MiB):** U-Boot and `firmware.bin` written and CRC-verified, erased 0x50000+0x7B0000. It boots with `Verifying Hash Integrity ... crc32+ sha1+ OK`, and the partitions are where expected: kernel 0x50000–0x230000, rootfs from 0x230000, rootfs_data from 0x730000. - **GK7205V300 (16 MiB, detected by the reads):** erased 0x50000+0xFB0000, rootfs_data from 0x8D0000. After the `totalmem` fix, the first boot picks the CMA allocator with a 96 MB zone, as before the install.
…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.
Today each image has to fit its own fixed slot: kernel 2 MiB, rootfs 5 MiB (8 MB parts) or 8 MiB. Slack in one slot is lost to the other, and every build becomes a round of trimming. On the gk7205v200 family, a camera can now carry both in one
firmwarepartition, which the kernel splits at boot. Only the sum has to fit the chip.Depends on OpenIPC/linux#96 (mtdsplit) and OpenIPC/u-boot#18 (boots the layout), both merged.
What ships
openipc.<soc>-nor-<variant>.tgzis unchanged: the fixed-slot uImage and rootfs, size-gated as before. Every camera in the field upgrades from it with its own sysupgrade, and the openipc.org installer reads it.openipc.<soc>-nor-<variant>-split.tgzis new and holdsfirmware.bin:The space win arrives once the plain package can be retired.
sysupgrade
openipc_nor_fit=1to the command line. The default URL then names the-splitpackage.firmware.bingoes down through mtdblock at 0x50000, either overfirmwareor, coming from fixed slots, across kernel, rootfs and rootfs_data. Each write runsdd conv=fsync, then is read back through the MTD character device. Without the fsync, the last block written into the mountedrootfsstayed in mtdblock's cache and was lost at the reboot (measured on GK7205V300).OPENIPC-OVL1, a 12-digit length, a gzipped tar) written where the new rootfs_data starts./initrestores it before it mounts the overlay.-nwrites a blob of length 0, which only erases.Tests
test_sysupgrade.shcovers the split write and overlay offset,-n, the move from fixed slots, each refusal, a write that never reached the chip, and the default URL.test_init_overlay.shruns the carry-over itself.Verified on hardware
GK7205V200 (8 MB) and GK7205V300 (16 MB) NOR, on OpenIPC U-Boot with
CONFIG_OPENIPC_NOR_FIT_SPLIT:/proc/mtdis split at the computed offsets.-n: the camera comes up on defaults.gk7202v300 and gk7605v100 get the kernel options and a
-splitpackage too. Their U-Boot doesn't enable the layout yet, so sysupgrade keeps them on the plain package.Hardware evidence (serial console)
All runs below use the images built from this branch, upgrading with the sysupgrade inside them.
GK7205V200 (8 MB), fixed slots → split:
A marker file written to
/etcbefore the upgrade read back afterwards, and SSH key login still worked.GK7205V300 (16 MB), split → split:
/proc/mtdafterwards:mtd5: 00730000 00010000 "rootfs_data"GK7205V200,
sysupgrade -n:The hostname is back to its default, so the overlay was cleared.
GK7205V200, the new kernel as a uImage on fixed slots:
The
firmwarealias holds a uImage and is not split.GK7205V300, the plain package on a split camera (no reboot; uptime unchanged):
Sizes (build output):