docs+repo: 正式化发布——三份 README 重写为正式版说明、DEVELOPMENT.md 取代交接文档、历史档案统一更名 worklog、全库清理交接字样;脱敏:用户本机路径/设备序列号/内网 Git 地址全部泛化,.tools 本地缓存(13MB,pyc内嵌路径)移出追踪并忽略;123 单测全绿

This commit is contained in:
ZXCLI
2026-10-08 00:37:57 +08:00
parent 0c99f6e1b5
commit ce885926fe
259 changed files with 211 additions and 55141 deletions
+3 -3
View File
@@ -43,8 +43,8 @@
- `coresdk_arm64_defined.txt`:ARM64 库符号表
## history/ — 过程记录(按时间)
`task_plan_20260714` → `findings_20260810` / `progress_20260810` / `handoff_20260810..13` /
`交接_完整逆向工程说明_20260811`(PC SDK 全流程报告)→ `reverse_20260813_full` /
`task_plan_20260714` → `findings_20260810` / `progress_20260810` / `worklog_20260810..13` /
`worklog_完整逆向工程说明_20260811`(PC SDK 全流程报告)→ `reverse_20260813_full` /
`progress_reverse`。历史参考,协议细节以 `magcx_official_flow.md` 为准。
## preview/ — 渲染验证截图
@@ -55,4 +55,4 @@ demo2_v3..v7 系列(管线复刻过程对照)、preview_*.png(安卓 UI
Kotlin 管线(android/app)与其逐字节差分验证一致。
- `android/app/src/main/java/com/mag160c/thermal/usb/IrSession.kt`:官方
UsbCommunication.java 的 Kotlin 等价实现(含小端命令、800ms 超时、0x84 标定下载)。
- `docs/android_app/HANDOFF_DEVELOPMENT.md` §4.2 指向本目录。
- `docs/android_app/DEVELOPMENT.md` §4.2 指向本目录。
+1 -1
View File
@@ -182,7 +182,7 @@ All previously "unknown" protocol facts were recovered by disassembling the x86-
analysis/revtools.py (ELF loader, ARM64 PLT resolver, C++-lite demangler,
xref scan); objdump/readelf/nm/strings from C:/mingw64/bin.
## Handoff Summary
## 阶段总结
- The key protocol facts to carry into a new conversation are:
- IR camera VID/PID: `0x833C/0x0001`.
+4 -4
View File
@@ -39,9 +39,9 @@
- Implemented Task 4 USB device model, endpoint-pair selection, and C ABI device listing/freeing.
- Task 4 verification note: cmake remains unavailable in PATH, so substituted direct MinGW g++ compile/run verification for test_c_api and test_device_model; both passed with exit code 0.
## 2026-07-14 Handoff
## 2026-07-14 阶段总结
- User asked to stop and then requested a compact context handoff for a new conversation.
- User asked to stop and then needed a compact context summary for a new conversation.
- Updated `task_plan.md`, `findings.md`, and `progress.md` with a short resume-ready summary.
- Current implementation state to remember:
- design and plan are already approved
@@ -54,7 +54,7 @@
- User explicitly resumed the task and added a Linux SDK under `IR_Camera_SDK-1.0.1/linux`.
- Restored context from `task_plan.md`, `findings.md`, and `progress.md`.
- Attempted planning-with-files session catchup via `.claude` skill path; it failed because `C:\Users\ZXC\.claude\skills\planning-with-files\scripts\session-catchup.py` does not exist in this Codex install.
- Attempted planning-with-files session catchup via `.claude` skill path; it failed because `<本地技能目录>/planning-with-files/session-catchup.py` does not exist in this Codex install.
- Verified the workspace is still not a git repository, so implementation continues in-place with markdown progress tracking.
- Began Linux SDK inventory. Found versioned Linux packages for 1.0.0, 1.0.1, 1.2.1, and 1.2.2; 1.2.2 is extracted with Qt demo sources, headers, Linux shared libraries, and firmware.
- Read Linux 1.2.2 `CHANGELOG`, `Coding Tips`, `ThermalSDK.h`, `CameraSDK.h`, `Def.h`, and Qt project file.
@@ -173,7 +173,7 @@
## 2026-08-10 Live Hardware Protocol Verification (WinUSB/libusb-win32)
User connected the actual device (Magnity Thermal Camera, VID 0x833C PID 0x0001,
serial 160043865). Full protocol verified live against the official Windows demo
serial <SN>). Full protocol verified live against the official Windows demo
(EloThermal.exe, which shows a real thermal image).
### Driver / libusb matrix (important)
+1 -1
View File
@@ -176,7 +176,7 @@ LUT 濉厖鍏紡锛氬湪姝g‘ center 涓?834/1024 绮剧‘锛屽叾
- `keyfuncs_decomp_CoreSDKLib.dll.txt`锛堟牳蹇冨嚱鏁颁吉浠g爜锛? - `callers_decomp_CoreSDKLib.dll.txt`锛堣皟鐢ㄥ叧绯?+ 涓荤绾匡級
- `exports_decomp_CoreSDKLib.dll.txt`锛堝叏閮ㄥ鍑哄嚱鏁帮級
- `exports_decomp_ThermalSDK.dll.txt`
- `all_functions_decomp_libcoresdk_arm64.so_00100000.txt`锛圓RM64 21.6MB锛?- DDT 鏂囦欢锛歚build-artifacts/mag160c_official.ddt`銆乣analysis/ida/Core160043865.ddt`
- `all_functions_decomp_libcoresdk_arm64.so_00100000.txt`锛圓RM64 21.6MB锛?- DDT 鏂囦欢锛歚build-artifacts/mag160c_official.ddt`銆乣analysis/ida/mag160c_unit.ddt`
- 瀹樻柟鎶撳抚锛歚analysis/pairs_verify_20260813/`銆乣analysis/pairs_final_20260813/`
- demo3 v5锛歚csdk/tools/mag160c_demo3.c`
- 閲囬泦宸ュ叿锛歚csdk/tools/tsdk_pair3.c`锛堝惈 DDT 澶嶅埗銆佽〃/鐩插厓/蹇棬/绐楀彛鎶撳彇锛?
+2 -2
View File
@@ -12,7 +12,7 @@
- [x] 工具链:Ghidra 12.1.2(headless)+ IDA Free 8.4 部署,5 个二进制全量导出
- [x] 官方管线完整反编译(DDT 加载 / 端点选择 / Q12 插值 / ref=4×type1 帧均值 /
NUC / 盲元 / 窗口 / LUT1024 / 2x 升采样 / FFC 状态机)
- [x] DDT 文件解析(%TEMP%\Core160043865 → build-artifacts/mag160c_official.ddt)
- [x] DDT 文件解析(%TEMP%\Core<SN> → build-artifacts/mag160c_official.ddt)
- [x] 逐像素验证:NUC+盲元 0/19200、插值 0 误差、2x 0/76800、窗口一致
- [x] 鬼影根因文档:analysis/reverse_20260813_full.md §7
- [x] demo3 v5 官方复刻实现并实机运行
@@ -73,7 +73,7 @@ Stop-Process -Name mag160c_demo3 -Force -ErrorAction SilentlyContinue
# analysis/reverse_tools/verify_full.py 全链路验证
# analysis/reverse_tools/parse_ddt.py DDT 文件解析
# analysis/reverse_tools/parse_pcap.py pcap 抓包解析
# C:\Users\ZXC\AppData\Local\Temp\opencode\verify_c_pipeline.exe C实现离线复算
# %TEMP%\opencode\verify_c_pipeline.exe C实现离线复算
```
## 心跳约定
+2 -2
View File
@@ -31,14 +31,14 @@ Create an original, Linux-usable source implementation for the USB thermal camer
| 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. |
| Old using-superpowers path missing | Tried .system path | Read correct skill path under <本地技能目录>/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.
@@ -1,4 +1,4 @@
# MAG160C 项目交接文档 (2026-08-10)
# MAG160C 项目工作记录文档 (2026-08-10)
> **2026-08-10 晚更新(本会话)**:FFC 停帧问题已解决并多次实机验证;
> 坏点/对比度/标定管线已按开源方案重做并合入 csdk。详见第 10 节。
@@ -15,7 +15,7 @@ Linux/Windows C SDK + Windows GUI Demo。已完成的逆向依据:
## 2. 硬件事实(实机确认)
- 设备名:Magnity Thermal Camera,VID 0x833C PID 0x0001,序列号 160043865
- 设备名:Magnity Thermal Camera,VID 0x833C PID 0x0001,序列号 <SN>
- 分辨率 160x120,帧率 ~15fps,每帧 38456 字节
- USB:config 值 1(仅一个配置),interface 0,端点:0x03 OUT、0x81/0x82/0x84 IN
- 设备只有 config 1——Linux SDK 逆向中的 set_configuration(2) 在这台机器上失败,
@@ -1,4 +1,4 @@
# MAG160C 逆向交接文档 v2(2026-08-11)
# MAG160C 逆向工作记录文档 v2(2026-08-11)
> **本文件是当前最新、最完整的上下文快照。** 覆盖硬件/协议/官方SDK逆向/
> 显示管线演进/全部失败教训。下一轮请从第 1 节开始读,严格按第 7 节
@@ -14,7 +14,7 @@
## 2. 硬件与协议(已验证,权威)
### 2.1 USB 拓扑
- VID 0x833C PID 0x0001,序列号 160043865,config 1,interface 0
- VID 0x833C PID 0x0001,序列号 <SN>,config 1,interface 0
- 端点:0x03 OUT(命令)、0x82 IN(命令响应)、0x81 IN(帧流)、0x84 IN(大读取,未用)
- 驱动:libusb-win32 v1.2.6.0;传输库:TI libusb-1.0.dll + dlltool 导入库
@@ -86,7 +86,7 @@ Start(); // 内部:NewChannel(0) -> EnumCameras -> LinkCamera(chan,pid) -> Star
| 官方灰度图 | `build-artifacts/official_gray.bin` | 160x120,93% 像素=0,顶部14行坏点带 |
| 官方调色板(错误读取) | `build-artifacts/official_palette_live.bin` | Jet 色系 BGR,疑似偏移错误,勿用 |
| 官方调色板(帧反推 115色) | `analysis/temp/official_palette_full.npy` | 品红系,可信 |
| 官方探针温度 | 记录在 handoff | 背景 26.7~27.4°C |
| 官方探针温度 | 记录在工作记录 | 背景 26.7~27.4°C |
| 官方 T2E 表(已转C头) | `csdk/src/mag160c_official_t2e.h` | 646 项 |
| 官方调色板(已转C头,插值) | `csdk/src/mag160c_official_palette.h` | 256 项,品红系(可能需修正) |
@@ -1,4 +1,4 @@
# MAG160C 热像仪渲染项目交接 - 2026-08-11
# MAG160C 热像仪渲染项目工作记录 - 2026-08-11
项目目录: `C:\Project\MAG160C`
@@ -344,7 +344,7 @@ FFC:
- 主程序: [mag160c_demo3.c](/abs/path/C:/Project/MAG160C/csdk/tools/mag160c_demo3.c)
- 官方抓帧工具: [tsdk_pair2.c](/abs/path/C:/Project/MAG160C/csdk/tools/tsdk_pair2.c)
- 当前交接: [handoff_20260811_full.md](/abs/path/C:/Project/MAG160C/analysis/handoff_20260811_full.md)
- 当前记录: [worklog_20260811_full.md](/abs/path/C:/Project/MAG160C/analysis/worklog_20260811_full.md)
- 历史进展: [progress_reverse.md](/abs/path/C:/Project/MAG160C/analysis/progress_reverse.md)
- 官方抓帧预览表: [summary.tsv](/abs/path/C:/Project/MAG160C/analysis/pairs_move/preview/summary.tsv)
@@ -1,6 +1,6 @@
# MAG160C 逆向交接文档 v3(2026-08-12)
# MAG160C 逆向工作记录文档 v3(2026-08-12)
> **本文件是最新、最完整上下文快照。** 上一版:handoff_20260811.md。
> **本文件是最新、最完整上下文快照。** 上一版:worklog_20260811.md。
> 本轮(2026-08-11 晚)完成**官方"读取→显示"完整管线逆向,全部实机
> 像素级验证(100.0% 精确),并交付 demo3(官方管线版)**。
@@ -1,6 +1,6 @@
# MAG160C 逆向交接文档 v4(2026-08-12 深夜)
# MAG160C 逆向工作记录文档 v4(2026-08-12 深夜)
> **最新快照。** 前版:handoff_20260812.md(白天)。
> **最新快照。** 前版:worklog_20260812.md(白天)。
> 本轮完成:官方 NUC/参考帧机制完整逆向 + demo3 修复(颗粒感/FFC 变色)。
## 1. 本轮成果
@@ -1,4 +1,4 @@
# MAG160C 热像仪渲染管线交接文档 v5
# MAG160C 热像仪渲染管线工作记录文档 v5
> 项目:MAG160C 热像仪(160x120, USB, VID 0x833C)自实现渲染管线 demo3
> 目标:复刻官方 CoreSDKLib.dll 渲染效果
@@ -1,4 +1,4 @@
# MAG160C 热像仪逆向工程完整交接说明
# MAG160C 热像仪逆向工程完整工作说明
## 1. 文档目的
@@ -14,7 +14,7 @@
- 如何继续逆向低温残影,并避免重复走已经验证失败的路线。
- 让下一位 AI 从零开始接手时可以直接使用的中文提示词。
文档日期:2026-08-11。工作目录:`C:\Project\MAG160C`。远端仓库:`https://git.zxcli.top/zxc/MAG160C.git`。
文档日期:2026-08-11。工作目录:`C:\Project\MAG160C`。远端仓库:`<内部 Git 服务器>/MAG160C.git`。
## 2. 一分钟结论
@@ -87,10 +87,10 @@ USB type=0 原始帧
| 路径 | 用途 |
|---|---|
| `README.md` | 仓库入口和最短说明。 |
| `交接_完整逆向工程说明_20260811.md` | 本完整交接文档。 |
| `worklog_完整逆向工程说明_20260811.md` | 本完整工作记录文档。 |
| `findings.md` | 早期和中期的综合逆向发现,包含 Windows、Android、Linux SDK 证据。 |
| `progress.md` | 按日期记录的长期工程进度、协议恢复和工具安装记录。 |
| `task_plan.md` | 早期 Linux SDK 实现计划和历史任务状态。后续热像渲染工作应以本交接文档和 `analysis/handoff_*.md` 为准。 |
| `task_plan.md` | 早期 Linux SDK 实现计划和历史任务状态。后续热像渲染工作应以本工作记录文档和 `analysis/worklog_*.md` 为准。 |
| `frame_stats.txt` | 历史原始帧统计。 |
| `pair_*.win`、`pair_*.win2`、`pair_*.nuctab` | 根目录中遗留的官方抓帧窗口、字段和短 NUC 表样本。完整抓帧在 `analysis/pairs_*`。 |
| `.gitattributes` | Git LFS 大文件规则。 |
@@ -131,12 +131,12 @@ USB type=0 原始帧
| `analysis/disasm/` | Windows CoreSDK、Linux libmagcore、Android ARM64 的反汇编、符号和函数切片。 |
| `analysis/protocol_spec.md` | USB 协议、帧格式、命令、温度和 NUC 公式的正式规格。 |
| `analysis/progress_reverse.md` | 官方渲染主链和反汇编阶段性结论。 |
| `analysis/handoff_20260810.md` | demo2 早期路线、MOG、平场和问题演化。 |
| `analysis/handoff_20260811.md` | 较短的 2026-08-11 交接。 |
| `analysis/handoff_20260811_full.md` | 当前残影问题最重要的交接文档之一。 |
| `analysis/handoff_20260812.md` | 官方活体抓帧、NUC 和显示数据分析。 |
| `analysis/handoff_20260812_night.md` | 平滑器、参考和 NUC 查表的夜间逆向结论。 |
| `analysis/handoff_20260813.md` | 黑洞、SBNUC、Hardie/Kalman 路线的历史总结。 |
| `analysis/worklog_20260810.md` | demo2 早期路线、MOG、平场和问题演化。 |
| `analysis/worklog_20260811.md` | 较短的 2026-08-11 记录。 |
| `analysis/worklog_20260811_full.md` | 当前残影问题最重要的工作记录文档之一。 |
| `analysis/worklog_20260812.md` | 官方活体抓帧、NUC 和显示数据分析。 |
| `analysis/worklog_20260812_night.md` | 平滑器、参考和 NUC 查表的夜间逆向结论。 |
| `analysis/worklog_20260813.md` | 黑洞、SBNUC、Hardie/Kalman 路线的历史总结。 |
| `analysis/pairs_nuc2/` | 官方 NUC 同帧数据。 |
| `analysis/pairs_move/` | 官方移动目标数据。注意旧 `.gain/.thr` 曾被覆盖。 |
| `analysis/pairs_recheck_20260811/` | 使用修复后的 `tsdk_pair2_fixed.exe` 重新捕获的数据,包含未覆盖的真实 `.gain/.thr`。 |
@@ -756,7 +756,7 @@ build-artifacts\csdk_cli_libusb.exe ir-info
本工程原先只有空的 `.git` 目录,不是有效 Git 仓库。本次移交应初始化真实 Git 仓库并推送到:
```text
https://git.zxcli.top/zxc/MAG160C.git
<内部 Git 服务器>/MAG160C.git
```
仓库约 0.824 GB,包含大量 DLL、EXE、APK、PDF、PNG、BMP、抓帧和反汇编二进制。已准备 Git LFS 规则。提交前必须检查:
@@ -770,7 +770,7 @@ https://git.zxcli.top/zxc/MAG160C.git
### 第一步:确认环境和版本
1. 阅读本文、`analysis/handoff_20260813.md`、`analysis/handoff_20260811_full.md`。
1. 阅读本文、`analysis/worklog_20260813.md`、`analysis/worklog_20260811_full.md`。
2. 检查 `git status` 和远端分支,确认没有并行改动。
3. 检查设备 PID、驱动、DLL、表文件。
4. 编译并启动当前 demo3,保存一轮不移动时的日志。
@@ -804,14 +804,14 @@ https://git.zxcli.top/zxc/MAG160C.git
主程序:C:\Project\MAG160C\csdk\tools\mag160c_demo3.c
输出程序:C:\Project\MAG160C\build-artifacts\mag160c_demo3.exe
官方 DLL:IR_Camera_SDK-1.0.1\windows\windows\app\CoreSDKLib.dll 和 ThermalSDK.dll
远端仓库:https://git.zxcli.top/zxc/MAG160C.git
远端仓库:<内部 Git 服务器>/MAG160C.git
严格执行以下步骤:
1. 先读:
- 交接_完整逆向工程说明_20260811.md
- analysis/handoff_20260813.md
- analysis/handoff_20260811_full.md
- worklog_完整逆向工程说明_20260811.md
- analysis/worklog_20260813.md
- analysis/worklog_20260811_full.md
- analysis/protocol_spec.md
- csdk/tools/mag160c_demo3.c
- csdk/tools/tsdk_pair2.c
@@ -878,7 +878,7 @@ https://git.zxcli.top/zxc/MAG160C.git
然后再开始修改或抓帧。
```
## 16. 交接结束条件
## 16. 收尾条件
下一位接手者在以下条件都满足前,不应把项目标记为完成:
+1 -1
View File
@@ -286,7 +286,7 @@ buffers this+0x10 (u16 acc), this+0x18.
## 2026-08-10 Live Hardware Verification (supplement to sections 3-4)
Measured on a real unit (VID 0x833C PID 0x0001, serial 160043865) by
Measured on a real unit (VID 0x833C PID 0x0001, serial <SN>) by
intercepting the official Windows demo (libusb0.dll API shim) and by direct
libusb-1.0 probing. These override the earlier Linux-SDK-derived assumptions:
+1 -1
View File
@@ -1,6 +1,6 @@
import struct, sys, os
path = r"C:\Project\MAG160C\analysis\ida\Core160043865.ddt"
path = r"C:\Project\MAG160C\analysis\ida\mag160c_unit.ddt"
b = open(path, "rb").read()
print(f"size: {len(b)}")
+1 -1
View File
@@ -21,7 +21,7 @@ gain = load16(r"C:\Project\MAG160C\build-artifacts\mag160c_official_nuc_gain.bin
thr = loadi16(r"C:\Project\MAG160C\build-artifacts\mag160c_official_nuc_thr.bin", npix*(nsegs-1))
# blind records from DDT (all endpoints identical; use EP2)
ddt = open(r"C:\Project\MAG160C\analysis\ida\Core160043865.ddt", "rb").read()
ddt = open(r"C:\Project\MAG160C\analysis\ida\mag160c_unit.ddt", "rb").read()
thr_ep0 = 0x80
block = (nsegs-1)*npix*2 + 1024 + nsegs*npix*4
blind_off = thr_ep0 + 6*block
@@ -98,17 +98,17 @@ java analysis/tools/PalScan.java \
csdk/src/mag160c_official_palette256.h
# 生成物可复现:重新生成后与仓库文件 diff 应为空
mkdir -p /c/Users/zxc/AppData/Local/Temp/regen_build && \
cd /c/Users/zxc/AppData/Local/Temp/regen_build && \
mkdir -p %TEMP%/regen_build && \
cd %TEMP%/regen_build && \
cp "C:\Project\MAG160C\analysis\tools\PalIdentify.java" . && \
cp "C:\Project\MAG160C\analysis\tools\PalExport2.java" . && \
"C:\Tools\jdk-21\bin\javac" -d out PalIdentify.java PalExport2.java && \
"C:\Tools\jdk-21\bin\java" -cp out PalExport2 \
"C:\Project\MAG160C\android\app\src\main\kotlin\com\mag160c\thermal\core\OfficialTables.kt" \
"C:\Users\zxc\AppData\Local\Temp\cxres\res\mipmap-hdpi-v4" \
"C:\Users\zxc\AppData\Local\Temp\regen_core" \
"C:\Users\zxc\AppData\Local\Temp\regen_out"
diff "C:\Users\zxc\AppData\Local\Temp\regen_core\VendorPalettes.kt" \
"%TEMP%\cxres\res\mipmap-hdpi-v4" \
"%TEMP%\regen_core" \
"%TEMP%\regen_out"
diff "%TEMP%\regen_core\VendorPalettes.kt" \
"C:\Project\MAG160C\android\app\src\main\kotlin\com\mag160c\thermal\core\VendorPalettes.kt"
# 实测:diff 为空;铁虹锚点 256/256
```