Skip to content

fh8852v200_lite_tuya-f1602-d2: the MIS4001 library from source - #294

Merged
openipc-ai merged 1 commit into
masterfrom
f1602-mis4001-source
Dec 4, 2026
Merged

openipc-ai merged 1 commit into
masterfrom
f1602-mis4001-source

Conversation

@openipc-ai

Copy link
Copy Markdown
Contributor

The Tuya F1602-D2's MIS4001 library and tuning now come from source, OpenIPC/openfullhan#1, through the firmware's fullhan-opensdk package (OpenIPC/firmware#3078). Until now this profile carried the binary from the stock firmware (OpenIPC/firmware#3027).

  • Defconfig: BR2_PACKAGE_FULLHAN_OPENSDK=y. It installs /usr/lib/sensors/libmis4001_mipi.so and /etc/sensors/mis4001_mipi*_attr.hex.
  • Overlay: the binary libmis4001_mipi.so and the two tuning files go. The tuning files move unchanged to openfullhan, which now carries their notes.
  • NOTES.md: points to the source and says what changed.

What changes on the camera:

Merge order

  1. fh8852v200: MIS4001, 2560x1440 MIPI 2-lane, from source openfullhan#1.
  2. fullhan-opensdk: build the fh8852v200 sensors too, MIS4001 first firmware#3078.
  3. This PR.

Until #3078 is in firmware master, this profile's CI builds against a firmware whose fullhan-opensdk cannot be enabled on fh8852v200. Such an image would have no MIS4001 library at all, so this waits.

Testing

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

qodo-free-for-open-source-projects Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

fh8852v200_lite_tuya-f1602-d2: the MIS4001 library from source

✨ Enhancement ⚙️ Configuration changes 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Replaces the stock binary MIS4001 sensor library with one built from source.
• Enables fullhan-opensdk, which installs the library and tuning files from openfullhan.
• Removes the binary library and tuning overlay; NOTES.md documents the source and changes.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed defconfig, deleted tuning overlays, selected sensor environment, and flip/mirror settings all participate in one bounded end-to-end camera imaging behavior.
  • They affect sensor initialization and rendered image output, not separate user capabilities or merely independent technical layers.
Sources

devices/fh8852v200_lite_tuya-f1602-d2/br-ext-chip-fullhan/configs/fh8852v200_lite_tuya-f1602-d2_defconfig[80-81]

# The MIS4001 sensor library and its tuning, built from source (OpenIPC/openfullhan).
BR2_PACKAGE_FULLHAN_OPENSDK=y
Behavioral complexity 🟡 Medium 🧩 Interacting branches, Compatibility cases

  • Before, the profile shipped a fixed vendor library and two checked-in tuning files.
  • After, a source-built library and package-installed tuning must remain compatible with the existing Majestic sensor contract and the configured flip/mirror modes.
  • The new correctness condition is that all supported orientation states, including live flip and mirror changes, continue mapping the sensor Bayer order and tuning to valid rendered colors and exposure.
  • The compatibility characteristic comes from replacing the old artifact source while retaining the existing consumer and sensor configuration; no new concurrency or recovery protocol is introduced.
Sources

devices/fh8852v200_lite_tuya-f1602-d2/br-ext-chip-fullhan/configs/fh8852v200_lite_tuya-f1602-d2_defconfig[80-81]

# The MIS4001 sensor library and its tuning, built from source (OpenIPC/openfullhan).
BR2_PACKAGE_FULLHAN_OPENSDK=y
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the replacement library or tuning regresses, the camera can produce wrong Bayer interpretation, color, exposure, noise behavior, or orientation while the rest of the device remains operational.
  • The evidence supports the imaging scope, but exact source-built values and installation behavior remain externally unverified.
  • Reverting the firmware or rebuilding with the prior sensor artifacts should restore the prior image behavior; no persistent application state or external effect is indicated.
  • A deployed device would still require firmware replacement or reflash.
Sources

devices/fh8852v200_lite_tuya-f1602-d2/br-ext-chip-fullhan/configs/fh8852v200_lite_tuya-f1602-d2_defconfig[80-81]

# The MIS4001 sensor library and its tuning, built from source (OpenIPC/openfullhan).
BR2_PACKAGE_FULLHAN_OPENSDK=y
Assessed commit 7d32c2b
Diagram

graph TD
  A["defconfig"] --> B["fullhan-opensdk pkg"] --> C["libmis4001_mipi.so"] --> D["majestic sensor load"]
  B --> E["mis4001 attr hex files"] --> D
Loading
High-Level Assessment

Building the MIS4001 library from openfullhan through fullhan-opensdk is the right direction. It removes an opaque vendor binary and keeps the register values, so the change is low-risk. The PR correctly waits for openfullhan#1 and firmware#3078 to merge first, since CI would otherwise build an image with no MIS4001 library. Keeping the binary was the only other option, and it is what this PR replaces.

Files changed (2) +18 / -15

Documentation (1) +16 / -15
NOTES.mdDocument source-built MIS4001 library and its changes +16/-15

Document source-built MIS4001 library and its changes

• Replaces the binary-library and tuning notes with a pointer to openfullhan. Lists the fixes: live flip/mirror colour handling and the measured Bayer table.

devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md

Other (1) +2 / -0
fh8852v200_lite_tuya-f1602-d2_defconfigEnable fullhan-opensdk package for MIS4001 library +2/-0

Enable fullhan-opensdk package for MIS4001 library

• Adds BR2_PACKAGE_FULLHAN_OPENSDK=y with a comment. This installs the MIS4001 library and tuning files from source in place of the overlay copies.

devices/fh8852v200_lite_tuya-f1602-d2/br-ext-chip-fullhan/configs/fh8852v200_lite_tuya-f1602-d2_defconfig

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

qodo-free-for-open-source-projects Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (2) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Stock-firmware origin of the library is no longer stated here 📎 Requirement gap ⚙ Maintainability
Description
The rewritten NOTES.md drops the paragraph that disclosed the library's origin: stock firmware
version 8.37.200, the Tuya dgiot SDK application (platform "HC1702") it was taken from, and its
repackaging as a 31-slot sensor_if library. The new section only says "Built from source" in
OpenIPC/openfullhan and defers the origin to that repository's README, which is outside this PR. A
reader of this profile therefore sees the sensor library presented as source-built with no
vendor-origin disclosure in the device notes, and a later change to the openfullhan README would
silently remove the only record here.
Code

devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[L11-15]

-#### MIS4001 sensor library (binary, from the stock firmware)
-
-`general/overlay/usr/lib/sensors/libmis4001_mipi.so` is the vendor's MIS4001 driver, not built from source. It ships as a binary until OpenIPC has a MIS4001 driver built from source to replace it (OpenIPC/firmware#3027).
-
-- **Where it came from:** the stock firmware, version `8.37.200` (from the sticker on the microSD slot). The driver code was taken from the Tuya SDK application `dgiot` (platform "HC1702") and repackaged as the standard 31-slot `sensor_if` library that majestic loads, like the other libraries in `fullhan-osdrv-fh8852v200`.
Evidence
The removed lines disclose the vendor origin (stock firmware 8.37.200, Tuya dgiot SDK, repackaged as
sensor_if). The added lines replace them with "Built from source" and a pointer to an external
README, so the origin is no longer stated in this repository.

MIS4001 sensor library provenance and packaging
devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[11-16]

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 device notes for the MIS4001 library no longer say the library's vendor origin. The removed paragraph named the stock firmware version 8.37.200, the Tuya `dgiot` SDK application (platform "HC1702"), and the repackaging as a 31-slot `sensor_if` library. The new section says only "Built from source" and defers to an external README.
## Fix Focus Areas
- devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[11-25]
## Recommended Fix
In `devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md`, add back a short provenance paragraph under the MIS4001 library heading. It should state that the driver code was taken from the stock Tuya firmware 8.37.200, from the `dgiot` SDK application (platform "HC1702"), and repackaged as the 31-slot `sensor_if` library. Keep the link to OpenIPC/openfullhan as the source of truth for the build.

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


2. Notes call untested colours verified on the camera 📎 Requirement gap ≡ Correctness
Description
The new Bayer bullet in NOTES.md states that all four orientations are right from a fresh start,
and the live-switch bullet states that flip and mirror now give correct colours. The PR description
says the build is "Not confirmed on the camera yet" and has only been run as a test build. The notes
therefore claim verified results for the new library that the PR itself says have not been measured.
Code

devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[R21-25]

+- `image.flip` and `image.mirror` now give the right colours when switched live
+  too (OpenIPC/majestic#416). The stock library could leave a magenta picture
+  until the next switch.
+- The Bayer table is the one measured on this camera (OpenIPC/builder#292):
+  all four orientations are right from a fresh start. This camera hangs upside
Evidence
The added bullets assert camera-verified orientation colours and a live-switch fix. The PR
description states that the test build is not confirmed on the camera, so the claim is ahead of the
testing evidence.

Verify MIS4001 Bayer mapping for supported orientations
Keep colours correct during live flip and mirror changes
devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[21-25]

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 `NOTES.md` text states that the Bayer table gives correct colours in all four orientations from a fresh start, and that live `image.flip`/`image.mirror` switches now give correct colours. The PR description says the test build is "Not confirmed on the camera yet". The notes therefore report unverified results as fact.
## Fix Focus Areas
- devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md[21-25]
## Recommended Fix
In `devices/fh8852v200_lite_tuya-f1602-d2/NOTES.md`, reword the bullets so that they separate measured results from expected results. Say which orientations were checked on the camera, and mark any others and the live-switch fix as untested until the test build (`test-fh8852v200-5-20261204`) is confirmed on the camera. Remove the claim that the live-switch behaviour is fixed unless it has been observed.

ⓘ 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 import rules and skills only from the repositories your team follows

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai

Copy link
Copy Markdown
Contributor Author

On the review's two findings, both fair. They go into the follow-up that comes once the owner has tested the library on the camera (OpenIPC/majestic#416):

  1. Origin no longer stated here: the notes now point to openfullhan's README for it, which names stock firmware 8.37.200, dgiot and "HC1702". The follow-up puts a short provenance line back into this profile's NOTES.md too, so the record doesn't depend on another repository.
  2. Untested colours stated as verified: right for the live-switch bullet. The Bayer bullet describes fh8852v200_lite_tuya-f1602-d2: fix the MIS4001 Bayer table for normal and mirror-only #292's measurements, which were made with the stock library from fresh starts, and this library writes the same registers there. Whether live switches are now right is what the camera test answers. The follow-up rewrites that bullet to say what the camera showed.

The sensor library and its tuning now come from OpenIPC/openfullhan
through the firmware's fullhan-opensdk package, in place of the stock
firmware's library this profile carried (OpenIPC/firmware#3027). Same
register values; live image.flip / image.mirror switches no longer leave
a magenta picture (OpenIPC/majestic#416).
@openipc-ai
openipc-ai force-pushed the f1602-mis4001-source branch from a182ba0 to 7d32c2b Compare December 4, 2026 08:47
@openipc-ai
openipc-ai merged commit 04176ff into master Dec 4, 2026
7 checks passed
@openipc-ai
openipc-ai deleted the f1602-mis4001-source branch December 4, 2026 08:56
@lexleite

lexleite commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Tested on the camera: this PR's CI image (294/merge+3276e98, which also has #293) works, and so does the QR Wi-Fi setup.

I flashed it with sysupgrade --kernel=... --rootfs=... -z, keeping the settings. The rootfs is 5024 KiB, 92 KiB under the limit.

Source-built MIS4001 library: all four orientations are correct from a fresh start, and 26 of 26 live switches are correct; details in OpenIPC/majestic#416.

Regression, the same checks as on #291:

  • Wi-Fi: 8733bu and cfg80211, no mac80211;
  • video: snapshots, and RTSP at 2560x1440 HEVC;
  • audio: a 1 kHz tone sent to /play_audio comes back in the RTSP audio;
  • pan/tilt, SADC day/night, and the reset watcher;
  • SD card: inserted while the camera was running, it came up as mmcblk0 and mounted at /mnt/mmcblk0; a 4 MB random file was written, synced and read back identical after drop_caches, at about 2.5 MB/s in 1-bit mode, with no mmc errors;
  • the media pool at a1f00000.

QR Wi-Fi setup (#293):

  • I started qrscan.sh and showed a phone's Wi-Fi QR code for the router's 5 GHz network.
  • Log: Code read, trying network "..._5G", then Joined "..._5G"; credentials saved, rebooting.
  • The "scanned" and "connected" IR-cut chimes were heard next to the camera, so the excluded ready_48k.pcm isn't missed.
  • After the reboot, wlanssid is the new network, and the camera came back in about 50 s on it: 802.11an, channel 36, 72.2 Mbit/s. RTSP ran at 25 fps.

So the RTL8733BU works on 5 GHz too. Its driver reports band_cap: 2G 5G and proto_cap: b g n: Wi-Fi 4 on both bands, no 802.11ac.

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