Skip to content

Install NAND cameras on u-boot-xmedia SoCs as one UBI device, written with write.trimffs - #392

Merged
widgetii merged 2 commits into
masterfrom
nand-ubi-layout
Oct 4, 2026
Merged

widgetii merged 2 commits into
masterfrom
nand-ubi-layout

Conversation

@widgetii

@widgetii widgetii commented Oct 4, 2026

Copy link
Copy Markdown
Member

OpenIPC NAND images for the u-boot-xmedia SoCs now use one layout, described below. It landed in OpenIPC/u-boot-xmedia#11 and OpenIPC/firmware#2537.

0x000000  boot 768K   u-boot-<soc>-nand.bin
0x0C0000  env  256K
0x100000  ubi  rest   rootfs.ubi.<board>: UBIFS rootfs (kernel inside, /boot) + rootfs_data

The wizard's NAND instructions for these SoCs followed the retired split layout: run uknand; run urnand; run setnand, a uImage at 0x100000, and rootfs.ubi at 0x400000. They now match the new layout.

What changes

The catalogue drives the change: a SoC entry with uboot_nand_filename uses the new flow.

SoCs and bootloader files

  • The flow is set on HI3516EV200, HI3516EV300, HI3518EV300 and HI3516DV200.
  • GK7205V500, V510 and V530 are added to goke.yml; they were missing from the catalogue.
  • For these SoCs uboot_filename is the -nor.bin image, and NAND uses the -nand.bin one. u-boot-xmedia now publishes both for all seven, replacing the old -universal image.

U-Boot block

  • mw.b … 0xc0000
  • tftpboot u-boot-<soc>-nand.bin && nand erase 0x0 0xc0000 && nand write … 0x0 0xc0000

Linux block

Full-flash image (firmware/layout.go)

  • The NAND bootloader at 0, rootfs.ubi at 0x100000, and no uImage.
  • Written with nand write.trimffs.
  • layoutVersion is bumped so cached images rebuild.

Rest of the site

  • The per-SoC JSON gains uboot_nand_filename, bl_nand_url and bootloader_nand_published, and only for these SoCs, so it stays backward compatible.
  • The SoC page shows a NOR and a NAND bootloader link, and the U-Boot step links the file its commands write.

Every other SoC's output is unchanged. The documents.json golden diffs are limited to the seven SoCs above.

Verification

  • service/run.sh test (go vet + go test against postgres:17) passes.
  • Frontend lint, typecheck, test (664) and build pass under Node 24, and export:check is current.
  • New TestUBINandLines and TestUBINandImage.
  • A hi3516ev300 with W25N01GV NAND was installed with exactly these U-Boot and Linux blocks. It booted /boot/fitImage from UBIFS with its hashes verified.
  • The release now carries u-boot-<soc>-{nor,nand}.bin for the four HiSilicon SoCs (published 2026-10-04), so the links resolve.

… with write.trimffs

