Skip to content

hi3516ev200: sensor_dvp opt-in, SC2235 DVP sensor config and IQ profile - #2446

Merged
openipc-ai merged 1 commit into
OpenIPC:masterfrom
HeytalePazguato:imou-cue2
Sep 28, 2026
Merged

openipc-ai merged 1 commit into
OpenIPC:masterfrom
HeytalePazguato:imou-cue2

Conversation

@HeytalePazguato

@HeytalePazguato HeytalePazguato commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Family-level pieces for Hi3516EV200 boards with an SC2235 on the DVP pads. The board itself (Imou Cue 2, IPC-C22EN) is OpenIPC/builder#160.

  • load_hisilicon: fw_setenv sensor_dvp 1 selects DVP pad routing (YUV_TYPE0=1). With the MIPI default the I2C controller is muxed to pads that a DVP sensor is not wired to, so detection NACKs on every address. Unset, nothing changes for existing boards.
  • sensor/config/sc2235_i2c_dc_1080p.ini: 1080p 10-bit parallel input. Sync polarities picked by sweeping all 16 combinations; only this one produces VI frame interrupts.
  • sensor/iq/sc2235.ini: IQ profile, installed next to the existing three. default.ini still points at imx307.ini.

The SC2235 driver change is OpenIPC/openhisilicon#233. Once that lands, HISILICON_OPENSDK_VERSION needs a bump for DVP boards to get video.

Testing

Built from this branch + builder#160 + openhisilicon#233, flashed (kernel + rootfs, overlay erased) to one Imou Cue 2: video from cold boot with no runtime scripts, main + sub stream into Frigate, night mode switching, two-way audio.

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

Copy link
Copy Markdown

PR Summary by Qodo

Add Imou Cue 2 IPC-C22EN board support

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds a complete Imou Cue 2 firmware profile for Hi3516EV200 hardware.
• Enables SC2235 DVP capture with required clock, pad, and synchronization settings.
• Configures networking, media, lighting, and flash footprint for unattended operation.
Diagram

