Skip to content

fix(imx296): FT N-1/绿线/#1016 UV/#1017 Y 尾修补与 procfs 门闩(#2026082001) - #14

Open
OKayJH wants to merge 22 commits into
rk3576from
fix/imx296-fast-trigger-n1-pwm-period
Open

fix(imx296): FT N-1/绿线/#1016 UV/#1017 Y 尾修补与 procfs 门闩(#2026082001)#14
OKayJH wants to merge 22 commits into
rk3576from
fix/imx296-fast-trigger-n1-pwm-period

Conversation

@OKayJH

@OKayJH OKayJH commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

提出者:@ymxc152 / @OKayJH

概要

  • 修复 IMX296 快速触发(FT)下 ROI / 模式切换后的 N-1 旧帧、底行残帧 / 绿带 / 产品灰接缝 / Y 亮度串帧
  • 将 FT 状态传给 RKISP;V39 early-done 走 MI 双读 + ceiling-force + force_post,不再 bare wait_line 完成。
  • 进入 FT 时 dummy 触发关残留打开帧;warmup / pub_gate / skip / drop 收至 2,靠完成路径与尾修补而不是加长 quarantine。
  • #1016rkisp_ft_sanitize_nv12_bot 仅在 mean/neu 判定为坏行时用 last-good UV 扩展(neu 仅当 ref 有 chroma 时生效)。禁止无条件整尾 0x80(#1013 会出产品灰接缝)。
  • #1017:同一 sanitize 对 Y 尾做条件 last-good 扩展。PWM/曝光大跳时底 8 行相对 pre-tail mean 跳 >12 且坏行 ≥4 → 整带 memcpy 上一行。未加长 warmup/gate。
  • 缓存固件 PWM 基准周期,长曝光切回短曝光后触发频率可恢复。
  • 外部触发运行时总开关:模式 / ROI 切换期间可屏蔽输入并清空 pending;free_run 忽略外部 XTRIG,避免打乱进 FT 相位。
  • procfs MMIO 门闩/proc/rkisp* 在 ISP 未 START / teardown 时拒绝 FIL_AIQ/FIL_SW 写,避免 Asynchronous SError panic。
  • n1trace / per-frame dev_info 改为 imx296.n1trace / video_rkisp.n1trace 默认关闭,避免 FT 日志打满 rootfs。
  • 并入 build(dlcvcam): boot.img 一键打包与 sidecar 校验 #15boot.img 一键打包 + sidecar SHA 校验;交付物仅 boot.img + .sha256
  • DLCVCAM 构建号:YYYYMMDDNN,当前 2026082001(内核 12abd272)。
  • 文档:问题全景 IMX296_问题全景_给后续Agent_20260820.md 替换过时 24h/4h / 0810 过程稿。验收脚本默认 CamOS /ws/cmd/ws 只读)。

