Skip to content

Stop shipping a dangling /etc/sensors/iq/default.ini - #150

Merged
openipc-ai merged 1 commit into
masterfrom
fix/dangling-default-iq-symlink
Sep 7, 2026
Merged

Stop shipping a dangling /etc/sensors/iq/default.ini#150
openipc-ai merged 1 commit into
masterfrom
fix/dangling-default-iq-symlink

Conversation

@widgetii

@widgetii widgetii commented Sep 6, 2026

Copy link
Copy Markdown
Member

Reported as two symptoms on a lab hi3516ev300_85h50ai: video0.bitrate set to 4000 kbit/s while the WebUI dashboard showed 14.2 Mbit/s, and visibly noisy video that looked like 3DNR was off. They are one bug, and it is in this repo.

What happens

The osdrv packages create default.ini as a symlink to one fixed sensor's IQ file — imx307.ini for both hisilicon-osdrv-hi3516ev200 and goke-osdrv-gk7205v200. Two device profiles prune that exact file to fit NOR and leave the symlink behind, so the image ships a default.ini that resolves to nothing:

root@hi3516ev300_85h50ai:~# ls -l /etc/sensors/iq/
lrwxrwxrwx 1 root root     10 Sep  4 18:52 default.ini -> imx307.ini
-rw-r--r-- 1 root root 148822 Sep  4 18:52 imx335.ini

majestic answers that silently. init_iq_monitor() (src/hisi/sdk.c) has no default for isp.iqProfile, falls through to /etc/sensors/iq/default.ini, and returns on access(default_prof, 0) != 0 without logging at any level. No IQ profile means no monitor thread, so SCENE_Set3DNR() never runs and VPSS keeps the single static NRX block from scene.c tune_vpss() at every ISO.

Measured

Lab hi3516ev300_85h50ai (IMX335, nightly-20260904-605fa9d), night scene at ISO ~30000, changing nothing but the profile majestic loads:

dangling imx335.ini
RTSP, 20 s capture 14.13 Mbit/s 3.54 Mbit/s
/proc/umap/rc InsBr 14310 kbps 3626 kbps
StartQp 42 (= MaxQp) 31
3DNR SFS2 5/16/0/30 36/60/60/52
3DNR SFS4 5/16/0/10 32/60/60/32
3DNR TFS 1/7/12/10 5/9/13/11
3DNR MATH 60/170/150/150 100/320/300/220

The encoder was configured correctly the whole time — /proc/umap/rc showed VBR 4096, MinQp 28, MaxQp 42. Rate control pinned at MaxQp while still emitting 14 Mbit/s is what an undenoised sensor at ISO 30000 costs, not a bitrate that was ignored. It reads from the outside as "the bitrate setting does nothing" and "3DNR is off", which is how it was reported.

The fix

hi3516ev300_lite_xm-85h50ai keeps imx335.ini and runs an IMX335, so general/overlay now carries a default.ini aimed at it. BR2_ROOTFS_OVERLAY is rsynced after the packages install and rootfs_script.sh runs the excludes list after that, so the overlay's symlink replaces the package's and the pruning that follows is harmless. Simulated end to end:

--- after package install:   default.ini -> imx307.ini   f23.ini  imx307.ini  imx335.ini
--- after overlay rsync:     default.ini -> imx335.ini   f23.ini  imx307.ini  imx335.ini
--- final image:             default.ini -> imx335.ini   imx335.ini
resolves? YES -> imx335.ini

This also stops the board loading an IMX307 profile for an IMX335 sensor, which is what it would have got had imx307.ini simply been kept instead — so it is a better outcome than reverting the exclusion, at the same size.