graph TD
  A["Board Defconfig"] --> B["Firmware Image"] --> C["Board Runtime"] --> D["WiFi LEDs IR"]
  C --> E["DVP Loader"] --> F["SC2235 Driver"] --> G["ISP IQ"] --> H["Majestic Services"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Board-specific SC2235 DVP variant
  • ➕ Isolates the Dahua sequence from existing SC2235 boards
  • ➕ Avoids globally changing a shared sensor initialization routine
  • ➕ Makes DVP-specific behavior explicit during board selection
  • ➖ Duplicates some SC2235 driver logic
  • ➖ Requires additional package and sensor-object wiring
2. Runtime-only register initialization
  • ➕ Avoids modifying the shared OpenSDK sensor driver
  • ➕ Keeps all Imou-specific behavior in the board overlay
  • ➖ Depends on fragile boot timing and process restarts
  • ➖ Sensor detection may fail before runtime scripts execute
  • ➖ Duplicates initialization responsibilities across driver and rc.local

Recommendation: Prefer a board-selected SC2235 DVP variant if the sensor packaging supports it, because the current patch replaces initialization globally for every Hi3516EV200 SC2235 user. Runtime-only programming is too timing-sensitive; if the shared replacement remains, regression-test another existing SC2235 board and document why the sequence is universally compatible.

Files changed (16) +2419 / -11

Enhancement (4) +49 / -0
S01ledsSet boot-in-progress LED state +12/-0

Set boot-in-progress LED state

• Adds early initialization that lights the active-low red LED and disables the green and bottom-red LEDs.

general/overlay/etc/init.d/S01leds

S99ledsSet ready-state LEDs after boot +19/-0

Set ready-state LEDs after boot

• Switches to the green ready LED after startup, while honoring the persistent LED-disable setting.

general/overlay/etc/init.d/S99leds

usbRegister the Imou RTL8188FU adapter +7/-0

Register the Imou RTL8188FU adapter

• Adds standard network initialization for the board by enabling GPIO 52 and loading the 8188fu module.

general/overlay/etc/wireless/usb

load_hisiliconSelect DVP routing for opted-in boards +11/-0

Select DVP routing for opted-in boards

• Reads the sensor_dvp environment flag and selects digital-camera routing instead of the default MIPI path.

general/package/hisilicon-osdrv-hi3516ev200/files/script/load_hisilicon

Bug fix (2) +225 / -11
rc.localInitialize IR PWM and stabilize sensor startup +35/-11

Initialize IR PWM and stabilize sensor startup

• Programs the PWM-driven IR illuminator, reapplies SC2235 orientation and DVP pad registers, then restarts Majestic after sensor initialization.

general/overlay/etc/rc.local

0001-sc2235-replace-init-table-with-dahua-dvp-sequence.patchEnable SC2235 DVP pixel-clock output +190/-0

Enable SC2235 DVP pixel-clock output

• Replaces the stock SC2235 initialization with the Dahua-derived register sequence. It starts streaming, enables PCLK and pad drive registers, then reasserts streaming so frames reach the SoC.

general/package/hisilicon-opensdk/0001-sc2235-replace-init-table-with-dahua-dvp-sequence.patch

Other (10) +2145 / -0
hi3516ev200_lite_imou-cue2_defconfigDefine the Imou Cue 2 firmware build +65/-0

Define the Imou Cue 2 firmware build

• Adds an 8 MB Hi3516EV200 lite configuration with Majestic, RTL8188FU, WPA supplicant, Opus, and required platform packages.

br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig

nrx_night_06.txtAdd night-mode noise-reduction parameters +28/-0

Add night-mode noise-reduction parameters

• Provides the board's numeric night-mode NRX parameter set for low-light image processing.

general/overlay/etc/ir/nrx_night_06.txt

nrxsetInclude the NRX application helper +0/-0

Include the NRX application helper

• Tracks the NRX helper used by the board's image-processing setup; the supplied patch contains no textual changes.

general/overlay/etc/ir/nrxset

majestic.yamlConfigure Majestic camera services +182/-0

Configure Majestic camera services

• Defines SC2235 ISP and IQ paths, dual H.264 streams, Opus audio, RTSP backchannel, night mode, mDNS, ONVIF, and watchdog defaults.

general/overlay/etc/majestic.yaml

sc2235_i2c_1080p.iniAdd runtime SC2235 DVP sensor definition +80/-0

Add runtime SC2235 DVP sensor definition

• Configures 10-bit 1080p CMOS input, Bayer order, DVP masks, synchronization polarities, and active frame geometry.

general/overlay/etc/sensors/sc2235_i2c_1080p.ini

customizer.shPersist Imou Cue 2 hardware identity +24/-0

Persist Imou Cue 2 hardware identity

• Stores the SoC, SC2235 DVP mode, upgrade URL, reset-button GPIO, and board-specific wireless device in U-Boot environment variables.

general/overlay/usr/share/openipc/customizer.sh

sc2235_i2c_dc_1080p.iniPackage the SC2235 digital-camera profile +46/-0

Package the SC2235 digital-camera profile

• Adds the compact OSDRV sensor definition for 1080p, 10-bit parallel CMOS capture with the verified synchronization settings.

general/package/hisilicon-osdrv-hi3516ev200/files/sensor/config/sc2235_i2c_dc_1080p.ini

sc2235.iniAdd tuned SC2235 image-quality profile +1647/-0

Add tuned SC2235 image-quality profile

• Adds day and infrared ISP tuning for exposure, gamma, sharpening, dehazing, color, and dynamic processing. Includes boosted temporal and chroma 3DNR profiles across ISO levels.

general/package/hisilicon-osdrv-hi3516ev200/files/sensor/iq/sc2235.ini

hisilicon-osdrv-hi3516ev200.mkInstall the SC2235 IQ profile +1/-0

Install the SC2235 IQ profile

• Copies the new SC2235 image-quality profile into the target sensor IQ directory during the firmware build.

general/package/hisilicon-osdrv-hi3516ev200/hisilicon-osdrv-hi3516ev200.mk

hi3516ev200_lite.listReduce the lite firmware root filesystem +72/-0

Reduce the lite firmware root filesystem

• Excludes unused sensor libraries, profiles, high-frame-rate and WDR configurations, and the camera motor module to fit the 8 MB flash layout.

general/scripts/excludes/hi3516ev200_lite.list

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

qodo-free-for-open-source-projects Bot commented Sep 18, 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. All boards inherit one camera's wiring ⊘ Outdated 📘 Rule violation ≡ Correctness
Description
majestic.yaml, rc.local, the LED scripts, and customizer.sh hard-code the SC2235 sensor,
Imou-specific GPIOs, I2C writes, resolution, and upgrade image in general/overlay/. The shared
overlay is copied into every firmware image, so cameras with different sensors and wiring also
receive these startup operations and defaults.
Code

general/overlay/etc/majestic.yaml[12]

+  sensorConfig: /etc/sensors/sc2235_i2c_1080p.ini
Evidence
Rule 5 prohibits sensor names, resolutions, and GPIO values in general/overlay/. The cited files
select SC2235, configure 1920x1080 video, write fixed sensor and PWM addresses, operate fixed GPIOs,
and install a model-specific upgrade URL through an overlay shared by all images.

Rule 5: No device-specific values in generic configuration
general/overlay/etc/majestic.yaml[10-51]
general/overlay/etc/rc.local[3-35]
general/overlay/etc/init.d/S01leds[3-8]
general/overlay/usr/share/openipc/customizer.sh[6-22]

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 unconditional shared overlay contains sensor, GPIO, I2C, resolution, and upgrade settings that are valid only for the Imou Cue 2.
## Fix Focus Areas
- general/overlay/etc/majestic.yaml[12-12]
- general/overlay/etc/rc.local[3-35]
- general/overlay/etc/init.d/S01leds[3-8]
- general/overlay/etc/init.d/S99leds[3-15]
- general/overlay/usr/share/openipc/customizer.sh[6-22]
## Recommended Fix
Remove the board-specific files and values from `general/overlay/`. Place them in the Imou Cue 2 device profile in OpenIPC/builder, retaining only board-agnostic behavior or additive dispatch logic in this repository.

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


2. Existing cameras lose sensor support ⊘ Outdated 📘 Rule violation ≡ Correctness
Description
hi3516ev200_lite.list removes nearly every sensor library and configuration except the retail Cue
2 camera's SC2235 assets, including the IMX307 files required by existing boards. Because
rootfs_script.sh selects this list solely from the shared hi3516ev200 model and lite variant,
every lite image for that SoC loses support for its configured sensors instead of limiting the
pruning to the Cue 2 device.
Code

general/scripts/excludes/hi3516ev200_lite.list[R1-4]

+/usr/lib/sensors/libsns_ar0237.so
+/usr/lib/sensors/libsns_bt656.so
+/usr/lib/sensors/libsns_f22.so
+/usr/lib/sensors/libsns_f23.so
Evidence
The post-build script derives the exclusion filename solely from OPENIPC_SOC_MODEL and
OPENIPC_VARIANT and deletes every listed path, so both the existing generic target and the new Cue
2 target resolve to hi3516ev200_lite. The exclusion list removes numerous sensor libraries and
configurations—including an IMX307 configuration that explicitly depends on the removed
libsns_imx307.so—demonstrating that board-specific values are being applied indiscriminately
across the entire family, contrary to Rule 24.

CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files: CLAUDE.md: Keep Board-Specific Hardware Values Out of Shared Files
general/scripts/excludes/hi3516ev200_lite.list[1-72]
general/scripts/rootfs_script.sh[25-27]
general/scripts/rootfs_script.sh[27-30]
general/scripts/rootfs_script.sh[34-55]
br-ext-chip-hisilicon/configs/hi3516ev200_lite_defconfig[37-42]
br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[37-42]
general/package/hisilicon-osdrv-hi3516ev200/files/sensor/config/imx307_i2c_2l_1080p.ini[1-4]
general/scripts/excludes/hi3516ev200_lite.list[11-17]
general/scripts/excludes/hi3516ev200_lite.list[35-47]

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 new model-wide Hi3516EV200 lite exclusion list strips sensor dependencies required by existing boards that share the Cue 2's model and variant.
## Fix Focus Areas
- general/scripts/excludes/hi3516ev200_lite.list[1-72]
- general/scripts/rootfs_script.sh[27-55]
## Recommended Fix
Remove the Cue 2 pruning list from the generic model-and-variant exclusion key and shared firmware tree. Apply these size optimizations only in the Imou Cue 2 device build under OpenIPC/builder, or extend exclusion selection with a genuine device identifier, while preserving all sensor libraries and configurations for the generic `hi3516ev200_lite` target.

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


3. New board is absent from CI builds ⊘ Outdated 📘 Rule violation ☼ Reliability
Description
The new hi3516ev200_lite_imou-cue2_defconfig has no matching entry in ALL_BOARDS,
UNBUILT_BOARDS, or an excluded family. Because the matrix self-test requires every defconfig to be
registered, CI cannot account for this target and the repository self-test will reject it.
Code

br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[R38-42]

+BR2_OPENIPC_SOC_VENDOR="hisilicon"
+BR2_OPENIPC_SOC_MODEL="hi3516ev200"
+BR2_OPENIPC_SOC_FAMILY="hi3516ev200"
+BR2_OPENIPC_VARIANT="lite"
+BR2_OPENIPC_FLASH_SIZE="8"
Evidence
Rule 16 requires every new defconfig to be represented in the CI matrix or a reasoned exclusion. The
PR adds the defconfig, but the current matrix's Hi3516EV200 entries and unbuilt-board registry do
not contain its name.

CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI: CLAUDE.md: Register Every New Board Configuration with CI
br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[38-42]
.github/scripts/ci-matrix.py[45-98]
.github/scripts/ci-matrix.py[111-158]

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 newly added board defconfig is not represented in the CI build matrix or an exclusion list with a reason.
## Fix Focus Areas
- br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[38-42]
- .github/scripts/ci-matrix.py[45-98]
## Recommended Fix
Add the defconfig name to `ALL_BOARDS`, or add it to `UNBUILT_BOARDS` with a concrete reason if it intentionally cannot be built. Run `ci-matrix.py --self-test` afterward.

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


View action required (5)
4. Board support lands in the wrong tree ⊘ Outdated 📘 Rule violation ⚙ Maintainability
Description
The model-named defconfig and accompanying scripts implement support for exactly one Imou retail
camera inside the shared firmware repository. This placement leaves device-only configuration
alongside family-wide assets instead of under the device-oriented builder hierarchy that owns
per-board support.
Code

br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[R38-42]

+BR2_OPENIPC_SOC_VENDOR="hisilicon"
+BR2_OPENIPC_SOC_MODEL="hi3516ev200"
+BR2_OPENIPC_SOC_FAMILY="hi3516ev200"
+BR2_OPENIPC_VARIANT="lite"
+BR2_OPENIPC_FLASH_SIZE="8"
Evidence
Rule 8 requires support for one retail model to live in OpenIPC/builder. The added defconfig is
named for the Imou Cue 2, and its customizer selects an Imou-specific upgrade artifact and wireless
device, demonstrating that the added support targets exactly one camera model.

Rule 8: No single-board support in the shared tree
br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[37-65]
general/overlay/usr/share/openipc/customizer.sh[12-22]
general/overlay/etc/wireless/usb[110-115]

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 change adds support targeting one retail camera model to the shared firmware tree, contrary to the required device-repository boundary.
## Fix Focus Areas
- br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig[1-65]
- general/overlay/usr/share/openipc/customizer.sh[1-24]
- general/overlay/etc/init.d/S01leds[1-12]
- general/overlay/etc/init.d/S99leds[1-19]
## Recommended Fix
Move the Imou Cue 2 defconfig, startup scripts, customizer, and hardware settings into an appropriate `devices/common/br-ext-chip-hisilicon/` device directory in OpenIPC/builder. Keep only reusable SoC-family sensor integration in this repository.

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


5. Other cameras become Cue 2 devices ⊘ Outdated 🐞 Bug ≡ Correctness
Description
The shared customizer.sh unconditionally persists the Cue 2 SoC, SC2235 sensor, DVP mode, upgrade
URL, reset pin, and wireless device into the bootloader environment. S30customizer executes this
file on first boot of every image using the global overlay, after which loaders and sysupgrade
consume those persistent values on unrelated hardware.
Code

general/overlay/usr/share/openipc/customizer.sh[R8-10]

+fw_setenv soc hi3516ev200
+fw_setenv sensor sc2235
+fw_setenv sensor_dvp 1
Evidence
Every board build appends the common fragment that installs general/overlay, and the shared init
script runs any customizer present on first boot. The resulting environment values are persistent
and are later used by the HiSilicon loader and upgrade command.

Makefile[51-56]
general/openipc.fragment[1-5]
general/overlay/etc/init.d/S30customizer[8-14]
general/overlay/usr/share/openipc/customizer.sh[8-22]
general/package/hisilicon-osdrv-hi3516ev200/files/script/load_hisilicon[41-43]
general/overlay/usr/sbin/sysupgrade[503-503]

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 global first-boot customizer permanently assigns Cue 2 identity, sensor, networking, GPIO, and upgrade settings to every camera image.
## Fix Focus Areas
- general/overlay/usr/share/openipc/customizer.sh[1-24]
## Recommended Fix
Remove the Cue 2 customizer from the shared firmware overlay and install it only from a device-specific OpenIPC/builder profile for this retail camera. Ensure generic firmware images retain their existing board detection and upgrade settings.

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


6. Other cameras lose their video setup ⊘ Outdated 🐞 Bug ≡ Correctness
Description
The new global majestic.yaml hardcodes the SC2235 configuration, SC2235 image-quality profile,
1080p streams, and Cue 2 night-mode pins. The root filesystem overlay replaces Majestic's
package-generated configuration for every Majestic-enabled board, so cameras with other sensors and
wiring start the streamer using the wrong hardware definition.
Code

general/overlay/etc/majestic.yaml[R10-12]

+isp:
+  antiFlicker: disabled
+  sensorConfig: /etc/sensors/sc2235_i2c_1080p.ini
Evidence
The common Buildroot fragment applies general/overlay to every target, after the Majestic package
has installed its generated configuration. An unrelated Goke board also enables Majestic and
therefore receives this SC2235 configuration despite selecting different platform drivers.

general/openipc.fragment[1-5]
general/package/majestic/majestic.mk[23-24]
general/overlay/etc/majestic.yaml[10-30]
general/overlay/etc/majestic.yaml[133-143]
br-ext-chip-goke/configs/gk7205v300_lite_defconfig[38-71]

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

## Issue description
A Cue 2-specific Majestic configuration is installed as the default configuration for all firmware targets.
## Fix Focus Areas
- general/overlay/etc/majestic.yaml[1-182]
## Recommended Fix
Remove this configuration from the shared overlay and provide it through the Cue 2 device overlay in OpenIPC/builder. Leave the Majestic package-generated defaults intact for generic and unrelated board targets.

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


7. Other cameras receive hardware writes ✓ Resolved 🐞 Bug ☼ Reliability
Description
The shared rc.local writes Cue 2-specific memory-mapped PWM registers and SC2235 registers before
killing and relaunching Majestic. The common boot sequence runs this script on every board, so
unrelated SoCs receive writes to hardware addresses with different meanings and have their video
service interrupted regardless of whether setup succeeded.
Code

general/overlay/etc/rc.local[R8-11]

+  devmem 0x120101BC 32 $(( $(devmem 0x120101BC 32) | 0x80 ))
+  devmem 0x100C0010 32 0x1001
+  devmem 0x12080020 32 0x3e8
+  devmem 0x12080024 32 0x3b0
Evidence
The global overlay installs this rc.local, while S99rc.local invokes it and the common rcS
runner executes that init script on every platform. The body contains fixed HiSilicon MMIO
addresses, a fixed I2C bus and address, and an unconditional Majestic restart.

general/overlay/etc/init.d/rcS[16-24]
general/overlay/etc/init.d/S99rc.local[3-18]
general/overlay/etc/rc.local[3-14]
general/overlay/etc/rc.local[21-35]
br-ext-chip-goke/configs/gk7205v300_lite_defconfig[38-71]

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 global boot script performs Cue 2-specific memory, sensor, and service operations on every supported camera.
## Fix Focus Areas
- general/overlay/etc/rc.local[3-36]
## Recommended Fix
Restore the shared `rc.local` to a hardware-neutral implementation and move these PWM, sensor-register, and Majestic restart operations into the Cue 2 device overlay in OpenIPC/builder. Do not execute them based only on a shared SoC-family image.

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


8. Other cameras drive the wrong pins ⊘ Outdated 🐞 Bug ☼ Reliability
Description
The globally installed LED init scripts unconditionally configure pins 0, 4, and 9 as Cue 2 status
LEDs during startup and shutdown. The common init runner executes both scripts on every board,
causing unrelated cameras to export and drive pins that may serve different hardware functions.
Code

general/overlay/etc/init.d/S01leds[R6-9]

+case "$1" in
+	start | "")
+		gpio set 0; gpio clear 9; gpio clear 4
+		;;
Evidence
The common rcS script executes every S??* entry, and both added scripts drive fixed pin numbers
without a platform guard. The shared gpio utility exports each requested line and changes its
direction and value, so these calls actively reconfigure hardware rather than merely updating an LED
abstraction.

