Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ Backends: `spi_flash.c` (fmc100), `spi_flash_hisfc350.c` (V1-era parts),
env, rest ubi), whose mtdparts/bootcmd/bootargs come from the U-Boot default
env; `NAND_LAYOUT` is the legacy split layout for other chips. The
`NOR_SPLIT_SOCS` (gk7205v200 family, hi3516cv6xx, hi3519dv500,
hi3516cv300/ev100; keyed by
hi3516cv300/ev100, hi3516ev200/hi3518ev300/hi3516dv200 but not
hi3516ev300; keyed by
package board, `FIRMWARE_PACKAGE_BOARD` maps cv608/cv610/cv613 to
`hi3516cv6xx` and hi3516dv500 to `hi3519dv500`) install the split NOR
package: one `firmware.bin.<board>` where the boot area ends (0x50000;
Expand Down
3 changes: 3 additions & 0 deletions src/defib/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"gk7202v300", "gk7205v200", "gk7205v300", "gk7605v100",
"hi3516cv6xx", "hi3519dv500",
"hi3516cv300", "hi3516ev100",
# Not hi3516ev300: its kernel fills the 2 MiB slot, so its firmware
# ships fixed slots only.
"hi3516ev200", "hi3518ev300", "hi3516dv200",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Fixed-slot installs can use wrong partitions 🐞 Bug ≡ Correctness

Adding these chips to NOR_SPLIT_SOCS also makes scanning_nor_uboot select env default -a for
fixed-slot packages, replacing the previous explicit mtdparts and bootcmd setup. When a NOR
U-Boot's defaults describe different slots from those selected for the detected flash size, the
installer still writes the selected slots but saves the mismatched defaults; this also affects
existing fixed-slot packages, not just the new split packages.
Agent Prompt
## Issue description
Adding split-package support also changes how fixed-slot installs configure the boot environment. An older NOR U-Boot with fixed defaults can retain partition settings that disagree with the installer-selected flash layout.

## Fix Focus Areas
- src/defib/firmware.py[86-93]
- src/defib/install/orchestrator.py[234-265]
- src/defib/install/orchestrator.py[1760-1821]

## Recommended Fix
Decouple eligibility for a split firmware package from the decision to rely on a scanning U-Boot's default environment. Preserve or verify layout-matching environment settings for fixed-slot installs using a non-scanning NOR binary, and test the path with mismatched default and detected flash sizes.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping this. The env default -a path runs only when the same install wrote the U-Boot ("uboot" in stage_set), and for these SoCs that is the published u-boot-<soc>-nor.bin: built by OpenIPC/u-boot openipc-hisilicon since u-boot-xmedia stopped publishing them, and it scans the layout on fixed slots too, so its defaults always match what is on the flash. In qemu-hisilicon, the published u-boot-hi3516ev200-nor.bin (2022.10-g862ab6b1) on fixed-slot images:

  • 8 MB lite: Found RootFS at 0x00250000, mtdparts=...2048k(kernel),5120k(rootfs)..., root on 31:3;
  • 16 MB ultimate: Found RootFS at 0x00350000, mtdparts=...3072k(kernel),10240k(rootfs)..., root on 31:3.

A hand-supplied non-scanning --uboot binary would hit the same assumption on the gk7205v200 family and hi3516cv300 already; deciding on the U-Boot rather than the SoC would be its own change across all split SoCs.

})

# NOR boot area -- (boot partition size, env partition size) -- where it is
Expand Down
3 changes: 2 additions & 1 deletion tests/test_install_nor_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def test_package_board_and_boot_area_are_data():
assert package_board("gk7205v210") == "gk7205v200"
assert "hi3516cv6xx" in split_boards("hi3516cv608")
for chip in ("hi3516cv608", "hi3516cv610", "hi3516cv613", "hi3519dv500",
"hi3516dv500", "gk7205v200", "hi3516cv300", "hi3516ev100"):
"hi3516dv500", "gk7205v200", "hi3516cv300", "hi3516ev100",
"hi3516ev200", "hi3518ev300", "hi3516dv200"):
assert supports_nor_split(chip), chip
assert nor_boot_area("hi3516cv300") == (0x40000, 0x10000)
assert not supports_nor_split("hi3516ev300")
Expand Down
Loading