gk7202v300_lite_ipg-g3-wr prunes every IQ file its package installs (imx307, imx335, sc2232), so there is nothing to aim a symlink at. It drops default.ini instead. Behaviour is unchanged — majestic already loads no profile there — but the image stops carrying a broken link that would silently start resolving to the wrong sensor's profile the moment one of those entries goes stale. The board runs jxh63, which no shipped IQ file covers; a note in the list records that keeping imx307.ini costs 126 KB if it turns out to want one. That call belongs to whoever has the hardware.

Blast radius

Audited every device profile against its SoC's osdrv package (default.ini target: imx307 for hi3516ev200/gk7205v200, sc2232 for gk7205v500, ar0130 for hi3516cv200, imx323 for hi3516cv300). These two are the only ones that remove the target while keeping the symlink. The rest either keep the target, remove default.ini already, or pin .isp.iqProfile in customizer.sh.

One thing the audit turned up that is not fixed here: /etc/sensors/iq/*.ini in gk7205v200_lite_vixand-ipc-1 is a dead entry — the excludes runner quotes its paths, so the glob never expands and nothing is pruned. Harmless, but it is not doing what it looks like it does.

Follow-ups worth doing separately

  • firmware: a dangling-symlink check in rootfs_script.sh after the excludes run would catch this whole class at build time, next to the existing stale-entry report.
  • majestic: one log_w() on the mute default.ini fallback. The explicit-iqProfile path already logs Cannot find %s file; only this one is silent, which is why this took proc-file archaeology rather than reading a log.
  • firmware, larger: every ev200/ev300/gk7205v200 board that keeps imx307.ini has an IMX335 camera loading the IMX307 IQ profile. A lab hi3516ev300-imx335 is doing that today and looks fine, because a wrong profile still carries usable 3DNR ISO tables — the failure is quiet in that direction too. Resolving default.ini per detected sensor would fix the class.

The osdrv packages create default.ini as a symlink to one fixed sensor's
IQ file -- imx307.ini for hisilicon-osdrv-hi3516ev200 and
goke-osdrv-gk7205v200. Two device profiles prune that exact file to fit
NOR and leave the symlink behind, so the image ships a default.ini that
resolves to nothing.

majestic answers that silently. init_iq_monitor() (src/hisi/sdk.c) has no
default for isp.iqProfile, falls through to /etc/sensors/iq/default.ini,
and returns on `access(default_prof, 0) != 0` without logging at any
level. No IQ profile means no monitor thread, so SCENE_Set3DNR() never
runs and VPSS keeps the single static NRX block from scene.c tune_vpss()
at every ISO. The explicit-iqProfile path does log "Cannot find %s file";
only this fallback is mute.

Measured on a lab hi3516ev300_85h50ai (IMX335, nightly-20260904-605fa9d)
against a night scene at ISO ~30000, changing nothing but the profile
majestic loads:

                        dangling      imx335.ini
  RTSP, 20 s capture    14.13 Mbit/s  3.54 Mbit/s
  /proc/umap/rc InsBr   14310 kbps    3626 kbps
  StartQp               42 (= MaxQp)  31
  3DNR SFS2             5/16/0/30     36/60/60/52
  3DNR TFS              1/7/12/10     5/9/13/11

The encoder was configured correctly the whole time -- VBR 4096, MinQp
28, MaxQp 42. Rate control pinned at MaxQp while still emitting 14 Mbit/s
is what an undenoised sensor at ISO 30000 costs, not a bitrate that was
ignored. It reads as "the bitrate setting does nothing" and "3DNR is
off", which is how it was reported.

hi3516ev300_lite_xm-85h50ai keeps imx335.ini and runs an IMX335, so
general/overlay now carries a default.ini aimed at it. BR2_ROOTFS_OVERLAY
is rsynced after the packages install and rootfs_script.sh runs the
excludes list after that, so the overlay's symlink replaces the package's
and the pruning that follows is harmless. This also stops the board
loading an IMX307 profile for an IMX335 sensor, which is what it would
have got had imx307.ini simply been kept.

gk7202v300_lite_ipg-g3-wr prunes every IQ file its package installs
(imx307, imx335, sc2232), so there is nothing to aim a symlink at. It
drops default.ini instead. Behaviour is unchanged -- majestic already
loads no profile there -- but the image stops carrying a broken link that
would silently start resolving to the wrong sensor's profile the moment
one of those entries goes stale. The board runs jxh63, which no shipped
IQ file covers; a note in the list records that keeping imx307.ini costs
126 KB if it turns out to want one.

An audit of every device profile against its SoC's osdrv package finds no
others: the rest either keep the symlink's target, remove default.ini
already, or pin .isp.iqProfile in customizer.sh.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Prevent dangling default IQ profiles in two device images

🐞 Bug fix ⚙️ Configuration changes 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Point the IMX335 board's default IQ profile at its sensor-correct configuration.
• Remove the default IQ symlink when every compatible packaged profile is pruned.
• Document build-order and sensor constraints behind both device-specific fixes.
Diagram

graph TD
  A["OSDRV IQ package"] --> B{"Device profile"} -->|XM 85H50AI| C["IMX335 overlay"] --> D["Profile pruning"] --> E["Valid IQ default"] --> F["Majestic 3DNR"]
  B -->|IPG G3 WR| G["Remove IQ default"] --> H["No dangling link"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Retain the package target
  • ➕ Preserves the package-created default.ini invariant
  • ➕ Requires no overlay replacement
  • ➖ Loads an IMX307 profile on an IMX335 sensor
  • ➖ Consumes additional NOR space without providing sensor-correct tuning
  • ➖ Does not address the JXH63 board's missing compatible profile
2. Pin iqProfile in runtime configuration
  • ➕ Makes the selected IQ profile explicit per board
  • ➕ Avoids relying on the package's generic fallback
  • ➖ Still requires a compatible retained profile
  • ➖ Leaves the filesystem's dangling default symlink unless separately removed
  • ➖ Adds runtime configuration coupling for an image-construction problem
3. Resolve profiles from detected sensors
  • ➕ Addresses incorrect defaults across all supported boards
  • ➕ Eliminates dependence on a fixed package-level sensor profile
  • ➖ Requires broader firmware and runtime changes
  • ➖ Needs reliable sensor-to-profile mappings and hardware validation
  • ➖ Is disproportionate to this targeted image fix

Recommendation: Use the PR's board-specific image fix: it selects the correct retained IMX335 profile where one exists and removes the fallback where none is compatible. Sensor-aware runtime resolution is the stronger long-term solution, but it should be implemented separately because its scope and validation requirements are substantially larger.

Files changed (3) +17 / -0

Bug fix (2) +11 / -0
gk7202v300_lite.listRemove the unusable default IQ symlink +10/-0

Remove the unusable default IQ symlink

• Adds default.ini to the exclusion list because every packaged IQ profile is already removed for this JXH63 board. Comments explain why preserving the dangling link risks silently selecting an incompatible profile later.

devices/gk7202v300_lite_ipg-g3-wr/general/scripts/excludes/gk7202v300_lite.list

default.iniSelect the IMX335 IQ profile by default +1/-0

Select the IMX335 IQ profile by default

• Adds a board overlay symlink from default.ini to the retained imx335.ini profile. This lets majestic initialize IQ monitoring and apply sensor-appropriate 3DNR tuning.

devices/hi3516ev300_lite_xm-85h50ai/general/overlay/etc/sensors/iq/default.ini

Documentation (1) +6 / -0
hi3516ev300_lite.listDocument the sensor-correct default replacement +6/-0

Document the sensor-correct default replacement

• Documents that the overlay replaces the package's IMX307 default before exclusions remove imx307.ini. This clarifies why pruning remains safe and leaves a valid IMX335 target.

devices/hi3516ev300_lite_xm-85h50ai/general/scripts/excludes/hi3516ev300_lite.list

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit 6947491 into master Sep 7, 2026
7 checks passed
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.

2 participants