general/overlay/etc/init.d/rcS[16-24]
general/overlay/etc/init.d/S01leds[3-10]
general/overlay/etc/init.d/S99leds[3-16]
general/overlay/usr/sbin/gpio[17-27]
general/overlay/usr/sbin/gpio[45-64]

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

## Issue description
Shared init scripts drive Cue 2 LED pins on every supported board without checking the device identity.
## Fix Focus Areas
- general/overlay/etc/init.d/S01leds[1-12]
- general/overlay/etc/init.d/S99leds[1-19]
## Recommended Fix
Remove both scripts from the global overlay and install them only through the Cue 2 device profile in OpenIPC/builder. If a shared implementation is retained, require an explicit device-specific configuration before exporting or changing any pin.

ⓘ 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 turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread general/overlay/etc/majestic.yaml Outdated
Comment thread general/scripts/excludes/hi3516ev200_lite.list Outdated
Comment thread br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig Outdated
Comment thread br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig Outdated
Comment thread general/overlay/usr/share/openipc/customizer.sh Outdated
Comment thread general/overlay/etc/majestic.yaml Outdated
Comment thread general/overlay/etc/rc.local Outdated
Comment thread general/overlay/etc/init.d/S01leds Outdated

@openipc-ai openipc-ai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for this — four cameras, a CH341A recovery path and a DVP sequence you clearly worked out the hard way is real work, and none of what follows says otherwise. But almost all of it is filed in the wrong repository, and a few parts do not do what the description says they do. Details are inline; the shape of it is here.