问题描述

  1. 帧交付 / N-1:FT 下 V39 MI OFFS 常为 0;若放弃 early-done 等到下一次 XTRIG 的 MI FE,会发布落后一拍的内容。
  2. 绿带 / 灰接缝:ceiling-force 完成后底 ~8 行 UV 仍可能未写完 → classic 绿带。#1013 无条件写 0x80 消绿但引入产品底灰接缝。
  3. Y 串帧(#1017):曝光/PWM 大跳(如 gain=240、1500↔15000)时底 8 行 Y 仍可能是上一档或未写完,缝在 h-8。#1016 只修 UV。
  4. PWM 周期:长曝光扩大 PWM 后,短曝光未恢复固件基准周期,触发帧率卡在约 20 fps。
  5. 外部触发:模式 / ROI 切换中外部输入可能排队执行;free_run 期间外部 XTRIG 会打乱进 FT 相位。
  6. SError 硬复位:重度 ROI/mode thrash 时 userspace(CamOS)经 /proc/rkisp-vir0 写 WB,ISP 已 teardown 仍 MMIO → panic。
  7. 日志打满 rootfs:早期 n1trace 每帧 dev_info,长期 FT 会写爆分区。

修复方案

绿线 / 帧完成(现行口径 #1016 + #1017)

  1. MI:SHD+START 双读 OFFS;ceiling-force + force_post,禁止 bare wait_line 完成。
  2. residual / post 只作安全上限日志,超时强制 vb2_done
  3. 入 FT:warmup=2pub_gate=2skip/drop=2;dummy 关残留打开帧(enter/ROI 短脉宽,leave/stream-off 仍等满帧)。
  4. free-run:清理 early-done,不 arm;忽略外部 XTRIG。
  5. #1016 条件 UV 尾修补:仅坏行用 last-good UV 扩展;禁止整尾中性化。
  6. #1017 条件 Y 尾修补:坏带过半则整带复制上一行;UV 路径保持 #1016。副作用:坏带被上一行纹理盖住,不是真读出。
  7. 验收检测改为多信号:classic / seam / tearscripts/imx296_bottom_quality.py)。禁止再靠加长 warmup/gate 消绿。

既有(本分支前期)

  • ROI 后交付当前 FT 帧、全幅几何恢复、无效帧 drain。
  • PWM 基准周期缓存与按脉宽重算。
  • 外部触发 enable / 抑制计数门控。
  • DLCVCAM_BUILD_VERSION 日期构建号。

SError / procfs

  • rkisp_proc_write:FIL_AIQ/FIL_SW 写前检查 ISP_START + pm_runtime_get_sync;拒绝越界 / 非对齐 reg;限制写入长度。
  • mode= 仍可设置;streaming 时正常 MMIO 不受影响。
  • 与板端 CamOS streaming 门闩(仓库外)双层防护;本 PR 仅内核侧。

编包 / 交付

  • build_bootimg.sh + scripts/dlcvcam_verify_bootimg.py:整包 SHA 与 FIT 内嵌 hash。
  • 交付 boot.img / boot-rk3576-*.img + .sha256;不生成 .dlcvcam.json
  • dist/ 正式交付目录已 gitignore。
  • 当前镜像:boot-rk3576-6.1.99-2026082001-12abd272.img

文档 / 验收脚本(9047c5a

  • 现行入口:IMX296_问题全景_给后续Agent_20260820.md
  • 删除过时过程稿:24h/4h、0810 ceiling-force 排查、早期绿线修复记录。机理附录仍保留 N-1 文与 0812 gate/IRQ 文。
  • CamOS 控制面默认 ws://127.0.0.1:8000/ws/cmd/ws 只读,没有 REST set_exposure);可用 CAMOS_WS 覆盖。账号走 CAMOS_USER / CAMOS_PASS
  • 新增 scripts/imx296_148_extra.py:§4 E/F/I/J(Y 跳、idle line0、pulse 恢复、n1trace 默认关)。优先加载仓内 imx296_bottom_quality.py
  • imx296_day_watchdog.py 报告默认改到 /tmp,不再依赖已删的 24h md。

#9 / #15 的关系

仓库外(不在本 PR)

  • CamOS 冷启动 line0 首枪 +2 / 整幅绿 / irq 闸 / WB pre-gate:板端 gst_v4l2_grabber.py不是再加长内核 gate。
  • 148 产品 line0 是 echo 1 > 4-001a/trigger(不增 trigger-dev irq);预览 X-Frame-Tag 是 hold-last,不等于入模 seq。
  • CamOS WB streaming 门闩在板端 smartcam。三板 grabber 不同步,不要假设 84 已有 180/148 的修。

验证

构建

  • 定向 / 完整 ARM64 构建通过。
  • 板上当前镜像 #2026082001uname -vDLCVCAM_BUILD_VERSION 一致)。
  • 历史节点:#2026080601(绿线策略 + procfs)、#2026080701(N-1 / ceiling-force)、#2026081001(n1trace 默认关)、#2026081301(#1016 UV)。

用户场景验收(#2026081301,2026-08-13,板 180)

scripts/verify_accept_user.py + smartcam_bs

结果
classic / seam / tear 0
N-1 pass
mon→software apply avg 2.835s(2.791–2.866,目标 ≤3s,硬上限 5s)
accept_pass true

#1017 Y 尾(#2026082001,2026-08-20,板 84)

gain=240,1500↔15000,software:

结果
1500→15000 max |dY| 2.23(修前 ≈74)
反向 0.67
tear 0

未做:soak、真 GPIO line0、ROI 跳、180 回归。

procfs 门闩(#2026080601 冒烟,策略未回退)

场景 结果
streaming=1 写 mode/400/538/53c 成功,无 skip
reg 0x6000 / 非对齐 0x401 reject bad reg
streaming=0 写 MMIO skip MMIO(-ENODEV),无 panic

已知限制

  • #1205 2h endurance 曾 FAIL(未满 2h;当时 green=0 口径不可信,接缝见 #1013)。当前验收以 #1016/#1017 多信号 + apply 耗时 + N-1 tag 为准,长稳尚未用新检测重跑满窗。
  • systemd RuntimeWatchdogSec=30s 未改(收尸配置,非 SError 根因)。
  • #1017 坏带是上一行纹理覆盖,不是真读出。

主要提交(增量节选)

  • fix(imx296): deliver current fast-trigger frame after ROI
  • fix(imx296): restore PWM period after shorter exposure
  • feat(trigger): gate external input during transitions
  • fix(imx296): close FT frame and harden V39 early-done drain
  • fix(imx296/isp): 强化 V39 early-done 完成条件并关闭 FT 入模脏帧
  • fix(rkisp): procfs MMIO 门闩,避免 teardown 窗口 SError panic
  • fix(imx296/isp): 修复 FT N-1 相位并加固 V39 early-done 绿线防护
  • merge: 将 #15 boot.img 打包与 sidecar 校验并入 FT 修复分支
  • fix(imx296/isp): 默认关闭 n1trace,避免 FT 日志打满 rootfs
  • fix(imx296/isp): #1016 条件 UV 尾修补并交付 #2026081301
  • chore: 忽略 dist/ 正式交付目录
  • fix(imx296/isp): #1017 条件 Y 尾修补并交付 #2026082001
  • docs(imx296): 用问题全景替换过时过程稿,验收脚本默认 /ws/cmd

ymxc152 added 3 commits July 22, 2026 09:49
Track fast-trigger mode across CIF so RKISP can identify IMX296.

Finish V39 buffers at the last observable line.

Delay vb2_done until tail DMA has drained.

Restore full-frame ROI registers.

Drain the invalid ROI frame during the free-run restart.

Drop diagnostic and timing experiments from the production fix.

Signed-off-by: OKayJH <okayjhh@gmail.com>
Cache the firmware PWM period instead of mutable runtime state.

Recompute the period from the base period.

Include the current pulse width and safety margin.

Apply the disabled PWM state when trigger_pulse_us changes.

This restores trigger rate after long-to-short exposure without reboot.

Signed-off-by: OKayJH <okayjhh@gmail.com>
@OKayJH
OKayJH force-pushed the fix/imx296-fast-trigger-n1-pwm-period branch from 8f5e7c6 to 2c9b30b Compare July 22, 2026 04:12
@ymxc152 ymxc152 changed the title fix(imx296): correct fast-trigger frame delivery and PWM recovery fix(imx296): 修复快速触发帧交付与 PWM 周期恢复 Jul 28, 2026
ymxc152 and others added 7 commits August 4, 2026 10:02
- build_bootimg.sh:配置/编译/打包命名镜像 + 自动 bump
- scripts/dlcvcam_verify_bootimg.py:整包 SHA 与 FIT 内嵌 hash
- 手册:编包与烧录前校验;防砖改外链 u-boot / CamOS Admin
- gitignore:本地 bad_packages 与镜像 sidecar

boot-try 用户态与 recovery sync 不在本仓(见 u-boot tools/dlcvcam、Admin)。

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Monitor↔trigger green bottom lines and full green frames after ROI come
from two residual races on top of the N-1 early-done path:

1. The 50 ms tail-DMA hrtimer can fire after the next SOF and complete
   the wrong buffer. Stamp the armed SOF, drop late timers, cut the
   default drain to 2 ms, and clear wait_line/OUT_FRM_HALF when leaving
   fast-trigger so free-run restarts do not keep early-done.

2. Fast-trigger leaves the MIPI frame open until the next XTRIG. Emit a
   light-free dummy pulse before stream-off / leave-FT, drain the
   datasheet ROI invalid frame on free-run and FT stream-on, and keep
   GAINDLY in sync on hot mode_switch.

Board flashed with build 2026080501 for validation.
交付物收敛为 boot.img / boot-rk3576-*.img 与整包 .sha256。
FIT 内嵌 hash 仍由 verify 检查;JSON 清单不再生成。
IMX296 fast-trigger 下 V39 在 wait_line 处 early-done 过早,MI Y/CB
尚未 live 写满即 vb2_done,导致底行残帧/绿线。

- MI 完成改为 live ramp + full,再 post-MI hold(warmup 更保守)
- 入 FT 前若干 SOF 走真实 MI FE,并用 early_done_drop_left 持久丢头帧
- free-run 清理 early-done 状态,不 arm
- 进入 XTRIG 时 dummy 触发 ×2,关掉残留打开帧

板上 #2026080518/#2026080601 长期 ROI/mode thrash green=0。
CamOS 经 /proc/rkisp* 写 WB 寄存器(mode=0x100 / 400=0x6197)时,
若 ISP 未 START 或已 teardown,非法 MMIO 会触发 Asynchronous SError。

- FIL_AIQ/FIL_SW 写路径要求 ISP_START,并 pm_runtime_get/put
- 拒绝越界/非对齐寄存器;限制单次写入长度
- mode= 仍可设置;streaming 时正常 MMIO 不受影响

已在 180 刷入 #2026080601 冒烟:accept/reject/skip 路径正常。
对应已刷板镜像 boot-rk3576-6.1.99-2026080601(含绿线策略与 procfs 门闩)。
@ymxc152 ymxc152 changed the title fix(imx296): 修复快速触发帧交付与 PWM 周期恢复 fix(imx296): 快速触发绿线/帧交付修复与 procfs SError 门闩 Aug 6, 2026
ymxc152 added 3 commits August 7, 2026 17:43
IMX296 master_fast_trigger 下 V39 MI OFFS 常为 0,early-done 放弃到下一
次 XTRIG 的 MI FE 会导致发布内容落后一拍(N-1);free_run 期间外部 XTRIG
也会把进 FT 相位打乱。

主要变更:
- imx296: free_run 忽略 XTRIG;进 FT / STREAMON 后 short dummy×3;
  enter/ROI dummy 强制 800us 脉宽,leave/stream-off 仍等满帧关闭
- rkisp capture: SHD+START 双读 MI offs;ceiling-force + force_post 持有,
  不再 bare wait_line 完成;n1trace 诊断计数
- capture_v39: FT mi_drop/skip/pub 与 early 路径对齐
- rkisp: 放宽 residual/post/force_post,warmup=6、skip/drop=2
- 补充 N-1/绿线诊断文档与 bootimg 构建/校验脚本
对应 fix(imx296/isp) N-1/绿线合入后的 boot 镜像 #2026080701 (8950d5f)。
以 feat/dlcvcam-recovery-golden-boot 为编包/校验权威口径:
仅交付 boot.img + .sha256,去掉 .dlcvcam.json;补齐 .gitignore 与手册 §4。
冲突文件 build_bootimg.sh、scripts/dlcvcam_verify_bootimg.py 采用 #15 版本。
8950d5f 引入的 per-frame n1trace/dev_info/v4l2_info 改为 module_param
门控(imx296.n1trace / video_rkisp.n1trace,默认 0),保留诊断可热开。
同步 bump DLCVCAM 构建号至 2026081001,并清理本地 worktree 忽略项。
@ymxc152
ymxc152 force-pushed the fix/imx296-fast-trigger-n1-pwm-period branch from d47a4b9 to 01726d6 Compare August 10, 2026 06:40
ceiling-force early-done 底行 UV 不完整导致 mon→FT/ROI 绿带;#1013
整尾 0x80 虽消 classic 却引入产品灰接缝。#1016 仅在 mean/neu 判定为
坏行时用 last-good UV 扩展,neu 占比仅在 ref 有 chroma 时生效。

主要变更:
- capture_v39: rkisp_ft_sanitize_nv12_bot 条件修补(#1016)
- rkisp: warm/gate/skip 收至 2,靠 UV 修补而非加长 quarantine
- capture/h: FT sanitize 钩子
- DLCVCAM_BUILD_VERSION → 2026081301
- 多信号底带检测与验收脚本;绿线排查/验收记录

板端 smartcam_bs 用户场景验收:classic/seam/tear=0,N-1 pass,
mon→trigger apply ~2.83s(≤3s)。
本地打包的 boot 镜像与校验文件不进版本库。
@ymxc152 ymxc152 changed the title fix(imx296): 快速触发绿线/帧交付修复与 procfs SError 门闩 fix(imx296): FT 绿线/N-1/条件 UV 尾修补与 procfs 门闩(#2026081301) Aug 13, 2026
FT ceiling-force 后曝光/PWM 大跳时底 8 行 Y 仍可能是上一档曝光,
表现为底部亮度串帧(84,gain=240,1500→15000)。在
rkisp_ft_sanitize_nv12_bot 对 Y 尾做条件 last-good 扩展,坏行过半
则整带复制上一行;UV 路径保持 #1016。未加长 warmup/gate。

影响:V39 MP NV12/NV21 early-done 发布前;构建号 2026082001。
- 删除 24h/4h、0810 ceiling-force 排查、早期绿线修复记录(口径已过时)
- 加入 IMX296_问题全景_给后续Agent_20260820.md(#2026082001 / #1017)
- 验收脚本默认 CamOS 控制面 /ws/cmd;账号改走 CAMOS_USER/CAMOS_PASS
- 新增 scripts/imx296_148_extra.py(Y 跳 / idle line0 / pulse / n1trace)
- watchdog 报告默认改到 /tmp,不再依赖已删的 24h md
@ymxc152 ymxc152 changed the title fix(imx296): FT 绿线/N-1/条件 UV 尾修补与 procfs 门闩(#2026081301) fix(imx296): FT N-1/绿线/#1016 UV/#1017 Y 尾修补与 procfs 门闩(#2026082001) Aug 26, 2026
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.

3 participants