Files
MAG160C/analysis/history/task_plan_20260714.md
T
ZXCLI 0bfb926892 完成官方管线全量逆向与 demo3 v5 复刻,清理仓库
- 逆向:Ghidra/IDA 全量反编译 CoreSDKLib.dll/ThermalSDK.dll/libthermalSDK.so/
  libcoresdk.so(ARM64)/libmagcore.so,导出 analysis/ida/export/
- 解码官方渲染管线:DDT 校准表加载->快门端点选择->Q12 插值->ref(4x type1 帧
  均值)->NUC 查表->盲元补偿->窗口->LUT1024 重建->2x 升采样->调色板
- 逐像素验证:NUC+盲元 0/19200、插值 0 误差、2x 0/76800、窗口一致
- demo3 v5:完整复刻官方管线(含 DDT 解析、FFC 状态机、快门温度驱动),
  修复 load_ddt 表错位导致的零像素问题
- 鬼影根因分析写入 analysis/reverse_20260813_full.md
- 心跳/恢复机制:analysis/session_state.md + tools/resume_rev.ps1
- 新增 tsdk_pair3 增强采集工具;历史工具归档 csdk/tools/legacy/;
  根目录抓帧残留删除,历史文档归档 analysis/history/
- csdk/README.md 完整使用文档;.gitignore/.gitattributes 补 LFS 规则
2026-08-13 23:16:12 +08:00

59 lines
4.0 KiB
Markdown

# MAG160C Linux SDK Reverse Engineering Plan
## Goal
Create an original, Linux-usable source implementation for the USB thermal camera in this workspace, using the bundled Windows/Android apps and SDK as interoperability references.
## Constraints
- Prefer clean-room-style interoperability notes: derive public behavior, protocol, data formats, and API shapes; do not copy proprietary binary code.
- Do not install tools unless they are needed. If tools are installed, record what was installed and where.
- Current workspace is not a git repository, so progress is tracked in these markdown files instead of commits.
- Ask for approval before writing implementation code because the brainstorming skill requires an approved design first.
## Phases
1. [complete] Set up persistent planning files.
2. [complete] Inventory SDK documents, headers, examples, APK/AAR/native libraries, and USB identifiers.
3. [complete] Extract public API and data-flow evidence from Windows C# and Android Java/JNI/libuvc code.
4. [complete] Inspect binaries only as needed for symbols/strings/imports, using installed or portable open-source tools where available.
5. [complete] Present Linux implementation design with 2-3 approaches and get user approval.
6. [pending] Implement Linux source after approval, preferably as a small libusb/libuvc-based C/C++ project plus CLI sample.
7. [pending] Verify build/tests as far as possible without physical hardware, and document hardware test steps.
## Open Questions
- Whether the physical camera is currently attached to this Windows machine/WSL environment for live USB descriptor capture.
- Whether the desired Linux API should be C, C++, Python bindings, or a CLI-first tool. Answered: C++ core library with stable C ABI, CLI sample, and Python-callable wrapper/tooling.
## Errors Encountered
| Error | Attempt | Resolution |
|---|---|---|
| Not a git repository | Ran git status | Track with markdown files instead of commits. |
| Old using-superpowers path missing | Tried .system path | Read correct skill path under C:/Users/ZXC/.codex/skills/using-superpowers. |
| Get-PnpDevice access denied | Tried to enumerate attached USB devices from PowerShell | Need elevated device enumeration or user-provided lsusb/USB descriptor if live hardware testing is required. |
| ARM64 disassembly unsupported by MinGW objdump | Tried objdump on Android libcoresdk.so | Need LLVM objdump/capstone/ghidra/r2 or USB trace to recover low-level vendor protocol. |
| pip install capstone/pyelftools failed | Tried sandbox and escalated pip install into .tools/python-revlibs | Network/proxy unavailable; no new reverse-engineering package installed. |
| planning catchup script missing | Tried planning-with-files `.claude` catchup path from Codex session | Logged error; continued because task planning files were read directly. |
| PowerShell heredoc/Python quoting failed | Tried Bash heredoc and then malformed `python -c` for PDF extraction | Switched to PowerShell here-string piped into `python -`; PDF extraction succeeded. |
## Handoff Summary
- Reverse-engineering evidence is complete enough for a Linux-first source implementation skeleton.
- User chose approach 1: C++ core library + stable C ABI + CLI sample + Python-callable wrapper.
- Implemented so far:
- public C ABI scaffolding
- TCM frame encode/decode
- TCM command builders
- USB device model and endpoint discovery
- IR API skeleton with explicit protocol-unknown errors and Linux endpoint/marker evidence in diagnostics
- CLI diagnostics and dry-run commands
- Verification status:
- CMake is not available in PATH in this environment.
- Direct MinGW g++ compile/run checks were used instead and passed for the completed tasks.
- Current stop point:
- Task 6 was implemented and locally verified in no-libusb mode after the user resumed work.
- Next implementation task is Task 7: Python ctypes wrapper.
- If a new chat resumes work, start from the existing implementation plan and continue with the remaining Linux runtime pieces, keeping the same file-based notes.