This belongs in OpenIPC/builder

Not a technicality. general/overlay/ is copied verbatim into every image this tree builds, so as written, every camera of every vendor gets majestic.yaml pointing at an SC2235, rc.local writing Hi3516EV200 PWM registers, LED scripts driving GPIO 0/4/9, and a customizer.sh that fw_setenvs them into believing they are an Imou Cue 2 — including the upgrade URL, on first boot, permanently.

Builder already has a home for every file here, at the identical paths: devices/hi3516ev200_lite_imou-cue2-c22en/general/overlay/.... 96 devices ship a customizer.sh that way, 18 a gpio.conf, 15 a muxes.sh, and 89 an excludes list.

Three things I do not think work as intended

  1. ipctool is not on the image. general/package/ipctool/ipctool.mk installs ipcinfo and nothing else, so BR2_PACKAGE_IPCTOOL=y supplies no binary of that name. /usr/sbin/ipctool is a symlink to extutils, which downloads the tool from a latest release into /tmp on first use. I suspect your four cameras work for a different reason, and it is worth finding out which — otherwise the fix is load-bearing on your bench and absent in the field.
  2. nrxset is a binary with no source, which is a hard gate here (pr_compliance_checklist.yaml), and I cannot review what I cannot read. Nothing in firmware or builder reads /etc/ir/ either.
  3. The majestic restart re-opens several failures S95majestic exists to prevent.