OpenIPC is retiring the HiSilicon split NAND layout (boot, env, a raw
kernel at 0x100000, UBI at 0x400000; `run uknand; run urnand; run
setnand`) on the SoCs whose bootloader is u-boot-xmedia. Their NAND is now
mtdparts <hinand|nand>:768k(boot),256k(env),-(ubi): U-Boot at 0, env at
0xc0000, and one UBI device from 0x100000 to the end of the chip holding
the kernel (FIT), rootfs and rootfs_data volumes. rootfs.ubi.<board> is
the only file an install writes, and it must go on with `nand
write.trimffs`: a plain write programs the 0xFF padding pages, UBIFS
programs them again later, and the ECC breaks (OpenIPC/firmware#2519).
The same holds for a full image that contains it.

Data-driven: a catalogue entry that names `uboot_nand_filename` is on the
UBI-only layout and installs that bootloader on NAND; `uboot_filename`
becomes its -nor.bin build. HI3516EV200, HI3516EV300, HI3518EV300 and
HI3516DV200 move to u-boot-<soc>-{nor,nand}.bin. GK7205V500, GK7205V510
and GK7205V530 join the Goke catalogue the same way (board gk7205v500,
load address 0x42000000 per u-boot-xmedia's baseaddr). Every other NAND
SoC keeps today's flow; its wizard document is byte for byte unchanged.

For a UBI-only NAND camera the wizard now prints:

  U-Boot: tftpboot <la> u-boot-<soc>-nand.bin && nand erase 0x0 0xc0000
          && nand write <la> 0x0 0xc0000 (after mw.b <la> 0xff 0xc0000)
  Linux:  tftpboot <la> rootfs.ubi.<board> && nand erase 0x100000
          0x7f00000 && nand write.trimffs <la> 0x100000 ${filesize}
          (fatload from SD likewise; env/ethaddr/saveenv lines kept)
  Full:   ... && nand erase 0x0 0x8000000 && nand write.trimffs <la> 0x0
          ${filesize}

with no `run setnand` in any block and no bootloader macros advertised
(bootloader_variables is empty; the page drops its printenv sentence when
there is nothing to name). NOR installs are unchanged apart from the
bootloader file name.

The full NAND image for these SoCs is the NAND bootloader at 0 (refused
past 0xc0000) and rootfs.ubi at 0x100000 (bounded by the 128 MiB chip),
ending at the UBI image rounded up to a 2 KiB page, 0xFF between; no
uImage. layoutVersion goes to 2 so every cached image is rebuilt.
Availability and the download page's missing-bootloader message ask after
the bootloader the requested flash type installs.

The wizard document gains uboot_nand_filename, bl_nand_url and
bootloader_nand_published only on the UBI-only SoCs, so the JSON stays
backward compatible; the SoC page offers both bootloaders, labelled NOR
and NAND, and the by-parts U-Boot step links the one its commands write.

Goldens: documents.json changes for exactly hi3516dv200, hi3516ev200,
hi3516ev300 and hi3518ev300, and gains gk7205v500/510/530. The release
index fixture gains u-boot-{hi3516dv200,hi3516ev200,hi3518ev300}-{nor,nand}.bin
and u-boot-hi3516ev300-nor.bin as synthetic rows (no digest), standing
for files the firmware repository must publish before this deploys; until
it does, those SoCs read as firmware_only. The sitemap golden and
deploy/firmware-segments.tsv gain the three Goke SoCs.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Install u-boot-xmedia NAND cameras with a single UBI layout

✨ Enhancement 🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Switch seven HiSilicon and Goke SoCs to NAND-specific bootloaders and a single UBI device.
• Write UBI images with nand write.trimffs to avoid programming padding pages twice and breaking
 ECC.
• Align wizard instructions, full-flash images, download links, and availability while preserving
 other SoCs’ layouts.
Diagram

graph TD
  C["SoC catalogue"] --> D{"NAND build?"} -->|yes| W["Wizard commands"] --> T["trimffs flashing"] --> N["UBI NAND"]
  D -->|yes| I["Image builder"] --> T
  D -->|no| L["Existing layouts"]
  C --> E["Bootloader links"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Declare the NAND layout explicitly
  • ➕ Separates partition-layout selection from bootloader naming.
  • ➕ Scales better if another SoC needs a distinct NAND layout.
  • ➖ Adds catalogue fields and validation that must stay consistent with bootloader assets.
  • ➖ Expands this migration without changing the seven SoCs’ resulting behavior.

Recommendation: Use the PR’s optional NAND bootloader field as the discriminator for this bounded migration: it keeps existing SoC documents and layouts unchanged. Introduce an explicit layout field if additional NAND layouts or exceptions emerge.

Files changed (22) +745 / -93

Enhancement (9) +271 / -55
goke.ymlCatalogue three GK7205V500-family SoCs +46/-1

Catalogue three GK7205V500-family SoCs

• Adds GK7205V500, V510, and V530 with NOR and NAND bootloader filenames, their shared firmware board, and load addresses.

data/catalogue/goke.yml

hisilicon.ymlAssign separate bootloaders to four HiSilicon SoCs +8/-4

Assign separate bootloaders to four HiSilicon SoCs

• Replaces universal bootloader filenames with NOR builds and adds NAND builds for the four migrated SoCs.

data/catalogue/hisilicon.yml

Form.tsxExpose separately published NAND bootloaders +22/-2

Expose separately published NAND bootloaders

• Treats either published flash-specific bootloader as sufficient for wizard availability. Shows distinct NOR and NAND download links where both exist.

frontend/apps/site/src/components/wizard/Form.tsx

wizard-export.tsModel optional NAND bootloader exports +29/-0

Model optional NAND bootloader exports

• Adds backward-compatible NAND bootloader fields to wizard documents and a helper that selects the filename, URL, and publication state for a flash type.

frontend/apps/site/src/lib/wizard-export.ts

catalogue.goMake NAND bootloader presence a catalogue capability +30/-8

Make NAND bootloader presence a catalogue capability

• Parses the optional NAND filename and exposes helpers for UBI-only layout detection and flash-specific bootloader selection.

service/internal/catalogue/catalogue.go

build.goAssemble variable-partition full-flash images +18/-11

Assemble variable-partition full-flash images

• Selects the flash-specific bootloader and streams only the members required by the chosen layout. Bumps the layout cache version so old images rebuild.

service/internal/firmware/build.go

layout.goDefine the single-UBI NAND image layout +48/-17

Define the single-UBI NAND image layout

• Places the NAND bootloader within the 768 KiB boot partition and rootfs.ubi at 0x100000, with no separate kernel member. Retains the existing NOR and split-NAND layouts.

service/internal/firmware/layout.go

camera.goSelect UBI-only NAND installation behavior +52/-0

Select UBI-only NAND installation behavior

• Adds flash-specific bootloader, boot-partition size, and NAND write-command selection. Omits retired partition-setting commands and macro references for migrated SoCs.

service/internal/wizard/camera.go

export.goExport NAND bootloader metadata only where applicable +18/-12

Export NAND bootloader metadata only where applicable

• Adds the NAND filename, URL, and publication state only to UBI-only SoC documents. Reuses firmware availability logic for consistent flash-specific results.

service/internal/wizard/export.go

Bug fix (4) +80 / -28
Result.tsxMatch installer links to the selected flash type +19/-9

Match installer links to the selected flash type

• Links the bootloader named by the installation commands and hides the macro explanation when the UBI-only flow has no bootloader macros.

frontend/apps/site/src/components/wizard/Result.tsx

availability.goCheck firmware availability per flash type +18/-5

Check firmware availability per flash type

• Reports wizard availability when a flash type has both firmware and its corresponding bootloader, rather than checking only the default bootloader.

service/internal/firmware/availability.go

handler.goReport missing bootloaders for the requested flash type +6/-4

Report missing bootloaders for the requested flash type

• Passes the requested flash type into missing-asset diagnostics so a missing NAND build is not obscured by a published NOR build.

service/internal/firmware/handler.go

lines.goGenerate trimffs commands for UBI-bearing NAND writes +37/-10

Generate trimffs commands for UBI-bearing NAND writes

• Writes the NAND bootloader within 0xc0000 and rootfs.ubi at 0x100000, and uses write.trimffs for standalone UBI and full-flash images. Keeps legacy commands for other SoCs.

service/internal/wizard/lines.go

Tests (8) +364 / -10
sitemap.golden.xmlRecord routes for the new Goke SoCs +63/-0

Record routes for the new Goke SoCs

• Adds the three SoC pages and their language alternates to the sitemap fixture.

frontend/apps/site/src/lib/sitemap.golden.xml

wizard-export.test.tsTest flash-specific bootloader selection +43/-0

Test flash-specific bootloader selection

• Verifies that NAND selects its separate build and publication state, while NOR and legacy SoCs retain their existing selection.

frontend/apps/site/src/lib/wizard-export.test.ts

firmware_test.goVerify UBI-only NAND image contents and bounds +89/-0

Verify UBI-only NAND image contents and bounds

• Checks catalogue NAND filenames, bootloader and UBI offsets, erased gaps, omission of a separate kernel, page alignment, and oversized bootloader rejection.

service/internal/firmware/firmware_test.go

availability.jsonRefresh availability fixture for new Goke SoCs +1/-1

Refresh availability fixture for new Goke SoCs

• Adds wizard availability entries for GK7205V500, V510, and V530.

service/internal/firmware/testdata/availability.json

boards.jsonPin board and bootloader mappings +38/-4

Pin board and bootloader mappings

• Records shared firmware-board mappings and separate bootloaders for the three Goke additions and four migrated HiSilicon SoCs.

service/internal/firmware/testdata/boards.json

release-index.jsonFixture newly named HiSilicon bootloader assets +42/-0

Fixture newly named HiSilicon bootloader assets

• Adds release-index records for the renamed NOR and new NAND bootloader assets used by the fixture.

service/internal/firmware/testdata/release-index.json

documents.jsonPin affected wizard-document output +8/-5

Pin affected wizard-document output

• Adds three Goke documents and refreshes hashes for the four migrated HiSilicon SoCs; other SoC hashes remain unchanged.

service/internal/wizard/testdata/documents.json

wizard_test.goTest migrated commands and legacy isolation +80/-0

Test migrated commands and legacy isolation

• Checks NAND bootloader metadata, UBI-only installation and full-image commands, and absence of retired macros. Confirms a split-layout SoC still uses its prior commands.

service/internal/wizard/wizard_test.go

Other (1) +30 / -0
catalogue.jsonExport the new Goke SoCs to the site +30/-0

Export the new Goke SoCs to the site

• Adds generated frontend catalogue entries for GK7205V500, V510, and V530.

frontend/apps/site/src/data/catalogue.json

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

qodo-free-for-open-source-projects Bot commented Oct 4, 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. V510 owners receive V500 NOR firmware ✓ Resolved
Description
The GK7205V510 catalogue entry sets linux_filename to the V500 bundle, causing Board() and
LinuxAsset() to select V500 for both flash types. When a V510 owner chooses NOR, the wizard
ignores the separately published V510 NOR bundle and its V510 flash-fit record.
Code

data/catalogue/goke.yml[204]

+  linux_filename: openipc.gk7205v500-nor-lite.tgz
Evidence
The catalogue supplies the V500 filename for V510; the firmware board resolver derives its board
from that filename and uses it to construct asset names. The release index separately lists a V510
NOR bundle and V510 fit record.

data/catalogue/goke.yml[195-207]
service/internal/firmware/layout.go[146-166]
service/internal/firmware/testdata/release-index.json[144-161]
service/internal/firmware/testdata/release-index.json[1348-1360]

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

## Issue description
GK7205V510 resolves to the V500 board for NOR even though a distinct V510 NOR bundle is published. Its NAND bundle currently uses the V500 board, so changing the shared board name alone would also affect NAND.
## Fix Focus Areas
- data/catalogue/goke.yml[195-209]
- service/internal/firmware/layout.go[146-166]
- service/internal/wizard/export.go[45-83]
## Recommended Fix
Resolve the V510 firmware board per flash type: use gk7205v510 for NOR and retain gk7205v500 for NAND where that is the published bundle. Propagate that choice through firmware asset lookup and wizard download and member names, and test both choices.

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



Remediation recommended

2. Some flash choices lead to missing files ✓ Resolved
Description
Form treats publication of either bootloader as sufficient to show every firmware-backed flash
choice, without checking the bootloader for the selected flash type. If one build is unpublished
while the other is available, the user can select the unsupported type and reach commands and a
download link for its missing bootloader, while a full-image request cannot resolve that asset.
Code

frontend/apps/site/src/components/wizard/Form.tsx[78]

+    || ((doc.bootloader_published || doc.bootloader_nand_published === true) && doc.linux_filename !== ''
Evidence
The form's new OR permits either publication state, while chip choices and exported combinations
depend on firmware releases rather than per-type bootloader publication. The result renders a
filename-based link even when bootloaderFor reports published: false; the exporter gives an
absent asset a plausible latest URL, and Resolve rejects that missing asset.

frontend/apps/site/src/components/wizard/Form.tsx[75-79]
frontend/apps/site/src/lib/wizard-menu.ts[88-108]
frontend/apps/site/src/components/wizard/Result.tsx[563-580]
frontend/apps/site/src/lib/wizard-export.ts[117-129]
service/internal/wizard/export.go[176-185]
service/internal/firmware/build.go[90-109]

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 wizard permits a firmware-backed flash type when only the other flash type's bootloader is published. Its result then offers the unpublished file, and full-image resolution rejects it.
## Fix Focus Areas
- frontend/apps/site/src/components/wizard/Form.tsx[75-79]
- frontend/apps/site/src/components/wizard/Result.tsx[563-580]
- frontend/apps/site/src/lib/wizard-menu.ts[88-108]
## Recommended Fix
Use the selected flash type's publication flag when offering or accepting a chip, choosing the corresponding NOR or NAND bootloader state. Ensure an unsupported choice cannot reach install commands or a bootloader download link, including through an existing link.

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


3. Cameras with NAND larger than 128 MiB may fail to boot after install ✓ Resolved
Description
flashingLinux erases only ubiRegionSize = 0x7f00000 from 0x100000 (ubiChipEnd in layout.go is
128 MiB as well), but the u-boot-xmedia mtdparts -(ubi) makes the UBI partition run to the real
end of the chip. On a 256 MiB or larger part, the blocks past 128 MiB keep whatever the stock
firmware left there, and UBI scans them as corrupted PEBs when it attaches the whole partition,
which can make attach fail (or leave far fewer usable PEBs) and stop the camera from booting its
kernel volume.
Code

service/internal/wizard/camera.go[R51-55]

+const (
+	ubiBootSize   = "0xc0000"
+	ubiOffset     = "0x100000"
+	ubiRegionSize = "0x7f00000"
+)
Evidence
The new constants hard-code the erase to 128 MiB minus 1 MiB, while the comment above them says the
bootloader's own mtdparts is 768k(boot),256k(env),-(ubi), i.e. the partition goes to the end of
the chip. The Linux block erases 0x100000 0x7f00000 and nothing else, so on a larger chip
everything above 0x8000000 is left as it was. The full-image path erases nandSizeHex (128 MiB), so
it has the same gap.

service/internal/wizard/camera.go[43-55]
service/internal/wizard/lines.go[176-191]
service/internal/firmware/layout.go[48-58]

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 UBI-only NAND install erases a fixed 0x7f00000 starting at 0x100000, but the partition the bootloader defines (`-(ubi)`) runs to the end of the chip. On chips larger than 128 MiB, stale data stays in the upper blocks and UBI treats those blocks as corrupted when it attaches.
## Fix Focus Areas
- service/internal/wizard/camera.go[51-55]
- service/internal/wizard/lines.go[176-191]
## Recommended Fix
Erase the whole partition with a size-independent command. For example, use `nand erase.part ubi` (the NAND bootloader's mtdparts names the partition), or `nand erase 0x100000` followed by a size taken from the chip, instead of the fixed `0x7f00000`. If you keep the 128 MiB assumption, state on the installation page that it covers 128 MiB parts only.

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



Informational

4. NAND U-Boot link shows even when the NAND file is unpublished ✓ Resolved
Description
Result.tsx uses bootloaderFor(...) to pick the file and URL but shows the link whenever
bootloader.filename !== '', and never reads the published flag that bootloaderFor returns. On
a UBI-only SoC whose -nand.bin is not in the release yet (bootloader_nand_published: false), the
U-Boot step links to a file that returns 404. Form.tsx also counts the SoC as usable as soon as
either bootloader is published.
Code

frontend/apps/site/src/components/wizard/Result.tsx[R576-580]

+                {bootloader.filename !== '' && (
                <div class="github">
                  <Icon name="github" size="github" class="float-start me-2" />
                  <h6 class="site-h6 mb-0">
-                      <a href={doc.bl_url} title={doc.uboot_filename}>{install('flashing_uboot.link')}</a>
+                      <a href={bootloader.url} title={bootloader.filename}>{install('flashing_uboot.link')}</a>
Evidence
bootloaderFor returns published: document.bootloader_nand_published ?? false for NAND, but the
Experts block only checks filename. Form's usable is `bootloader_published ||
bootloader_nand_published`, so a SoC with only one of the two published still reaches Result for
either flash type.

frontend/apps/site/src/lib/wizard-export.ts[117-130]
frontend/apps/site/src/components/wizard/Result.tsx[561-583]
frontend/apps/site/src/components/wizard/Form.tsx[75-79]

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 U-Boot download link in the Experts section is shown based on the filename alone, so a NAND bootloader that has not been published yet still gets a link.
## Fix Focus Areas
- frontend/apps/site/src/components/wizard/Result.tsx[576-580]
## Recommended Fix
Change the condition to `bootloader.filename !== '' && bootloader.published`, or render a 'not yet published' note when `published` is false.

ⓘ 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 describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread data/catalogue/goke.yml Outdated
Comment thread frontend/apps/site/src/components/wizard/Form.tsx
Comment thread service/internal/wizard/camera.go
Comment thread frontend/apps/site/src/components/wizard/Result.tsx Outdated
…th its bootloader

Review on #392.

- GK7205V510 has a NOR build of its own, but its NAND firmware is the
  GK7205V500 build. A new catalogue field, nand_board, names the build a
  SoC's NAND firmware comes from. firmware.BoardFor resolves the build per
  flash type, and the tarball, the image members, availability, the
  wizard's releases and its install lines all go through it.
- On a UBI-only SoC, each flash type installs its own bootloader. A flash
  type whose bootloader is not published is no longer offered: it gets no
  editions and no combinations, rather than the nothing-published menu.
  Old links fall back to an offered chip as before. The U-Boot download
  link only shows when its file is published.
- The UBI install erases a 128 MiB chip. The Linux block now says so, and
  gives the 0xff00000 length for a 256 MiB part.

New tests: TestUBINandWithoutItsBootloaderIsNotOffered and
TestNANDBoardIsUsedForNANDOnly. boards.json now records V510's own NOR
build. Go (service/run.sh test), frontend lint, typecheck, tests and
build all pass.
@widgetii
widgetii merged commit e01a9f6 into master Oct 4, 2026
2 checks passed
@widgetii
widgetii deleted the nand-ubi-layout branch October 4, 2026 16:03
widgetii added a commit that referenced this pull request Oct 4, 2026
… MiB install too (#393)

The UBI-only NAND install erased a fixed 0x7f00000 from 0x100000, which is
the end of a 128 MiB chip. The partition is -(ubi) and runs to the end of
whatever chip there is, so on a bigger one stale blocks were left behind,
which UBI counts as corrupted PEBs when it attaches.

- The Linux step now erases with `nand erase.part ubi`, which the
  u-boot-xmedia NAND build carries (OpenIPC/u-boot-xmedia#12) and the
  U-Boot step installs first.
- The full-flash image, written from whatever U-Boot the camera has,
  erases with `nand erase.chip`.
- Both keep write.trimffs.

Also gofmt on catalogue.go, which #392 left unformatted.
widgetii added a commit to OpenIPC/defib that referenced this pull request Oct 4, 2026
The u-boot-xmedia SoCs (hi3516ev200/ev300/dv200, hi3518ev300,
gk7205v500/v510/v530) moved to one NAND layout. It landed in
OpenIPC/u-boot-xmedia#11 and #12, OpenIPC/firmware#2537, and
OpenIPC/website#392 and #393:

```
0x000000 boot 768K   u-boot-<soc>-nand.bin
0x0C0000 env  256K
0x100000 ubi  rest   rootfs.ubi.<board>: UBIFS rootfs (kernel inside, /boot/fitImage) + rootfs_data
```

defib still installed the retired split layout on these SoCs and
downloaded the retired `-universal` bootloader for them.

## Install (`install --nand`)

For these SoCs `install --nand` now:
- writes `u-boot-<soc>-nand.bin` into 0..0xc0000;
- writes `rootfs.ubi.<board>` with `nand erase.part ubi` and `nand
write.trimffs`, then reads it back and CRC-checks it;
- runs `env default -a`, restores the MAC, and saves.

**Never sent:** `setenv mtdparts`, `mtdids`, `bootcmd`, `bootargs`, or
`ubi part`/`create`/`write`.

**Kernel and `rootfs-data` stages:** no-ops. The kernel and an empty
`rootfs_data` are inside the UBI image.

**Erase safety:**
- The installer checks that `mtdparts` puts `ubi` at 0x100000 before
erasing.
- It falls back to `nand erase 0x100000` (to the chip end) where
`erase.part` is unavailable.
- Other chips keep the split-layout path.

## Bootloader names

These seven SoCs resolve per flash type, to `u-boot-<soc>-nor.bin` or
`u-boot-<soc>-nand.bin`.
- `install` follows `--nand`. `burn` gains `--nand` and defaults to NOR.
`restore --flash-type` follows the flash type.
- The `-universal` image is never downloaded for them, and a stale
cached one doesn't stand in for the new build.
- Every other chip is unchanged.

## Web UI

- Takes the `-nor` build for these SoCs.
- Now cuts the SPL where the compressed payload starts (`detectSplSize`,
a port of `HiSiliconStandard._detect_spl_size`). The u-boot-xmedia
images put it at 0x4400, while the profile says 0x6000. Sending the
profile length writes into SRAM the boot ROM uses for its own state.

## Verified

On a hi3516ev300 (W25N01GV, 128 MiB, 5 factory bad blocks), `defib
install -c hi3516ev300 --nand --power-cycle` with the NAND package and
the u-boot-xmedia master NAND image ran end to end:
- burned U-Boot to RAM from the boot ROM;
- `U-Boot OK`;
- `Erased ubi: 0x100000, 0x7F00000 bytes`;
- `Flash verified: E2E60EAA`;
- `Restoring factory ethaddr`, `Environment saved`;
- rebooted into OpenIPC, which booted `/boot/fitImage` and came up on
the network.

Separately, `defib burn -c hi3516ev300 -f u-boot-hi3516ev300-nand.bin`
loaded the u-boot-xmedia image from the boot ROM; defib found its gzip
SPL boundary at 0x4400.

## Tests

- pytest: 1020 passed. ruff and mypy clean.
- New `tests/test_nand_ubi_install.py`: the exact console sequence, the
erase fallback, the missing-`mtdparts` path, refusing a relocated `ubi`,
an env-only run, and a NOR install taking `-nor` over a cached
`-universal`.
- `tests/test_firmware.py` covers names per flash type.
- Web tests: 92 pass. The new `detectSplSize` gives 0x4400 on the real
hi3516ev300 image.

## Not verified on hardware

- The gk7205v5xx and hi3516dv200 paths.
- The Web UI recovery with the `-nor` images.
- The `erase.part` fallback on a U-Boot without it.
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