Skip to content

ipctool: build ipcinfo for the board it ships on - #2432

Merged
widgetii merged 1 commit into
masterfrom
ipctool-trim-per-board
Sep 16, 2026
Merged

widgetii merged 1 commit into
masterfrom
ipctool-trim-per-board

Conversation

@widgetii

Copy link
Copy Markdown
Member

ipcinfo is 34,916 bytes on a gk7205v300_lite image whose rootfs sits at 5080 KB of a 5120 KB cap. It links libipchw, which knows every SoC vendor and every HiSilicon generation ipctool has ever learned — a detection table for eleven vendor HALs, plus a chip-ID table, a sensor-bus back-end, a temperature formula and a die-ID reader for each of ten HiSilicon generations. A camera is one SoC.

Upstream takes both as build options defaulting to all (ipctool#178, #211); majestic already derives them the same way from its VENDOR and SDK code. This derives them from OPENIPC_SOC_VENDOR and OPENIPC_SOC_FAMILY.

The family names are not a coincidence — ipctool's getchipfamily() returns the same strings, so ipcinfo -f on a board prints the key the table is indexed by.

Measured

gk7205v300_lite, same tree and commit, only this file differing:

ipcinfo          34916 -> 22036 bytes   -12880  (-37%)
rootfs.squashfs   5080 ->  5076 KB      -4 KB, headroom 40KB -> 44KB

Hardware

On a hi3516ev200 (V4, SC2315E, musl armv7), which takes the same options this file gives the Goke family — -c -f -v -s -l -F -i -S -x, every long form, the combined -ci that extutils uses, and -t, all against the stock 35,124-byte binary on the same box:

board: hi3516ev200_lite, stock 35124 B, firmware-built 22036 B
ok  -c -> hi3516ev200          ok  --chip-name    -> hi3516ev200
ok  -f -> hi3516ev200          ok  --family       -> hi3516ev200
ok  -v -> hisilicon            ok  --vendor       -> hisilicon
ok  -s -> sc2315e              ok  --short-sensor -> sc2315e
ok  -l -> sc2315e_i2c          ok  --long-sensor  -> sc2315e_i2c
ok  -F -> nor                  ok  --flash-type   -> nor
ok  -i -> 02183b87...29e3      ok  --info         -> 02183b87...29e3
ok  -S -> majestic             ok  --streamer     -> majestic
ok  -x -> 00:12:31:56:58:69    ok  --xm-mac       -> 00:12:31:56:58:69
ok  -ci                        -t: stock=52.01 new=52.01
RESULT fail=0

What is dropped, and how that was checked rather than assumed

A vendor that is not HiSilicon reaches hal_hisi through nothing — the only route is a HiSilicon UART0 base in chipid.c's dispatch — so those boards drop hal_hisi.c and ispreg.c from the library altogether. Verified on the two non-HiSilicon lab boards:

board /proc/iomem uart reaches hisi?
ssc30kq no matching line at all no → generic_detect_cpu → sstar
t31 0x10031000 no (one digit from xm510's 0x10030000, and not it)

Worth recording the third: hi3516av300 reports 0x120a0000 — a base ipctool comments as "hi3516ev200" — on a board that is V4A. That is real-hardware confirmation of why ipctool#211 gates those arms all-or-nothing rather than per generation.

Two families deliberately unmapped

The 3520DV200 ID sets no chip_generation at all, and no ID in ipctool's table matches a GK7101/GK7102 — neither has a generation to name, so they keep every one rather than be trimmed on a guess. Unmapped means nothing is passed and upstream's default applies, so ambarella, anyka and ti keep every HAL too, and a new SoC is never silently trimmed to the wrong thing.

Two knobs deliberately not used

IPCHW_SENSORS exists upstream and is not touched. A mainline image is per-family and gets flashed onto whatever camera someone bought; ipcinfo --short-sensor exists to name a sensor nobody catalogued, and it runs once, on an unprovisioned camera, with the answer written to U-Boot env. Compiling a probe family out turns that into SENSOR is not detected, aborting. The gk7205v200 driver set needs eight of the eleven families anyway (os02g10 is found by the SuperPix probe, not OmniVision), so the whole knob was worth 536 bytes there.

IPCHW_PADMUX is left alone: --gc-sections already drops it from ipcinfo, and libipchw carries its selection as a PUBLIC compile definition, so setting it would break config_tool in sigmastar-osdrv-infinity6 on ssc325_lite and ssc325de_lite.

Notes for review

CONF_OPTS only, never DEPENDENCIES — a _DEPENDENCIES line would add an edge to the graph ci-matrix.py walks and move its frozen board counts. --self-test passes unchanged (99 boards, 136 packages, 56 cases), and touching this package builds every board, which is the coverage this wants.

If you build locally and see no change, check the download cache. IPCTOOL_VERSION = HEAD and buildroot names the tarball ipctool-HEAD.tar.gz, caching it by filename with no .hash, so a warm dl/ keeps whatever HEAD was when that machine first built it — cmake then says Manually-specified variables were not used by the project: IPCHW_HISI and the binary comes out 26424 instead of 22036. It bit me mid-measurement. CI is unaffected: the "Refresh moving-ref package downloads" step added in #2352 deletes *-HEAD.tar.gz every run.

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

qodo-free-for-open-source-projects Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Build board-specific ipcinfo binaries

✨ Enhancement ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Selects ipctool HALs and HiSilicon generations from each board's SoC metadata.
• Preserves upstream defaults for unmapped hardware to prevent unsafe trimming.
• Reduces ipcinfo size while retaining sensor discovery and dependent padmux behavior.
Diagram

graph TD
  A["Board config"] --> B["SoC metadata"] --> C["ipctool mapping"] --> D{"Mapping found?"}
  D -->|Mapped| E["CMake filters"] --> F["Board ipcinfo"]
  D -->|Unmapped| G["Upstream defaults"] --> F
Loading
High-Level Assessment

The board-metadata lookup with fail-open upstream defaults is the appropriate approach: it removes unreachable HAL and HiSilicon-generation code without risking unknown hardware. More aggressive sensor or padmux filtering was correctly rejected because it could break sensor discovery and downstream config_tool builds, while trimming unknown families speculatively would create compatibility risk.

Files changed (1) +82 / -0

Other (1) +82 / -0
ipctool.mkDerive ipctool hardware filters from board SoC metadata +82/-0

Derive ipctool hardware filters from board SoC metadata

• Adds vendor-HAL and HiSilicon-generation mappings keyed by OpenIPC vendor and family values, then passes resolved IPCHW_VENDORS and IPCHW_HISI options to CMake. Unknown targets omit the options and retain upstream defaults; comments document intentional exclusions for sensor probes, padmux, and ambiguous families.

general/package/ipctool/ipctool.mk

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

qodo-free-for-open-source-projects Bot commented Sep 16, 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. Non-HiSilicon firmware fails to build 🐞 Bug ≡ Correctness
Description
The indented continuation in IPCTOOL_IPCHW_HISI becomes leading whitespace in the second or
argument, so a fallback such as none expands the unquoted option into -DIPCHW_HISI= plus a
separate none argument. This affects every mapped non-HiSilicon build, while the intentionally
unmapped Goke and HiSilicon families instead receive an empty override rather than retaining
upstream’s all default.
Code

general/package/ipctool/ipctool.mk[R89-90]

+IPCTOOL_IPCHW_HISI = $(or $(IPCTOOL_HISI_$(OPENIPC_SOC_FAMILY)),\
+	$(IPCTOOL_HISI_VENDOR_$(OPENIPC_SOC_VENDOR)))
Evidence
The continuation at lines 89-90 inserts whitespace before the vendor fallback, and lines 95-96 test
and append that preserved value without stripping it. The fallback table supplies none for active
vendors such as Allwinner, while the Goke and HiSilicon families explicitly left unmapped are active
ipctool targets and therefore exercise the whitespace-only case.

general/package/ipctool/ipctool.mk[79-96]
general/package/ipctool/ipctool.mk[36-38]
br-ext-chip-allwinner/configs/v83x_lite_defconfig[39-50]
br-ext-chip-goke/configs/gk7102_lite_defconfig[37-47]
br-ext-chip-hisilicon/configs/hi3520dv200_lite_defconfig[43-55]

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 multiline `or` expression preserves whitespace before its second argument. This splits mapped fallback values into a separate CMake argument and makes empty fallbacks appear nonempty.
## Fix Focus Areas
- general/package/ipctool/ipctool.mk[89-96]
## Recommended Fix
Wrap the complete `or` expression in `$(strip ...)`, or format both arguments without whitespace after the comma. Verify that mapped fallbacks produce exactly `none` and that an unmapped family and vendor leave `IPCTOOL_IPCHW_HISI` empty so no CMake option is appended.

ⓘ 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 group findings by type and pick your Finding display, from Minimal to Full

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@widgetii
widgetii marked this pull request as draft September 16, 2026 19:49
@widgetii

Copy link
Copy Markdown
Member Author

Parked as draft behind #2433.

This PR's CI is red on hi3519v101_lite and gk7202v300_lite — not from anything here. Master itself went red on those two boards plus gk7205v300_lite in nightly 35129237971, from upstream drift in the unpinned majestic/majestic-webui refs. The ipcinfo trim here is actually what already rescued the third board: gk7205v300_lite passes on this branch at 5120/5120 where master is 4KB over.

#2433 takes all three boards back under their caps. Once it lands I will rebase this onto the new master, where its own saving stacks on top.

ipcinfo links libipchw, which knows every SoC vendor and every HiSilicon
generation ipctool has ever learned: a detection table for eleven vendor
HALs, and a chip-ID table, a sensor-bus back-end, a temperature formula
and a die-ID reader for each of ten HiSilicon generations. A camera is
one SoC. The rest is code that cannot execute on it, and it ships on all
but three of this tree's board configs, onto boards whose rootfs cap
leaves tens of KB spare -- gk7205v300_lite sits at 5080KB of 5120KB.

Upstream takes both as build options defaulting to "all" (ipctool #178
and #211), and majestic already derives them the same way from its
VENDOR and SDK code. This derives them from OPENIPC_SOC_VENDOR and
OPENIPC_SOC_FAMILY. The family names are not a coincidence: ipctool's
getchipfamily() returns the same strings, so `ipcinfo -f` on a board
prints the key the table is indexed by.

A vendor that is not HiSilicon reaches hal_hisi through nothing -- the
only route is a HiSilicon UART0 base in chipid.c's dispatch -- so those
boards drop hal_hisi.c and ispreg.c from the library altogether.
Checked rather than assumed, on the two non-HiSilicon lab boards:
ssc30kq has no uart line in /proc/iomem at all, and t31 reports
0x10031000, which is not one of the six bases that dispatch (and is one
digit from xm510's 0x10030000 without being it).

Two families are deliberately unmapped. The 3520DV200 ID sets no
chip_generation, and no ID in ipctool's table matches a GK7101 or
GK7102, so neither has a generation to name -- they keep every one
rather than be trimmed on a guess. Unmapped means nothing is passed and
upstream's default applies, so ambarella, anyka and ti keep every HAL
too, and a new SoC is never silently trimmed to the wrong thing.

Nothing derives IPCHW_SENSORS. A mainline image is per-family and gets
flashed onto whatever camera someone bought; `ipcinfo --short-sensor`
exists to name a sensor nobody catalogued, and it runs once, on an
unprovisioned camera, with the answer written to U-Boot env. Compiling a
probe family out turns that into "SENSOR is not detected, aborting".
IPCHW_PADMUX is left alone too: --gc-sections already drops it from
ipcinfo, and libipchw carries its selection as a PUBLIC compile
definition, so setting it would break config_tool in
sigmastar-osdrv-infinity6 on ssc325_lite and ssc325de_lite.

CONF_OPTS only, never DEPENDENCIES: a _DEPENDENCIES line would add an
edge to the graph ci-matrix.py walks and move its frozen board counts.

Measured on gk7205v300_lite, same tree and commit, only this file
differing:

  ipcinfo          34916 -> 22036 bytes   -12880  (-37%)
  rootfs.squashfs   5080 ->  5076 KB      -4KB, headroom 40KB -> 44KB

Verified on a hi3516ev200 (V4, SC2315E, musl armv7), which takes the
same options this file gives the Goke family: -c -f -v -s -l -F -i -S
-x, every long form, the combined -ci that extutils uses, and -t all
answer exactly as the stock 35124-byte binary does.

ci-matrix --self-test passes and the frozen counts are unchanged;
touching this package builds every board, which is the coverage this
wants.
@widgetii
widgetii marked this pull request as ready for review September 16, 2026 20:43
@widgetii
widgetii force-pushed the ipctool-trim-per-board branch from 8b692f4 to 5a92725 Compare September 16, 2026 20:43
@widgetii

Copy link
Copy Markdown
Member Author

Rebased onto master now that #2433 has landed (ce3cbef). Git dropped the three size commits as already-upstream, so this is back to a single ipctool.mk commit — the change is unaltered.

The size picture it lands into, from #2433's own CI:

board before after #2433 this PR stacks
hi3519v101_lite 5136 (16KB over) 5064, 56KB free ~4KB more
gk7202v300_lite 5136 (16KB over) 4988, 132KB free ~8KB more
gk7205v300_lite 5124 (4KB over) 5100, 20KB free ~4KB more

That last row is why this one still matters beyond its own merits: gk7205v300_lite is the tightest board of the three and is the only one still tripping the 32KB headroom warning. Its gadget lever was spent in #2421 and it has no staging r8188eu to drop, so the ipcinfo trim here is the next increment available to it.

Comment thread general/package/ipctool/ipctool.mk
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5a92725

@widgetii
widgetii marked this pull request as draft September 16, 2026 21:30
@widgetii
widgetii marked this pull request as ready for review September 16, 2026 21:30
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5a92725

@widgetii
widgetii merged commit 1ebaef8 into master Sep 16, 2026
138 of 141 checks passed
@widgetii
widgetii deleted the ipctool-trim-per-board branch September 16, 2026 22:43
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