The SC2235 patch belongs upstream

HISILICON_OPENSDK_SITE is $(call github,openipc,openhisilicon,…), and the file being patched is checked in there. Please open it as a PR against OpenIPC/openhisilicon, which fixes it for everyone rather than only for boards built from this tree.

On the ISP not tracking gain

The behaviour the boosted 3DNR compensates for is worth its own issue on OpenIPC/majestic with your before/after, rather than being absorbed into a tuning profile here. A camera-side workaround leaves it in place for every other board.

Mechanical blockers

  • The defconfig needs registering in ALL_BOARDS in .github/scripts/ci-matrix.py (or UNBUILT_BOARDS with a reason) or --self-test fails the merge.
  • general/scripts/excludes/hi3516ev200_lite.list breaks the generic board — see inline.

What can stay

The load_hisilicon sensor_dvp opt-in is genuinely good and family-wide. Split that into its own small PR and it would be welcome as-is.


Separately, and not your problem: this PR exposed several gaps in our own review rules, which I have written up in #2452.

Comment thread general/overlay/etc/rc.local Outdated
Comment thread general/overlay/etc/rc.local Outdated
Comment thread general/overlay/etc/rc.local Outdated
Comment thread general/overlay/etc/ir/nrx_night_06.txt Outdated
Comment thread general/overlay/etc/init.d/S01leds Outdated
Comment thread general/overlay/etc/majestic.yaml Outdated
Comment thread general/scripts/excludes/hi3516ev200_lite.list Outdated
Comment thread br-ext-chip-hisilicon/configs/hi3516ev200_lite_imou-cue2_defconfig Outdated
Comment thread general/overlay/etc/wireless/usb Outdated
openipc-ai added a commit that referenced this pull request Sep 19, 2026
Both come from the bot review on the pull request that added them, and
both were right.

The patch rule claimed no patch in the tree targets an OpenIPC-org
repository. That is false: libevent-openipc carries
0001-CMakeLists-remove-epoll_pwait2-check.patch against
github.com/OpenIPC/libevent. My own check missed it because the SITE
grep matched LIBEVENT_OPENIPC_SITE_METHOD first and took that line.
Counted properly it is 22 of 23, not 23 of 23 -- and the one exception
is the legitimate shape the rule should have described from the start:
one hunk, a build fix, obviously temporary, riding ahead of a bump.
So the gate no longer refuses every such patch. It asks whether the
patch is a bridge or a substitute -- is the upstream pull request named,
is it the minimal delta, does it go at the next *_VERSION bump -- which
still catches #2446, whose 114-entry table replacement is none of those.

The reachability rule was worse than the bot said. It asked that an
added file be "read at its installed path", but most of this tree's data
is never named by anyone: hisilicon-osdrv-hi3516ev200 installs
files/sensor/config/*.ini by wildcard and the one that gets used is
chosen at runtime from the configured sensor, a module is reached by
`modprobe <name>`, an IQ profile through isp.iqProfile. A new sensor ini
would have failed the gate while working perfectly. It also contradicted
a gate five entries above it in the same file, which already exempts a
data file landing under a path an existing install rule globs. Both now
say the same thing: trace the mechanism -- path, basename, a name built
at runtime, or an install glob a convention selects from -- and raise
only the residue, which is what /etc/ir/ actually is.

A rule that fires on correct work costs more than the rule is worth, and
best_practices.md already carries one warning about a false finding this
project has seen made. These two would have been the next.
openipc-ai added a commit that referenced this pull request Sep 19, 2026
#2446 (Imou Cue 2 board support) is the shape of PR these files exist to
catch, and the automated review caught eight of twelve problems in it. The
four it missed, and the five it half-caught, are all gaps in what we wrote
down rather than gaps in the reviewer.

The binaries gate enumerated .ko/.so/.a/.bin, so an executable with no
extension at all -- general/overlay/etc/ir/nrxset -- was reported back as
"contains no textual changes", which is exactly what a blob looks like to
anything reading a diff as text. The gate now keys on the "Binary files ...
differ" marker, which is the one signal that survives, and says outright
that general/overlay/ is never the place for a compiled artefact. A
register table copied out of a vendor's driver gets the same treatment: it
is the same provenance failure written in C.

Three things the tree already owns had no rule at all. ipctool is not on a
camera -- the package installs ipcinfo, and /usr/sbin/ipctool is an
extutils arm that curls the tool from a "latest" release into tmpfs at
first use -- so calling it from rc.local twelve seconds into boot on a
WiFi-only board is four bad properties at once. An overlay file needs no
Config.in, so nothing caught /etc/ir/nrxset and nrx_night_06.txt, which
nothing in firmware or builder reads and which the same PR's rc.local
never invokes, whatever its comment says. And S95majestic carries an -s
argument, a start-stop-daemon lookup, a ten-second wait for the sensor HAL
and a trap '' HUP that its own comment measured at 25 deaths out of 25 on
a hi3516ev200 -- all of which a hand-rolled killall-and-relaunch throws
away, on that same SoC.

A patch against a package this project owns is a bridge, not a substitute:
the pull request against the owning repository is named, the patch is the
minimal delta, and it goes at the next *_VERSION bump. libevent-openipc is
the tree's one instance and the model; #2446's 114-entry table replacement
is none of the three. OpenIPC/openhisilicon and OpenIPC/sensors join the
redirect table, which listed only linux, builder, ipctool and majestic.

The rest is telling contributors what already exists. customizer.sh,
muxes.sh, gpio.conf, late-overlays.list and the excludes lists are a
complete per-device mechanism, shipped per device in builder at the same
paths -- and documented nowhere, which is why somebody writes an S01leds
with GPIO 0, 4 and 9 typed into it instead. "Move it to builder" is half an
answer; say which seam it becomes. Two smaller notes go with it: the
"additive, so it changes nothing" exemption belongs to load_<vendor> case
arms and not to the overlay, where etc/wireless/usb has quietly reached 46
retail-model arms; and an excludes list added here is keyed <model>_<variant>,
which is the generic board's key too, so #2446's list took libsns_imx307.so
away from hi3516ev200_lite itself.

Lastly, devmem in a shipped script is now a question rather than a given.
It is the worst way to record what is soldered to a pad -- undone by
anything that later exports it, lost at the next reflash -- and the camera
can be told instead, through the /api/v1/pinmux surface the pins page in
OpenIPC/majestic-webui draws.

Two of these rules would themselves have generated false findings, and the
bot review on this PR caught both. The patch rule claimed no patch in the
tree targets an OpenIPC-org repository; libevent-openipc does, and my check
had missed it because the SITE grep matched LIBEVENT_OPENIPC_SITE_METHOD
first. The reachability rule asked that a file be read at its installed
path, but most of this tree's data is never named by anyone -- sensor inis
arrive through a wildcard and are chosen at runtime, modules through
modprobe, IQ profiles through isp.iqProfile -- and it contradicted a gate
five entries above it in the same file. Both now define reachability
semantically and agree with each other. A rule that fires on correct work
costs more than the rule is worth.
HeytalePazguato added a commit to HeytalePazguato/builder that referenced this pull request Sep 28, 2026
Hi3516EV200 + SC2235 on the DVP pads, RTL8188FTV USB WiFi, 8 MB NOR.
Everything board-specific lives here; the family-level pieces
(sensor_dvp in load_hisilicon, SC2235 sensor ini and IQ profile) are in
OpenIPC/firmware#2446, and the SC2235 DVP pad enables go to
OpenIPC/openhisilicon.

- customizer.sh: soc/sensor/sensor_dvp, upgrade URL, wlandev, and the
  majestic settings (sensor ini, IQ profile, mirror/flip, streams,
  night mode pins, two-way audio) as cli -s writes.
- etc/wireless/usb: own copy with the rtl8188fu arm (GPIO 52 power).
- gpio.conf: pin map (button 56, IR-cut 55, LEDs 0/9, IR 39,
  speaker 53, WiFi power 52).
- S01leds/S99leds: red while booting, green when up, led_disabled=1
  turns them off.
- rc.local: PWM drive for the IR illuminator.
- defconfig: WPA supplicant CLI + passphrase from Buildroot instead of
  a shell shim; libevent listed like every other defconfig.
- excludes: generated from what the hi3516ev200 osdrv installs, keeping
  the SC2235 files plus iq/default.ini and its imx307.ini target.
@HeytalePazguato HeytalePazguato changed the title Add Imou Cue 2 (IPC-C22EN) board support hi3516ev200: sensor_dvp opt-in, SC2235 DVP sensor config and IQ profile Sep 28, 2026
@HeytalePazguato

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review. Reworked and force-pushed as one commit on current master:

  • Moved to builder#160: majestic.yaml, rc.local, S01leds/S99leds, customizer.sh, the /etc/wireless/usb arm, the excludes list and the defconfig. Nothing in general/overlay/ any more, and with no defconfig here there is nothing to register in ci-matrix.py. The board name question goes away with it (hi3516ev200_lite_imou-cue2-c22en only).
  • /etc/ir/ (including nrxset): removed. You were right that nothing read it; the IQ profile is where the 3DNR settings live.
  • ipctool in rc.local: removed. Mirror/flip is now .image.mirror/.image.flip in the customizer, and the pad writes are in the driver.
  • majestic restart: removed entirely; nothing needs it now.
  • SC2235 patch: now hi3516ev200/sc2235: repeat DVP pad setup after stream start openhisilicon#233, reduced to the delta (repeat 0x3d08/0x3640/0x3641 after stream start, then stream start again). The rest of the table is untouched. That PR says where the values come from.
  • Kept here: the load_hisilicon sensor_dvp opt-in, the sensor ini and the IQ profile + its install line.
  • ISP gain tracking: left out of this PR; that belongs in a separate OpenIPC/majestic issue.

Tested by building firmware + builder#160 + openhisilicon#233 and flashing one Cue 2 clean (kernel + rootfs, overlay erased). Video, both streams in Frigate, night mode and two-way audio all work with no runtime scripts.

Family-level pieces needed by DVP-wired SC2235 boards such as the
Imou Cue 2 (board profile lives in OpenIPC/builder):

- load_hisilicon: `fw_setenv sensor_dvp 1` selects DVP pad routing
  (YUV_TYPE0=1). With the MIPI default the I2C controller is muxed to
  pads not wired to a DVP sensor, so detection NACKs on every address.
  Unset, nothing changes for existing boards.
- sensor/config/sc2235_i2c_dc_1080p.ini: 1080p 10-bit parallel input.
  Sync polarities chosen by sweeping all 16 combinations; only this one
  produces VI frame interrupts.
- sensor/iq/sc2235.ini: IQ profile, installed next to the existing ones.
  The default.ini symlink is unchanged.

@openipc-ai openipc-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. This is the right shape now, and the split was done properly — thank you for taking it apart rather than arguing for it.

What is left here is family-wide and additive:

  • load_hisilicon — YUV_TYPE0 keeps its 0 default and only flips when a profile sets sensor_dvp, so no existing ev200 board changes behaviour. The comment explains why the MIPI default leaves the I2C controller on unconnected pads, which is the part a future reader needs.
  • sc2235_i2c_dc_1080p.ini — lands under files/sensor/config/, which the existing *.ini install rule already globs, and is selected at runtime by sensor name. No .mk change needed and none made.
  • sc2235.ini — a new IQ profile for a sensor that had none on this family, with the install line it does need. smart_sc2235/libsns_sc2235 is already in HISILICON_OPENSDK_SENSORS_hi3516ev200, so there is a driver behind both files.

Nothing reaches general/overlay/, there is no binary, no defconfig to register, and the sensor patch went upstream reduced to its delta. Rebased onto master and the matrix is green across all 8 affected boards and every GCC row.

Two notes, neither blocking:

  • The sensor_dvp opt-in lives only in load_hisilicon, so a Goke board with a DVP-wired sensor cannot use it yet. Additive to add later if one turns up; not this PR's job.
  • This is inert until OpenIPC/openhisilicon#233 lands — the sensor still drives no pixel clock without it. That is fine for merging here, since nothing in this diff changes an existing board, but it does mean OpenIPC/builder#160 should not merge until #233 does, or the published Cue 2 image would have no video.

@openipc-ai
openipc-ai merged commit ce57824 into OpenIPC:master Sep 28, 2026
34 checks passed
openipc-ai added a commit that referenced this pull request Sep 28, 2026
openhisilicon c1f9eb5c is one commit on from the current pin: the SC2235
driver repeats its DVP pad setup once the sensor is streaming, with stronger
drive on 0x3641, and starts streaming again. The stock sequence sets those
enables before stream start, which on a DVP-wired board leaves the SoC with
no pixel clock -- the sensor answers on the bus and no VI interrupts arrive.

Measured rather than assumed. Building gk7205v200_lite at both pins in the
same tree, with the SDK build directory cleared each time, changes four of
378 rootfs files: libsns_sc2235.so, the os-release build stamp, and
open_mipi_rx.ko and open_wdt.ko, which embed __DATE__/__TIME__ and so differ
between any two builds minutes apart -- the commit touches nothing under
kernel/. So one functional file changes, and it is the sensor library.

No board regresses, because nothing selects that sensor yet: no defconfig
here and no builder device sets it, and the two builder devices that mention
it prune it in exclusion lists. On a running gk7205v200 the library is on
disk and mapped by no process. The Imou Cue 2 will be the first device to
select it, and its contributor verified this exact commit on one.

This is what #2446's sensor ini and IQ profile were waiting for, and what
OpenIPC/builder#160 needs before a Cue 2 image is worth publishing.
openipc-ai pushed a commit to OpenIPC/builder that referenced this pull request Sep 28, 2026
hi3516ev200 + SC2235 over DVP. The firmware side landed as OpenIPC/firmware#2446 (sensor ini, IQ profile, sensor_dvp opt-in) and #2494 (the openhisilicon pin carrying the DVP pad fix), so the profile now has everything it depends on.

customizer.sh sets the board identity in the bootloader environment and presets the streamer with cli -s; muxes.sh re-applies what a power cycle drops; gpio.conf names the pins; the wireless profile and the excludes list are the device's own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants