diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index cde71185..ed3c4f2a 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -32,6 +32,12 @@ jobs: run: python -m unittest discover -s installer/tests -v - name: Build portable release run: python installer/build.py + - name: Browser test dependencies + run: | + python -m pip install playwright + python -m playwright install chromium + - name: Production UI regression (simulated transport only) + run: python -X utf8 installer/tests/run_ui.py - uses: actions/upload-artifact@v4 with: name: openwrt-installer-windows diff --git a/README.md b/README.md index 15d68963..a8c4525e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ Windows desktop installer: extract the complete release package and run root `OpenWrt-Installer.exe`. Device selection, persistent recovery and the two-stage Android reset flow share the existing backend. Python/CLI and Magisk entries remain available. See the bilingual [user guide](installer/GUIDE.md), [build instructions](installer/README.md), and [verification/screenshots](installer/VERIFICATION.md). Multiple ADB devices can be selected in the GUI or interactive CLI, or explicitly bound with `--serial SERIAL`. +U30 Air mainline updates now include both charger variants, corrected fuel-gauge persistence, +Type-C current detection, OTG boost control and native dual-SIM boot/live switching. +See the [U30 Air port and verification record](docs/U30AIR-UPSTREAM-20261015.zh-CN.md). + V50/MU3351 desktop-installer support and the new LED driver are documented in [the V50 adaptation record](docs/V50-MU3351-20261014.zh-CN.md), including what has been checked on hardware and what remains unverified. diff --git a/docs/U30AIR-UPSTREAM-20261015.zh-CN.md b/docs/U30AIR-UPSTREAM-20261015.zh-CN.md new file mode 100644 index 00000000..2d5fe6d8 --- /dev/null +++ b/docs/U30AIR-UPSTREAM-20261015.zh-CN.md @@ -0,0 +1,91 @@ +# U30 Air 上游适配记录(2026-10-15) + +本次仅修改 MU300 仓库 `feat/u30air-upstream-support`,不修改 E5 仓库。 +对照上游 `main` 的 `e9b4009`,选择性导入 U30 Air 支持,并接入本分支已有的公共看板和双卡接口。 +这不是新支持 U30 Pro;U30 Pro 的不同 SoC 不在本次范围内。 + +## 内核硬件支持 + +适用主线内核 6.18.54 和 7.2.8,保留 5.4 原状。 + +- 导入补丁 0009–0013、0015、0016:SGM41511/BQ25601(0x6b)和 SGM41513(0x1a)充电管理;包含不同芯片的电流编码、终止电流、供电状态、充电完成状态。 +- UMP9620 的 BC1.2 检测地址修正为 0x239c,保留 Type-C Rp 输入电流识别;不把电脑 USB 当作大电流充电器。 +- 电量计恢复原厂保存电量与完成状态的处理,修正跨重启容量保持。 +- 网页百分比与短信电量通知共用电源节点探测:兼容原厂 battery、主线 sc27xx-fgu、实际 Battery 类型节点及 bq256xx-charger 外部供电状态;过滤 F50/V50 的虚假电量和 0–100 以外的值。 +- 引入 UMS9620 pinctrl 和 I2C6 管脚修正,让充电芯片总线可以实际工作。 +- 同时导入最新防误识别补丁:只有具有 `/charger_policy_service` 的电池机型才能尝试备用 0x1a 地址。F50/V50 上的同地址应答不当作充电芯片。 +- LED、蓝牙、Wi-Fi、安装识别此前已支持 U30 Air,继续使用本分支原有公共实现。 + +对应上游来源: + +- [U30 Air 充电/Type-C](https://github.com/dikeckaan/mu300-linux/commit/d8387d9) +- [pinctrl / I2C6](https://github.com/dikeckaan/mu300-linux/commit/21e2d23) +- [0x1a 芯片变体](https://github.com/dikeckaan/mu300-linux/commit/1947354) +- [仅在电池机型探测备用充电器](https://github.com/dikeckaan/mu300-linux/commit/9741a46) + +## USB / OTG + +`mu300-usb` 保留原有角色接口,增加两种充电器地址识别、已绑定驱动下的访问兼容。 +电池升压与外部供电互斥:外部供电的 Hub 使用其自身 VBUS,不同时打开升压。 +切回电脑角色前关闭升压;内核充电驱动存在时,不重新开启芯片看门狗,避免其超时把充电设置恢复成默认值。 +角色切换失败时会关闭刚开启的升压。F50/V50 不执行这些充电寄存器操作。 + +## U30 Air 原生双卡 + +原生冷启动和热切换脚本来自上游 [0d520f4](https://github.com/dikeckaan/mu300-linux/commit/0d520f4),按本仓库的接口适配。 + +- U30 Air 同一时间只启用一张卡的射频;不能照搬 V50 同时启动两个射频的流程。 +- NR1/NR2 与 NR4/NR5 各自持有命令通道,NR0/NR3 各自只有一个 URC 读取者。等待 SIPC SBUF 就绪后才打开设备。 +- U30 所有通道禁用失败重开和 procd 重启,缺少持久 AT owner 时不直接打开 tty。 +- 冷启动保留基带当前网络模式;先 RIL 握手,再检查冷态、SIM 上电与身份、设置数据通路,最后启用射频。 +- 持久化的频段/小区设置在射频启用前回放,不额外打乱原有回放顺序。 +- 热切换先检查目标 SIM,然后停止旧 WAN,确认拆除完成后关闭旧卡射频和 SIM 电源,再启用目标卡、切换数据通路、打开新卡射频。 +- 切换中的 AT、射频、网络锁定操作互斥。命令不返回或控制进程异常时,不循环盲目重置射频;保留上游受控回退/重启机制。 +- 目标卡有实际数据连接后才自动保存开机默认卡。目标卡无数据而旧卡原来有数据,则恢复旧卡;两张卡都无数据时保留用户当前选卡,但不覆盖开机默认。 +- 用户主动关闭 WAN 时,切卡后保持关闭;显式选择会保存到开机默认卡。 +- 首次选择 SIM2 后支持限时首数据检查;已经成功使用过的卡不会因普通网络波动被切走。 +- 普通 SIM1 启动会按需要恢复此前可能留在 SIM2 上的数据路由。 + +配置存储沿用 `unisoc_modem.main.data_sim`,不建立第二份相互冲突的开机选卡配置。 +当前实际卡槽单独存在 `/run/mu300/sim-slot`,因此启动回退和未保存的实时切换不会错误拨打默认卡。 +两卡 APN、短信、网络锁定、终端及流量统计复用现有按槽位隔离的公共实现。 + +## 核对后的公共修复 + +下列处理适用于 MU300 仓库所有机型,未放进 U30 Air 判断里: + +- 射频初始化与拨号互斥改用原子 PID 符号链接,消除“目录已创建、PID 尚未写入”窗口,避免并发调用误删新锁。 +- 回收僵尸锁也有单独原子互斥,多个等待者不会把前一个刚取得的新锁删掉;同时检查 PID 对应进程,防止 PID 复用误判。 +- 正常射频等待仍为原来的 8 秒、拨号等待仍为 150 秒,只改变加锁方式,不改变 AT/回放顺序。 +- 公共 AT 适配器支持事务进行中及射频状态未知时拒绝外来命令,并在实际发送前再次检查,防止排队请求穿过切卡窗口。标记由对应控制器创建,不会使普通启动多等时间。 +- 电量计的供电来源和保存容量处理在公共驱动中按 PMIC/硬件能力生效;未按产品名称硬编码。 +- 任务超时、界面状态刷新和打包脚本缺失检查均复用公共代码;仅原生切卡的耗时预算单独扩展。 + +充电芯片地址探测、OTG 升压、单活动射频切换、禁止 SIPC 重开等基于板级验证的行为仍保留机型边界,避免改变 F50/V50 的硬件控制方式。 + +## 网页入口与默认行为 + +蜂窝 → SIM 卡管理增加 U30 Air 原生双卡设置,仅 U30 Air 显示: + +1. 保持默认普通 SIM1 启动,热切换默认关闭。 +2. 可选择卡槽并点击“仅保存为下次开机默认卡”,不立即切卡、不自动重启。 +3. 启用双卡热切换后,如当前启动没有完成双卡准备,手动重启一次。 +4. 准备完成后,使用原有“切换上网卡”按钮即可在线切换。 + +新增文案包含中文、英文和土耳其文。状态接口不在轮询时发送 AT,也不写闪存。 +已有 U30 Air 配置会一次性升级为双卡能力,保留当前选卡、APN、短信和流量历史;F50/V50 保留现有双卡协议;射频与拨号锁使用上文的公共修复。 + +## 验证与限制 + +- 6.18.54、7.2.8 内核 Image 均构建成功,三个新增配置实际生效。 +- 7.2.8 的 201 个、6.18.54 的 194 个配套内核模块已重新构建;BTF 检查、模块/Image 指纹和容器内核能力校验通过。 +- 测试覆盖原生冷启动、热切换、缺卡/PIN、忙锁、通道丢失、失败回退、主动关闭 WAN、等待拆除、当前卡/默认卡分离,以及原有 F50/V50/USB 逻辑。 +- 电量读取、看板与短信转发相关 24 项测试运行完成,22 项通过,2 项需真实 OpenWrt 测试环境而跳过;覆盖主线/原厂节点、外部充电在线状态、0% 电量、无电池机型和非法百分比。 +- 原生冷启动/热切换与接口集成共 75 项测试通过;公共锁/数据优先级 10 项(包含八路并发旧锁回收)、移动恢复/早期回放 18 项,以及锁定/APN/翻译/构建检查相关测试通过。 +- 扩大运行时,已有 LED 报警动画测试出现一次采样时序失败,独立重跑通过;本次未修改其灯控实现,不把这次整套扩大运行写成全部通过。 +- rootfs 构建安装并检查原生切卡所需的 flock,显式设置新脚本执行权限;TF 与正式发布脚本校验这些脚本和配置库是否确实进入包。 +- **当前没有连接 U30 Air,因此本次是代码移植、内核编译和模拟回归验证;未声称已完成该机实测,也未刷写其他机器。** +- 仍需 U30 Air 实机验证:两种充电芯片对应样机的充电与 OTG、跨重启电量、双卡冷启动/双向切换、缺卡回退。 + +编译输出位于 Docker 卷 `mu300-mainline-clean-tf-7-2` 的 `/src/u30air-validation-7.2`、`/src/u30air-validation-6.18`。 +Image 与模块必须配套使用,不能只替换 Image 而留下旧 BTF 模块。 diff --git a/installer/GUIDE.md b/installer/GUIDE.md index 3989ff35..b4bbee27 100644 --- a/installer/GUIDE.md +++ b/installer/GUIDE.md @@ -20,6 +20,8 @@ ### 独立内置分区 +检查设备不会替换你已选择的安装方式;“推荐”只作提示。重装已有内置分区不要求插 TF 卡,也不会校验 TF 卡容量。只有选择 TF 卡安装时才要求卡及其目标分区有效。最终计划会明确列出安装方式、写入目标和数据影响;返回修改时会保留所选方式及原页面。 + 优先使用已验证 GPT 未分配区域,足够时不缩容或清空 userdata。没有合适区域时使用既有离线缩容逻辑。计划显示 Android 保留空间、OpenWrt 分配大小及数据影响。 “使用全部已分配的 OpenWrt 分区容量”默认开启,意思是扩满选定大小的 OpenWrt 分区,**不是占用设备所有剩余空间**。设备端写入后检查文件系统块数,进入 OpenWrt 后再次读取 ext4 超级块验证实际容量。验证没通过不会显示安装成功。 @@ -38,9 +40,15 @@ 这些等待**没有总超时**。预期重启或 USB 消失属于等待状态,不是 EOF 失败。无 ADB 时电脑无法区分“Android 仍在开机”和“尚未开启调试”;界面同时给出初始化、开启调试与允许授权的具体步骤。未加密 userdata 保留离线保数据缩容,不默认清空。 +### 更新与自动重启 + +更新提交后,设备会自动重启以应用更新,网络会暂时断开。页面与通知会显示“更新已提交,设备将自动重启”;请保持供电。安装器确认同一设备的启动标识确实变化,再校验实际容量,最后显示“OpenWrt 已更新并通过校验”。重启前旧系统仍能响应 SSH 时不会提前显示完成。点击“我已进入 OpenWrt”也仍会核验真实重启;地址或密码变化时可在此处修正。完成、失败和暂停后阶段计时停止;这些时间保存在记录中,重新打开后仍可查看,重试开始新的执行计时。旧更新记录若未保存重启前证据,不能自动认定更新完成,应保留记录人工复核。 + +重启期间的 SSH 断开、连接被拒绝、连接超时或 USB 网卡暂时消失,均属于正常的“设备正在重启,等待重新连接”,不会显示连接错误或要求重新更新,也没有固定等待总时限。详细原因仅记入 DEBUG 日志;认证失败或地址确实对应另一台设备时,才提示修正密码/目标。管理地址与密码输入框始终保留,设备开机后可手动确认并重试校验。 + ### 暂停、关闭与失败恢复 -事务默认位于 `%LOCALAPPDATA%\OpenWrt-Installer\transactions\\`。通过“打开事务目录”查看,通过“导出事务与备份”生成 ZIP。备份含设备身份和可能含无线配置的旧后端记录,请妥善保管,不要公开上传。默认日志不包含原终端输出、密码、短信正文或完整设备标识。 +事务默认位于 `%LOCALAPPDATA%\OpenWrt-Installer\transactions\\`。通过“打开事务目录”查看,通过“导出事务与备份”生成 ZIP。备份含设备身份和可能含无线配置的旧后端记录,请妥善保管,不要公开上传。DEBUG 日志记录命令边界、脱敏后的 CLI 输出、校验结果及具体异常堆栈;密码、无线密钥与完整设备标识在写入日志前脱敏,不读取短信正文。 “在安全边界暂停”会等待正在进行的存储操作结束,不会直接杀进程。任务执行中关闭窗口会被阻止并提示先暂停。暂停后可以关闭、重启电脑或移动包;重新打开 EXE,选择“继续未完成的安装”。若已提交离线准备,暂停不会撤销设备已收到的启动请求,仍须保持设备供电。完成页保持显示,不会自动关闭。 @@ -52,6 +60,16 @@ 窗口顶部、步骤导航和底部操作按钮保持固定;安装内容、续装列表和展开的日志各自滚动。侧栏底部可打开事务目录。操作结果、错误与阶段变化统一通过右上角通知提示;错误通知可以手动关闭,详细信息仍可在日志或对应事务页面查阅。通知不会覆盖底部最终确认按钮。数据影响、等待操作指引和完成结果会持续显示在页面中。界面动效会遵循 Windows 的“动画效果/减少动态效果”设置。 +开始或继续安装后,底部“详细日志 · DEBUG”自动展开,可随时收起;日志列表限制高度,不会推走操作按钮。出错时可一键“复制诊断信息给开发者”,也可复制或导出日志。分享内容来自电脑上持久保存的日志,不局限于界面最近显示的 500 条;完整轮转日志随事务备份导出。旧版记录没有保存的调试细节无法凭空恢复,使用新版重试后会开始记录。备份及传输显示真实字节数、速度和进度条;写入、检查、缩容或扩容缺少可信百分比时,显示活动进度条、阶段及耗时,不生成虚假百分比。等待用户操作时,进度条停止活动并显示下一步指引。 + +启动链备份逐项 `dd` 到设备 `/data/local/tmp/` 下的独立临时目录,再通过 `adb pull` 拉到电脑;源分区、临时文件、电脑文件的 SHA-256 必须一致。每项完成后删除设备临时文件,全部完成后删除临时目录。不使用 Base64 或压缩流备份;临时空间不足时会明确停止。备份只读取启动相关源分区,不向源分区写入。 + +文件传输的 100% 仅代表当前文件已传完。后续提取、音频或蓝牙固件转换会切换到独立阶段和活动进度条,并在日志中显示转换器文件名、输出及耗时。电脑端转换支持安全暂停,单个转换器超过 120 秒会明确报错;Android 初始化和授权等待仍没有此时限。 + +详细日志按最新记录在上、较早记录在下显示;一条异常内的堆栈顺序保持不变。复制及导出的持久化诊断仍按发生时间排列,方便开发者分析。 + +阶段 4 需要手动重启时,页面顶部会明确显示“请现在手动重启设备”。使用设备正常重启功能;已经重启或进入 OpenWrt 时不要重复重启。自动重启流程会显示已发送请求。进入 OpenWrt 后,将电脑连接到这台设备的 USB 网络或热点,核对管理地址和 SSH root 密码,点击“我已进入 OpenWrt,开始校验”。多台 OpenWrt 的默认地址可能冲突,请连接目标设备的网络并填写它可访问的地址;安装器不会自动改网卡或路由。地址对应另一台设备、连接失败或认证失败时,可以直接修正地址/密码并重试,不必重新安装。手动确认会立即请求最终身份及容量校验,通过后显示完成;不会跳过校验或重新执行分区写入。所选地址与启动确认保存在原记录中,密码只在内存使用,重启安装器后需重新填写。 + ### 连接与常见问题 #### 第一次使用,从哪里开始? @@ -60,7 +78,7 @@ #### 没有发现设备,或者同时连接了多台设备? -先完成安装包校验,再刷新设备。确认 USB 线支持数据传输、设备供电正常;必要时更换线缆或 USB 口,并在 Windows 设备管理器检查设备及其 USB 驱动。Android 中开启开发者选项和 USB 调试。多台设备会列在下拉列表中,请核对型号和序列号末四位,明确选择目标后检查;后续操作绑定所选设备,不会任选另一台。 +刷新设备不依赖安装包校验;没有设备时也可以反复刷新。进入安装、临时启动或高级选项时会先自动刷新一次。枚举连接不读取分区或请求 root,检查设备和安装前仍须校验安装包。确认 USB 线支持数据传输、设备供电正常;必要时更换线缆或 USB 口,并在 Windows 设备管理器检查设备及其 USB 驱动。Android 中开启开发者选项和 USB 调试。多台设备会列在下拉列表中,请核对型号和序列号末四位,明确选择目标后检查;后续操作绑定所选设备,不会任选另一台。 #### 显示“等待调试授权”或“离线”? @@ -94,6 +112,8 @@ Extract the complete ZIP and run **OpenWrt-Installer.exe** at its root. Keep all ### Storage and capacity +Inspecting a device never changes your selected installation method; recommendation badges are advisory. Reinstalling an existing internal partition needs no TF card and does not validate card capacity. A valid card/target is required only for TF installation. The final plan names the method, write target and data impact. Returning to edit preserves the chosen method and original page. + TF installation follows the existing first-partition preference, using the raw card only when it has no partitions. It does not repartition cards or impose a 32 GiB ceiling. Check the exact target and capacity. The payload and local firmware are prepared before releasing Android mounts and formatting. A release failure stops installation. Magisk TF installation remains supported. Internal installation first checks validated GPT gaps. A sufficient gap avoids shrinking/resetting userdata. Otherwise the existing offline resize is used. The plan displays retained Android space, allocated OpenWrt space and data impact. **Use all allocated OpenWrt partition capacity** is enabled by default: it fills the chosen allocation, not all remaining device storage. Device-side block-count checks and final ext4 superblock verification prevent a 10 GiB partition with an unexpanded 2 GiB filesystem from being reported as success. @@ -108,9 +128,15 @@ Wait for offline preparation and stock recovery to finish. Complete Android setu There is **no overall deadline** for user setup or authorization. Expected reboots and missing USB are waiting states. Without ADB the computer cannot distinguish Android still booting from USB debugging not yet enabled; the UI provides both instructions. Unencrypted userdata retains its preserving offline-shrink path. +### Updates and automatic restart + +After submission the device automatically restarts to apply the update, briefly disconnecting its network. The page and notification show “Update submitted; device restarting.” Keep power connected. Completion requires the same device’s boot identifier to change, followed by actual-capacity verification; an SSH response from the old runtime before reboot cannot complete the update. Explicit boot confirmation retains this check. Correct changed addresses/passwords in the verification form. Phase clocks stop on completion, failure and pause, persist across application restart, and begin a new execution segment on retry. Older update records without pre-reboot evidence require manual review and are not automatically accepted as complete. + +SSH EOF, refused connections, timeouts and a temporarily absent USB network during reboot are normal reconnection waits. They do not generate connection-error warnings, request another update or impose a fixed overall deadline. Transport details remain in DEBUG diagnostics. Authentication failure or a confirmed different device still asks for corrected credentials/target. The editable management endpoint and explicit verification button remain available. + ### Recovery and results -Transactions live in `%LOCALAPPDATA%\OpenWrt-Installer\transactions\\`. Open this directory or export the full transaction/backup ZIP from the application. Backups include private hardware identity and may contain wireless settings in legacy records; do not publish them. Default logs omit legacy terminal output, passwords, SMS bodies and full hardware identifiers. +Transactions live in `%LOCALAPPDATA%\OpenWrt-Installer\transactions\\`. Open this directory or export the full transaction/backup ZIP from the application. Backups include private hardware identity and may contain wireless settings in legacy records; do not publish them. DEBUG logs include command boundaries, sanitized CLI output, verification results and exception tracebacks. Passwords, wireless keys and complete hardware identifiers are redacted before logging; installation does not read SMS bodies. Pause takes effect at a safe boundary. A partition or boot write is not killed. Closing an active window is blocked until a safe pause. Pausing cannot undo an already submitted offline boot request: keep the device powered. After closing the application, restarting the computer or moving the package, reopen it and choose **Continue an unfinished installation**. The completed page stays open. @@ -122,6 +148,16 @@ Connect to USB networking or the device hotspot manually. Default management add The header, step navigation and bottom actions stay fixed. Installation content, recovery records and expanded logs scroll independently. The transaction-folder shortcut stays at the bottom of the sidebar. Results, errors and phase changes share the notification area at the upper right, away from the final confirmation buttons. Dismiss error notifications manually; consult the log or transaction page for details. Data-impact warnings, waiting instructions and completed results remain on the page. Interface motion follows the Windows animation/reduced-motion preference. +Detailed logs · DEBUG opens automatically when starting or continuing and can be collapsed at any time. Its bounded list keeps the action buttons visible. On failure, use Copy diagnostics for the developer; the log also supports copying and export. Sharing reads persisted diagnostics rather than only the last 500 UI entries; full rotated logs are included in backup export. Missing debug details from an older release cannot be reconstructed; retrying with this release begins recording them. Backup and transfer bars show measured bytes, speed and progress. Writing, checking, shrink and growth without a reliable percentage show an activity bar, phase and elapsed time. Waiting pauses bar activity and provides the next action. + +Boot-chain backups use device-side `dd` into a private temporary directory under `/data/local/tmp/`, then `adb pull` to the computer. Source, temporary and computer SHA-256 checksums must match. Device temporary files are removed after each item, and the directory is removed when finished. Backup does not use Base64 or compressed streams and stops clearly if temporary space is insufficient. Source partitions are read without writing to them. + +A transfer reaching 100% means only that file finished. Firmware extraction and audio/Bluetooth conversion have separate phases and activity bars, with converter names, output and elapsed time in the log. Host conversion can be safely paused and has a 120-second per-converter timeout. Android setup and authorization waits retain no overall deadline. + +The detailed log displays newest entries first while preserving line order within each traceback. Copied/exported persistent diagnostics retain chronological order for investigation. + +At phase 4, a manual restart requirement appears prominently as “Restart the device now.” Use the device’s normal restart control; do not restart again if OpenWrt is already starting or running. Automatic paths identify the requested restart instead. Once OpenWrt starts, connect this computer to that device’s USB network or hotspot, check its management address and SSH root password, and select “OpenWrt is running — verify now.” Multiple routers can have conflicting default addresses: use the target network and a reachable address. The installer never changes adapters or routes. Wrong-device, connection and authentication errors allow correcting the endpoint/password and retrying without reinstalling. Confirmation requests final device identity and capacity checks; it neither bypasses verification nor repeats partition writes. The endpoint and boot confirmation persist in the original record; passwords remain in memory and must be reentered after restarting the installer. + ### Connection and troubleshooting #### Where should a beginner start? @@ -130,7 +166,7 @@ The three-step getting-started guide appears on first launch when no installatio #### No devices, or several devices connected? -Verify the package before refreshing devices. Use a data-capable USB cable, keep power connected and try another cable or USB port if necessary. Check the device and USB driver in Windows Device Manager. Enable Android developer options and USB debugging. With multiple devices, check the model and last four serial characters in the list, explicitly select your target and inspect it. Later operations remain bound to that device. +Refreshing devices does not require package verification, and an empty list can be refreshed repeatedly. Entering Install, one-time boot or Advanced options refreshes once automatically. Enumeration does not read partitions or request root; verify the package before device inspection or installation. Use a data-capable USB cable, keep power connected and try another cable or USB port if necessary. Check the device and USB driver in Windows Device Manager. Enable Android developer options and USB debugging. With multiple devices, check the model and last four serial characters in the list, explicitly select your target and inspect it. Later operations remain bound to that device. #### Awaiting debugging authorization, or offline? diff --git a/installer/PROTOCOL.md b/installer/PROTOCOL.md index 36d947fa..e3a129e0 100644 --- a/installer/PROTOCOL.md +++ b/installer/PROTOCOL.md @@ -2,16 +2,34 @@ The canonical implementation is `e5-linux/installer`. `sync.py ` generates the other repository's mirror and `SHARED-SOURCE.json`. Edit the canonical source, synchronize, and run `--check`. Do not independently maintain two frontends/state machines. Both builds use the same Tauri executable and backend; repository-specific behavior is in `backend/adapter.py` and the existing Python/device scripts. -Protocol 1: one JSON object per line on stdin/stdout. A request is `{"protocol":1,"id":1,"command":"hello","params":{}}`. Responses contain the same `id`, `type:"response"` and `data:{ok,result}` or `{ok:false,error}`. Events use `type:"transaction"`, `"transfer"`, `"log"`. No terminal-text matching. Legacy stdout/stderr is suppressed; named observer callbacks produce events. +Protocol 1: one JSON object per line on stdin/stdout. A request is `{"protocol":1,"id":1,"command":"hello","params":{}}`. Responses contain the same `id`, `type:"response"` and `data:{ok,result}` or `{ok:false,error}`. Events use `type:"transaction"`, `"transfer"`, `"log"`. No terminal-text matching. Legacy stdout/stderr becomes sanitized diagnostic log events, independently of named state/effect callbacks. -Commands are allowlisted in both Rust and Python: hello, snapshot, list, package, devices, probe, probe_update, plan, start, resume, retry, cancel, can_close, export, import. There is no shell/exec command. A frontend-selected serial is checked against an actual device. All ADB operations use that serial; eMMC CID and profile are rechecked after reset. SSH maintenance binds the key fingerprint between planning and execution; final verification binds the hardware CID. A plan cannot become executable without `confirmed:true` on its persisted transaction ID. +Commands are allowlisted in both Rust and Python: hello, snapshot, list, package, devices, probe, probe_update, plan, start, resume, retry, cancel, can_close, export, import, diagnostics, verify_openwrt. There is no shell/exec command. A frontend-selected serial is checked against an actual device. All ADB operations use that serial; eMMC CID and profile are rechecked after reset. SSH maintenance binds the key fingerprint between planning and execution; final verification binds the hardware CID. A plan cannot become executable without `confirmed:true` on its persisted transaction ID. + +`verify_openwrt` accepts only the active transaction ID, a management host and in-memory SSH password during safe `openwrt_boot` waiting. It queues an endpoint change/boot acknowledgement for the existing worker and wakes its retry loop; it cannot mark a transaction completed or execute an installation. The worker persists the endpoint and boot acknowledgement, never the password. Details include `reboot_manually`, `boot_confirmed`, `host` and optional `verification_error`. Manual paths wait for user action; automatic reboot paths identify that request. Wrong CID and SSH authentication/connection errors remain editable waits. Actual filesystem-capacity failure remains a failure and cannot be bypassed with confirmation. Transactions include format/version, device identity/profile/original slot/storage geometry, selected method/allocation, original partition layout, content-based payload identity, backups, legacy transaction path, completed effects, started/done mutation ledger, current stage/status and final measured result. Writes use flush/fsync plus atomic replacement. Per-CID and per-serial OS locks are shared between repositories. Kernel-released locks survive abnormal process termination correctly. Device scripts retain their own upgrade/partition locks. +Each saved checkpoint increments `revision`. The UI ignores older snapshots for the same transaction, including a request response delivered after a newer event. Existing version-1 records without a revision acquire one on their next save. An unconfirmed saved plan opens its review/confirmation screen; it cannot be resumed as an authorized installation. + +Stage timing uses persisted `stage_started_at` and terminal `stage_finished_at` timestamps. Repeated waiting/error snapshots within a phase keep its start time; completed, failed and cancelled states freeze it. Retrying starts a new execution segment. Completion retains the preceding verification phase start. The UI stops its interval on terminal states and renders saved times rather than counting after completion. + +Update execution captures the actual SSH runtime's boot UUID in `update_boot_id` before uploading/writing. A completed `update-commit` is a final commit checkpoint: restart goes directly to verification and never repeats the update. The UI announces the automatic restart immediately after commit. Verification requires the bound CID, a valid boot UUID different from the captured one, and measured capacity. A responsive pre-reboot runtime remains a wait; explicit user boot confirmation does not bypass the UUID check. Missing evidence in older update records stops for manual review. + +Expected SSH transport loss during the final wait emits `details.connection_state:"reconnecting"` with no `verification_error`. Automatic restart paths stay `waiting_device`; a manually initiated boot retains its pending user action if necessary. Connection refusals/timeouts, absent network interfaces, EOF and SSH banner loss are logged at DEBUG, not presented as warnings or failures. Retry has no overall deadline. Actual authentication failure and a proven wrong CID retain actionable errors and endpoint correction. + +Restarting during `openwrt_boot` or `verify_capacity` returns directly to SSH hardware/capacity verification. The coordinator also recognizes final verified commit effects before rechecking an obsolete initial Android plan. A stage-one boot effect, partial/started write or root-only E5 TF write is insufficient; legacy preparation records still require their token/geometry-aware resume path. + Statuses: ready, running, waiting_user, waiting_device, failed, cancelled (a resumable pause), completed. Stages are independent of frontend navigation. Waiting for Android initialization, ADB authorization or root has no transaction deadline. Expected reboot is checkpointed before the reboot command. Every write has a stored intent and a completion checkpoint; completed effects are skipped. Uncertain nonrepeatable writes stop for readback/recovery. Existing backend transaction/geometry/token checks remain authoritative during stage-two resume. Safety boundaries are before effects and between verified transfer chunks. Cancellation is requested, not process termination. Close is blocked for active operations; the user first requests a pause. If the host disappears during an unsafe operation, the ledger retains the incomplete intent. Reconnecting is not permission to repeat GPT shrink/format. Backups must be exported before reinstalling Windows or deleting app data. Device-only recovery with insufficient identity/layout/backup evidence is refused. -Transfer events contain `name`, actual acknowledged `bytes`, `total`, and `bytes_per_second`. Check/format/shrink/grow only emit phase and activity. Final verification reads an ext4 superblock over SSH base64, checks the expected allocated byte count and running OpenWrt, and reports filesystem bytes separately from partition size. No `od` or SFTP is required by that verification. +Transfer events contain `name`, actual acknowledged `bytes`, `total`, and `bytes_per_second`. Check/format/shrink/grow only emit phase and activity. Final verification reads raw ext4 superblock bytes over SSH, checks the expected allocated byte count and running OpenWrt, and reports filesystem bytes separately from partition size. No `od` or SFTP is required by that verification. + +`log` events include timestamp, DEBUG/ERROR level, scope, stage and sanitized message. Legacy CLI text is diagnostic output only; no state transition is inferred from it. Command boundaries, output, effect checkpoints, backup/hash results and exception tracebacks persist in `debug.ndjson` with a 4 MiB rotation and one previous file. `diagnostics` returns a bounded redacted sharing report from persisted logs even during an active operation; full logs are included in exported backups. Passwords, wireless keys, hardware identifiers and legacy secrets are masked before disk or UI emission. + +Boot/chain backup uses device-side `dd` into a private shell-owned directory under `/data/local/tmp/`, then ordinary serial-bound `adb pull`. Source, temporary file and computer file SHA-256 must match. The UI observes actual local file growth for byte progress. Per-file staging is deleted in a finally block and the directory is removed on exit. Temporary-space checks run before `dd`; each partition is staged individually. Failed downloads remain `.partial` and cannot replace an existing verified backup. There is no Base64 or compressed-stream backup path or fallback. + +Named `activity` events clear completed transfer counters when another operation starts. `firmware_extract` and `firmware_convert` are preparation stages; the latter includes `details.tool`. Converter changes reset phase timing even within the same stage. Allowlisted host converters run with stdin detached, captured stdout/stderr, hidden Windows processes, five-second diagnostic heartbeats, safe cancellation and a 120-second timeout. Source helper scripts explicitly compile with optimization zero so their docstrings and guards survive the sidecar's optimized build. No installation decision is inferred from their terminal text. Content compatibility binds adapter, profile, root layout, kernel family and critical boot/rootfs/filesystem-tool hashes. Package paths and GUI/host-script versions are not compatibility keys. Package checksums are verified again on resume. This is integrity against corruption and accidental mismatch, not a signed release authenticity mechanism. diff --git a/installer/README.md b/installer/README.md index c04254e5..75937b33 100644 --- a/installer/README.md +++ b/installer/README.md @@ -14,6 +14,8 @@ The artifact also includes ADB and its two Windows USB DLLs under `tools/`, plus The host uses fixed Rust commands for dialogs, protocol requests and opening the application-data directory. CSP restricts remote content and scripts. Window-close handling prevents killing an active backend. A missing WebView2 Runtime produces native installation instructions. Portable distribution requires the complete adjacent `tools/backend` directory; the root EXE by itself is not the complete package. +Host firmware converters are allowlisted under `scripts/tools`. They have detached stdin, captured stdout/stderr, hidden subprocesses, diagnostic heartbeats, safe pause and a 120-second timeout. `--run-tool` compiles source helpers with optimization zero, preserving their docstrings and guards when the sidecar is built with `--optimize 2`. Firmware extraction/conversion have named UI phases; structured activity events clear the preceding file's completed progress bar. Tests include real converter execution after simulated extraction and optimized-host execution, rather than only checking process routing. + `OPENWRT_GUI_ARTIFACT` can point to an extracted Windows build artifact while packaging on Linux. Existing e5 `install-entrypoints.py` and MU300 `desktop/package.py` call `package_gui.attach` before generating final manifests. GUI sources and binaries are fingerprinted; missing/stale artifacts fail normal packaging. `OPENWRT_GUI_OPTIONAL=1` permits source-only/test fixtures and must not be used for a GUI release. Old optional console EXEs are stored under `tools/legacy`; the root EXE is always Tauri. MU300's `--exe` packaging option accepts the GUI artifact **directory**. Legacy console EXE input remains accepted under `tools/legacy`. `tools/build-openwrt-tf-magisk.sh` still calls the same package assembler; set `OPENWRT_GUI_ARTIFACT` (or its existing MU300_DESKTOP_EXE to the directory). e5's profile builder and make-flash-bundle paths use the same attachment. Root Magisk files and a single rootfs remain intact; desktop code is not added to any device initramfs or rootfs. @@ -29,10 +31,22 @@ python installer/sync.py D:\Git\mu300-linux-clean-tf-7.2 --check Validation uses fake transports and disposable files. Run POSIX device-script tests in Linux/WSL; Windows path syntax is not valid in those shell test fixtures. Actual hardware erase, resize, boot synchronization and Magisk installation require a separate authorized hardware run. See the verification report for what was actually executed. +For the complete browser regression suite, install development-only Playwright (`python -m pip install playwright`, then `python -m playwright install chromium`), build the production frontend and run `python -X utf8 installer/tests/run_ui.py`. It starts and stops its own local server, checks all six UI suites and writes `verification/ui-regression.json`. It refuses an occupied test port and never connects to ADB/SSH. Windows CI runs the same suites after its release build. + ## Desktop layout, feedback and motion The window has a fixed viewport: header, sidebar, primary actions and footer stay visible. Purpose lists, recovery records, installation content and expanded logs have independent scroll areas. The package extraction reminder and transaction-folder shortcut stay at the bottom of the sidebar. Recovery controls remain compact at the minimum 800×650 window size, including when the log is open. +Device enumeration is independent of payload verification: the install/advanced/one-time-boot views refresh once on entry, and Refresh devices remains available with an empty list or before verification. Device inspection and installation still require a verified package. Every refresh clears the old inspection so stale root/readiness cannot authorize a later action. Empty responses and enumeration failures clear stale selection; multiple-device responses retain only an explicitly selected device that is still present. + +Installation mode is explicit and stable: probing does not change it, Advanced defaults to reinstall, and returning from review preserves the method and originating page. The review names the selected method. Non-TF probes collect only an optional removable-card availability hint and never call the legacy mandatory SD detector or validate card capacity. Physical card discovery excludes the eMMC carrying userdata instead of assuming `mmcblk1` is the card. TF probes retain strict card/partition selection and failure handling. Execution rejects a method that differs from the saved plan before probing or writing. + +`tests/test_method_routing.py` exercises the actual adapter probe and coordinator planning paths, real E5 legacy GUI-mode SD errors, all method argument/entrypoint mappings and mismatched-plan refusal using simulated reads and mocked write entrypoints. `tests/method_smoke.py` checks the exact frontend protocol parameters, no-card reinstall review, explicit choices with a present card and return-to-edit behavior. Neither test writes to a connected device. + +`tests/frozen_method_smoke.py --report ` runs the same no-card probe/plan isolation inside each real bundled backend executable using a simulated transport. It loads the package's actual legacy installer/profile, verifies that all non-TF probes and the internal-reinstall plan succeed without card detection, and confirms that TF installation still rejects a missing card. No external Python is used by the child backend and no device connection is opened. + +Static captions, navigation, button text and headings do not allow text selection. Editable fields, paths, device/plan values, logs, error details and manual body text remain selectable for copying. `tests/refresh_smoke.py` covers empty-list/error retries before verification, multi-device and unauthorized states, stale inspection invalidation, relevant views and selection behavior without device writes. + [Sonner](https://sonner.emilkowal.ski/) is the single notification surface for request results, native/clipboard errors and transaction changes. Transaction snapshots are deduplicated by identity, stage, status and error; repeated polling does not reset elapsed time or flood notifications. Destructive warnings, actionable waiting guidance, failures and final results also remain in context. Notifications appear above the content, away from the bottom confirmation controls. Loading notifications transition to their result; cancelling a save dialog does not report a successful export. [Motion for React](https://motion.dev/docs/react) supplies short page entrances/exits, purpose-row interactions, phase/result entrances and log expansion. `LazyMotion` loads the DOM animation feature set without layout/drag features. `MotionConfig`, `useReducedMotion` and CSS respect the operating system's reduced-motion preference; waiting for the user uses a static device icon rather than an endless execution spinner. No transfer percentages are synthesized. diff --git a/installer/SHARED-SOURCE.json b/installer/SHARED-SOURCE.json index 5bcd6b8c..9e893349 100644 --- a/installer/SHARED-SOURCE.json +++ b/installer/SHARED-SOURCE.json @@ -3,44 +3,75 @@ "policy": "Generated mirror. Edit upstream then run sync.py; do not fork UI/protocol.", "sha256": { ".gitignore": "a5773f83330fc9adddfd159fe0391bccffbf7663dccb2b873f6b2d1b2d2eca11", - "backend_entry.py": "b7fea0acd7f3ddbd268c465fb089a258203c1d65f8e4230e35a98d78d7382e90", + "backend_entry.py": "238a3534a790ce46ae396040623117299f78b9fc9fc89fe152bfdd5788f7b664", "build.py": "e3adff7e7c6a20e19ed541a4fc22589ba65306cd70dae2b4afde582e8c55a976", - "GUIDE.md": "f812f7ee5c2873d7eeade1b5f0a234bf6fefa3c218b88634a4e4b10374cf7671", + "GUIDE.md": "479c4d67c28c1004f6db46a67d082c1f494ad1ac8557051d1d3adb085b76d1e3", "package_gui.py": "76435dcfd5c6386f39735b74e8c1dd541dbfdf4da391d02636c4482cc1b6d715", "platform-tools.json": "d8fcf938e150bc314b5e6b2660c540976bb12ea6108fa75a8fb183115ebbd01e", - "PROTOCOL.md": "fa1353791fd861a0b7e649e3be3224a91384489b73817ced88a17d6d52bd3dd4", - "README.md": "7d906eb6693180b1c05cdf0c928437523240414b55e48a246cbb2434be7505bf", + "PROTOCOL.md": "542b7909ffbcc9aa6c3ca5acffdbf8137f5a64487d52ba3997514d8cb5cbd2cc", + "README.md": "33e7e52d03bd89d2081b248d6a1d2034c48b68890ef6539ff4636decec6071a3", "release.py": "c1432d3b4e48e094d79753d6be3f432d9e05744abfa816bd4d6e1a04d06b6432", "requirements-build.txt": "762ee573a22c790eb3c5ccba4616632373d947dc88eb91fc85f3c678ac7b2259", "sync.py": "8a6160a68cadbb3295303505c94d6cb5a8229c9ccb2d652408660b1711fccfdf", - "VERIFICATION.md": "56048f975f614824f627442f8376234e98c4359d09bf6e7292f83c2c066e288e", - "backend/adapter.py": "ea817c559d9abc8748b8b528622620a2abcd215eb6937ad2c80717353f5be52d", + "VERIFICATION.md": "054cd33728bc0b152ae288d3b58948609ba34eefb29b63bff990975617aa8936", + "backend/adapter.py": "a286a92894b9aa800a9671fb94caf37997a2a0207da0542a484c209f27b4cf77", + "backend/diagnostics.py": "9660b22d3bf9be229ce16d6dafd7c26c8180abe5b7e2b00bbb32bec7ce9bb1f5", "backend/gpt.py": "4eca5ccf458ef86b9dfcea6388da61defe61af6389565cadf2fda6616e28b791", + "backend/helpers.py": "ac5422e60bcdd0273baa5d5796d64aa5b1e0687a709afc5bdf9c8501a7154d36", "backend/package.py": "5c55e91f2c348ac957d7803810e6396edf3aae573da401ecf46e773ac75e70ee", - "backend/service.py": "0bd4137a37cb6346bc5c6ad6f9f580e6fc9e3311e32510022340c4505e95a89c", - "backend/state.py": "af15010d0b1cb7b827f2cf69cb4b18139d5f33d408aae47da65b2c7cacc5952a", - "backend/transport.py": "91017d0116a0d7b2c6f763ac6c8b092dedca987dce0b686e9b6f57681af25d1b", + "backend/service.py": "b80c9bc9a92e2b5ef2fc9fa810be01c65873c76e986bc879d6cb7aa9d12ba7a4", + "backend/state.py": "bc17eac46b099524b2f2ad687d9fd6fcd3d867929487ef4a80d528992d6b3d48", + "backend/transport.py": "b022c4b6c2bc63090ebc2bf64ce6f3720a71cc90c95cfd5fa81836c156d956ba", "backend/__init__.py": "4227d63763e764fd2de7fc2bc13e474ae5de33176fb57aa0fd51cbb4ad80b88c", - "screenshots/complete-dark-en.png": "f8709858ee45e4a562195684cdb17087ce7d6c60dcd7e3e0883f83b5baac4e07", - "screenshots/help-recovery-light-zh.png": "7443b3880bcd616e861a436e50778414e246ae299c6ddf3eec65f2e44671c874", - "screenshots/help-small-dark-en.png": "001502ca276fb48b5370a95c4211828809ffd53c6a110bc58eb71f30a63c563d", - "screenshots/home-light-zh.png": "fe8e87a1c37d05dcc2eee9c688f10d0fd170b6ff0495a71270881378eb366a7a", - "screenshots/install-small-light-zh.png": "46b3e5a494c32da5959b4cb5a80694a5a7eefd86f0c6942e9978c5723ea1dd5d", - "screenshots/native-home.png": "c5503e2ad3b01508b86cf5802501ce12c8c7b8856d452487941b5fcb44b18c80", + "screenshots/automatic-restart-log-en.png": "3556b20363fc5cc825062247a47ab35f7de4829ab5d500756cfed059d2473b90", + "screenshots/backup-progress-debug-zh.png": "bf3c0579b42de5bc4256b68cf474a493f5d8c533c0597e6ce8cf8f1e6946d1b8", + "screenshots/complete-dark-en.png": "b5e2dcc01b733acb950b13fb58112c88441e93de7a5698d3e669eed6ed33c396", + "screenshots/failure-copy-diagnostics-zh.png": "6acd6c41ba95a0454c9ecbcb616d0a89a52fd3152e171f669e693a678313ae1a", + "screenshots/firmware-convert-debug-zh.png": "0f1da31afe5956f38b8c5f0d302438a22a4fc1b31ba06d73d24c2496d3679dad", + "screenshots/help-recovery-light-zh.png": "d727104e9111ffde9bc498dcf3bb1d3b252fb420882023fa926c48e591032d29", + "screenshots/help-small-dark-en.png": "1578a98c7146afa4914865e4c9f0ccb089f74ae2fc357cd83e6e153362d87228", + "screenshots/home-light-zh.png": "ecf1f16b74e4c7ad522ad332f6086a6c8a85a25e0e0bcd45be056366a1e4d334", + "screenshots/install-activity-debug-zh.png": "61d2eeb1011faa4953f17a6f7b8b1552ae79b293f991ea563a6645b11b682ccb", + "screenshots/install-small-light-zh.png": "979b0fbce2626cbdcb909cf665ebf0474f04f960865a588c2b807dd6c2ebd8a9", + "screenshots/manual-restart-log-zh.png": "d9f7c306553ce7041152d7fc06a50fa598507d0fef71994c4be2f558d2f6c824", + "screenshots/native-home.png": "7b6709a73d05acccba0e199fe31fb0b862e555a5dd18f12ec94584fc80aaddc7", "screenshots/native-mu300-home.png": "48ca20b2732f9a3d9522512ddd6121fc5eac4943d2cd928d7a21f0ba7c82a3a3", - "screenshots/onboarding-light-zh.png": "37d8e26be61aff5b7c1851bce83af415666d8b6916775a58ac8e2f0446fbb4be", - "screenshots/onboarding-small-dark-en.png": "f4f82bb46596db713021ec3d1398f83b5f96e0413ae7711a7b384c5c11b140fa", - "screenshots/plan-light-zh.png": "9ff13ad155cb5c2fc58f34dae0345971787216f3a70ccadcd28d4adf1da37b3c", - "screenshots/plan-small-dark-en.png": "13910ce085be317b4f72783a2275728a513257e31b693713510a2bcaa4f1843a", - "screenshots/resume-small-light-zh.png": "b6ba295df3405b99434b153874be27f291038d4a61e63155b0914667bdafaa59", - "screenshots/wait-root-dark-en.png": "940dd1a9059c32b08acd9adbc626fa5e59ef1999d9e84f2846ca503d9629805d", - "screenshots/wait-setup-light-zh.png": "4c5be7057a8e9c7ce15e8fa9294678bda3a28d7a11208ee36ec63e03ead3d1d9", + "screenshots/no-device-refresh-light-zh.png": "95b5dde3539e6c62c7444fd410888fcddd60a501a3464c3988b5ee905095e807", + "screenshots/onboarding-light-zh.png": "e4af2536e761793a92cd52f2f9d470d889e0f742480d74993eae1064aad4cfec", + "screenshots/onboarding-small-dark-en.png": "f0ed612d361dc23e42698fea89d3b7ea6683794334dd9edc00d10a5a94fdde0b", + "screenshots/openwrt-endpoint-mismatch-zh.png": "4b1e5ee4e3688e7e280267378b9ef7f93789d7cea4f012bd6186f9a5af2d33f2", + "screenshots/plan-light-zh.png": "7d5423a937bc6f7a3ef3c303b888adfc2f0fcae1f7b65e0566c6d66f7261fb94", + "screenshots/plan-small-dark-en.png": "ac3892d855da2e5678065215cf2bd97547bd5d458f5ebae34596c31ccad63968", + "screenshots/reinstall-no-card-plan-zh.png": "dd34b831ef466640c2f4a1cc69f295ec893fcadd07e31432a368a7db04994add", + "screenshots/resume-small-light-zh.png": "41ae73d32f70e5da51dbd99adda4351bdbbb85c6e8174b3037012068efb118ac", + "screenshots/update-complete-clock-en.png": "4c0475e7c4a4816ca94b8569182ea76bb4a969cc8ec4d54a670acf7a2ecbf97b", + "screenshots/update-reboot-zh.png": "39c598e7ea8a8a483604eae01070b43a54bcd6be7dc148ece04f074aad29f733", + "screenshots/update-reconnecting-zh.png": "2e7b99634dd6a0634d154615737903d4b442183088962990be9d68567953a020", + "screenshots/wait-root-dark-en.png": "e124ab41e57c1ea67a7f0721c561a999606fbb85da179c7923b2ce1f90c9421f", + "screenshots/wait-setup-light-zh.png": "28b006e5aaf0929a66b1a6ecd24fb387647ab8bae3265c213b8125d19cd09e39", + "tests/diagnostics_smoke.py": "aefbcb66ae473453b2943d95af1d12ca74d11cae84d05a02f8b49c3e9b1664c1", + "tests/enumeration_smoke.py": "289a34ebaf95eb6e41fda57d6386d9aa848ba7f219a16ec05d49497ef93345d9", + "tests/frozen_flow_smoke.py": "9c451b8dcfa36154063a68c1690dbe0eefbdc48a73d58e3ace4a3d7ff6afd8af", + "tests/frozen_method_smoke.py": "5741114dc5468c36652d832c5206c1f207a10010f43bc29f0f8e4ce68f9da2de", "tests/help_smoke.py": "18469c928604d5e8581c1aa702aa7cb9fae59a0dccca2ddd0a808263ae8b920f", + "tests/method_smoke.py": "67cb5d5a3f6a80f8981fec28af25ed6e7801eeeab85fea79e8a935fd8bd5bf32", + "tests/ordering_smoke.py": "f4f735dcb3d4a711133b67a7089c5258c9a06881c98d6c89986c36eec0249207", "tests/package_smoke.py": "f9ea830ae0e1801f52c8669b0b06033c6ee8c9a16745acc56c4b70b5f575ed26", + "tests/refresh_smoke.py": "f68af963f467f8591aab08d0c18837f0686c8db45b4ac57e5ed069a71fc29df7", + "tests/run_ui.py": "862dc5bc66dca2480895a6b4c3e731a9c60d69ad09a8b5011b937fbe4eb72a99", + "tests/test_backup.py": "1e9e877b592113c9778367de3fd5e19452d61b96a93163e5430a6328c9113793", + "tests/test_diagnostics.py": "7abc3c103cba42a0eb10b62f12edcca3f40efc3a959efb5dbc7cd5fe5f24e581", + "tests/test_flow_boundaries.py": "e38366eb46c433ddc5080484f451ff072d2f40242893de3667ea792a89fe87ec", + "tests/test_helpers.py": "317f4c2216e8e60c1024931eef3e2a5a23d43ea152a931ae830865362576c4cb", "tests/test_legacy_binding.py": "b2bbae1ef0c2ecdecb2b3caeaee47047293d89507bf890592c1bd23d76908c82", - "tests/test_recovery.py": "a3dac4c91f6a7bd5ee0e3f6d7e6ae2e3f692d28224be03bd30c58f1eb0db51c3", - "tests/test_state.py": "7fcce0b6788210c6f0378be961aa1561a5f77bcca57e4ed9c9492d2e156b2649", - "tests/ui_smoke.py": "d66191f40544b27109f99d6743e80077888f637a1fe9bf47394f359d5229305d", + "tests/test_method_routing.py": "b8a7f820c91a97bf73a980972850cacb00bb7968488a695911d55043cd67a744", + "tests/test_openwrt_confirmation.py": "ed9fb932cb6be775a52cd569b61a245c787bbe2b2935a21d469f38daf3c0c469", + "tests/test_recovery.py": "7b066dc300ee5df2e4e819aa2a7c2ab6a9c1e8a07d044da2ca3d3b2860945a64", + "tests/test_state.py": "ee80f34e9b295ffd4a92280836ceb6090b17d531e5914f0f5b86fa3bce0dca19", + "tests/test_transfer.py": "9e32e05d43274a1910335c9fca212cd6eeb1c82e3265fdcbcd98612ef9cd14f7", + "tests/test_update_lifecycle.py": "2527f1cfc3f51dc332c857d658b9fc44f1e8f4df026ce535bfe406e602a15da0", + "tests/ui_smoke.py": "fe42a51381995b8e060ed67d1cbd49bfc021cd63a64737d07eeee4e4ffc70197", + "tests/update_smoke.py": "bb16efe0dbd6379b6ab7b6f45cd5cdf1beb56e01bda232bd82cb6c69be5a3fb1", "ui/components.json": "c9956b81d4afe05c5df651ab933d75a4aae6782e499fba9a653fd992381b2fba", "ui/index.html": "0ce43c18781e1d0d6184ab0e4dade150a2a79ab8afc3693c54f491bd19dae5d8", "ui/package-lock.json": "20dc70b3177789a10c9de3f2d6bcdc3cbc570dac47bd8a5c4e31ff137cbe1cda", @@ -50,25 +81,71 @@ "ui/tailwind.config.js": "83a2b606389ae80ddc566da9f28fc5a87b6b012c33d0e2140396b81f8c784131", "ui/tsconfig.json": "cd09393aa9aab0b15cb2020d329e9f77a745efaa83c032a81121ea6f80c4face", "ui/vite.config.ts": "0cdd04c180bc500cfbada1781eaba986a84637c820c0bea668c148ed08136d7b", + "verification/boot-confirm-e5-sizes.json": "d5a21942ec6359f0d4cbb0697d820e8443a9f8079c21fbe4b040759dd133f6a9", + "verification/boot-confirm-frozen-flows.json": "2a729d3fef6054d75fbaf782ec830f4441e6ab5e2b879a134f21b5a5f6dbd0cf", + "verification/boot-confirm-frozen-methods.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/boot-confirm-packages.json": "597eed8a4bdb622cc213315c330056e6dde447de15456be62c08dd89bfd4b668", + "verification/boot-confirm-record-compatibility.json": "ff91441ec1ea51b87707e5ce8b63498d98b2dfdc1d78e502046654ad6412bc5a", + "verification/boot-confirm.json": "b9758a7009b3ee34bb2a59fb1cee62792885e1aefb054557f4fc99470481b37a", + "verification/debug-artifact-flow.json": "e5cc619afb32147e5b589d986333a5f367f5809aa119dbc33fc55ba5333dff28", + "verification/debug-e5-sizes.json": "10d8bf1462fcec2cc930c964133aae206dc5e1f0425db92b5d2723a8eafa7615", + "verification/debug-frozen-flows.json": "4ff97bfcdcd532abe4de81932d9695179134eac07315fd796288d1cc1d39ee78", + "verification/debug-frozen-methods.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/debug-packages.json": "7c9bc43eb4c5e1770c8a205413de110aae2fe378d0f82c113b830122afdb5d78", + "verification/debug.json": "31e6d428cd8dff6ce125eb1bd819756a77f77d96c8f39bdfdc3e56fe6f082f55", + "verification/flow-posix.json": "cf3c3decd20b64b735384b1c64ed8667fea60a3594c7fad115392a28a7b1625d", "verification/help-e5-packages.json": "a2fbf23958da15413d69ec5f5b177bd8628aa2fe54a335308df1374d446f5b88", "verification/help-e5-sizes.json": "78dd447ba24857800450358348e7fad3bba9e81ac11673aad7e00e2e1477f23f", "verification/help-mu300-packages.json": "bdd34148c3fe201dac204166635bbc2c1db7a706472031ea98119319aa6ff3fd", "verification/help-mu300-sizes.json": "7cb880644efb91a6db992746455a6fdbe4019fdb49837c8364ddcaab6a16656b", "verification/help.json": "d96debbb19bb0f25114fba7e6aa3d5dde9078da64c6e53154114904b2267e11b", + "verification/helper-real-m8.json": "eaff8e208a69d0d5319c580e408ae2cf5d6094bfe2d17b3e4cace9c96c325d0b", + "verification/helpers-e5-sizes.json": "31617688e7456c31cfabf37d1949b259aaad937f714a0e6e472044d3230125fe", + "verification/helpers-frozen-flows.json": "4ff97bfcdcd532abe4de81932d9695179134eac07315fd796288d1cc1d39ee78", + "verification/helpers-frozen-methods.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/helpers-packages.json": "ad7c0cb7a4f16f7485a302f7604460a99d637b46c9cdba22c9ac385c4f2a25d9", + "verification/helpers-record-compatibility.json": "a07fcc27530c98ef4c06b8dda4199a55ef8677e5ff04bf4cfac22ceaa819aa7c", + "verification/helpers.json": "89c0ff3a2bb7283efb01e3c377650b899faf8dbf916681e6d2d302850f079d0a", + "verification/m8-frozen-backup.json": "e2e1a951745ae8f44a661803a03166db4a968e8041f44f9f85f3a38c1f281a69", + "verification/m8-readonly-backup.json": "23020579c3eba9434dcdaaf041f5e9c407ac19a9d667546f9d163f02efe6699a", "verification/payload-invariance.json": "e7b36a11dc32fbbaad6bc58a9fd57dff6578bfe0b63ff99fa8218af3cecb2e62", + "verification/reboot-wait-e5-sizes.json": "898f9758613c692f3fb4875bae048e993bf52dbdfa6fa8d3b4112f7f86f7c66e", + "verification/reboot-wait-frozen-flows.json": "2165947fc27b3972fd9d1b3b3943d803d92112d0bc4d60c00b4370c538a78b13", + "verification/reboot-wait-frozen-methods.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/reboot-wait-packages.json": "274729e2221029c128bf4dfc1cd5a0c4d096cf6fd722a7c076281e3c9e4bd45f", + "verification/reboot-wait.json": "e1a1afee5f57a131047fa220584c80543b7070a7d3d405f7f751d236f406edea", + "verification/refresh-e5-packages.json": "aac98757b7bef81185dcf22d6fe7929c088de83b5376e4310b1f0bd846777739", + "verification/refresh-e5-sizes.json": "153aab3fe70b37b16eb12bbdc488e350b9ad03d02334b12c8a777349ac9e324b", + "verification/refresh-enumeration-artifact.json": "1dcb16dae37e1d96e62f387e57f1cf65e573ef2322044ea3a4c613cfc247582e", + "verification/refresh-enumeration-packages.json": "32b96af06e999c365fc2ba94e84c8b48f0dd7486c06c4d88ab3ff40d97d6faa8", + "verification/refresh-mu300-packages.json": "76d97fecc96070487fae9cb5a17569e4ef5c8f4b8ef2a2095c25829e2ac90440", + "verification/refresh-mu300-sizes.json": "415caea4f2d7f6ff97728e6b0c81ac0fb66dfee9c030be92d60e80509eeb36ce", + "verification/refresh.json": "53ddb48f87ff32844411a522b81ba5c2f44c4463507532fe012f9f952a234a77", + "verification/routing-e5-packages.json": "a9d71e5a85e3c878c08af2177d6f8bb74d82d647c27ca9ef5bd08fb6ded291e4", + "verification/routing-e5-sizes.json": "f582e445b4aec4801b654c3fa444909fe428196c2feec3a6d453ab95b637f0af", + "verification/routing-frozen-probes.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/routing-mu300-packages.json": "a8de9d59275095dc0efc431fa4ba45844199c1358449b1357ecee95530829bba", + "verification/routing-mu300-sizes.json": "696e3c2546ec09bb817d33bb4694730d7c25823dfae164d96566b72168c54f51", + "verification/routing.json": "cd8b3b63c413871322a1252755d57e9a08c4254297424aea3be124dc8a77719d", "verification/ui-polish-e5-packages.json": "ae81da39699cdd8fac3acde62928d4299d6c15c5da9ff2cb1dc16ad072983a1f", "verification/ui-polish-e5-sizes.json": "93c7833215d99598951392c2608c82f4c6e23605398db02aae6aebd8f1a4d013", "verification/ui-polish-mu300-packages.json": "0002096d1a12d38c68d09166ed3b63bddc6ec1c199a43ccedc3bac2836f40e86", "verification/ui-polish-mu300-sizes.json": "31e0df9b4645e98f1fe91c5b831b556424d413d2afa31000e6a90e2ea5c8a350", "verification/ui-polish-t551m-package.json": "a59c13ef8903326cafae846b00803de934b28ff128c85c55a5b1c3936685d726", "verification/ui-polish.json": "014d2e86010336d9fafac14eb5852139172cc228c389d5efb1a74fd9acfd7245", + "verification/ui-regression.json": "c9ef5029fa4f124503f43d9c2c9097711186e96f8a237cde285c0d12462eba2f", + "verification/update-reboot-e5-sizes.json": "d8a2d1aa7d06e48e79198c5374a126a3c69216761d2d060dcfd476313786042f", + "verification/update-reboot-frozen-flows.json": "8c40288dfb40fbe9c4933730f47c2d6789725bfb51f96d27e5af5e91346e4ef9", + "verification/update-reboot-frozen-methods.json": "f91e016535fd1d473a87dcca44919f2aa338372945dbf79716c982a20114f0d0", + "verification/update-reboot-packages.json": "861a7816829aeb3c94ea0a1297e457a01ae70e82999b95a5690b02a9bb30adb5", + "verification/update-reboot.json": "26d586d25315c1d290d3e6ddae83322dd294a00a43a60ec232d7e47af7f61dee", "verification/windows-packages.json": "2527a520a27d9eb0f9243aa9e2ed05b0e4b90caefc8257ea3afe76acdb75a19d", "ui/src/help-data.ts": "3559333ab059b60829b7aef8fbdf92b932c2ce01cee5d7d8b5eef40cae42e4b6", "ui/src/help-i18n.ts": "ffc22b67831f01ae70e8d3d98c6e3c0a351f22a1049e05b998bc072ca9b2864a", - "ui/src/i18n.ts": "7f8c2f012a05f0b929b5e24d5474b3757416c2676e96f416134555c11d6db35f", - "ui/src/main.tsx": "04503826ce30559f2f7ad491336de8adcb68970fe5fa20b50f5a0121a1955cbe", - "ui/src/protocol.ts": "c2395c2a4bfea8f0ee399d121087f70c9be1c110f794848648689600c9bbe653", - "ui/src/style.css": "3ce3723977143c46d9ed0bc996540aea0f6b509608a8e4742ff99de24890df8a", + "ui/src/i18n.ts": "b288b30cc15eed937f602c9df39047107debea45a7ac0517ff2b0858e2c84940", + "ui/src/main.tsx": "13ef14c117f3c95318a26c3fda58cd534727ee9a256da5a5a988dfd52ff9534f", + "ui/src/protocol.ts": "acee2ee6a5608024563087a194998ebc4f2b55df01b449075bac3cb8e9f7e723", + "ui/src/style.css": "9a9de3abad20439ec00fdf97d4abb7c2428ed47b835ebba657905b8f0df406d9", "ui/src/utils.ts": "dd51582c0905c3507bd5dc3d32215a43fc156f6432042a7deb393fe4258b05ba", "ui/src/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5", "ui/src-tauri/build.rs": "8af41c0062014fc594e4bb9899e60ee9930ab57d4cf0c73041ff557d6ec736e6", @@ -81,7 +158,7 @@ "ui/src/components/ui/sonner.tsx": "59738d9ced20160c9d74971beb4fd23b794e5ff0682b998af55f604f92fdc9f8", "ui/src-tauri/capabilities/default.json": "84a9a609f4cae132de6b7ee626a8d5c396eee5c2030d416922f4db5dc9624299", "ui/src-tauri/icons/icon.ico": "5851131da4274abc593d41fa701a14ea3a99fda2da02bc5845c70664f7766094", - "ui/src-tauri/src/main.rs": "41368ae5682cd8e71af470ce07685b50267324b9082d87f05bbce08e332c5024", + "ui/src-tauri/src/main.rs": "d2056aab9e8cc7597518c3c7f9dc95c6d1d2c52c6c6dbf382ff927dc7e7aa0d1", "ui/src-tauri/gen/schemas/acl-manifests.json": "bdc3ced2ae416f11b23bc9c9b62341a3a59aa7bb5322f04f197bb08cb610409f", "ui/src-tauri/gen/schemas/capabilities.json": "a4a9ce710aadc06946c296cfb8a0df506767ed310de13e32b5914d295fc81e56", "ui/src-tauri/gen/schemas/desktop-schema.json": "4a946fe48fbb0c7c535ea53e6070bd8276f3f3d74f96efbaa6d85bd7b53b0f05", diff --git a/installer/VERIFICATION.md b/installer/VERIFICATION.md index 6e66dddc..0d738932 100644 --- a/installer/VERIFICATION.md +++ b/installer/VERIFICATION.md @@ -6,14 +6,19 @@ Implemented in both repositories with one canonical shared source and a hash-che | Check | Result | |---|---| -| Persistent protocol/state/recovery tests | 27 passed on Windows; real temporary journals, CLI selection among multiple devices and a separate-process OS lock contender | +| Persistent protocol/state/recovery/routing/diagnostic/backup/helper tests | E5: 79 passed. MU300: 79 run, 77 passed and two E5-source-specific tests skipped. Includes adapter/routing/recovery/backup/converter tests, endpoint correction, mandatory capacity checks, pre-update boot capture, commit without replay, old-runtime rejection before reboot, manual confirmation retaining reboot proof, missing/invalid evidence, frozen phase clocks, connection refusal/timeout/absent interface/EOF/SSH-banner loss as neutral waits, disconnect during remote reads and SSH close without a command exit status | | e5 targeted installer suites | 65 passed across entrypoints (7), installed detection (3), diagnostics (22), two-stage preparation (9), TF growth (5), partition boot (5), userdata size/failure ordering (6), hybrid package/Magisk fixtures (8) | | MU300 desktop suites | 43 run in WSL; 39 passed, 4 environment-dependent checks skipped | +| Expanded device-script regression | 27 suites pass in WSL (12 E5 and 15 MU300). One additional E5 GPT allocation-plan suite is environment-blocked because its required local Docker image is missing. No Docker/image was installed. `verification/flow-posix.json` records exact outputs/skips. MU300 BusyBox fault injection initially bypassed PATH; the fixture now explicitly invokes its injected dd, and all 33 boot-chain tests pass | | React/TypeScript/Vite release | Passed; main JS about 430 kB (138 kB gzip), help module about 184 kB (61 kB gzip), CSS about 26 kB; help/Markdown code loads on demand | | Tauri Windows x64 release | Passed with Rust 1.90.0/MSVC, size optimization, LTO and strip | | Native Windows launch | Passed using system WebView2; real native window captured in `screenshots/native-home.png` | | UI interaction smoke | Passed: fixed 1120×900 and 800×650 viewport; 120 recovery records; 500-line bounded log; independent scrolling; fixed titles/actions/footer; bottom sidebar reminder; Sonner results/errors and repeated-state deduplication; native dialog/export error handling; light/dark/system themes, Chinese/English, reduced motion, explicit multi-device selection, confirmation, waiting states and completion | | Onboarding/help smoke | Passed: first launch, three steps/back/finish/skip/replay, persistent acknowledgement, saved-record suppression, offline manual/search/no matches, keyboard focus trapping/restoration, Escape/F1, contextual help during a waiting transaction without sending backend commands, English/Chinese, dark/light and minimum-window bounds | +| Device refresh/copy regression | Passed: refresh before package verification, repeated empty results and errors leave retry enabled, multiple/unauthorized devices, stale root inspection cleared, install/advanced/boot views, bounded layout and selective text copying | +| Installation method UI regression | Passed: Advanced defaults to reinstall; explicit internal/TF/image choices survive device inspection; no-card reinstall sends reinstall to probe and plan; review names the internal method/target/impact; returning preserves origin and method; no start command sent | +| Ordering/debug/progress UI regression | Passed: older responses/events cannot replace newer checkpoints; unconfirmed saved plans reopen confirmation; rejected pause has no success toast; DEBUG logs automatically open and collapse/reopen; real-byte backup bar; activity bar without fake percentages; actionable exception and one-click persisted diagnostics; all six browser suites pass | +| M8 physical backup and metadata verification | Saved identity matched VIPME M8. All 13 misc/A-B boot-chain backups, 159,387,648 bytes, completed in 17.70 s via dd to a private `/data/local/tmp/` directory plus adb pull. Source, staged and PC SHA-256 agree; staging cleaned. Original backup preserved. GPT/model/slot/root/existing 10 GiB partition inspected read-only. No device partition writes. See `verification/m8-readonly-backup.json` | | Visible button contrast | Home/install pages: minimum 4.91:1 in light mode and 8.76:1 in dark mode (computed colors with alpha compositing; hidden/disabled controls excluded) | | Frozen backend and CLI | All five final package folders pass real NDJSON hello/package/list and bundled CLI package verification; stdout is strict UTF-8 | | Frozen MU300 boot builder | Both kernel families pass `--check-boot`, constructing actual boot images for Android A/B on the computer without device access | @@ -40,6 +45,18 @@ Device-script tests ran in WSL Ubuntu 22.04 with disposable files and mock block - [Offline help and recovery FAQ, Chinese](screenshots/help-recovery-light-zh.png). - [Help at 800×650, dark English](screenshots/help-small-dark-en.png). - [Getting started at 800×650, dark English](screenshots/onboarding-small-dark-en.png). +- [No-device state with enabled refresh before package verification](screenshots/no-device-refresh-light-zh.png). +- [Reinstall internal partition plan without a TF card](screenshots/reinstall-no-card-plan-zh.png). +- [Measured backup byte progress and DEBUG log](screenshots/backup-progress-debug-zh.png). +- [Installation activity bar and DEBUG log](screenshots/install-activity-debug-zh.png). +- [Failure details and one-click diagnostic copying](screenshots/failure-copy-diagnostics-zh.png). +- [Named firmware conversion stage with stale transfer progress cleared](screenshots/firmware-convert-debug-zh.png). +- [Manual restart guidance and explicit OpenWrt confirmation with logs expanded](screenshots/manual-restart-log-zh.png). +- [Correcting a management address belonging to another device](screenshots/openwrt-endpoint-mismatch-zh.png). +- [Automatic restart guidance and editable verification target, dark English](screenshots/automatic-restart-log-en.png). +- [Update submitted and automatic restart guidance](screenshots/update-reboot-zh.png). +- [Expected update reboot disconnect as a neutral reconnection wait](screenshots/update-reconnecting-zh.png). +- [Update verified with a stopped phase clock, dark English](screenshots/update-complete-clock-en.png). The browser screenshots use the production React bundle with a **test-only** protocol fixture in `tests/ui_smoke.py` and `tests/help_smoke.py`. That fixture is not imported into production, does not exist in the firmware packages, and does not open ADB/SSH. These screenshots verify rendering and interaction, not a completed hardware installation. The native screenshot verifies an actual Windows launch. @@ -49,7 +66,9 @@ Onboarding and help use the same source in both repositories. The detailed manua ## Hardware boundary and recovery limitations -No connected-device installation, formatting, GPT mutation, userdata reset/shrink, boot-chain synchronization, misc write, live SSH upgrade or Magisk flash was performed in this task. ADB enumeration during read-only package smoke found zero devices. Hardware behavior of those paths is therefore **not newly hardware-validated**. Their existing device code is reused; automatic tests exercise the host protocol and recovery logic with simulated transports. +No connected-device installation, formatting, GPT mutation, userdata reset/shrink, boot-chain synchronization, misc write, live SSH upgrade or Magisk flash was performed. The physical M8 validation was limited to identity/root/GPT inspection and source-partition reads for backup. As explicitly requested, dd wrote ordinary temporary files under `/data/local/tmp/`; adb pulled and verified them, then removed those files and their private directory. Device partitions were not written. Installation/update/reset behavior remains **not newly hardware-validated**; automatic tests use simulated transports. + +The supplied M8 failure record stopped at `backup`, with no effects/completed writes. The old whole-boot Base64 read reproduced a 120-second timeout on 64 MiB `boot_a`, which was hidden by the generic interruption message. The final implementation removes Base64 and custom compressed/raw-stream backup paths entirely. It uses staged dd/adb pull, reports actual local bytes, preserves verified files on failed download, and records the concrete exception/traceback. DEBUG logs persist across restarts and are redacted before disk/UI emission. Copy diagnostics reads the persisted report rather than only the UI's recent 500 entries. Uncertain interrupted writes do not automatically repeat partition preparation. A trusted host transaction plus matching hardware/geometry/token is required to enter stage two. A completed effect is skipped; a started nonrepeatable effect without conclusive completion stops for recovery. Missing host records with insufficient backups/markers stop rather than infer a partition layout. This is deliberate fail-closed behavior, not a guarantee that every power-loss point can recover without manual backup-based repair. @@ -68,6 +87,22 @@ The polished UI refresh is delivered separately in e5 `out/gui-releases/20261015 The subsequent onboarding/offline-help revision is in e5 `out/gui-releases/20261015-guide/` and MU300 `release/gui-20261015-guide/`. It retains the same system/boot payloads and independent package directories. Use these `guide` paths for the latest local build. Per-package sizes and frozen-backend checks are recorded under `verification/help-*.json`. +The device-refresh and text-selection fix is in e5 `out/gui-releases/20261015-refresh/` and MU300 `release/gui-20261015-refresh/`. Use these `refresh` paths for the latest build; earlier local packages remain separate. The refresh button no longer depends on payload verification. Enumeration is read-only; device inspection and writing retain the payload gate. Per-package checks and sizes are under `verification/refresh-*.json`. + +The internal-reinstall/method-routing fix is in e5 `out/gui-releases/20261015-routing/` and MU300 `release/gui-20261015-routing/`. Root cause: the shared E5 probe called the mandatory SD detector for every mode and caught `SystemExit`, while GUI-mode `die()` raises `ValueError`. The fix removes that detector/capacity check from non-TF modes rather than swallowing errors. A separate UI issue that replaced selected methods with recommendations was removed, and Advanced's hidden `part` default and review-back reset were corrected. + +The debug/progress/fast-backup revision is in e5 `out/gui-releases/20261015-debug/` and MU300 `release/gui-20261015-debug/`. It includes the routing fixes, recovery checkpoint fixes, detailed diagnostic sharing and staged dd/adb pull. Earlier local releases and the user's original backup ZIP are left intact. Firmware payload hashes remain unchanged. Per-archive sizes, checksums and frozen-backend checks use `verification/debug-*.json`. + +The latest local build fixes host firmware conversion: e5 `out/gui-releases/20261015-helpers/` and MU300 `release/gui-20261015-helpers/`. The optimized frozen backend stripped the VBC helper's module docstring, causing its argparse initialization to fail. The old unbounded, uncaptured child execution also left the UI displaying the preceding transfer's 100%. Helpers now run with source docstrings/assertions preserved, detached stdin, captured diagnostics, named stages, safe host-child cancellation and a 120-second converter timeout. The exact internal reason the original child remained alive is not established; the missing-docstring exception was reproduced independently. + +Both real converters were executed by the rebuilt frozen backend against six preserved M8 input files, with no device access. All five generated files matched normal-Python reference bytes, completing together in 0.547 seconds in the first run. Only output sizes and pass/fail evidence appear in `verification/helper-real-m8.json`; private input files and Bluetooth addresses are excluded. Backend tests include an optimized-host regression, timeout/cancellation/errors, and the actual extraction-to-conversion path with simulated ADB. Browser regression verifies that structured activity clears stale transfer percentages within a stage. `verification/helpers-*.json` records the new package sizes and frozen-package checks. A real reinstall remains unperformed. + Each extracted folder contains `OpenWrt-Installer.exe`, compatible `OpenWrt-Installer.py`, bilingual `START-HERE.md`, Magisk root entries and subdirectories for tools/resources. The EXE must be kept with its package. `verification/windows-packages.json` contains actual frozen-backend/CLI results. Machine-readable per-archive size reports distinguish root GUI executable, host backend/tools (`tools/`, `scripts/`, `desktop/`), firmware payload (`files/` or `payload/`) and compressed ZIP bytes. Counts do not include build caches or development dependencies. +The newest-first log/restart/explicit-verification revision is in e5 `out/gui-releases/20261015-boot-confirm/` and MU300 `release/gui-20261015-boot-confirm/`. Use these paths for the latest build. Manual restart instructions remain above the scrolling content; phase 4 includes editable host/password and a boot-confirmation button. Multiple routers with the same default address cannot be disambiguated by clicking confirmation alone: the computer must reach the intended endpoint, whose CID is checked before root-device/capacity reads. Wrong-device/authentication/connection failures allow retargeting while the original worker keeps the device mutex. UI logs reverse whole entries, preserving multiline tracebacks; copied/exported diagnostics remain chronological. Tests use simulated SSH only; no device restart or installation was performed for this revision. Evidence uses `verification/boot-confirm-*.json` and `verification/ui-regression.json`. + See [build instructions](README.md), [user guide](GUIDE.md) and [protocol contract](PROTOCOL.md). + +The latest update/reboot/timer revision is in e5 `out/gui-releases/20261015-update-reboot/` and MU300 `release/gui-20261015-update-reboot/`. The prior version could verify the still-running old system during the three-second scheduled reboot delay. Update completion now requires a new boot UUID from the same CID before capacity reads, and committed updates resume verification without replaying uploads or writes. A missing pre-update boot UUID in an older saved update is reported explicitly rather than guessed. Plans, persistent progress guidance, notifications and update-specific results explain the automatic reboot. Completed/failed/paused clocks use saved phase bounds and do not keep ticking. Seven browser suites include these states; frozen-package simulation tests the old/new boot sequence for all five packages. This revision did not reboot, update or install any real device. Reports use `verification/update-reboot-*.json`. + +The latest reconnection correction is in e5 `out/gui-releases/20261015-reboot-wait/` and MU300 `release/gui-20261015-reboot-wait/`. Expected transport loss now keeps automatic update reboot in `waiting_device`, clears stale verification errors and shows a neutral restarting/reconnecting heading. The old generic connection warning is removed from this wait; DEBUG retains the transport exception. Authentication and wrong-device errors remain actionable. Unit tests cover five connection-loss types in both adapters and SSH loss during command reads; browser tests check neutral toasts, deduplication and editable controls. Frozen-package tests inject EOF and refusal before an old/new boot sequence. No hardware access was performed. Evidence uses `verification/reboot-wait-*.json`. diff --git a/installer/backend/adapter.py b/installer/backend/adapter.py index 0d15bfd2..ae9aee47 100644 --- a/installer/backend/adapter.py +++ b/installer/backend/adapter.py @@ -1,5 +1,5 @@ """Repository adapters call existing installation code, never frontend shell.""" -from contextlib import redirect_stdout, redirect_stderr +from contextlib import contextmanager, redirect_stdout, redirect_stderr import gzip import hashlib import importlib.util @@ -17,6 +17,7 @@ from types import SimpleNamespace from . import gpt from .state import Pending, RecoveryRequired, atomic_json, sha from .transport import Adb, push_chunks +from .diagnostics import DebugStream, traced def load(path, name): @@ -26,11 +27,14 @@ def load(path, name): return module -class Quiet(io.TextIOBase): - def write(self, text): - return len(text) - def flush(self): - pass +@contextmanager +def debug_output(context): + stream = DebugStream(context) + try: + with redirect_stdout(stream), redirect_stderr(stream): + yield + finally: + stream.flush() def args_for(record, directory): @@ -46,6 +50,25 @@ def args_for(record, directory): serial=record['device']['serial'], adb=None, host=choices.get('host')) +def installation_committed(record): + """Only final, verified effects can bypass the initial Android plan. + + A stage-one boot selection is not a final installation. Legacy two-stage + records must still use their geometry/token-aware resume implementation. + """ + method = record['choices']['method'] + if record.get('legacy') or record['plan'].get('method') != method: + return False + done = {name for name, value in record['effects'].items() if value['state'] == 'done'} + if method == 'update': + return 'update-commit' in done + if record['package']['adapter'] == 'e5': + return method in ('tf', 'part', 'image', 'boot') and 'misc-trial' in done + return record['package']['adapter'] == 'mu300' and ( + method == 'tf' and 'root-tf-write' in done or + method in ('part', 'reinstall', 'image') and any(name.startswith('boot-and-misc-') for name in done)) + + class Adapter: def __init__(self, package, context=None): self.package = package @@ -61,6 +84,19 @@ class Adapter: self.adb = None self.password = '' self.expected_ssh_key = None + if self.ctx: + if self.kind == 'e5': + original = self.legacy.adb + def observed(*args, **kwargs): + return traced(self.ctx, 'legacy ADB '+shlex.join(map(str,args)), + lambda:original(*args, **kwargs), output=True) + self.legacy.adb = observed + else: + original = self.legacy.Android.call + def observed(android, *args, **kwargs): + return traced(self.ctx, 'legacy ADB '+shlex.join(map(str,args)), + lambda:original(android, *args, **kwargs), output=False) + self.legacy.Android.call = observed def stage(self, stage, status='running', **details): if self.ctx: @@ -70,13 +106,21 @@ class Adapter: if self.ctx: self.ctx.transfer(name, done, total, since) + def run_tool(self, script, *arguments): + from .helpers import run_helper + return run_helper(self.ctx, self.root, script, arguments) + def action(self, name, operation, retry_safe=False): if not self.ctx: raise ValueError('Writes are unavailable during a probe') if self.ctx.record.get('legacy') and name in ('bootchain-sync', 'misc-trial'): state = json.loads(Path(self.ctx.record['legacy']).read_text(encoding='utf-8')) name += '-' + state.get('phase', state.get('state', 'unknown')) - return self.ctx.effect(name, operation, retry_safe=retry_safe) + result = self.ctx.effect(name, operation, retry_safe=retry_safe) + if name == 'update-commit': + self.stage('openwrt_boot','waiting_device',reboot_manually=False, + host=self.ctx.record['choices'].get('host')) + return result def saved(self, path, record): if self.ctx: @@ -98,7 +142,8 @@ class Adapter: def reboot(self): # Persist expected loss of transport BEFORE sending reboot. - self.stage('android_boot' if self.ctx.record['plan'].get('two_stage') else 'openwrt_boot', 'waiting_device') + self.stage('android_boot' if self.ctx.record['plan'].get('two_stage') else 'openwrt_boot', + 'waiting_device', reboot_manually=False) def push(self, call, shell, local, remote): return push_chunks(call, shell, local, remote, self.ctx) @@ -107,10 +152,19 @@ class Adapter: fingerprint = hashlib.sha256(client.get_transport().get_remote_server_key().asbytes()).hexdigest() if self.expected_ssh_key and fingerprint != self.expected_ssh_key: raise ValueError('SSH device identity changed / SSH 设备身份改变') + if self.ctx and self.ctx.record['choices']['method'] == 'update': + _, out, _ = client.exec_command('cat /proc/sys/kernel/random/boot_id', timeout=15) + boot_id = out.read().decode().strip() + if out.channel.recv_exit_status() or not re.fullmatch(r'[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}',boot_id): + raise ValueError('Cannot establish pre-update boot identity / 无法确认更新前的启动标识') + self.ctx.record['update_boot_id'] = boot_id + self.ctx.store.save(self.ctx.record) + self.stage('transfer_install') return fingerprint def bind(self, serial): self.adb = Adb(self.root, serial) + self.adb.context = self.ctx if self.kind == 'e5': self.legacy.ADB = self.adb.exe self.legacy.SERIAL = serial @@ -118,6 +172,8 @@ class Adapter: self.legacy.find_adb = lambda: None def probe(self, serial, method='part'): + if method not in ('tf', 'part', 'reinstall', 'image', 'boot'): + raise ValueError('Unsupported Android installation method / 不支持的 Android 安装方式') self.bind(serial) devices = self.adb.devices() entry = next((d for d in devices if d['serial'] == serial), None) @@ -159,8 +215,12 @@ class Adapter: 'echo SOURCE=$(awk \'$2=="/data" {print $1;exit}\' /proc/mounts); ' 'for u in /sys/class/block/${b}p*/uevent; do ' 'grep -qE "^PARTNAME=(e5root|mu300root)$" "$u" && { n=${u%/uevent}; echo ROOT=${n##*/}; } || true; done; ' - 'if [ -b /dev/block/mmcblk1p1 ]; then echo TF=/dev/block/mmcblk1p1; ' - 'elif [ -b /dev/block/mmcblk1 ]; then echo TF=/dev/block/mmcblk1; fi', root=True) + 'cards=""; for p in /sys/class/block/mmcblk*; do k=${p##*/}; ' + 'case $k in *p[0-9]*|*boot*) continue;; esac; ' + '[ "$k" = "$b" ] || cards="$cards $k"; done; ' + 'set -- $cards; if [ "$#" -eq 1 ]; then ' + 'if [ -b /dev/block/"${1}p1" ]; then echo TF=/dev/block/"${1}p1"; ' + 'elif [ -b /dev/block/"$1" ]; then echo TF=/dev/block/"$1"; fi; fi', root=True) storage = dict(line.split('=', 1) for line in text.splitlines() if '=' in line) if not re.fullmatch(r'mmcblk\d+p\d+', storage['NODE']) or not re.fullmatch('[a-f0-9]{32}', storage['CID']): raise ValueError('Cannot establish eMMC identity / 无法确认闪存身份') @@ -169,7 +229,9 @@ class Adapter: encrypted = properties['ro.crypto.state'] == 'encrypted' or properties['ro.crypto.type'] in ('file', 'block') or storage['SOURCE'].startswith(('/dev/block/dm-', '/dev/mapper/')) device.update(cid=storage['CID'], storage=storage, encrypted=encrypted, existing=bool(storage.get('ROOT')), tf=storage.get('TF'), userdata_bytes=storage['SIZE']*512, free_bytes=storage['FREE']*1024) - if storage.get('TF'): + # Other modes need only a read-only availability hint for recommendations. + # A removable card and its readable capacity are prerequisites only for TF. + if method == 'tf' and self.kind != 'e5' and storage.get('TF'): node = storage['TF'].rsplit('/', 1)[-1] device['tf_bytes'] = int(self.adb.shell('cat /sys/class/block/' + node + '/size', root=True).strip())*512 disk_node = re.sub(r'p\d+$', '', node) @@ -182,26 +244,23 @@ class Adapter: if method != 'boot': space = self.read_gpt(storage) device['gpt'] = {k: v for k, v in space.items() if k not in ('first', 'last')} - if self.kind == 'e5': + if self.kind == 'e5' and method == 'tf': # Reuse the existing internal-vs-removable selection policy. - try: - disk = self.legacy.device_sd() - node = disk.rsplit('/', 1)[-1] - if self.adb.shell('test -b '+disk+'p1; echo $?', root=True).strip() == '0': - target = disk+'p1' - else: - parts = self.adb.shell('ls /sys/class/block/'+node+'p* 2>/dev/null; true', root=True).strip() - if parts: raise ValueError('TF has partitions but no p1; cannot select the whole card') - target = disk - device['tf'] = target - device['tf_bytes'] = int(self.legacy.device_size(target)) - device['tf_identity'] = {'cid': self.adb.shell('cat /sys/class/block/'+node+'/device/cid', root=True).strip(), - 'sectors': device['tf_bytes']//512, - 'start': self.adb.shell('cat /sys/class/block/'+target.rsplit('/',1)[-1]+'/start 2>/dev/null || echo 0', root=True).strip()} - storage['TF'] = target - except SystemExit: - device['tf'] = None - storage.pop('TF', None) + # Do not catch discovery failures: TF must stop on missing/ambiguous cards. + disk = self.legacy.device_sd() + node = disk.rsplit('/', 1)[-1] + if self.adb.shell('test -b '+disk+'p1; echo $?', root=True).strip() == '0': + target = disk+'p1' + else: + parts = self.adb.shell('ls /sys/class/block/'+node+'p* 2>/dev/null; true', root=True).strip() + if parts: raise ValueError('TF has partitions but no p1; cannot select the whole card') + target = disk + device['tf'] = target + device['tf_bytes'] = int(self.legacy.device_size(target)) + device['tf_identity'] = {'cid': self.adb.shell('cat /sys/class/block/'+node+'/device/cid', root=True).strip(), + 'sectors': device['tf_bytes']//512, + 'start': self.adb.shell('cat /sys/class/block/'+target.rsplit('/',1)[-1]+'/start 2>/dev/null || echo 0', root=True).strip()} + storage['TF'] = target return device def read_gpt(self, storage): @@ -249,17 +308,12 @@ class Adapter: (destination/'gpt-first.bin').write_bytes(space['first']) (destination/'gpt-last.bin').write_bytes(space['last']) atomic_json(destination/'identity.json', device) - for name in ['misc'] + [f'{n}_{slot}' for n in ('boot', 'uboot', 'sml', 'teecfg', 'trustos', 'vbmeta') for slot in ('a', 'b')]: - self.ctx.boundary() - script = f'dd if=/dev/block/by-name/{name} bs=4096 count=1 2>/dev/null' if name == 'misc' else f'cat /dev/block/by-name/{name}' - data = self.adb.read(script) - if not data: - raise ValueError('Empty backup / 备份为空: ' + name) - (destination/(name+'.bin')).write_bytes(data) - expected = hashlib.sha256(data).hexdigest() - actual = self.adb.shell('(set -o pipefail; ' + script + ') | sha256sum', root=True, timeout=120).split()[0] - if expected != actual: - raise ValueError('Backup readback checksum mismatch / 备份回读校验失败: ' + name) + try: + for name in ['misc'] + [f'{n}_{slot}' for n in ('boot', 'uboot', 'sml', 'teecfg', 'trustos', 'vbmeta') for slot in ('a', 'b')]: + self.ctx.boundary() + self.adb.backup_partition(name, destination/(name+'.bin'), self.ctx) + finally: + self.adb.cleanup_backup(self.ctx) atomic_json(destination/'checksums.json', {p.name: sha(p) for p in destination.iterdir() if p.is_file() and p.name != 'checksums.json'}) self.ctx.record['completed'].append('backup') self.ctx.store.save(self.ctx.record) @@ -268,12 +322,14 @@ class Adapter: record = self.ctx.record choices = record['choices'] method = choices['method'] + if method not in ('tf', 'part', 'reinstall', 'image', 'boot', 'update') or record['plan'].get('method') != method: + raise RecoveryRequired('Installation method differs from the saved plan / 安装方式与已保存计划不一致,已停止') a = args_for(record, self.ctx.directory) if method != 'update': self.bind(record['device']['serial']) a.adb = self.adb.exe self.expected_ssh_key = record['device'].get('ssh_key') - with redirect_stdout(Quiet()), redirect_stderr(Quiet()): + with debug_output(self.ctx): if method == 'update': self.stage('transfer_install') if self.kind == 'e5': @@ -302,9 +358,7 @@ class Adapter: a.resume = True a.transaction = record['legacy'] return self.legacy.install(a, self.root, json.loads((self.root/'desktop/manifest.json').read_text())) - done = {name for name, value in record['effects'].items() if value['state'] == 'done'} - if (self.kind == 'e5' and 'misc-trial' in done or self.kind == 'mu300' and - ('root-tf-write' in done or any(name.startswith('boot-and-misc-') for name in done))): + if installation_committed(record): # Final selection is after image/root readback in the legacy # installers. A crash before the coordinator's next checkpoint # must only wait for boot, never replay the full entrypoint. diff --git a/installer/backend/diagnostics.py b/installer/backend/diagnostics.py new file mode 100644 index 00000000..6bf941fb --- /dev/null +++ b/installer/backend/diagnostics.py @@ -0,0 +1,61 @@ +"""Bounded, redacted diagnostic text; never used to drive installation state.""" +import io +import re +import threading +import time + + +def redact(text, secrets=()): + text = str(text) + for value in sorted({str(v) for v in secrets if v}, key=len, reverse=True): + text = text.replace(value, '[redacted]') + # Mask credentials even when a legacy helper creates its own settings. + text = re.sub(r"(?im)((?:[\w-]*(?:password|passwd|wifi_key|pwhash|token)|密码|密钥|key)\s*[:=]\s*)(?:'[^']*'|\"[^\"]*\"|[^\s;,]+)", + r'\1[redacted]', text) + text = re.sub(r'\b[a-fA-F0-9]{32}\b', '[redacted-id]', text) + # Strip terminal control sequences; these are text records, not a terminal. + return re.sub(r'\x1b\[[0-?]*[ -/]*[@-~]', '', text).replace('\x00', '') + + +class DebugStream(io.TextIOBase): + def __init__(self, context): + self.context = context + self.pending = '' + self.lock = threading.RLock() + + def write(self, value): + with self.lock:return self._write(value) + + def _write(self, value): + self.pending += value.replace('\r', '\n') + while '\n' in self.pending or len(self.pending) > 8192: + line, separator, rest = self.pending.partition('\n') + if not separator: + line, rest = self.pending[:8192], self.pending[8192:] + self.pending = rest + if line.strip():self.context.log(line, scope='legacy') + return len(value) + + def flush(self): + with self.lock: + if self.pending.strip():self.context.log(self.pending, scope='legacy') + self.pending = '' + + +def traced(context, label, operation, output=False): + if context is None:return operation() + context.activity(label) + context.log('BEGIN '+label, scope='transport') + started = time.monotonic() + try: + result = operation() + except BaseException as error: + context.log(f'FAILED {label}: {type(error).__name__}: {error} ({time.monotonic()-started:.2f}s)', + level='error', scope='transport') + raise + context.log(f'END {label} ({time.monotonic()-started:.2f}s)', scope='transport') + if output and isinstance(result, str) and result.strip(): + # Large base64/root-image output is not a useful CLI diagnostic. + if len(result) > 32768:context.log(f'Captured {len(result)} characters; tail:\n'+result[-4096:], scope='transport') + else:context.log(result, scope='transport') + return result diff --git a/installer/backend/helpers.py b/installer/backend/helpers.py new file mode 100644 index 00000000..10a94fc8 --- /dev/null +++ b/installer/backend/helpers.py @@ -0,0 +1,68 @@ +"""Allowlisted host converters with bounded execution and captured diagnostics.""" +from pathlib import Path +import subprocess +import sys +import time +import types + +from .diagnostics import traced +from .transport import hidden_process + + +def execute_script(path, arguments): + """Keep script docstrings/guards even when the sidecar uses -OO. + + Helpers are separate source files. Their semantics must not depend on the + optimization used to build the host executable. + """ + path = Path(path).resolve() + previous_main = sys.modules.get('__main__') + previous_argv, previous_path = sys.argv, sys.path[:] + module = types.ModuleType('__main__') + module.__file__ = str(path) + sys.modules['__main__'] = module + sys.argv = [str(path), *arguments] + sys.path.insert(0, str(path.parent)) + try: + exec(compile(path.read_bytes(), str(path), 'exec', optimize=0), module.__dict__) + finally: + sys.argv, sys.path[:] = previous_argv, previous_path + if previous_main is None:sys.modules.pop('__main__', None) + else:sys.modules['__main__'] = previous_main + + +def run_helper(context, package, script, arguments, timeout=120): + root = Path(package).resolve() + script = Path(script).resolve() + allowed = {root/'scripts/tools/sprd-bt-config.py', root/'scripts/tools/vbc-profile/vbc-profile.py'} + if script not in allowed or not script.is_file(): + raise ValueError('Unsupported firmware converter / 不支持的固件转换器') + context.boundary() + context.stage('firmware_convert', tool=script.name) + command = [sys.executable, *(['--run-tool'] if getattr(sys, 'frozen', False) else []), str(script), *map(str, arguments)] + def perform(): + process = subprocess.Popen(command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, **hidden_process()) + since = time.monotonic(); heartbeat = since + try: + while True: + context.boundary() + try: + output, _ = process.communicate(timeout=.2) + break + except subprocess.TimeoutExpired: + now = time.monotonic() + if now-since >= timeout: + raise TimeoutError(f'Firmware converter {script.name} exceeded {timeout}s / 固件转换超时') + if now-heartbeat >= 5: + context.log(f'{script.name}: running, {now-since:.0f}s elapsed', scope='helper') + heartbeat = now + if output: + context.log(output.decode('utf-8', 'replace')[-32768:], scope='helper') + if process.returncode: + detail = context.sanitize(output.decode('utf-8', 'replace')[-4000:]) + raise ValueError(f'Firmware converter {script.name} failed ({process.returncode}) / 固件转换失败:\n{detail}') + finally: + if process.poll() is None:process.kill() + process.communicate(timeout=5) + return traced(context, 'firmware converter '+script.name, perform) diff --git a/installer/backend/service.py b/installer/backend/service.py index 254fffab..a0c0bfb8 100644 --- a/installer/backend/service.py +++ b/installer/backend/service.py @@ -12,9 +12,10 @@ import shutil import sys import threading import time +import traceback import zipfile -from .adapter import Adapter +from .adapter import Adapter, installation_committed from .package import inspect_package from .state import Cancelled, Context, DeviceLock, Pending, RecoveryRequired, Store, compatible from .transport import Adb @@ -91,6 +92,9 @@ class Service: self.package = None self.adapters = Adapter self.stop = threading.Event() + self.verification_lock = threading.Lock() + self.verification_request = None + self.verification_wake = threading.Event() def emit(self, kind, data, request_id=None): event = {'protocol': 1, 'type': kind, 'data': data} @@ -120,7 +124,7 @@ class Service: if command == 'list': return [self.public(r) for r in self.store.list()] if command == 'cancel': - if self.active: + if self.active and self.worker and self.worker.is_alive(): self.active.cancel = True self.active.record['cancel_requested'] = True self.store.save(self.active.record) @@ -128,6 +132,39 @@ class Service: return {'accepted': False} if command == 'can_close': return not self.worker or not self.worker.is_alive() + if command == 'verify_openwrt': + context = self.active + if (not context or not self.worker or not self.worker.is_alive() or + p.get('transaction') != context.record['id'] or context.record['unsafe'] or + context.record['stage'] != 'openwrt_boot' or + context.record['status'] not in ('waiting_user','waiting_device')): + raise ValueError('OpenWrt verification is unavailable at this stage / 当前阶段不能确认 OpenWrt 启动') + host = p.get('host', '') + password = p.get('password', '') + if not isinstance(host,str) or not re.fullmatch(r'[A-Za-z0-9][A-Za-z0-9.-]{0,252}',host): + raise ValueError('Enter an IP address or hostname / 请输入 IP 地址或主机名') + if not isinstance(password,str) or len(password)>4096: + raise ValueError('Invalid SSH password / SSH 密码无效') + with self.verification_lock: + self.verification_request = (context.record['id'], host, password) + self.verification_wake.set() + return {'accepted':True} + if command == 'diagnostics': + record = self.store.load(p['transaction']) + ctx = Context(self.store, record, lambda *_:None) + header = {key:record.get(key) for key in ('version','revision','stage','status','choices','plan','completed','error')} + header['model'] = record['device'].get('model') + header['package'] = {key:record['package'].get(key) for key in ('adapter','profile','kernel','layout')} + parts = ['OpenWrt Installer diagnostics (redacted)\n'+ctx.sanitize(json.dumps(header,ensure_ascii=False,indent=2))] + for name in ('debug.previous.ndjson','debug.ndjson'): + path = ctx.directory/name + if path.is_file(): + with path.open('rb') as stream: + size = stream.seek(0, 2) + stream.seek(max(0, size-512*1024)) + parts.append(name+'\n'+stream.read().decode('utf-8','replace')) + if len(parts)==1:parts.append('This older transaction has no debug log. Retry with the current installer to record detailed diagnostics.') + return {'text':'\n\n'.join(parts)} if self.worker and self.worker.is_alive() and command not in ('export',): raise ValueError('An operation is active / 任务正在执行') if command == 'package': @@ -172,12 +209,16 @@ class Service: raise ValueError('This plan has not been confirmed / 此计划尚未确认') self.store.save(record) context = Context(self.store, record, self.emit) + context.private.append(p.get('password', '')) adapter = self.adapter(current, context) adapter.password = p.get('password', '') context.cancel = False record['cancel_requested'] = False record['error'] = None self.active = context + with self.verification_lock: + self.verification_request = None + self.verification_wake.clear() self.worker = threading.Thread(target=self.run, args=(context, adapter), daemon=False) self.worker.start() return self.public(record) @@ -225,12 +266,13 @@ class Service: client.connect(host, username='root', password=p.get('password', ''), timeout=12, auth_timeout=15, look_for_keys=False, allow_agent=False) key = hashlib.sha256(client.get_transport().get_remote_server_key().asbytes()).hexdigest() - def read(script): + def read_bytes(script): _, out, err = client.exec_command(script, timeout=15) - data = out.read().decode('utf-8', 'replace').strip() + data = out.read() if out.channel.recv_exit_status(): raise ValueError('OpenWrt preflight failed / OpenWrt 预检失败') return data + def read(script):return read_bytes(script).decode('utf-8','replace').strip() if read('id -u') != '0': raise ValueError('SSH root required') kind = self.package['adapter'] @@ -241,11 +283,10 @@ class Service: if not re.fullmatch('[a-f0-9]{32}', cid): raise ValueError('Cannot establish OpenWrt eMMC identity') capacity = int(read("df -Pk / | awk 'END {print $2}'"))*1024 - import base64 root_dev = read('cat /run/mu300/disk-dev' if kind == 'mu300' else "readlink -f $(awk '$2==\"/\" {print $1}' /proc/mounts | tail -1)") if re.fullmatch(r'/dev/(?:block/)?(?:mmcblk\d+(?:p\d+)?|loop\d+)', root_dev): - raw = base64.b64decode(read(f'dd if={root_dev} bs=1024 skip=1 count=1 2>/dev/null | base64')) + raw = read_bytes(f'dd if={root_dev} bs=1024 skip=1 count=1 2>/dev/null') capacity = verify_ext4_capacity(raw, 0) return dict(serial='ssh:'+key, cid=cid, ssh_key=key, host=host, profile=profile, model=profile.upper(), system='OpenWrt', slot=read('cat /run/mu300/linux-slot') if kind == 'mu300' else 'B', @@ -259,7 +300,8 @@ class Service: with ExitStack() as locks: for identity in sorted({r['device']['serial'], r['device']['cid']}): locks.enter_context(DeviceLock(self.store.base, identity)) - if r['stage'] == 'openwrt_boot': + if r['stage'] in ('openwrt_boot', 'verify_capacity') or installation_committed(r): + self.openwrt_wait_stage(context) return self.wait_openwrt(context, adapter) if r.get('legacy'): self.wait_android(context, adapter) @@ -282,13 +324,14 @@ class Service: if result is not None and getattr(result, 'state', '') == 'pending' and r.get('legacy'): self.wait_android(context, adapter) result = adapter.execute() - context.stage('openwrt_boot', 'waiting_device', reboot_manually=True) + self.openwrt_wait_stage(context) self.wait_openwrt(context, adapter) except Cancelled: context.stage(r['stage'], 'cancelled') except BaseException as error: - message = str(error)[:2000] if isinstance(error, (ValueError, RecoveryRequired)) else \ - 'Operation interrupted; keep backups and retry from the saved record / 操作中断,请保留备份并从记录续装' + context.private.append(adapter.password) + context.log(''.join(traceback.format_exception(error)), level='error', scope='exception') + message = context.sanitize(f'{type(error).__name__}: {error}')[:2000] for private in (r['device'].get('serial'), r['device'].get('cid'), adapter.password, r.get('secrets', {}).get('wifi_key')): if private: message = message.replace(private, '[redacted]') @@ -320,6 +363,19 @@ class Service: if self.stop.wait(3): raise Cancelled() + def openwrt_wait_stage(self, context, error=None, connection_state=None): + r = context.record + # These entrypoints send their own reboot request. The other install + # paths finish after verified writes and explicitly leave reboot to the user. + manual = r['choices']['method'] != 'update' and not ( + r['package']['adapter'] == 'e5' and r['choices']['method'] == 'boot') + manual = manual and not r.get('openwrt_confirmed',False) + host = r['choices'].get('host') or ('192.168.9.1' if r['package']['adapter'] == 'e5' else + '192.168.78.1' if r['device']['profile'] == 'u30air' else '192.168.77.1') + context.stage('openwrt_boot', 'waiting_user' if manual or error else 'waiting_device', + host=host, reboot_manually=manual, boot_confirmed=bool(r.get('openwrt_confirmed')), + verification_error=error, connection_state=connection_state) + def wait_openwrt(self, context, adapter): import paramiko r = context.record @@ -328,30 +384,53 @@ class Service: # No network/interface changes and no automatic hotspot connection. while True: context.boundary() + with self.verification_lock: + pending = self.verification_request + self.verification_request = None + self.verification_wake.clear() + if pending and pending[0] == r['id']: + _, host, adapter.password = pending + context.private.append(adapter.password) + r['choices']['host'] = host + r['openwrt_confirmed'] = True + self.openwrt_wait_stage(context) + context.log('User confirmed OpenWrt boot; checking the selected management address', scope='verification') client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: client.connect(host, username='root', password=adapter.password or 'root', timeout=5, auth_timeout=5, look_for_keys=False, allow_agent=False) - def read(script): + def read_bytes(script): _, out, _ = client.exec_command(script, timeout=15) - value = out.read().decode().strip() - if out.channel.recv_exit_status(): + value = out.read() + status = out.channel.recv_exit_status() + if status < 0: + raise EOFError('SSH closed before a command exit status was received') + if status: raise ValueError('Final verification command failed') return value + def read(script):return read_bytes(script).decode().strip() cid = read('cat /sys/class/block/mmcblk0/device/cid') if cid != r['device']['cid']: raise RecoveryRequired('Management address belongs to another device / 管理地址对应另一台设备') + if r['choices']['method'] == 'update': + before = r.get('update_boot_id') + if not before: + raise ValueError('Update record lacks pre-update boot evidence; automatic completion cannot be verified / 旧更新记录缺少重启前标识,无法自动确认更新完成,请保留记录人工复核') + boot_id = read('cat /proc/sys/kernel/random/boot_id') + if not re.fullmatch(r'[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}',boot_id): + raise ValueError('Cannot verify post-update boot identity / 无法校验更新后的启动标识') + if boot_id == before: + raise Pending() context.stage('verify_capacity') - # Read superblock via SSH base64; no od/SFTP dependency. - import base64 + # SSH exec preserves raw stdout bytes; no encoding/od/SFTP. if r['package']['adapter'] == 'e5': dev = read("readlink -f $(awk '$2==\"/\" {print $1}' /proc/mounts | tail -1)") else: dev = read('cat /run/mu300/disk-dev') if not re.fullmatch(r'/dev/(?:block/)?(?:mmcblk\d+(?:p\d+)?|loop\d+)', dev): raise ValueError('Cannot identify installed root block device') - raw = base64.b64decode(read(f'dd if={dev} bs=1024 skip=1 count=1 2>/dev/null | base64')) + raw = read_bytes(f'dd if={dev} bs=1024 skip=1 count=1 2>/dev/null') capacity = verify_ext4_capacity(raw, r['plan']['openwrt_bytes'] if r['plan'].get('grow', True) else 0) # Mounted and usable, not just a larger partition entry. read('test -s /etc/openwrt_release && test -x /sbin/init') @@ -360,14 +439,29 @@ class Service: 'temporary': r['choices']['method'] == 'boot'} context.stage('complete', 'completed') return - except (RecoveryRequired, ValueError): + except Pending: + # The old runtime can still answer during the scheduled reboot + # delay. It is not proof that the new system has started. + self.openwrt_wait_stage(context) + except RecoveryRequired as error: + # The default address can belong to another router. Keep all + # writes blocked, but let the user select the intended endpoint. + self.openwrt_wait_stage(context, str(error)) + except ValueError: raise - except (OSError, EOFError, paramiko.SSHException): - context.stage('openwrt_boot', 'waiting_device', host=host, reboot_manually=True) + except paramiko.AuthenticationException: + self.openwrt_wait_stage(context, 'SSH authentication failed; check the root password / SSH 认证失败,请核对 root 密码') + except (OSError, EOFError, paramiko.SSHException) as error: + # Transport loss is expected during restart, including refused + # connections, missing interfaces, timeouts and SSH EOF. Keep + # retrying without a user-facing warning or arbitrary deadline. + context.log(f'Waiting for OpenWrt reconnection: {type(error).__name__}: {error}', scope='reconnect') + self.openwrt_wait_stage(context, connection_state='reconnecting') finally: client.close() - if self.stop.wait(4): - raise Cancelled() + for _ in range(40): + if self.verification_wake.is_set():break + if self.stop.wait(.1):raise Cancelled() def verify_ext4_capacity(superblock, expected): @@ -392,8 +486,8 @@ def main(): a = p.parse_args() output = sys.stdout service = Service(a.package_root, Store(a.data_dir), output) - # Legacy prints are suppressed at the source; service replies always use - # this captured protocol stream, even while legacy code redirects stdout. + # Legacy prints become sanitized diagnostic events; protocol replies use + # this captured stream even while legacy code redirects stdout. for line in sys.stdin: if len(line) > 1024*1024: continue @@ -403,7 +497,11 @@ def main(): value = service.dispatch(request) service.emit('response', {'ok': True, 'result': value}, request.get('id')) except Exception as error: - service.emit('response', {'ok': False, 'error': str(error)[:2000]}, request.get('id')) + from .diagnostics import redact + params = request.get('params', {}) + private = [params.get(key) for key in ('serial','password')] if isinstance(params,dict) else [] + message = redact(f'{type(error).__name__}: {error}',private)[:2000] + service.emit('response', {'ok': False, 'error': message}, request.get('id')) # EOF requests safe cancellation; never kill a storage operation. if service.active: service.active.cancel = True diff --git a/installer/backend/state.py b/installer/backend/state.py index 82000135..ace7c5da 100644 --- a/installer/backend/state.py +++ b/installer/backend/state.py @@ -6,8 +6,10 @@ import os from pathlib import Path import re import tempfile +import threading import time import uuid +from .diagnostics import redact VERSION = 1 TERMINAL = {'completed', 'cancelled'} @@ -101,6 +103,7 @@ class Store: return self.base / 'transactions' / tid def save(self, record): + record['revision'] = record.get('revision', 0) + 1 record['updated'] = time.time() atomic_json(self.directory(record['id']) / 'transaction.json', record) @@ -145,6 +148,15 @@ class Context: self.store, self.record, self.emit = store, record, emit self.cancel = False self.clock = time.monotonic() + self.private = [] + self.log_lock = threading.Lock() + self.last_transfer = {} + if record.get('legacy'): + try: + old = json.loads(Path(record['legacy']).read_text(encoding='utf-8')) + self.private.extend(old.get(key) for key in ('key','token','password') if old.get(key)) + except (OSError,ValueError): + pass @property def directory(self): @@ -170,17 +182,34 @@ class Context: return out def stage(self, stage, status='running', **details): + now = time.time() + previous = self.record + phase_changed = stage != previous['stage'] or details.get('tool') != previous.get('details',{}).get('tool') + resumed = previous['status'] in ('ready','failed','cancelled') and status in ('running','waiting_user','waiting_device') + if (phase_changed and stage != 'complete') or resumed: + previous['stage_started_at'] = now + elif 'stage_started_at' not in previous: + previous['stage_started_at'] = previous.get('updated',now) + if status in ('completed','failed','cancelled'): + previous['stage_finished_at'] = now + else: + previous.pop('stage_finished_at',None) self.record.update(stage=stage, status=status, details=details) self.store.save(self.record) self.snapshot() + self.log(f'STAGE {stage} / {status}', scope='state') def boundary(self): if self.cancel or self.record.get('cancel_requested'): raise Cancelled() + def activity(self, name): + self.emit('activity', {'name':self.sanitize(name)}) + def effect(self, name, operation, *, retry_safe=False): entry = self.record['effects'].get(name) if entry and entry['state'] == 'done': + self.log('SKIP verified effect: '+name, scope='effect') return entry.get('result') if entry and not retry_safe: raise RecoveryRequired('Interrupted write requires readback / 写入中断,必须复核: ' + name) @@ -189,6 +218,7 @@ class Context: self.record['unsafe'] = not retry_safe self.store.save(self.record) self.snapshot() + self.log('BEGIN effect: '+name, scope='effect') result = operation() self.record['effects'][name] = {'state': 'done', 'time': time.time(), 'result': result} self.record['unsafe'] = False @@ -196,10 +226,12 @@ class Context: self.record['completed'].append(name) self.store.save(self.record) self.snapshot() + self.log('VERIFIED effect: '+name, scope='effect') self.boundary() return result def legacy_record(self, path, value): + self.private.extend(value.get(key) for key in ('key','token','password') if value.get(key)) self.record['legacy'] = str(Path(path).resolve()) self.record['legacy_phase'] = value.get('phase', value.get('state')) self.store.save(self.record) @@ -207,12 +239,28 @@ class Context: def transfer(self, name, done, total, since): self.emit('transfer', dict(name=name, bytes=done, total=total, bytes_per_second=done / max(time.monotonic() - since, .001))) + previous = self.last_transfer.get(name) + if previous is None or done == total or done < previous or done-previous >= 8*1024*1024: + self.last_transfer[name] = done + self.log(f'TRANSFER {name}: {done}/{total} bytes, {done/max(time.monotonic()-since,.001):.0f} bytes/s',scope='transfer') - def log(self, message): - # Legacy stdout can contain hotspot credentials, SMS or raw identifiers. - # It is intentionally not forwarded. Only named structured events log. - safe = str(message) - for value in (self.record['device'].get('serial'), self.record['device'].get('cid')): - if value: - safe = safe.replace(value, '[redacted]') - self.emit('log', {'time': time.time(), 'message': safe[:2000]}) + def sanitize(self, message): + device = self.record.get('device', {}) + return redact(message, [device.get('serial'), device.get('cid'), device.get('ssh_key'), + *self.record.get('secrets', {}).values(), *self.private]) + + def log(self, message, level='debug', scope='backend'): + event = {'time':time.time(), 'level':level, 'scope':scope, + 'stage':self.record['stage'], 'message':self.sanitize(message)[:32768]} + # Persist diagnostics across application restarts. Logging failure must + # never interrupt a partition write or hide the original exception. + try: + with self.log_lock: + path = self.directory/'debug.ndjson' + if path.exists() and path.stat().st_size > 4*1024*1024: + os.replace(path, self.directory/'debug.previous.ndjson') + with path.open('a', encoding='utf-8') as stream: + stream.write(json.dumps(event, ensure_ascii=False)+'\n') + except OSError: + pass + self.emit('log', event) diff --git a/installer/backend/transport.py b/installer/backend/transport.py index 49404ac2..e32aaf2f 100644 --- a/installer/backend/transport.py +++ b/installer/backend/transport.py @@ -1,14 +1,15 @@ """Serial-bound ADB operations. Frontend never supplies shell text.""" -import base64 import os from pathlib import Path import re +import secrets import shlex import shutil import subprocess import time from .state import sha +from .diagnostics import traced def hidden_process(): @@ -23,15 +24,20 @@ class Adb: if not self.exe: raise ValueError('ADB is missing from tools / 安装包缺少 ADB 工具') self.su = None + self.context = None + self.backup_staging = None def call(self, *args, timeout=20, check=True): cmd = [self.exe] if self.serial and args[0] != 'devices': cmd += ['-s', self.serial] - result = subprocess.run(cmd + list(args), capture_output=True, timeout=timeout, **hidden_process()) - if check and result.returncode: - raise ConnectionError('ADB connection interrupted / ADB 连接中断') - return result.stdout.decode('utf-8', 'replace').replace('\r', '') + def perform(): + result = subprocess.run(cmd + list(args), capture_output=True, timeout=timeout, **hidden_process()) + if check and result.returncode: + detail = (result.stderr or result.stdout).decode('utf-8', 'replace')[-4000:].strip() + raise ConnectionError('ADB command failed / ADB 命令失败'+(': '+detail if detail else '')) + return result.stdout.decode('utf-8', 'replace').replace('\r', '') + return traced(self.context, 'ADB '+shlex.join(list(args)), perform, output=True) def devices(self): result = [] @@ -68,8 +74,96 @@ class Adb: return 'root_permission' if found else 'magisk' def read(self, script): - encoded = self.shell('set -o pipefail; ' + script + ' | base64', root=True, timeout=120) - return base64.b64decode(''.join(encoded.split()), validate=True) + """Small binary metadata reads; partition backups use dd + adb pull.""" + if self.su is None:raise ValueError('Root has not been verified / 尚未验证 root') + command=(self.su+' -c ' if self.su else 'sh -c ')+shlex.quote('stty raw -echo -onlcr 2>/dev/null || true; '+script) + args=[self.exe]+(['-s',self.serial] if self.serial else [])+['exec-out',command] + def perform(): + result=subprocess.run(args,capture_output=True,timeout=45,**hidden_process()) + if result.returncode or not result.stdout: + raise ConnectionError('ADB metadata read failed / ADB 元数据读取失败') + return result.stdout + return traced(self.context,'ADB metadata read '+script,perform) + + def _backup_directory(self, context, total): + free=int(self.shell("df -Pk /data/local/tmp | tail -n1 | awk '{print $4}'").strip())*1024 + if freetotal:raise ValueError('Backup is larger than the selected partition / 备份大小超出分区范围') + if received!=previous: + last_change=time.monotonic();previous=received + context.transfer('backup/'+name,received,total,since) + if finished: + if process.returncode: + raise ConnectionError('ADB pull failed / ADB 拉取失败: '+err.decode('utf-8','replace')[-2000:]) + context.log(out.decode('utf-8','replace')+err.decode('utf-8','replace'),scope='adb-pull') + if received!=total:raise ValueError('Incomplete backup / 备份文件不完整: '+name) + return + if time.monotonic()-last_change>45: + raise TimeoutError('ADB pull received no data for 45 seconds / ADB 拉取 45 秒未收到数据') + finally: + if process.poll() is None:process.kill() + process.communicate(timeout=5) + + def backup_partition(self, name, destination, context): + if not re.fullmatch(r'(misc|(?:boot|uboot|sml|teecfg|trustos|vbmeta)_[ab])',name): + raise ValueError('Unsupported backup partition') + source='/dev/block/by-name/'+name + total=4096 if name=='misc' else int(self.shell('blockdev --getsize64 '+source,root=True).strip()) + if total<=0:raise ValueError('Invalid backup partition size: '+name) + remote=self._backup_directory(context,total)+'/'+name+'.img' + local=Path(str(destination)+'.partial') + context.log(f'Backing up {name}: {total} bytes; device dd -> adb pull',scope='backup') + try: + command=f'dd if={source} of={remote} bs=4M' + if name=='misc':command=f'dd if={source} of={remote} bs=4096 count=1' + self.shell('set -e; umask 077; '+command+'; chmod 644 '+remote,root=True,timeout=120) + expected=self.shell('sha256sum '+remote,root=True,timeout=120).split()[0] + original=f'dd if={source} bs=4096 count=1 2>/dev/null' if name=='misc' else 'cat '+source + actual=self.shell('(set -o pipefail; '+original+') | sha256sum',root=True,timeout=120).split()[0] + if not re.fullmatch('[a-f0-9]{64}',expected) or expected!=actual: + raise ValueError('Device backup checksum mismatch / 设备临时备份校验失败: '+name) + self._pull_backup(remote,local,total,name,context) + if sha(local)!=expected:raise ValueError('Computer backup checksum mismatch / 电脑备份校验失败: '+name) + with local.open('r+b') as stream:os.fsync(stream.fileno()) + os.replace(local,destination) + context.log(f'Backup verified: {name}, {total} bytes, SHA256 {expected}',scope='backup') + finally: + try:self.shell('rm -f '+remote,root=True) + except Exception as error:context.log('Backup staging cleanup: '+str(error),level='warning',scope='backup') + if local.exists():local.unlink() + + def cleanup_backup(self, context): + if not self.backup_staging:return + try: + self.shell('rmdir '+self.backup_staging) + context.record.pop('backup_staging',None) + context.store.save(context.record) + self.backup_staging=None + except Exception as error: + context.log('Backup staging directory cleanup: '+str(error),level='warning',scope='backup') def properties(self): names = ('ro.product.model', 'ro.product.device', 'ro.board.platform', 'ro.boot.slot_suffix', diff --git a/installer/backend_entry.py b/installer/backend_entry.py index 1f23aa5d..f93f90b4 100644 --- a/installer/backend_entry.py +++ b/installer/backend_entry.py @@ -1,7 +1,6 @@ """Frozen NDJSON entry; no console window is created by the Tauri host.""" import argparse from pathlib import Path -import runpy import sys from backend.service import main @@ -12,8 +11,8 @@ for stream in (sys.stdin, sys.stdout, sys.stderr): if __name__ == '__main__': if len(sys.argv) > 2 and sys.argv[1] == '--run-tool': tool = sys.argv[2] - sys.argv = [tool, *sys.argv[3:]] - runpy.run_path(tool, run_name='__main__') + from backend.helpers import execute_script + execute_script(tool, sys.argv[3:]) elif '--cli' in sys.argv: from backend.adapter import load parser = argparse.ArgumentParser(add_help=False) diff --git a/installer/screenshots/automatic-restart-log-en.png b/installer/screenshots/automatic-restart-log-en.png new file mode 100644 index 00000000..124616cc Binary files /dev/null and b/installer/screenshots/automatic-restart-log-en.png differ diff --git a/installer/screenshots/backup-progress-debug-zh.png b/installer/screenshots/backup-progress-debug-zh.png new file mode 100644 index 00000000..1c33aa5d Binary files /dev/null and b/installer/screenshots/backup-progress-debug-zh.png differ diff --git a/installer/screenshots/complete-dark-en.png b/installer/screenshots/complete-dark-en.png index a6d4825b..b55fcec5 100644 Binary files a/installer/screenshots/complete-dark-en.png and b/installer/screenshots/complete-dark-en.png differ diff --git a/installer/screenshots/failure-copy-diagnostics-zh.png b/installer/screenshots/failure-copy-diagnostics-zh.png new file mode 100644 index 00000000..72052449 Binary files /dev/null and b/installer/screenshots/failure-copy-diagnostics-zh.png differ diff --git a/installer/screenshots/firmware-convert-debug-zh.png b/installer/screenshots/firmware-convert-debug-zh.png new file mode 100644 index 00000000..9828c15b Binary files /dev/null and b/installer/screenshots/firmware-convert-debug-zh.png differ diff --git a/installer/screenshots/help-recovery-light-zh.png b/installer/screenshots/help-recovery-light-zh.png index dc5f5dd3..9f4f67ac 100644 Binary files a/installer/screenshots/help-recovery-light-zh.png and b/installer/screenshots/help-recovery-light-zh.png differ diff --git a/installer/screenshots/help-small-dark-en.png b/installer/screenshots/help-small-dark-en.png index 282b6694..75100050 100644 Binary files a/installer/screenshots/help-small-dark-en.png and b/installer/screenshots/help-small-dark-en.png differ diff --git a/installer/screenshots/home-light-zh.png b/installer/screenshots/home-light-zh.png index 8055f698..43917779 100644 Binary files a/installer/screenshots/home-light-zh.png and b/installer/screenshots/home-light-zh.png differ diff --git a/installer/screenshots/install-activity-debug-zh.png b/installer/screenshots/install-activity-debug-zh.png new file mode 100644 index 00000000..9a38c031 Binary files /dev/null and b/installer/screenshots/install-activity-debug-zh.png differ diff --git a/installer/screenshots/install-small-light-zh.png b/installer/screenshots/install-small-light-zh.png index 8831289b..66959e78 100644 Binary files a/installer/screenshots/install-small-light-zh.png and b/installer/screenshots/install-small-light-zh.png differ diff --git a/installer/screenshots/manual-restart-log-zh.png b/installer/screenshots/manual-restart-log-zh.png new file mode 100644 index 00000000..e2c65c74 Binary files /dev/null and b/installer/screenshots/manual-restart-log-zh.png differ diff --git a/installer/screenshots/native-home.png b/installer/screenshots/native-home.png index 12a04bd1..a926097d 100644 Binary files a/installer/screenshots/native-home.png and b/installer/screenshots/native-home.png differ diff --git a/installer/screenshots/no-device-refresh-light-zh.png b/installer/screenshots/no-device-refresh-light-zh.png new file mode 100644 index 00000000..6ba982ea Binary files /dev/null and b/installer/screenshots/no-device-refresh-light-zh.png differ diff --git a/installer/screenshots/onboarding-light-zh.png b/installer/screenshots/onboarding-light-zh.png index 2fd01c50..916bad29 100644 Binary files a/installer/screenshots/onboarding-light-zh.png and b/installer/screenshots/onboarding-light-zh.png differ diff --git a/installer/screenshots/onboarding-small-dark-en.png b/installer/screenshots/onboarding-small-dark-en.png index fcf150b4..b8814519 100644 Binary files a/installer/screenshots/onboarding-small-dark-en.png and b/installer/screenshots/onboarding-small-dark-en.png differ diff --git a/installer/screenshots/openwrt-endpoint-mismatch-zh.png b/installer/screenshots/openwrt-endpoint-mismatch-zh.png new file mode 100644 index 00000000..ee95cdda Binary files /dev/null and b/installer/screenshots/openwrt-endpoint-mismatch-zh.png differ diff --git a/installer/screenshots/plan-light-zh.png b/installer/screenshots/plan-light-zh.png index db92177a..cb16868e 100644 Binary files a/installer/screenshots/plan-light-zh.png and b/installer/screenshots/plan-light-zh.png differ diff --git a/installer/screenshots/plan-small-dark-en.png b/installer/screenshots/plan-small-dark-en.png index 8284377b..640db930 100644 Binary files a/installer/screenshots/plan-small-dark-en.png and b/installer/screenshots/plan-small-dark-en.png differ diff --git a/installer/screenshots/reinstall-no-card-plan-zh.png b/installer/screenshots/reinstall-no-card-plan-zh.png new file mode 100644 index 00000000..c265bea7 Binary files /dev/null and b/installer/screenshots/reinstall-no-card-plan-zh.png differ diff --git a/installer/screenshots/resume-small-light-zh.png b/installer/screenshots/resume-small-light-zh.png index 09654f11..0104465a 100644 Binary files a/installer/screenshots/resume-small-light-zh.png and b/installer/screenshots/resume-small-light-zh.png differ diff --git a/installer/screenshots/update-complete-clock-en.png b/installer/screenshots/update-complete-clock-en.png new file mode 100644 index 00000000..d25ff32b Binary files /dev/null and b/installer/screenshots/update-complete-clock-en.png differ diff --git a/installer/screenshots/update-reboot-zh.png b/installer/screenshots/update-reboot-zh.png new file mode 100644 index 00000000..e8183398 Binary files /dev/null and b/installer/screenshots/update-reboot-zh.png differ diff --git a/installer/screenshots/update-reconnecting-zh.png b/installer/screenshots/update-reconnecting-zh.png new file mode 100644 index 00000000..190d4b7a Binary files /dev/null and b/installer/screenshots/update-reconnecting-zh.png differ diff --git a/installer/screenshots/wait-root-dark-en.png b/installer/screenshots/wait-root-dark-en.png index 87b0c8d6..78c3c825 100644 Binary files a/installer/screenshots/wait-root-dark-en.png and b/installer/screenshots/wait-root-dark-en.png differ diff --git a/installer/screenshots/wait-setup-light-zh.png b/installer/screenshots/wait-setup-light-zh.png index ff7e70f9..5d8f4ba5 100644 Binary files a/installer/screenshots/wait-setup-light-zh.png and b/installer/screenshots/wait-setup-light-zh.png differ diff --git a/installer/tests/diagnostics_smoke.py b/installer/tests/diagnostics_smoke.py new file mode 100644 index 00000000..dc584a6f --- /dev/null +++ b/installer/tests/diagnostics_smoke.py @@ -0,0 +1,109 @@ +"""Debug-log controls, diagnostic copying and honest progress presentation.""" +from playwright.sync_api import sync_playwright +from ui_smoke import BRIDGE,ROOT,layout,settle + + +def main(): + with sync_playwright() as p: + browser=p.chromium.launch() + context=browser.new_context(viewport={'width':800,'height':650}) + context.add_init_script(BRIDGE+"localStorage.setItem('onboarding-v1','seen');") + page=context.new_page();errors=[] + page.on('pageerror',lambda e:errors.append(str(e))) + page.goto('http://127.0.0.1:1420') + page.evaluate("Object.defineProperty(navigator.clipboard,'writeText',{configurable:true,value:async(text)=>{window.__copied=text}})") + page.get_by_role('button',name='继续未完成的安装',exact=False).click();settle(page) + page.get_by_role('button',name='确认安装计划',exact=True).click();settle(page) + page.get_by_role('checkbox').check() + page.get_by_role('button',name='确认并开始').click();settle(page) + toggle=page.get_by_role('button',name='详细日志',exact=False) + assert toggle.get_attribute('aria-expanded')=='true' + def event(kind,data): + page.evaluate('''({kind,data})=>window.__fixture.callbacks.get(window.__fixture.event)({event:'backend',id:1,payload:{type:kind,data}})''',{'kind':kind,'data':data}) + page.evaluate("window.__emitFixture({stage:'backup',status:'running',revision:10})") + event('log',{'level':'debug','scope':'backup','message':'Backing up boot_a: 67108864 bytes; 1 MiB chunks'}) + event('transfer',{'name':'backup/boot_a','bytes':33554432,'total':67108864,'bytes_per_second':1048576}) + settle(page);layout(page) + progress=page.locator('progress') + assert progress.get_attribute('value')=='33554432' and progress.get_attribute('max')=='67108864' + assert page.locator('.transfer').get_by_text('50%',exact=True).count()==1 + assert '[DEBUG] [backup] Backing up boot_a' in page.locator('.log-panel pre').inner_text() + event('log',{'level':'debug','scope':'order','message':'OLDER-BLOCK\nolder detail'}) + event('log',{'level':'debug','scope':'order','message':'NEWER-BLOCK\nnewer detail'}) + settle(page) + text=page.locator('.log-panel pre').inner_text() + assert text.index('NEWER-BLOCK')el.scrollTop')==0 + page.screenshot(path=str(ROOT/'screenshots/backup-progress-debug-zh.png')) + event('transfer',{'name':'android-bootchain.sh','bytes':2048,'total':2048,'bytes_per_second':1024}) + settle(page) + assert page.locator('.transfer').get_by_text('100%',exact=True).count()==1 + event('activity',{'name':'checking firmware'}) + settle(page) + assert page.locator('progress').count()==0 + page.evaluate("window.__emitFixture({stage:'firmware_convert',status:'running',revision:11,details:{tool:'vbc-profile.py'}})") + settle(page);layout(page) + assert page.locator('h1').inner_text()=='转换本机音频与蓝牙固件' + assert page.locator('.activity').get_by_text('m8-openwrt-gui-1.0.0',exact=True).count()==0 + assert page.locator('.activity').get_by_text('e5-openwrt-release · vbc-profile.py',exact=True).count()==1 + page.screenshot(path=str(ROOT/'screenshots/firmware-convert-debug-zh.png')) + toggle.click();settle(page) + assert page.locator('.log-panel pre').count()==0 + toggle.click();settle(page) + assert '[DEBUG] [backup]' in page.locator('.log-panel pre').inner_text() + page.evaluate("window.__emitFixture({stage:'transfer_install',status:'running',revision:12,details:{}})") + settle(page) + bar=page.get_by_role('progressbar',name='当前阶段进度') + assert bar.get_attribute('aria-valuenow') is None + assert page.locator('progress').count()==0 + assert page.get_by_text('此操作没有可靠百分比,正在显示真实阶段与耗时。',exact=True).count()==1 + page.screenshot(path=str(ROOT/'screenshots/install-activity-debug-zh.png')) + page.evaluate("window.__emitFixture({stage:'openwrt_boot',status:'waiting_user',revision:13,details:{host:'192.168.9.1',reboot_manually:true}})") + settle(page);layout(page) + assert page.locator('h1').inner_text()=='请现在手动重启设备' + guidance=page.locator('.boot-guidance') + assert '已开始重启或已进入 OpenWrt' in guidance.inner_text() + box=guidance.bounding_box() + assert box['y']>=page.locator('header').bounding_box()['height'] and box['y']+box['height']c.command==='verify_openwrt').at(-1).params")=={'transaction':'a'*32,'host':'192.168.9.22','password':'fixture-private'} + assert page.locator('h1').inner_text()=='请现在手动重启设备' + page.evaluate("window.__emitFixture({stage:'openwrt_boot',status:'waiting_user',revision:14,details:{host:'192.168.9.22',boot_confirmed:true,reboot_manually:false,verification_error:'Management address belongs to another device / 管理地址对应另一台设备'}})") + settle(page);layout(page) + assert '另一台设备' in page.locator('.verification-error').inner_text() + assert page.get_by_label('设备管理 IP / 主机名').input_value()=='192.168.9.22' + assert page.get_by_role('button',name='我已进入 OpenWrt,开始校验',exact=True).is_enabled() + before=guidance.bounding_box() + page.locator('.page-scroll').evaluate('(el)=>el.scrollTop=el.scrollHeight') + assert guidance.bounding_box()==before + page.screenshot(path=str(ROOT/'screenshots/openwrt-endpoint-mismatch-zh.png')) + page.get_by_label('语言').select_option('en');page.get_by_label('Theme').select_option('dark') + page.evaluate("window.__emitFixture({stage:'openwrt_boot',status:'waiting_device',revision:15,details:{host:'192.168.9.1',reboot_manually:false}})") + settle(page);layout(page) + assert page.locator('h1').inner_text()=='Waiting for OpenWrt to start' + assert 'automatic restart was requested' in guidance.inner_text() + assert page.get_by_text('Newest entries first',exact=True).count()==1 + page.screenshot(path=str(ROOT/'screenshots/automatic-restart-log-en.png')) + page.get_by_label('Language').select_option('zh');page.get_by_label('主题').select_option('light') + page.evaluate("window.__emitFixture({stage:'backup',status:'failed',revision:16,error:{message:'TimeoutExpired: backup boot_a timed out after 120 seconds',retryable:true,code:'operation_failed'}})") + event('log',{'level':'error','scope':'exception','message':'Traceback: TimeoutExpired in backup_partition'}) + settle(page);layout(page) + page.get_by_role('button',name='复制诊断信息给开发者',exact=True).click();settle(page) + assert 'DEBUG fixture diagnostics' in page.evaluate('window.__copied') + assert page.evaluate("window.__fixture.requests.includes('diagnostics')") + assert page.get_by_text('日志已复制',exact=True).count()==1 + page.screenshot(path=str(ROOT/'screenshots/failure-copy-diagnostics-zh.png')) + page.get_by_label('语言').select_option('en');page.get_by_label('Theme').select_option('dark');settle(page);layout(page) + assert page.get_by_role('button',name='Copy diagnostics for the developer').count()==1 + assert not errors,errors + browser.close() + print('Diagnostics smoke passed: newest-first multiline logs, pinned manual/automatic restart guidance with logs expanded at 800x650, persistent collapse/reopen, real byte progress, honest activity, traceback copying and bounded bilingual layout') + + +if __name__=='__main__':main() diff --git a/installer/tests/enumeration_smoke.py b/installer/tests/enumeration_smoke.py new file mode 100644 index 00000000..960fe3f7 --- /dev/null +++ b/installer/tests/enumeration_smoke.py @@ -0,0 +1,35 @@ +"""Read-only ADB enumeration through a real bundled backend before package checks.""" +import argparse +import json +from pathlib import Path +import subprocess +import tempfile + + +def check(package): + package=Path(package).resolve() + with tempfile.TemporaryDirectory(prefix='openwrt-enumeration-') as directory: + commands=['hello','devices','devices','list'] + requests=''.join(json.dumps({'protocol':1,'id':i,'command':command,'params':{}})+'\n' for i,command in enumerate(commands)) + result=subprocess.run([str(package/'tools/backend/openwrt-backend.exe'),'--package-root',str(package),'--data-dir',directory],input=requests.encode('utf-8'),capture_output=True,timeout=90) + events=[json.loads(line) for line in result.stdout.decode('utf-8').splitlines()] + if result.returncode or len(events)!=4 or not all(event['data']['ok'] for event in events): + raise RuntimeError('Bundled enumeration failed: '+package.name) + lists=[event['data']['result'] for event in events[1:3]] + if not all(isinstance(values,list) for values in lists):raise AssertionError('Expected device lists') + # Device identity remains private; report only count and transport state. + row={'package':package.name,'commands':commands,'verified_package_required':False, + 'device_counts':[len(values) for values in lists], + 'states':[[device['state'] for device in values] for values in lists], + 'device_writes':False} + print(package.name+': enumeration passed, counts='+str(row['device_counts']),flush=True) + return row + + +if __name__=='__main__': + parser=argparse.ArgumentParser(description=__doc__) + parser.add_argument('packages',nargs='+',type=Path) + parser.add_argument('--report',type=Path) + args=parser.parse_args() + rows=[check(package) for package in args.packages] + if args.report:args.report.write_text(json.dumps(rows,indent=2)+'\n',encoding='utf-8') diff --git a/installer/tests/frozen_flow_smoke.py b/installer/tests/frozen_flow_smoke.py new file mode 100644 index 00000000..cacb6d52 --- /dev/null +++ b/installer/tests/frozen_flow_smoke.py @@ -0,0 +1,234 @@ +"""Exercise the actual shipped Python coordinator/backup code with fake transports.""" +import json +from pathlib import Path +import subprocess +import sys + +def child(package): + if not getattr(sys, 'frozen', False): + raise AssertionError('Frozen check failed') + import hashlib + import io + import shlex + import struct + import tempfile + from types import SimpleNamespace + import paramiko + import backend.transport as transport + from backend.service import Service + from backend.state import Context, Store + from backend.package import inspect_package + package_info = inspect_package(package) + cid = 'b' * 32 + serial = 'simulated-only' + data = bytes(range(256)) * 4096 + rows = [] + with tempfile.TemporaryDirectory() as directory: + store = Store(directory) + device = {'serial': serial, 'cid': cid, 'profile': package_info['profile'], 'model': 'Simulated device'} + record = store.create(package_info, device, {'method': 'reinstall'}, {'method': 'reinstall', 'openwrt_bytes': 4 << 30, 'grow': True}) + context = Context(store, record, lambda *_: None) + adb = transport.Adb.__new__(transport.Adb) + adb.exe = 'fixture-adb' + adb.serial = serial + adb.su = 'su' + adb.context = context + adb.backup_staging = None + files = {} + calls = [] + + def shell(command, **kwargs): + calls.append(command) + if command.startswith('blockdev'): + return str(len(data)) + if command.startswith('df '): + return str(1024 * 1024) + if command.startswith('umask 077; mkdir '): + return '' + if command.startswith('set -e; umask 077; dd '): + target = next((word[3:] for word in command.split() if word.startswith('of='))).rstrip(';') + files[target] = data + return '' + if command.startswith('sha256sum '): + return hashlib.sha256(files[shlex.split(command)[1]]).hexdigest() + ' file' + if command.startswith('(set -o pipefail; cat '): + return hashlib.sha256(data).hexdigest() + ' file' + if command.startswith('rm -f '): + files.pop(shlex.split(command)[2], None) + return '' + if command.startswith('rmdir '): + return '' + raise AssertionError('Unexpected simulated command') + + class Pull: + returncode = 0 + + def __init__(self, args, **kwargs): + if not args[:4] == ['fixture-adb', '-s', serial, 'pull']: + raise AssertionError('Frozen check failed') + Path(args[-1]).write_bytes(files[args[-2]]) + + def communicate(self, **kwargs): + return (b'1 file pulled', b'') + + def poll(self): + return 0 + adb.shell = shell + original = transport.subprocess.Popen + try: + transport.subprocess.Popen = Pull + destination = Path(directory) / 'boot_a.bin' + adb.backup_partition('boot_a', destination, context) + adb.cleanup_backup(context) + if not (destination.read_bytes() == data and (not files)): + raise AssertionError('Frozen check failed') + if not not any(('base64' in call or 'gzip' in call for call in calls)): + raise AssertionError('Frozen check failed') + finally: + transport.subprocess.Popen = original + rows.append('device dd -> adb pull, full hash and staging cleanup') + service = Service(package, store, io.StringIO()) + superblock = bytearray(1024) + superblock[56:58] = b'S\xef' + struct.pack_into('=record['stage_started_at']: + raise AssertionError('Terminal phase time not saved') + events=[json.loads(line) for line in service.output.getvalue().splitlines()] + reconnects=[e['data'] for e in events if e['type']=='transaction' and e['data'].get('details',{}).get('connection_state')=='reconnecting'] + if len(reconnects)!=2 or any(r['status']!='waiting_device' or r['details'].get('verification_error') for r in reconnects): + raise AssertionError('Expected restart disconnect became a warning or failure') + rows.append('committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen') + diagnostics = service.dispatch({'protocol': 1, 'command': 'diagnostics', 'params': {'transaction': record['id']}})['text'] + if not '"level": "debug"' in diagnostics: + raise AssertionError('Frozen check failed') + if not (serial not in diagnostics and cid not in diagnostics): + raise AssertionError('Frozen check failed') + if not ('Backup verified' in diagnostics and 'verify_capacity' in diagnostics): + raise AssertionError('Frozen check failed') + rows.append('persistent redacted diagnostic sharing') + print(json.dumps({'package': package.name, 'frozen_backend': True, 'simulated_transport': True, 'checks': rows, 'hardware_access': False})) +if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == '--child': + child(Path(sys.argv[2]).resolve()) + else: + import argparse + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('packages', nargs='+', type=Path) + parser.add_argument('--report', type=Path) + parser.add_argument('--backend', type=Path) + args = parser.parse_args() + rows = [] + for package in args.packages: + backend = args.backend.resolve() if args.backend else package.resolve() / 'tools/backend/openwrt-backend.exe' + result = subprocess.run([str(backend), '--run-tool', str(Path(__file__).resolve()), '--child', str(package.resolve())], capture_output=True, timeout=60) + if result.returncode: + raise RuntimeError(result.stderr.decode('utf-8')) + rows.append(json.loads(result.stdout.decode('utf-8'))) + print(package.name + ': frozen backup/recovery/diagnostics passed', flush=True) + if args.report: + args.report.write_text(json.dumps(rows, indent=2) + '\n', encoding='utf-8') diff --git a/installer/tests/frozen_method_smoke.py b/installer/tests/frozen_method_smoke.py new file mode 100644 index 00000000..1b6a3156 --- /dev/null +++ b/installer/tests/frozen_method_smoke.py @@ -0,0 +1,82 @@ +"""Run no-card probes through the actual frozen backend, with simulated ADB only.""" +import json +from pathlib import Path +import subprocess +import sys + +def child(package): + if not getattr(sys, 'frozen', False): + raise AssertionError('Run this check through the frozen backend') + from backend.adapter import Adapter + from backend.service import plan_install + mu = (package / 'desktop/manifest.json').is_file() + meta = {'path': str(package), 'adapter': 'mu300' if mu else 'e5'} + a = Adapter(meta) + model = 'MU300' if mu else a.legacy.package_profile()['android_models'][0] + calls = [] + + class Transport: + su = 'su' + + def devices(self): + return [{'serial': 'test-device', 'state': 'device'}] + + def properties(self): + return {'ro.product.model': model, 'ro.product.device': 'F50', 'ro.board.platform': 'ums9620', 'ro.boot.slot_suffix': '_a', 'ro.boot.verifiedbootstate': 'orange', 'ro.crypto.state': 'unencrypted', 'ro.crypto.type': '', 'sys.boot_completed': '1'} + + def root_status(self): + return 'ready' + + def shell(self, script, root=False): + if script == 'cat /proc/sys/kernel/random/boot_id': + return 'test-boot' + if script == 'settings get secure user_setup_complete': + return '1' + if script.startswith('set -e; d='): + return 'NODE=mmcblk1p16\nCID=' + 'b' * 32 + '\nSTART=2048\nSIZE=33554432\nDISK_SIZE=134217728\nFREE=12582912\nSOURCE=/dev/block/mmcblk1p16\nROOT=mmcblk1p20\n' + if script == 'cat /sys/class/block/mmcblk1p20/start /sys/class/block/mmcblk1p20/size': + return '33556480 8388608' + raise AssertionError('Unexpected simulated read') + + def missing_card(): + calls.append('sd') + raise ValueError('expected one SD card, found 0 (none): is a card in the slot?') + a.adb = Transport() + a.bind = lambda _serial: None + a.read_gpt = lambda _storage: {'empty': [1], 'safe_gaps': []} + a.legacy.device_sd = missing_card + for method in ('part', 'reinstall', 'image', 'boot'): + device = a.probe('test-device', method) + if not (device['existing'] and device['root']): + raise AssertionError('Frozen check failed') + plan = plan_install(meta, device, {'method': 'reinstall', 'grow': True}) + if not (plan['method'] == 'reinstall' and plan['target'] == 'mmcblk1p20' and (plan['openwrt_bytes'] == 4 << 30) and (not plan['wipe'])): + raise AssertionError('Frozen check failed') + if not not calls: + raise AssertionError('Frozen check failed') + try: + target = a.probe('test-device', 'tf') + plan_install(meta, target, {'method': 'tf'}) + except ValueError: + pass + else: + raise AssertionError('Missing card must block TF installation') + print(json.dumps({'package': package.name, 'frozen_backend': True, 'simulated_transport': True, 'non_tf_probes': ['part', 'reinstall', 'image', 'boot'], 'reinstall_target': plan['target'], 'reinstall_bytes': plan['openwrt_bytes'], 'tf_missing_card_rejected': True, 'hardware_access': False})) +if __name__ == '__main__': + if len(sys.argv) > 1 and sys.argv[1] == '--child': + child(Path(sys.argv[2]).resolve()) + else: + import argparse + p = argparse.ArgumentParser(description=__doc__) + p.add_argument('packages', nargs='+', type=Path) + p.add_argument('--report', type=Path) + args = p.parse_args() + rows = [] + for package in args.packages: + result = subprocess.run([str(package.resolve() / 'tools/backend/openwrt-backend.exe'), '--run-tool', str(Path(__file__).resolve()), '--child', str(package.resolve())], capture_output=True, timeout=30) + if result.returncode: + raise RuntimeError(result.stderr.decode('utf-8')) + rows.append(json.loads(result.stdout.decode('utf-8'))) + print(package.name + ': actual frozen backend method isolation passed', flush=True) + if args.report: + args.report.write_text(json.dumps(rows, indent=2) + '\n', encoding='utf-8') diff --git a/installer/tests/method_smoke.py b/installer/tests/method_smoke.py new file mode 100644 index 00000000..c38ea470 --- /dev/null +++ b/installer/tests/method_smoke.py @@ -0,0 +1,62 @@ +"""Verify explicit UI methods survive probing, review and back navigation.""" +from playwright.sync_api import sync_playwright +from ui_smoke import BRIDGE, ROOT, settle + + +def last(page,command): + return page.evaluate('(command)=>window.__fixture.calls.filter(call=>call.command===command).at(-1).params',command) + + +def main(): + with sync_playwright() as p: + browser=p.chromium.launch() + context=browser.new_context(viewport={'width':1120,'height':900}) + context.add_init_script(BRIDGE+"localStorage.setItem('onboarding-v1','seen');window.__fixture.probed={existing:true,tf:null};") + page=context.new_page();errors=[] + page.on('pageerror',lambda error:errors.append(str(error))) + page.goto('http://127.0.0.1:1420') + page.get_by_role('button',name='高级选项',exact=False).click();settle(page) + button=page.get_by_role('button',name='重装已有内置分区',exact=False) + assert button.get_attribute('aria-pressed')=='true' + page.get_by_role('button',name='校验安装包',exact=True).click() + page.get_by_label('请选择设备').select_option('fixture-1234') + page.get_by_role('button',name='检查设备',exact=True).click();settle(page) + assert last(page,'probe')['method']=='reinstall' + page.get_by_role('button',name='查看安装计划',exact=True).click();settle(page) + assert last(page,'plan')['choices']['method']=='reinstall' + assert page.locator('.plan-list').get_by_text('重装已有内置分区',exact=True).count()==1 + assert page.locator('.plan-list').get_by_text('mmcblk1p20',exact=True).count()==1 + assert page.get_by_text('已有 OpenWrt 系统与设置会被替换,Android 用户数据保留。',exact=True).count()==1 + assert page.get_by_role('button',name='确认并开始',exact=True).is_disabled() + page.screenshot(path=str(ROOT/'screenshots/reinstall-no-card-plan-zh.png')) + page.get_by_role('button',name='返回',exact=True).click();settle(page) + assert page.locator('h1').inner_text()=='高级选项' + assert button.get_attribute('aria-pressed')=='true' + page.get_by_role('button',name='检查设备',exact=True).click();settle(page) + assert last(page,'probe')['method']=='reinstall' + page.get_by_role('button',name='返回',exact=True).click();settle(page) + # A present card must never replace an explicit internal choice. + for method,label,existing in [('part','独立内置分区',False),('reinstall','重装已有内置分区',True),('tf','TF 卡',False)]: + page.evaluate('(existing)=>window.__fixture.probed={existing,tf:"/dev/block/mmcblk0p1"}',existing) + page.get_by_role('button',name='安装 OpenWrt',exact=False).click();settle(page) + choice=page.get_by_role('button',name=label,exact=False);choice.click() + page.get_by_role('button',name='检查设备',exact=True).click();settle(page) + assert last(page,'probe')['method']==method + assert choice.get_attribute('aria-pressed')=='true' + page.get_by_role('button',name='查看安装计划',exact=True).click();settle(page) + assert last(page,'plan')['choices']['method']==method + page.get_by_role('button',name='返回',exact=True).click();settle(page) + assert choice.get_attribute('aria-pressed')=='true' + page.get_by_role('button',name='返回',exact=True).click();settle(page) + page.get_by_role('button',name='高级选项',exact=False).click();settle(page) + page.get_by_role('button',name='userdata 镜像',exact=True).click() + page.get_by_role('button',name='检查设备',exact=True).click();settle(page) + assert last(page,'probe')['method']=='image' + assert page.get_by_role('button',name='userdata 镜像',exact=True).get_attribute('aria-pressed')=='true' + assert not errors,errors + assert not {'start','resume','retry','cancel'} & set(page.evaluate('window.__fixture.requests')) + print('Method smoke passed: no-card reinstall, explicit part/reinstall/TF/image preserved, exact probe/plan parameters, review target/impact and return-to-origin; no device writes') + browser.close() + + +if __name__=='__main__':main() diff --git a/installer/tests/ordering_smoke.py b/installer/tests/ordering_smoke.py new file mode 100644 index 00000000..e5d6a47a --- /dev/null +++ b/installer/tests/ordering_smoke.py @@ -0,0 +1,40 @@ +"""Exercise out-of-order checkpoints and saved unconfirmed plans in the UI.""" +from playwright.sync_api import sync_playwright +from ui_smoke import BRIDGE, settle + + +def main(): + with sync_playwright() as p: + browser=p.chromium.launch() + context=browser.new_context(viewport={'width':800,'height':650}) + context.add_init_script(BRIDGE+"localStorage.setItem('onboarding-v1','seen');window.__fixture.startRace=true;") + page=context.new_page();errors=[] + page.on('pageerror',lambda error:errors.append(str(error))) + page.goto('http://127.0.0.1:1420') + page.get_by_role('button',name='继续未完成的安装',exact=False).click();settle(page) + assert page.locator('.record').get_by_text('独立内置分区 · ••••1234',exact=True).count()==1 + page.get_by_role('button',name='确认安装计划',exact=True).click();settle(page) + assert page.get_by_role('button',name='确认并开始').is_disabled() + assert not {'start','resume','retry'} & set(page.evaluate('window.__fixture.requests')) + page.get_by_role('button',name='返回',exact=True).click();settle(page) + assert page.locator('h1').inner_text()=='继续未完成的安装' + page.get_by_role('button',name='确认安装计划',exact=True).click();settle(page) + page.get_by_role('checkbox').check() + page.get_by_role('button',name='确认并开始').click() + page.get_by_role('heading',name='OpenWrt 已安装并通过校验',exact=True).wait_for();settle(page) + # A late request response and arbitrarily late events must not undo completion. + for i in range(20): + page.evaluate("window.__emitFixture({stage:'root_permission',status:'waiting_user',revision:1})") + settle(page) + assert page.locator('h1').inner_text()=='OpenWrt 已安装并通过校验' + assert page.get_by_role('button',name='在安全边界暂停',exact=True).count()==0 + page.evaluate("window.__emitFixture({stage:'root_permission',status:'waiting_user',revision:3});window.__fixture.cancelAccepted=false") + page.get_by_role('button',name='在安全边界暂停',exact=True).click();settle(page) + assert page.get_by_text('已请求暂停,将在安全边界生效。',exact=True).count()==0 + assert page.evaluate("window.__fixture.calls.filter(c=>c.command==='start').length")==1 + assert not errors,errors + browser.close() + print('Ordering smoke passed: saved plans require confirmation, no stale response/event regression, 20 late events ignored, rejected pause has no success toast') + + +if __name__=='__main__':main() diff --git a/installer/tests/refresh_smoke.py b/installer/tests/refresh_smoke.py new file mode 100644 index 00000000..b254a520 --- /dev/null +++ b/installer/tests/refresh_smoke.py @@ -0,0 +1,86 @@ +"""Device enumeration remains available without a package; text selection is scoped.""" +from playwright.sync_api import sync_playwright +from ui_smoke import BRIDGE, ROOT, layout, settle + + +def selection(page,selector,expected): + assert page.locator(selector).first.evaluate('(el)=>getComputedStyle(el).userSelect')==expected,selector + + +def main(): + with sync_playwright() as p: + browser=p.chromium.launch() + context=browser.new_context(viewport={'width':800,'height':650}) + context.add_init_script(BRIDGE+"window.__fixture.devices=[];localStorage.setItem('onboarding-v1','seen');") + page=context.new_page();errors=[] + page.on('pageerror',lambda error:errors.append(str(error))) + page.goto('http://127.0.0.1:1420') + page.get_by_role('button',name='安装 OpenWrt',exact=False).click();settle(page) + refresh=page.get_by_role('button',name='刷新设备',exact=True) + assert refresh.is_enabled() + assert page.get_by_role('button',name='检查设备',exact=True).is_disabled() + assert page.get_by_role('button',name='查看安装计划',exact=True).is_disabled() + assert 'package' not in page.evaluate('window.__fixture.requests') + for _ in range(3): + refresh.click();settle(page) + assert refresh.is_enabled() + assert page.get_by_label('请选择设备').locator('option:checked').inner_text()=='未发现设备' + selection(page,'h1','none');selection(page,'.stepper','none');selection(page,'.ui-button','none') + selection(page,'.file-path','text') + page.screenshot(path=str(ROOT/'screenshots/no-device-refresh-light-zh.png')) + # A transient enumeration failure clears stale readiness and leaves retry available. + page.evaluate("window.__fixture.fail='devices'") + refresh.click() + page.get_by_text('Error: Fixture: operation rejected',exact=True).wait_for();settle(page) + assert refresh.is_enabled() + selection(page,'.toast-description','text') + page.evaluate("window.__fixture.fail=null;window.__fixture.devices=[{serial:'second-5678',state:'unauthorized',label:'Other'}, {serial:'chosen-1234',state:'device',label:'E5'}]") + refresh.click();settle(page) + assert page.get_by_label('请选择设备').input_value()=='' + page.get_by_label('请选择设备').select_option('chosen-1234') + assert page.get_by_role('button',name='检查设备',exact=True).is_disabled() + assert 'probe' not in page.evaluate('window.__fixture.requests') + page.get_by_role('button',name='校验安装包',exact=True).click() + page.get_by_role('button',name='检查设备',exact=True).click();settle(page) + assert page.get_by_role('button',name='查看安装计划',exact=True).is_enabled() + selection(page,'.device-card small','none');selection(page,'.device-card strong','text') + # Refresh invalidates old root inspection; no-device response cannot leave install enabled. + page.evaluate('window.__fixture.devices=[]') + refresh.click();settle(page) + assert page.get_by_label('请选择设备').input_value()=='' + assert page.locator('.device-card').count()==0 + assert page.get_by_role('button',name='查看安装计划',exact=True).is_disabled() + page.evaluate("window.__fixture.devices=[{serial:'single-1234',state:'unauthorized',label:'E5'}]") + refresh.click();settle(page) + assert page.get_by_label('请选择设备').input_value()=='single-1234' + assert '等待调试授权' in page.get_by_label('请选择设备').locator('option:checked').inner_text() + page.get_by_role('button',name='详细日志',exact=False).click();settle(page) + selection(page,'.log-toggle','none');selection(page,'.log-panel pre','text') + page.locator('.log-panel pre').dblclick(position={'x':95,'y':20}) + assert page.evaluate('getSelection().toString().length')>0 + page.evaluate('getSelection().removeAllRanges()') + page.locator('h1').dblclick() + assert page.evaluate('getSelection().toString()')=='' + page.get_by_role('button',name='详细日志',exact=False).click();settle(page) + page.get_by_role('button',name='返回',exact=True).click();settle(page) + for name in ['高级选项','临时启动已安装的 OpenWrt']: + page.get_by_role('button',name=name,exact=False).click();settle(page) + assert refresh.is_enabled() + page.get_by_role('button',name='返回',exact=True).click();settle(page) + page.get_by_label('语言').select_option('en') + page.get_by_role('button',name='Advanced options',exact=False).click();settle(page) + page.locator('.page-scroll').evaluate('(el)=>el.scrollTop=el.scrollHeight') + page.get_by_role('button',name='Userdata image',exact=True).click() + selection(page,'input[type=number]','text') + page.get_by_role('button',name='Help and user guide',exact=True).click();settle(page) + page.get_by_role('dialog').get_by_role('button',name='Connection and troubleshooting',exact=True).click() + selection(page,'.help-article>h2','none');selection(page,'.help-markdown p','text') + selection(page,'.help-topics button','none') + page.keyboard.press('Escape');settle(page);layout(page) + assert not errors,errors + assert not {'plan','start','cancel','resume','retry'} & set(page.evaluate('window.__fixture.requests')) + print('Refresh smoke passed: unverified package, repeated empty-list retry, error retry, multiple/unauthorized devices, stale-root clearing, install/advanced/boot pages, bounded layout and selective copying; no device writes') + browser.close() + + +if __name__=='__main__':main() diff --git a/installer/tests/run_ui.py b/installer/tests/run_ui.py new file mode 100644 index 00000000..9cb22920 --- /dev/null +++ b/installer/tests/run_ui.py @@ -0,0 +1,52 @@ +"""Run all production-bundle browser checks with an owned, temporary server.""" +import json +from pathlib import Path +import socket +import subprocess +import sys +import tempfile +import time +from urllib.request import urlopen + +ROOT=Path(__file__).resolve().parents[1] +CHECKS=('ui_smoke','help_smoke','refresh_smoke','method_smoke','ordering_smoke','diagnostics_smoke','update_smoke') + + +def main(): + if not (ROOT/'ui/dist/index.html').is_file(): + raise SystemExit('Build the production frontend first: npm run build in installer/ui') + # Never attach tests to, or terminate, somebody else's running application. + with socket.socket() as check: + check.bind(('127.0.0.1',1420)) + results=[] + with tempfile.TemporaryFile() as log: + server=subprocess.Popen([sys.executable,'-m','http.server','1420','--bind','127.0.0.1', + '--directory',str(ROOT/'ui/dist')],stdout=log,stderr=log) + try: + deadline=time.monotonic()+15 + while True: + if server.poll() is not None:raise RuntimeError('Test server exited') + try: + with urlopen('http://127.0.0.1:1420',timeout=1) as response: + if response.status==200:break + except OSError: + if time.monotonic()>deadline:raise RuntimeError('Test server did not start') + time.sleep(.1) + for name in CHECKS: + result=subprocess.run([sys.executable,'-X','utf8',str(ROOT/'tests'/(name+'.py'))], + capture_output=True,timeout=180) + row={'test':name,'exit':result.returncode,'output':result.stdout.decode('utf-8'), + 'error':result.stderr.decode('utf-8')} + results.append(row) + print(name+(': PASS' if result.returncode==0 else ': FAIL'),flush=True) + if result.returncode:print(row['error'],flush=True) + finally: + server.terminate() + server.wait(timeout=10) + report=ROOT/'verification/ui-regression.json' + report.parent.mkdir(exist_ok=True) + report.write_text(json.dumps(results,indent=2,ensure_ascii=False)+'\n',encoding='utf-8') + return 1 if any(row['exit'] for row in results) else 0 + + +if __name__=='__main__':raise SystemExit(main()) diff --git a/installer/tests/test_backup.py b/installer/tests/test_backup.py new file mode 100644 index 00000000..8ee608bf --- /dev/null +++ b/installer/tests/test_backup.py @@ -0,0 +1,116 @@ +"""Device dd -> adb pull backup tests; transport and device files are simulated.""" +import hashlib +from pathlib import Path +import re +import shlex +import subprocess +import sys +import tempfile +import unittest +from unittest.mock import patch + +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from backend.state import Context,Store,Cancelled +from backend.transport import Adb + + +class Pull: + def __init__(self,args,data,corrupt=False): + self.args=args;self.path=Path(args[-1]);self.data=data;self.steps=0 + self.returncode=None;self.killed=False;self.corrupt=corrupt + def communicate(self,timeout=None): + if self.killed:return b'',b'cancelled' + self.steps+=1 + if self.steps==1: + self.path.write_bytes(self.data[:len(self.data)//2]) + raise subprocess.TimeoutExpired(self.args,timeout) + if self.steps==2:self.path.write_bytes((b'X'+self.data[1:]) if self.corrupt else self.data) + self.returncode=0 + return b'1 file pulled',b'' + def poll(self):return self.returncode + def kill(self):self.killed=True;self.returncode=-1 + + +class Backup(unittest.TestCase): + def setUp(self): + self.temp=tempfile.TemporaryDirectory();self.store=Store(self.temp.name) + self.record=self.store.create({}, {}, {}, {}) + self.events=[];self.ctx=Context(self.store,self.record,lambda k,d:self.events.append((k,d))) + with patch('backend.transport.shutil.which',return_value='adb'):self.adb=Adb('.', 'selected') + self.adb.su='su';self.adb.context=self.ctx + self.data=bytes(range(256))*8192+b'last sector' + self.target=Path(self.temp.name)/'boot_a.bin' + self.remote={};self.commands=[];self.process=None;self.corrupt=False + + def tearDown(self):self.temp.cleanup() + + def shell(self,script,**_): + self.commands.append(script) + if script.startswith('blockdev'):return str(len(self.data)) + if script.startswith('df '):return str(1024*1024) + if script.startswith('umask 077; mkdir '):return '' + if script.startswith('set -e; umask 077; dd '): + match=re.search(r'of=(\S+)',script) + self.remote[match[1]]=self.data;return '' + if script.startswith('sha256sum '):return hashlib.sha256(self.remote[shlex.split(script)[1]]).hexdigest()+' file' + if script.startswith('(set -o pipefail; cat '):return hashlib.sha256(self.data).hexdigest()+' -' + if script.startswith('rm -f '):self.remote.pop(shlex.split(script)[2],None);return '' + if script.startswith('rmdir '):return '' + self.fail('Unexpected backup command: '+script) + + def popen(self,args,**_): + self.assertEqual(args[:4],['adb','-s','selected','pull']) + self.assertTrue(args[4].startswith('/data/local/tmp/openwrt-backup-')) + self.process=Pull(args,self.remote[args[4]],self.corrupt) + return self.process + + def run_backup(self): + with patch.object(self.adb,'shell',side_effect=self.shell),patch('backend.transport.subprocess.Popen',side_effect=self.popen): + try:self.adb.backup_partition('boot_a',self.target,self.ctx) + finally:self.adb.cleanup_backup(self.ctx) + + def test_stages_in_private_android_directory_and_pulls_with_true_progress(self): + self.run_backup() + self.assertEqual(self.target.read_bytes(),self.data) + events=[d for k,d in self.events if k=='transfer'] + self.assertEqual([d['bytes'] for d in events],[len(self.data)//2,len(self.data)]) + self.assertTrue(all(d['total']==len(self.data) for d in events)) + self.assertFalse(self.remote) + self.assertTrue(any('chmod 644 ' in command for command in self.commands)) + self.assertFalse(any('base64' in command or 'gzip' in command for command in self.commands)) + self.assertNotIn('backup_staging',self.record) + + def test_bad_download_preserves_existing_backup_and_cleans_staging(self): + self.target.write_bytes(b'existing verified backup');self.corrupt=True + with self.assertRaisesRegex(ValueError,'Computer backup checksum'):self.run_backup() + self.assertEqual(self.target.read_bytes(),b'existing verified backup') + self.assertFalse(Path(str(self.target)+'.partial').exists()) + self.assertFalse(self.remote) + + def test_cancel_kills_only_readonly_pull_and_cleans_partial_files(self): + def emit(kind,data): + if kind=='transfer':self.ctx.cancel=True + self.ctx.emit=emit + with self.assertRaises(Cancelled):self.run_backup() + self.assertTrue(self.process.killed) + self.assertFalse(self.target.exists()) + self.assertFalse(self.remote) + + def test_low_staging_space_stops_before_dd(self): + def shell(script,**kwargs): + if script.startswith('df '):return '1' + return self.shell(script,**kwargs) + with patch.object(self.adb,'shell',side_effect=shell): + with self.assertRaisesRegex(ValueError,'staging space'):self.adb.backup_partition('boot_a',self.target,self.ctx) + self.assertFalse(any('dd if=' in command for command in self.commands)) + + def test_metadata_read_is_binary_and_serial_bound(self): + result=type('Result',(),{'returncode':0,'stdout':self.data,'stderr':b''})() + with patch('backend.transport.subprocess.run',return_value=result) as run: + self.assertEqual(self.adb.read('bounded read'),self.data) + args=run.call_args.args[0] + self.assertEqual(args[:4],['adb','-s','selected','exec-out']) + self.assertNotIn('base64',args[-1]) + + +if __name__=='__main__':unittest.main() diff --git a/installer/tests/test_diagnostics.py b/installer/tests/test_diagnostics.py new file mode 100644 index 00000000..41b24113 --- /dev/null +++ b/installer/tests/test_diagnostics.py @@ -0,0 +1,72 @@ +"""Detailed diagnostics must remain actionable, durable and safe to share.""" +import io +import json +from pathlib import Path +import subprocess +import sys +import tempfile +from types import SimpleNamespace +import unittest + +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from backend.adapter import debug_output +from backend.service import Service,plan_install +from backend.state import Context,Store +from test_state import PACKAGE,DEVICE + + +class Diagnostics(unittest.TestCase): + def setUp(self): + self.temp=tempfile.TemporaryDirectory();self.store=Store(self.temp.name) + self.record=self.store.create(PACKAGE,DEVICE.copy(),{'method':'part','size_gib':4}, + plan_install(PACKAGE,DEVICE,{'method':'part','size_gib':4})) + self.record['secrets']={'wifi_key':'private-wireless-secret'} + self.events=[] + self.ctx=Context(self.store,self.record,lambda kind,data:self.events.append((kind,data))) + + def tearDown(self):self.temp.cleanup() + + def test_split_cli_output_and_trace_details_are_redacted_and_persisted(self): + self.ctx.private.append('private-root-password') + with debug_output(self.ctx) as _: + sys.stdout.write('partition backup started\npassword=private-') + sys.stdout.write('root-password\n'+DEVICE['serial']+'\n') + sys.stderr.write('E5_WIFI_KEY=private-wireless-secret\n') + text=(self.ctx.directory/'debug.ndjson').read_text(encoding='utf-8') + self.assertIn('partition backup started',text) + for secret in (DEVICE['serial'],'private-root-password','private-wireless-secret'): + self.assertNotIn(secret,text) + self.assertTrue(all(data['level']=='debug' for kind,data in self.events)) + + def test_actual_exception_is_visible_in_error_and_copyable_after_restart(self): + service=Service('.',self.store,io.StringIO()) + def fail(*_):raise subprocess.TimeoutExpired(['adb','-s',DEVICE['serial'],'private-root-password'],120) + adapter=SimpleNamespace(password='private-root-password',probe=fail) + service.run(self.ctx,adapter) + self.assertIn('TimeoutExpired',self.record['error']['message']) + reopened=Service('.',Store(self.temp.name),io.StringIO()) + reopened.worker=SimpleNamespace(is_alive=lambda:True) + result=reopened.dispatch({'protocol':1,'command':'diagnostics','params':{'transaction':self.record['id']}})['text'] + self.assertIn('Traceback',result) + self.assertIn('120',result) + for secret in (DEVICE['serial'],DEVICE['cid'],'private-root-password','private-wireless-secret'): + self.assertNotIn(secret,result) + + def test_log_rotation_and_copy_size_are_bounded(self): + path=self.ctx.directory/'debug.ndjson';path.write_text('x'*(4*1024*1024+1)) + self.ctx.log('latest failure detail',level='error') + self.assertTrue((self.ctx.directory/'debug.previous.ndjson').is_file()) + service=Service('.',self.store,io.StringIO()) + copied=service.dispatch({'protocol':1,'command':'diagnostics','params':{'transaction':self.record['id']}})['text'] + self.assertIn('latest failure detail',copied) + self.assertLess(len(copied),1100000) + + def test_resumed_legacy_secret_does_not_leak(self): + legacy=self.ctx.directory/'legacy.json';legacy.write_text(json.dumps({'key':'old-legacy-secret'})) + self.record['legacy']=str(legacy) + resumed=Context(self.store,self.record,lambda *_:None) + resumed.log('old-legacy-secret') + self.assertNotIn('old-legacy-secret',(self.ctx.directory/'debug.ndjson').read_text()) + + +if __name__=='__main__':unittest.main() diff --git a/installer/tests/test_flow_boundaries.py b/installer/tests/test_flow_boundaries.py new file mode 100644 index 00000000..b0ffed40 --- /dev/null +++ b/installer/tests/test_flow_boundaries.py @@ -0,0 +1,151 @@ +"""Restart/fault matrix using real coordinator, journals and SSH verification. + +Every transport is replaced before execution; no device is contacted. +""" +import io +import struct +from pathlib import Path +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import Mock, patch + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from backend.service import Service, plan_install +from backend.state import Context, Store +from test_state import PACKAGE, DEVICE + + +class FlowBoundaries(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.store = Store(self.temp.name) + self.service = Service('.', self.store, io.StringIO()) + self.record = self.store.create(PACKAGE, DEVICE.copy(), {'method':'part', 'size_gib':4}, + plan_install(PACKAGE, DEVICE, {'method':'part', 'size_gib':4})) + + def tearDown(self): + self.temp.cleanup() + + def restart_and_verify(self, expected_failure=False, disconnect=False): + # Load from disk with a new Store/Context, as after a computer restart. + store = Store(self.temp.name) + record = store.load(self.record['id']) + context = Context(store, record, self.service.emit) + adapter = SimpleNamespace(password='', probe=Mock(side_effect=AssertionError('Android probe replayed')), + execute=Mock(side_effect=AssertionError('Device writes replayed'))) + raw = bytearray(1024) + raw[56:58] = b'\x53\xef' + struct.pack_into('').encode() + legacy.SCRIPTS=str(self.root/'scripts');legacy.F=str(self.root/'files') + legacy.GUI=SimpleNamespace(stage=self.ctx.stage,run_tool=lambda script,*args:run_helper(self.ctx,self.root,script,args)) + def shell(command): + if command.startswith('ls /odm/firmware'):return '' + if command=='ls /data/local/tmp/e5pull':return '\n'.join(names) + if 'e5-collect.sh' in command:return 'E5-COLLECT-OK 123' + return '' + pushes=[] + def adb(command,source,target,**kwargs): + if command=='pull':Path(target).write_bytes(names[Path(source).name]) + elif command=='push':pushes.append((source,target)) + else:self.fail('Unexpected fixture transport') + legacy.su=shell;legacy.adb=adb + work=self.root/'work';work.mkdir() + with patch('sys.stdout',__import__('io').StringIO()):self.assertEqual(legacy.pull_device_files(str(work)),'123') + with tarfile.open(work/'firmware.tar') as archive: + for name in ('audio_structure','dsp_vbc','cvs'): + self.assertEqual(len(archive.extractfile('lib/firmware/'+name).read()),28) + self.assertEqual(len(archive.extractfile('lib/firmware/sprd/marlin3lite_pskey.bin').read()),176) + self.assertEqual(len(archive.extractfile('lib/firmware/sprd/marlin3lite_rf.bin').read()),252) + self.assertTrue(any(target.endswith('e5-firmware.tar') for source,target in pushes)) + self.assertFalse(self.record['effects']) + + +if __name__=='__main__':unittest.main() diff --git a/installer/tests/test_method_routing.py b/installer/tests/test_method_routing.py new file mode 100644 index 00000000..ee5a9058 --- /dev/null +++ b/installer/tests/test_method_routing.py @@ -0,0 +1,133 @@ +"""Exercise real probe/routing code with read-only simulated ADB, never hardware.""" +import io +import importlib.util +import json +from pathlib import Path +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import Mock, patch + +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from backend.adapter import Adapter, args_for +from backend.service import Service +from backend.state import Context, RecoveryRequired, Store + +TOP=Path(__file__).resolve().parents[2] +SERIAL='fixture-selected' +CID='b'*32 + + +class ReadOnlyAdb: + exe='test-adb' + su='su' + card=False + commands=[] + + def devices(self):return [{'serial':SERIAL,'state':'device'}] + def properties(self):return {'ro.product.model':'E5','ro.product.device':'fixture','ro.board.platform':'fixture','ro.boot.slot_suffix':'_a','ro.boot.verifiedbootstate':'orange','ro.crypto.state':'unencrypted','ro.crypto.type':'','sys.boot_completed':'1'} + def root_status(self):return 'ready' + def shell(self,script,root=False): + self.commands.append(script) + if script=='cat /proc/sys/kernel/random/boot_id':return 'boot-fixture' + if script=='settings get secure user_setup_complete':return '1' + if script.startswith('set -e; d='): + return f'NODE=mmcblk1p16\nCID={CID}\nSTART=2048\nSIZE=33554432\nDISK_SIZE=134217728\nFREE=12582912\nSOURCE=/dev/block/mmcblk1p16\nROOT=mmcblk1p20\n'+('TF=/dev/block/mmcblk0p1\n' if self.card else '') + if script=='cat /sys/class/block/mmcblk1p20/start /sys/class/block/mmcblk1p20/size':return '33556480 8388608' + if script=='test -b /dev/block/mmcblk0p1; echo $?':return '0' + if script=='cat /sys/class/block/mmcblk0p1/size':return '16777216' + if script=='cat /sys/class/block/mmcblk0/device/cid':return 'c'*32 + if script=='cat /sys/class/block/mmcblk0p1/start 2>/dev/null || echo 0':return '2048' + raise AssertionError('Unexpected simulated ADB command: '+script) + + +class MethodRouting(unittest.TestCase): + def adapter(self,kind='e5',card=False): + a=Adapter.__new__(Adapter);a.kind=kind;a.root=Path('.');a.ctx=None;a.password='' + a.package={'adapter':kind,'path':'.','profile':'e5' if kind=='e5' else 'mu300-family'} + a.adb=ReadOnlyAdb();a.adb.card=card;a.adb.commands=[] + a.bind=Mock() + a.legacy=SimpleNamespace(package_profile=Mock(return_value={'profile':'e5','android_models':['E5']}),android_profile=Mock(return_value='f50'),device_sd=Mock(side_effect=AssertionError('Internal mode touched TF discovery')),device_size=Mock(side_effect=AssertionError('Internal mode read TF capacity'))) + a.read_gpt=Mock(return_value={'empty':[1],'safe_gaps':[]}) + return a + + def test_internal_modes_do_not_require_or_validate_a_card(self): + for kind in ('e5','mu300'): + for card in (False,True): + for method in ('part','reinstall','image','boot'): + with self.subTest(kind=kind,card=card,method=method): + a=self.adapter(kind,card) + device=a.probe(SERIAL,method) + self.assertTrue(device['root']);self.assertTrue(device['existing']) + self.assertEqual(device['storage']['ROOT'],'mmcblk1p20') + a.legacy.device_sd.assert_not_called();a.legacy.device_size.assert_not_called() + self.assertNotIn('tf_bytes',device) + if method=='boot':a.read_gpt.assert_not_called() + + def test_reinstall_plan_on_device_without_card(self): + for kind in ('e5','mu300'): + with self.subTest(kind=kind), tempfile.TemporaryDirectory() as directory: + a=self.adapter(kind) + service=Service('.',Store(directory),io.StringIO());service.package=a.package + service.adapters=lambda *_args:a + result=service.dispatch({'protocol':1,'command':'plan','params':{'serial':SERIAL,'choices':{'method':'reinstall','size_gib':4,'grow':True}}}) + self.assertEqual(result['choices']['method'],'reinstall') + self.assertEqual(result['plan']['method'],'reinstall') + self.assertEqual(result['plan']['target'],'mmcblk1p20') + self.assertEqual(result['plan']['openwrt_bytes'],4<<30) + self.assertFalse(result['plan']['wipe']) + self.assertFalse(result['plan']['two_stage']) + a.legacy.device_sd.assert_not_called() + + def test_real_legacy_tf_error_only_applies_to_tf(self): + source=TOP/'openwrt/bundle/flash.py' + if not source.is_file():self.skipTest('E5 legacy source is tested in the E5 repository') + spec=importlib.util.spec_from_file_location('routing_legacy_fixture',source) + legacy=importlib.util.module_from_spec(spec);spec.loader.exec_module(legacy) + for cards in ('','mmcblk0 mmcblk2'): + with self.subTest(cards=cards): + a=self.adapter();a.legacy=legacy;legacy.GUI=a + with patch.object(legacy,'package_profile',return_value={'profile':'e5','android_models':['E5']}), patch.object(legacy,'su',side_effect=lambda script:'mmcblk1' if 'PARTNAME=userdata' in script else cards): + self.assertTrue(a.probe(SERIAL,'reinstall')['existing']) + with self.assertRaisesRegex(ValueError,'expected one SD card'): + a.probe(SERIAL,'tf') + + def test_tf_retains_first_partition_priority(self): + a=self.adapter(card=True) + a.legacy.device_sd=Mock(return_value='/dev/block/mmcblk0') + a.legacy.device_size=Mock(return_value=8<<30) + result=a.probe(SERIAL,'tf') + self.assertEqual(result['tf'],'/dev/block/mmcblk0p1') + self.assertEqual(result['tf_bytes'],8<<30) + a.legacy.device_size.assert_called_once_with('/dev/block/mmcblk0p1') + + def test_execute_routes_and_flags_are_exclusive(self): + for kind in ('e5','mu300'): + for method in ('tf','part','reinstall','image','boot','update'): + with self.subTest(kind=kind,method=method), tempfile.TemporaryDirectory() as directory: + root=Path(directory);(root/'desktop').mkdir();(root/'desktop/manifest.json').write_text('{}') + record=Store(root/'app').create({'path':directory,'adapter':kind},{'serial':SERIAL},{'method':method},{'method':method,'openwrt_bytes':4<<30}) + a=self.adapter(kind);a.root=root;a.ctx=Context(Store(root/'app'),record,lambda *_:None) + a.probe=Mock();a.backup=Mock();a.stage=Mock();a.update_e5=Mock() + a.legacy=SimpleNamespace(**{n:Mock() for n in ('install_sd','install','part_two_stage','boot_openwrt','install_part','update')}) + flags=args_for(record,root) + self.assertEqual(sum(bool(getattr(flags,n)) for n in ('tf','part','reinstall_part','data','boot_openwrt')),0 if method=='update' else 1) + a.execute() + if method=='update': + (a.update_e5 if kind=='e5' else a.legacy.update).assert_called_once() + elif kind=='mu300':a.legacy.install.assert_called_once() + else: + target={'tf':'install_sd','part':'install_part','reinstall':'part_two_stage','image':'install','boot':'boot_openwrt'}[method] + getattr(a.legacy,target).assert_called_once() + if method=='reinstall':self.assertEqual(a.legacy.part_two_stage.call_args.args[0],'reinstall') + for name in ('install_sd','install','part_two_stage','boot_openwrt','install_part'): + if name!=target:getattr(a.legacy,name).assert_not_called() + + def test_mismatched_saved_mode_stops_before_probe_or_write(self): + a=self.adapter();a.ctx=SimpleNamespace(record={'choices':{'method':'tf'},'plan':{'method':'reinstall'}}) + with self.assertRaises(RecoveryRequired):a.execute() + a.bind.assert_not_called() + + +if __name__=='__main__':unittest.main() diff --git a/installer/tests/test_openwrt_confirmation.py b/installer/tests/test_openwrt_confirmation.py new file mode 100644 index 00000000..c073111d --- /dev/null +++ b/installer/tests/test_openwrt_confirmation.py @@ -0,0 +1,113 @@ +"""Manual boot confirmation selects an SSH endpoint, never bypasses verification.""" +import io +import json +from pathlib import Path +import struct +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import Mock, patch + +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from backend.service import Service,plan_install +from backend.state import Context,Store +from test_state import PACKAGE,DEVICE + + +class OpenwrtConfirmation(unittest.TestCase): + def setUp(self): + self.temp=tempfile.TemporaryDirectory() + self.store=Store(self.temp.name) + self.output=io.StringIO() + self.service=Service('.',self.store,self.output) + device={**DEVICE,'existing':True,'storage':{**DEVICE['storage'],'ROOT':'mmcblk0p20','ROOT_SIZE':(4<<30)//512}} + self.record=self.store.create(PACKAGE,device,{'method':'reinstall','host':'192.0.2.1'}, + plan_install(PACKAGE,device,{'method':'reinstall'})) + self.ctx=Context(self.store,self.record,self.service.emit) + self.service.active=self.ctx + self.service.worker=SimpleNamespace(is_alive=lambda:True) + self.service.openwrt_wait_stage(self.ctx) + + def tearDown(self):self.temp.cleanup() + + def confirm(self,**extra): + return self.service.dispatch({'protocol':1,'command':'verify_openwrt', + 'params':{'transaction':self.record['id'],'host':'192.0.2.2','password':'private-root-secret',**extra}}) + + def test_confirmation_is_queued_and_does_not_complete_or_persist_password(self): + self.assertTrue(self.confirm()['accepted']) + self.assertEqual(self.record['status'],'waiting_user') + self.assertFalse(self.record.get('openwrt_confirmed')) + self.assertNotIn('private-root-secret',(self.ctx.directory/'transaction.json').read_text()) + self.assertEqual(self.record['choices']['host'],'192.0.2.1') + + def test_rejects_wrong_transaction_unsafe_stage_and_invalid_endpoint(self): + for extra in ({'transaction':'b'*32},{'host':''},{'host':'127.0.0.1; reboot'}, + {'host':'https://router/'},{'password':123}): + with self.subTest(extra=extra),self.assertRaises(ValueError):self.confirm(**extra) + for stage,unsafe in [('transfer_install',False),('verify_capacity',False),('openwrt_boot',True)]: + self.record.update(stage=stage,unsafe=unsafe) + with self.assertRaises(ValueError):self.confirm() + + def verify_after_retry(self,authentication=False,bad_capacity=False): + import paramiko + targets=[];reads=[];client=Mock() + def connect(host,**options): + targets.append((host,options['password'])) + if authentication and options['password']!='private-root-secret': + raise paramiko.AuthenticationException('denied') + client.connect.side_effect=connect + raw=bytearray(1024);raw[56:58]=b'\x53\xef' + struct.pack_into('>': + self.files[parts[3]]=self.files.get(parts[3],b'')+self.files.pop(parts[1]);return '' + self.fail('Unexpected simulated staging command: '+command) + + def transfer(self):return push_chunks(self.call,self.shell,self.source,self.remote,self.ctx) + + def test_progress_counts_only_verified_appended_bytes(self): + self.transfer() + self.assertEqual(self.files[self.remote],self.source.read_bytes()) + events=[data for kind,data in self.events if kind=='transfer'] + self.assertEqual([data['bytes'] for data in events],[8<<20,self.source.stat().st_size]) + self.assertTrue(all(data['total']==self.source.stat().st_size and data['bytes_per_second']>0 for data in events)) + + def test_corrupt_chunk_stops_before_append_or_progress(self): + self.corrupt=True + with self.assertRaisesRegex(ValueError,'checksum'):self.transfer() + self.assertNotIn(self.remote,self.files) + self.assertFalse(self.events) + + def test_disconnect_retry_replaces_partial_upload(self): + self.disconnect_at=2 + with self.assertRaises(ConnectionError):self.transfer() + self.assertEqual(len(self.files[self.remote]),8<<20) + self.disconnect_at=None + self.transfer() + self.assertEqual(self.files[self.remote],self.source.read_bytes()) + + def test_pause_stops_between_verified_chunks(self): + def emit(kind,data): + self.events.append((kind,data));self.ctx.cancel=True + self.ctx.emit=emit + with self.assertRaises(Cancelled):self.transfer() + self.assertEqual(self.pushes,1) + self.assertEqual(len(self.files[self.remote]),8<<20) + + +if __name__=='__main__':unittest.main() diff --git a/installer/tests/test_update_lifecycle.py b/installer/tests/test_update_lifecycle.py new file mode 100644 index 00000000..64d65f29 --- /dev/null +++ b/installer/tests/test_update_lifecycle.py @@ -0,0 +1,166 @@ +"""An update is complete only after a new boot, not a pre-reboot SSH response.""" +import hashlib +import io +import json +from pathlib import Path +import struct +import sys +import tempfile +from types import SimpleNamespace +import unittest +from unittest.mock import Mock,patch + +sys.path.insert(0,str(Path(__file__).resolve().parents[1])) +from backend.adapter import Adapter,installation_committed +from backend.service import Service,plan_install +from backend.state import Context,Store +from test_state import PACKAGE,DEVICE + +OLD='11111111-1111-4111-8111-111111111111' +NEW='22222222-2222-4222-8222-222222222222' + + +class UpdateLifecycle(unittest.TestCase): + def setUp(self): + self.temp=tempfile.TemporaryDirectory() + self.store=Store(self.temp.name) + self.output=io.StringIO() + self.service=Service('.',self.store,self.output) + device={**DEVICE,'capacity':4<<30} + self.record=self.store.create(PACKAGE,device,{'method':'update','host':'192.0.2.1'}, + plan_install(PACKAGE,device,{'method':'update','host':'192.0.2.1'})) + self.ctx=Context(self.store,self.record,self.service.emit) + + def tearDown(self):self.temp.cleanup() + + def test_capture_actual_boot_identity_before_update_uploads(self): + adapter=Adapter.__new__(Adapter);adapter.ctx=self.ctx + adapter.expected_ssh_key=hashlib.sha256(b'key').hexdigest() + client=Mock() + client.get_transport.return_value.get_remote_server_key.return_value.asbytes.return_value=b'key' + client.exec_command.return_value=(None,SimpleNamespace(read=lambda:OLD.encode(),channel=SimpleNamespace(recv_exit_status=lambda:0)),None) + adapter.validate_ssh(client) + self.assertEqual(self.store.load(self.record['id'])['update_boot_id'],OLD) + self.assertEqual(self.record['stage'],'transfer_install') + self.assertFalse(self.record['effects']) + client.exec_command.return_value=(None,SimpleNamespace(read=lambda:b'',channel=SimpleNamespace(recv_exit_status=lambda:0)),None) + with self.assertRaisesRegex(ValueError,'boot identity'):adapter.validate_ssh(client) + + def test_committed_update_announces_reboot_and_is_not_replayed(self): + adapter=Adapter.__new__(Adapter);adapter.ctx=self.ctx + operation=Mock(return_value='verified') + self.assertEqual(adapter.action('update-commit',operation),'verified') + self.assertEqual(self.record['stage'],'openwrt_boot') + self.assertEqual(self.record['status'],'waiting_device') + self.assertFalse(self.record['details']['reboot_manually']) + self.assertTrue(installation_committed(self.record)) + self.assertEqual(adapter.action('update-commit',operation),'verified') + operation.assert_called_once() + + def run_final_check(self,boot_ids,confirmed=False,missing=False,connection_errors=(),read_disconnect=False): + self.record.update(stage='prepare',effects={'update-commit':{'state':'done'}}) + if not missing:self.record['update_boot_id']=OLD + if confirmed:self.record['openwrt_confirmed']=True + self.store.save(self.record) + # A new app process reloads the committed transaction, preserving the + # pre-update boot proof even if the final wait checkpoint was not saved. + record=Store(self.temp.name).load(self.record['id']) + context=Context(self.store,record,self.service.emit) + values=iter(boot_ids);observed=[];root_reads=[];read_losses=[] + raw=bytearray(1024);raw[56:58]=b'\x53\xef' + struct.pack_into('el.scrollTop>0') page.evaluate('window.__logFixture()') - page.get_by_role('button',name='详细日志',exact=False).click();settle(page);layout(page) + if page.get_by_role('button',name='详细日志',exact=False).get_attribute('aria-expanded')=='false':page.get_by_role('button',name='详细日志',exact=False).click() + settle(page);layout(page) assert page.locator('.records-list').evaluate('(el)=>el.clientHeight>=100') assert page.locator('.log-panel pre').evaluate('(el)=>el.scrollHeight>el.clientHeight') assert page.locator('.log-toggle span').inner_text()=='500' diff --git a/installer/tests/update_smoke.py b/installer/tests/update_smoke.py new file mode 100644 index 00000000..3e15dec4 --- /dev/null +++ b/installer/tests/update_smoke.py @@ -0,0 +1,65 @@ +"""Update reboot guidance and clocks that stop on terminal states.""" +import time +from playwright.sync_api import sync_playwright +from ui_smoke import BRIDGE,ROOT,layout,settle + + +def main(): + with sync_playwright() as p: + browser=p.chromium.launch() + context=browser.new_context(viewport={'width':800,'height':650}) + context.add_init_script(BRIDGE+"localStorage.setItem('onboarding-v1','seen');window.__fixture.tx.choices={method:'update'};Object.assign(window.__fixture.tx.plan,{method:'update',wipe:false,two_stage:false,offline:false});") + page=context.new_page();errors=[] + page.on('pageerror',lambda error:errors.append(str(error))) + page.goto('http://127.0.0.1:1420') + page.get_by_role('button',name='继续未完成的安装',exact=False).click();settle(page) + page.get_by_role('button',name='确认安装计划',exact=True).click();settle(page) + assert '自动重启以应用更新' in page.locator('.page-scroll').inner_text() + page.get_by_role('checkbox').check() + page.get_by_role('button',name='确认并开始').click();settle(page) + now=time.time() + def event(**change):page.evaluate('change=>window.__emitFixture(change)',change) + event(stage='openwrt_boot',status='waiting_device',revision=10,stage_started_at=now-3, + details={'host':'192.168.9.1','reboot_manually':False}) + settle(page);layout(page) + assert page.locator('h1').inner_text()=='更新已提交,设备将自动重启' + assert '自动重启以应用更新' in page.locator('.boot-guidance').inner_text() + assert page.locator('[data-sonner-toast]').filter(has_text='自动重启以应用更新').count()>=1 + before=page.locator('.elapsed').inner_text() + page.wait_for_timeout(1300) + assert page.locator('.elapsed').inner_text()!=before + page.screenshot(path=str(ROOT/'screenshots/update-reboot-zh.png')) + event(stage='openwrt_boot',status='waiting_device',revision=11, + details={'host':'192.168.9.1','reboot_manually':False,'connection_state':'reconnecting','verification_error':None}) + settle(page);layout(page) + assert page.locator('h1').inner_text()=='设备正在重启,等待重新连接' + assert page.locator('.verification-error').count()==0 + assert page.locator('[data-sonner-toast][data-type=warning],[data-sonner-toast][data-type=error]').count()==0 + for revision in range(12,18):event(revision=revision) + settle(page) + assert page.locator('[data-sonner-toast][data-type=info]').filter(has_text='设备正在重启,等待重新连接').count()==1 + page.screenshot(path=str(ROOT/'screenshots/update-reconnecting-zh.png')) + page.get_by_label('语言').select_option('en');settle(page) + assert page.locator('h1').inner_text()=='Device restarting; waiting to reconnect' + page.get_by_label('Language').select_option('zh');settle(page) + for index,status in enumerate(('completed','failed','cancelled')): + event(stage='complete' if status=='completed' else 'verify_capacity',status=status,revision=20+index, + stage_started_at=now-9,stage_finished_at=now-1,updated=now-1, + result={'filesystem_bytes':10737418240,'url':'http://192.168.9.1'}) + settle(page) + assert page.locator('.elapsed').inner_text()=='阶段用时 8s' + page.wait_for_timeout(1300) + assert page.locator('.elapsed').inner_text()=='阶段用时 8s' + event(stage='complete',status='completed',revision=23) + page.get_by_label('语言').select_option('en');page.get_by_label('Theme').select_option('dark') + settle(page);layout(page) + assert page.locator('h1').inner_text()=='OpenWrt updated and verified' + assert 'device restarted' in page.locator('.success-panel').inner_text() + assert page.locator('.elapsed').inner_text()=='Stage elapsed 8s' + page.screenshot(path=str(ROOT/'screenshots/update-complete-clock-en.png')) + assert not errors,errors + browser.close() + print('Update smoke passed: plan/reboot guidance, reconnects stay neutral without error/warning toasts, repeated waits deduplicated, active clock advances, terminal clocks freeze, bilingual update result at 800x650') + + +if __name__=='__main__':main() diff --git a/installer/ui/src-tauri/src/main.rs b/installer/ui/src-tauri/src/main.rs index b28a87e2..92e686e1 100644 --- a/installer/ui/src-tauri/src/main.rs +++ b/installer/ui/src-tauri/src/main.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, io::{BufRead, BufReader, Write}, path::PathBuf, use tauri::{Emitter, Manager, State}; use tokio::sync::oneshot; -const COMMANDS: &[&str] = &["hello","snapshot","list","package","devices","probe","probe_update","plan","start","resume","retry","cancel","can_close","export","import"]; +const COMMANDS: &[&str] = &["hello","snapshot","list","package","devices","probe","probe_update","plan","start","resume","retry","cancel","can_close","export","import","diagnostics","verify_openwrt"]; struct Bridge { input: Mutex>, pending: Mutex>>>, @@ -25,7 +25,10 @@ async fn backend_request(state: State<'_, Arc>, command: String, params: let line = json!({"protocol":1,"id":id,"command":command,"params":params}).to_string()+"\n"; let written = { let mut input = state.input.lock().unwrap(); - input.as_mut().ok_or("Backend is unavailable")?.write_all(line.as_bytes()).map_err(|e|e.to_string()) + match input.as_mut() { + Some(stream) => stream.write_all(line.as_bytes()).map_err(|e|e.to_string()), + None => Err("Backend is unavailable".to_string()), + } }; if let Err(error) = written {state.pending.lock().unwrap().remove(&id); return Err(error);} // Verification and large archives can take minutes. No artificial device wait deadline. diff --git a/installer/ui/src/i18n.ts b/installer/ui/src/i18n.ts index 73cdd248..4073ab51 100644 --- a/installer/ui/src/i18n.ts +++ b/installer/ui/src/i18n.ts @@ -1,5 +1,8 @@ export const strings = { zh: { + copyDiagnostics:'复制诊断信息给开发者', phase:'阶段', stageProgress:'当前阶段进度', noPercentage:'此操作没有可靠百分比,正在显示真实阶段与耗时。', + installMethod:'安装方式', + noDevicesShort:'未发现设备', inspectNeedsPackage:'可以先刷新并选择设备;检查设备和安装前仍需校验安装包。', copied:'日志已复制', exportedLog:'日志已导出', exportedBackup:'事务与备份已导出', imported:'恢复记录已导入', openedData:'事务目录已打开', inspected:'设备检查完成', refreshed:'设备列表已刷新', noDevices:'未发现设备,请连接 USB 并开启调试。', multipleDevices:'检测到多台设备,请明确选择本次操作的设备。', pauseRequested:'已请求暂停,将在安全边界生效。', dismiss:'关闭提示', notifications:'操作通知', deviceStates:{device:'已连接',unauthorized:'等待调试授权',offline:'离线'}, title:'OpenWrt 安装器', subtitle:'安装、更新与恢复', home:'开始', package:'安装包', choosePackage:'选择安装包目录', verify:'校验安装包', verified:'校验通过', device:'设备', refresh:'刷新设备', select:'请选择设备', connect:'通过 USB 连接设备,开启调试并允许电脑访问。', inspect:'检查设备', @@ -11,14 +14,21 @@ export const strings = { plan:'查看安装计划', review:'确认安装计划', target:'写入目标', android:'Android 保留空间', allocation:'OpenWrt 分配空间', impact:'数据影响', wipe:'Android 应用、账号、照片和内部存储将全部清空。请先备份个人数据。', preserve:'保留 Android 用户数据。', tfErase:'会格式化所选 TF 目标,卡上该分区的数据会被替换。不会重新划分 TF 卡。', reinstallErase:'已有 OpenWrt 系统与设置会被替换,Android 用户数据保留。', imageImpact:'创建镜像,保留原有镜像备份。需额外安装临时空间。', - updateImpact:'保留设置、分区容量和本机固件;上传通过 SSH,设备端互斥锁保护提交。', bootImpact:'临时试启动;不挂载、不写入 OpenWrt 根分区。失败时由原启动策略回退。', + updateImpact:'保留设置、分区容量和本机固件;上传通过 SSH,设备端互斥锁保护提交。提交后设备会自动重启以应用更新,网络会暂时断开。', bootImpact:'临时试启动;不挂载、不写入 OpenWrt 根分区。失败时由原启动策略回退。', + updateReboot:'更新已提交,设备将自动重启', updateReconnecting:'设备正在重启,等待重新连接', updateRebootDesc:'设备将自动重启以应用更新,期间网络会暂时断开。请保持供电并等待,安装器将在确认设备重启、重新连接并校验实际容量后显示完成。', + updateNext:'设备已重启,更新已通过校验。请打开管理地址检查服务;原设置、容量和本机固件保留,事务记录仍保存在电脑上。', firstBoot:'首次启动会进行离线分区准备,可能需要数分钟,完成后设备会自动重启一次。', accept:'我已核对设备、写入目标和数据影响,并已备份需要保留的文件。', start:'确认并开始', back:'返回', progress:'安装进度', steps:['检查与计划','准备与备份','设备重启与授权','安装与校验','完成'], running:'正在执行', waiting_user:'等待用户操作', waiting_device:'等待设备重连', failed:'操作失败', completed:'已完成', cancelled:'已暂停', readyStatus:'等待确认', - stages:{plan:'安装计划已就绪',prepare:'准备安装',backup:'备份 GPT、misc 与启动链',android_boot:'等待 Android 开机',android_setup:'请完成 Android 初始设置',usb_debugging:'请启用 USB 调试',debug_authorization:'请在设备上允许调试',magisk:'请安装或恢复 Magisk',root_permission:'请允许 root 请求',root_ready:'root 已就绪,继续安装',recheck:'复核分区与事务状态',transfer_install:'传输及安装系统',verify_capacity:'扩容与最终容量校验',openwrt_boot:'等待启动 OpenWrt',complete:'安装完成'}, + stages:{firmware_extract:'提取本机固件',firmware_convert:'转换本机音频与蓝牙固件',plan:'安装计划已就绪',prepare:'准备安装',backup:'备份 GPT、misc 与启动链',android_boot:'等待 Android 开机',android_setup:'请完成 Android 初始设置',usb_debugging:'请启用 USB 调试',debug_authorization:'请在设备上允许调试',magisk:'请安装或恢复 Magisk',root_permission:'请允许 root 请求',root_ready:'root 已就绪,继续安装',recheck:'复核分区与事务状态',transfer_install:'传输及安装系统',verify_capacity:'扩容与最终容量校验',openwrt_boot:'等待启动 OpenWrt',complete:'安装完成'}, waitingAndroid:'保持设备供电。进入 Android 后完成初始设置、开启开发者选项及 USB 调试,并允许此电脑调试。若 root 仍可用,会直接继续;否则恢复 Magisk 并允许 root 请求。这里没有等待时限。', - waitingOpenwrt:'需要时请手动重启设备。连接设备的 USB 网络或热点后继续验证;安装器不会修改电脑网卡、路由或自动连接热点。请保持此窗口,或暂停后从记录继续。', + rebootNow:'请现在手动重启设备', rebootManual:'设备端安装操作已结束。请使用设备的正常重启功能进入 OpenWrt;已开始重启或已进入 OpenWrt 时,无需重复重启。', + rebootAutomatic:'已发送自动重启请求,请等待设备开机。若设备仍停留在原系统且未开始重启,请使用设备的正常重启功能。', + waitingOpenwrt:'进入 OpenWrt 后,请将电脑连接到设备的 USB 网络或热点,安装器会自动通过 SSH 校验。同一设备的身份与实际容量校验通过后才会完成。请保持此窗口,或暂停后从记录继续。', + newestFirst:'最新记录在上', + confirmOpenwrt:'我已进入 OpenWrt,开始校验', verificationRequested:'已请求校验,将核对设备身份与实际容量', + bootConfirmed:'已确认进入 OpenWrt。请核对这台设备的管理地址与 SSH root 密码,并将电脑连接到它的网络。', pause:'在安全边界暂停', unsafe:'正在写入,请保持供电。暂停将在当前操作完成后生效。', closeBlocked:'任务仍在执行。请先在安全边界暂停,再关闭窗口。', logs:'详细日志', copy:'复制', exportLog:'导出日志', exportBackup:'导出事务与备份', openData:'打开事务目录', import:'导入恢复目录', noRecords:'没有可恢复的事务。若电脑记录丢失,请导入完整备份目录;设备标记不足以证明安装计划时,安装器会停止。', continue:'继续安装', retry:'复核并重试', @@ -27,6 +37,9 @@ export const strings = { noBackend:'无法连接本地后端。请从完整解压后的安装包运行 OpenWrt-Installer.exe。', error:'操作未完成', elapsed:'阶段用时', bytes:'已传输', speed:'速度', packageHint:'请完整解压安装包;载荷校验通过后才能操作设备。', }, en: { + copyDiagnostics:'Copy diagnostics for the developer', phase:'Phase', stageProgress:'Current phase progress', noPercentage:'This operation has no reliable percentage. The phase and elapsed time are shown.', + installMethod:'Installation method', + noDevicesShort:'No devices found', inspectNeedsPackage:'You can refresh and select a device now. Verify the package before inspecting or installing.', copied:'Log copied', exportedLog:'Log exported', exportedBackup:'Transaction and backups exported', imported:'Recovery record imported', openedData:'Transaction folder opened', inspected:'Device inspection complete', refreshed:'Device list refreshed', noDevices:'No devices found. Connect USB and enable debugging.', multipleDevices:'Multiple devices found. Select the device for this operation.', pauseRequested:'Pause requested. It will take effect at a safe boundary.', dismiss:'Dismiss notification', notifications:'Operation notifications', deviceStates:{device:'Connected',unauthorized:'Awaiting debugging authorization',offline:'Offline'}, title:'OpenWrt Installer',subtitle:'Install, update and recover',home:'Start',package:'Package',choosePackage:'Choose package folder',verify:'Verify package',verified:'Verified', device:'Device',refresh:'Refresh devices',select:'Select a device',connect:'Connect by USB, enable debugging and authorize this computer.',inspect:'Inspect device', @@ -38,13 +51,20 @@ export const strings = { plan:'Review installation plan',review:'Confirm installation plan',target:'Write target',android:'Android retained space',allocation:'OpenWrt allocation',impact:'Data impact', wipe:'All Android apps, accounts, photos and internal storage will be erased. Back up personal files first.',preserve:'Preserve Android user data.',tfErase:'Format the selected TF target and replace its data. The card is not repartitioned.', reinstallErase:'Replace the installed OpenWrt system and settings. Preserve Android user data.',imageImpact:'Create an image and retain the previous image as a backup. Temporary staging space is also required.', - updateImpact:'Preserve settings, partition capacity and local firmware. Upload over SSH; a device upgrade lock protects commit.',bootImpact:'Trial boot only. Do not mount or write the OpenWrt root partition. Existing boot policy handles fallback.', + updateImpact:'Preserve settings, partition capacity and local firmware. Upload over SSH; a device upgrade lock protects commit. The device automatically restarts to apply the update, briefly disconnecting its network.',bootImpact:'Trial boot only. Do not mount or write the OpenWrt root partition. Existing boot policy handles fallback.', + updateReboot:'Update submitted; device restarting', updateReconnecting:'Device restarting; waiting to reconnect', updateRebootDesc:'The device will automatically restart to apply the update and its network will briefly disconnect. Keep power connected. Completion follows a confirmed restart, reconnection and actual-capacity verification.', + updateNext:'The device restarted and the update passed verification. Open its management address to check services. Settings, capacity and local firmware are retained; the transaction remains on this computer.', firstBoot:'The first boot performs offline partition preparation. This may take several minutes; the device will reboot automatically once it finishes.', accept:'I checked the device, write target and data impact, and backed up the files I need.',start:'Confirm and start',back:'Back',progress:'Installation progress',steps:['Checks and plan','Prepare and back up','Restart and authorize','Install and verify','Complete'], running:'Running',waiting_user:'Waiting for you',waiting_device:'Waiting for device',failed:'Failed',completed:'Completed',cancelled:'Paused',readyStatus:'Awaiting confirmation', - stages:{plan:'Installation plan ready',prepare:'Preparing installation',backup:'Backing up GPT, misc and boot chain',android_boot:'Waiting for Android to boot',android_setup:'Complete Android initial setup',usb_debugging:'Enable USB debugging',debug_authorization:'Allow debugging on the device',magisk:'Install or restore Magisk',root_permission:'Allow the root request',root_ready:'Root is ready; continuing installation',recheck:'Rechecking partitions and transaction',transfer_install:'Transferring and installing the system',verify_capacity:'Growing and verifying actual capacity',openwrt_boot:'Waiting for OpenWrt to start',complete:'Installation complete'}, + stages:{firmware_extract:'Extracting this device’s firmware',firmware_convert:'Converting device audio and Bluetooth firmware',plan:'Installation plan ready',prepare:'Preparing installation',backup:'Backing up GPT, misc and boot chain',android_boot:'Waiting for Android to boot',android_setup:'Complete Android initial setup',usb_debugging:'Enable USB debugging',debug_authorization:'Allow debugging on the device',magisk:'Install or restore Magisk',root_permission:'Allow the root request',root_ready:'Root is ready; continuing installation',recheck:'Rechecking partitions and transaction',transfer_install:'Transferring and installing the system',verify_capacity:'Growing and verifying actual capacity',openwrt_boot:'Waiting for OpenWrt to start',complete:'Installation complete'}, waitingAndroid:'Keep power connected. Complete Android setup, enable developer options and USB debugging, then authorize this computer. Existing working root is accepted immediately; otherwise restore Magisk and grant root. There is no waiting deadline.', - waitingOpenwrt:'Reboot the device manually if needed. Connect to its USB network or hotspot for verification. The installer does not change network adapters or routes, or connect to hotspots. Keep this window open, or pause and resume from the record.', + rebootNow:'Restart the device now', rebootManual:'Device installation operations have finished. Use the device’s normal restart control to enter OpenWrt. If it is already restarting or running OpenWrt, do not restart it again.', + rebootAutomatic:'An automatic restart was requested. Wait for the device to boot. If it stays in the previous system without restarting, use its normal restart control.', + waitingOpenwrt:'Once OpenWrt starts, connect this computer to the device’s USB network or hotspot. The installer will verify its identity and actual capacity over SSH before completing. Keep this window open, or pause and resume from the record.', + newestFirst:'Newest entries first', + confirmOpenwrt:'OpenWrt is running — verify now', verificationRequested:'Verification requested; checking device identity and actual capacity', + bootConfirmed:'OpenWrt boot confirmed. Check this device’s management address and SSH root password, and connect this computer to its network.', pause:'Pause at a safe boundary',unsafe:'A write is in progress. Keep power connected. Pause takes effect after the current operation finishes.',closeBlocked:'A task is still active. Pause at a safe boundary before closing the window.', logs:'Detailed log',copy:'Copy',exportLog:'Export log',exportBackup:'Export transaction and backups',openData:'Open transaction folder',import:'Import recovery folder', noRecords:'No saved transactions. If computer records were lost, import a full backup folder. Insufficient device evidence stops installation.',continue:'Continue installation',retry:'Recheck and retry', diff --git a/installer/ui/src/main.tsx b/installer/ui/src/main.tsx index f1413a89..eee7e546 100644 --- a/installer/ui/src/main.tsx +++ b/installer/ui/src/main.tsx @@ -30,12 +30,14 @@ function App() { const [pkg, setPkg] = useState(); const [path, setPath] = useState(''); const [devices, setDevices] = useState([]); + const [devicesLoaded, setDevicesLoaded] = useState(false); const [serial, setSerial] = useState(''); const [device, setDevice] = useState(); const [records, setRecords] = useState([]); const [tx, setTx] = useState(); const [transfer, setTransfer] = useState(); const [method, setMethod] = useState('part'); + const [planOrigin, setPlanOrigin] = useState('install'); const [size, setSize] = useState('4'); const [grow, setGrow] = useState(true); const [host, setHost] = useState('192.168.9.1'); @@ -44,10 +46,12 @@ function App() { const [busy, setBusy] = useState(false); const [logs, setLogs] = useState([]); const [logOpen, setLogOpen] = useState(false); - const [elapsed, setElapsed] = useState(0); + const [clock, setClock] = useState(Date.now()); const [since, setSince] = useState(Date.now()); const pending = useRef(0); const lastTransaction = useRef(''); + const verificationTransaction = useRef(''); + const revisions = useRef(new Map()); const pageRef = useRef(null); const reduceMotion = useReducedMotion(); const append = useCallback((text: string) => setLogs(old => [...old.slice(-499), `${new Date().toLocaleTimeString()} ${text}`]), []); @@ -56,21 +60,34 @@ function App() { append(message); }, [append, t.error]); const acceptTransaction = useCallback((next: Transaction, announce = true) => { - const key = `${next.id}:${next.stage}:${next.status}:${next.error?.message || ''}`; + // Native events can arrive before the response to start/resume. Never let + // that older response replace a newer persisted checkpoint on the screen. + if (next.revision !== undefined) { + if (next.revision < (revisions.current.get(next.id) ?? -1)) return; + revisions.current.set(next.id, next.revision); + } + const key = `${next.id}:${next.stage}:${next.status}:${next.details?.tool || ''}:${next.details?.connection_state || ''}:${next.details?.verification_error || ''}:${next.error?.message || ''}`; if (key !== lastTransaction.current) { lastTransaction.current = key; - setSince(Date.now()); setTransfer(undefined); - const label = t.stages[next.stage as keyof typeof t.stages] || next.stage; + if (!['completed','failed','cancelled'].includes(next.status)) setSince(Date.now()); + setTransfer(undefined); + const label = next.stage === 'openwrt_boot' && next.choices.method === 'update' ? next.details?.connection_state === 'reconnecting' ? t.updateReconnecting : t.updateReboot : t.stages[next.stage as keyof typeof t.stages] || next.stage; append(label); if (announce) { const options = {id: 'installation-status', description: next.error?.message || + (next.stage === 'openwrt_boot' && next.status.startsWith('waiting') ? (next.details?.verification_error || (next.choices.method === 'update' ? t.updateRebootDesc : next.details?.boot_confirmed ? t.bootConfirmed : next.details?.reboot_manually !== false ? t.rebootManual : t.rebootAutomatic)) : '') || (next.status === 'ready' ? t.readyStatus : (t as unknown as Record)[next.status]), duration: next.status === 'failed' ? Infinity : 5000}; if (next.status === 'failed') toast.error(label, options); else if (next.status === 'completed') toast.success(next.choices.method === 'boot' ? t.successBoot : next.choices.method === 'update' ? t.successUpdate : t.success, options); + else if (next.details?.verification_error) toast.warning(label, options); else if (next.status.startsWith('waiting')) toast.info(label, options); else toast.message(label, options); } } + if (next.stage === 'openwrt_boot' && verificationTransaction.current !== next.id) { + verificationTransaction.current = next.id; + setHost(next.details?.host || next.choices.host || (next.package.adapter === 'e5' ? '192.168.9.1' : next.device.profile === 'u30air' ? '192.168.78.1' : '192.168.77.1')); + } setTx(next); }, [append, t]); const task = async (fn: () => Promise, success?: string): Promise => { @@ -95,10 +112,14 @@ function App() { }, [theme]); useEffect(() => {localStorage.setItem('language', lang); document.documentElement.lang = lang === 'zh' ? 'zh-CN' : 'en';}, [lang]); useEffect(() => {pageRef.current?.querySelector('h1')?.focus({preventScroll: true});}, [view]); + const timingActive = tx && ['running','waiting_user','waiting_device'].includes(tx.status); + const elapsed = tx ? Math.max(0,Math.floor(((tx.stage_finished_at ? tx.stage_finished_at*1000 : timingActive ? clock : tx.updated*1000) - (tx.stage_started_at ? tx.stage_started_at*1000 : since))/1000)) : 0; useEffect(() => { - const timer = setInterval(() => setElapsed(Math.floor((Date.now() - since)/1000)), 1000); + if (!timingActive) return; + setClock(Date.now()); + const timer = setInterval(() => setClock(Date.now()), 1000); return () => clearInterval(timer); - }, [since]); + }, [timingActive, since]); useEffect(() => { let dispose: (() => void) | undefined; let cancelled = false; @@ -107,7 +128,11 @@ function App() { const next = event.data as Transaction; acceptTransaction(next); } else if (event.type === 'transfer') setTransfer(event.data as Transfer); - else if (event.type === 'log') append((event.data as {message: string}).message); + else if (event.type === 'activity') setTransfer(undefined); + else if (event.type === 'log') { + const entry = event.data as {message:string; level?:string; scope?:string}; + append(`[${(entry.level || 'debug').toUpperCase()}]${entry.scope ? ' ['+entry.scope+']' : ''} ${entry.message}`); + } else if (event.type === 'close_blocked') reportError(t.closeBlocked); else if (event.type === 'backend_exit') reportError(t.noBackend); }).then(stop => {if (cancelled) stop(); else dispose = stop;}).catch(e => {if (!cancelled) reportError(String(e));}); @@ -126,35 +151,42 @@ function App() { if (p) {setPkg(p); setPath(p.path); setHost(p.adapter === 'e5' ? '192.168.9.1' : '192.168.77.1'); append(t.verified);} }; const refresh = async () => { + setDevice(undefined); + setDevicesLoaded(false); const values = await task(() => request('devices')); if (values) { - setDevices(values); + setDevices(values); setDevicesLoaded(true); if (values.length === 1) {setSerial(values[0].serial); if (values[0].serial !== serial) setDevice(undefined);} else if (!values.some(d => d.serial === serial)) {setSerial(''); setDevice(undefined);} - if (!values.length) toast.info(t.noDevices); + if (!values.length) toast.info(t.noDevices, {id:'device-selection'}); else if (values.length > 1) toast.info(t.multipleDevices, {id:'device-selection'}); - else toast.success(t.refreshed); - } + else toast.success(t.refreshed, {id:'device-selection'}); + } else {setDevices([]); setSerial('');} }; const inspect = async () => { setDevice(undefined); const value = await task(() => request('probe', {serial, method: view === 'boot' ? 'boot' : method}), t.inspected); - if (value) {setDevice(value); if (value.existing && view === 'install') setMethod('reinstall'); else if (value.tf && view === 'install') setMethod('tf');} + if (value) setDevice(value); }; const navigate = async (next: View) => { setView(next); setAccepted(false); setTransfer(undefined); setDevice(undefined); if (next === 'resume') {const values = await task(() => request('list')); if (values) setRecords(values);} - if (['install','advanced','boot'].includes(next)) {if (next === 'boot') setMethod('boot'); else setMethod('part'); if (pkg) await refresh();} + if (['install','advanced','boot'].includes(next)) {setMethod(next === 'boot' ? 'boot' : next === 'advanced' ? 'reinstall' : 'part'); await refresh();} if (next === 'update') setMethod('update'); }; const plan = async () => { const value = await task(() => request('plan', {serial, choices: {method, size_gib: Number(size), grow, host}, password})); - if (value) {acceptTransaction(value); setView('plan'); setAccepted(false);} + if (value) {setPlanOrigin(view); acceptTransaction(value); setView('plan'); setAccepted(false);} }; const start = async (command: string, record = tx) => { if (!record) return; const value = await task(() => request(command, {transaction: record.id, confirmed: command === 'start', password, path: pkg?.path || path})); - if (value) {acceptTransaction(value); setView('progress'); setSince(Date.now()); setTransfer(undefined);} + if (value) {acceptTransaction(value); setView('progress'); setLogOpen(true); setSince(Date.now()); setTransfer(undefined);} + }; + const continueRecord = async (record: Transaction) => { + if (record.status === 'ready') { + acceptTransaction(record, false); setPlanOrigin('resume'); setAccepted(false); setView('plan'); + } else await start('resume', record); }; const exportBackup = async () => { if (!tx) return; @@ -163,10 +195,12 @@ function App() { return request('export', {transaction: tx.id, path: target}); }, t.exportedBackup); }; + const diagnosticText = async () => tx ? (await request<{text:string}>('diagnostics', {transaction:tx.id})).text : logs.join('\n'); + const copyDiagnostics = () => task(async () => navigator.clipboard.writeText(await diagnosticText()), t.copied); const exportLogs = async () => { await task(async () => {const target = await native('save_log'); if (!target) return false; - return invoke('write_log', {path: target, text: logs.join('\n')}); + return invoke('write_log', {path: target, text: await diagnosticText()}); }, t.exportedLog); }; const choosePackage = async () => { @@ -202,6 +236,8 @@ function App() { {id:'advanced', icon:Settings2, title:t.advanced, description:t.advancedDesc}, ] as const; const impact = tx?.plan.wipe ? t.wipe : tx?.choices.method === 'tf' ? t.tfErase : tx?.choices.method === 'reinstall' ? t.reinstallErase : tx?.choices.method === 'image' ? t.imageImpact : tx?.choices.method === 'update' ? t.updateImpact : tx?.choices.method === 'boot' ? t.bootImpact : t.preserve; + const waitingForOpenwrt = tx?.stage === 'openwrt_boot' && tx.status.startsWith('waiting') && !tx.unsafe; + const manualRestart = waitingForOpenwrt && tx?.details?.reboot_manually !== false; return
{t.title}{t.subtitle}
@@ -212,7 +248,7 @@ function App() {
    {t.steps.map((name, i) =>
  1. i ? 'done' : ''}>{current > i ? : i+1}
    {name}
  2. )}

{t.packageHint}

-
+
requestAnimationFrame(() => pageRef.current?.querySelector('h1')?.focus({preventScroll:true}))}> @@ -223,41 +259,45 @@ function App() { {['install','update','boot','advanced'].includes(view) && <>

{purposes.find(p => p.id === view)?.title}

{purposes.find(p => p.id === view)?.description}

{t.package}

{pkg && {t.verified}}
{pkg?.name || path || t.choosePackage}
- {view === 'update' ?

{t.device}

:

{t.device}

} + {view === 'update' ?

{t.device}

:

{t.device}

{devicesLoaded && !devices.length &&

{t.noDevices}

}{!pkg &&

{t.inspectNeedsPackage}

}
} {view === 'boot' &&

{t.visit}

} {device &&
{t.model}{device.model || t.unknown}
{t.os}{device.system || t.unknown}
{t.slot}{device.slot || t.unknown}
{t.root}{device.root ? t.ready : t.unavailable}
} {device?.readiness && device.readiness !== 'ready' &&
{stageLabel(device.readiness)}

{t.waitingAndroid}

} - {view !== 'update' && view !== 'boot' &&

{t.install}

{(view === 'advanced' ? ['reinstall','image'] : device?.existing ? ['reinstall'] : ['tf','part']).map(m => )}
+ {view !== 'update' && view !== 'boot' &&

{t.install}

{(view === 'advanced' ? ['reinstall','image'] : ['tf','part','reinstall']).map(m => )}
{method === 'image' &&
{t.experimental}
} {['part','image'].includes(method) && } {['part','reinstall'].includes(method) && }
}
} - {view === 'plan' && tx && <>
{t.review}

{tx.device.model}

{tx.package.name} · ••••{tx.device.serial.slice(-4)}

{t.target}
{tx.plan.target}
{t.android}
{gib(tx.plan.android_bytes)}
{t.allocation}
{tx.choices.method === 'boot' ? '—' : gib(tx.plan.openwrt_bytes)}
{t.grow}
{tx.plan.grow ? : '—'}
+ {view === 'plan' && tx && <>
{t.review}

{tx.device.model}

{tx.package.name} · ••••{tx.device.serial.slice(-4)}

{t.installMethod}
{tx.choices.method === 'boot' ? t.boot : tx.choices.method === 'update' ? t.update : (t as unknown as Record)[tx.choices.method]}
{t.target}
{tx.plan.target}
{t.android}
{gib(tx.plan.android_bytes)}
{t.allocation}
{tx.choices.method === 'boot' ? '—' : gib(tx.plan.openwrt_bytes)}
{t.grow}
{tx.plan.grow ? : '—'}
{t.impact}

{impact}

{tx.plan.experimental &&

{t.experimental}

}
{(tx.plan.offline || tx.plan.two_stage) &&

{t.firstBoot}

}
-
+
} {view === 'resume' && <>

{t.resume}

{t.resumeDesc}

-
{!records.length &&

{t.noRecords}

}{records.map(r =>

{r.device.model}

{stageLabel(r.stage)} · {statusLabel(r.status)}

{new Date(r.updated*1000).toLocaleString()} · {r.id.slice(0,8)}
)}
+
{!records.length &&

{t.noRecords}

}{records.map(r =>

{r.device.model}

{r.choices.method === 'boot' ? t.boot : r.choices.method === 'update' ? t.update : (t as unknown as Record)[r.choices.method]} · ••••{r.device.serial.slice(-4)}

{stageLabel(r.stage)} · {statusLabel(r.status)}

{new Date(r.updated*1000).toLocaleString()} · {r.id.slice(0,8)}
)}
} - {view === 'progress' && tx && <>
{t.progress} · {tx.device.model}

{tx.status === 'completed' ? tx.choices.method === 'boot' ? t.successBoot : tx.choices.method === 'update' ? t.successUpdate : t.success : stageLabel(tx.stage)}

{statusLabel(tx.status)}{t.elapsed} {elapsed}s
-
{tx.status === 'completed' ?
{t.actual}
{gib(tx.result?.filesystem_bytes)}
{t.visit}
{tx.result?.url}

{t.next}

{t.nextDesc}

: <> -
{tx.status === 'failed' ? : tx.status === 'running' ? : tx.status.startsWith('waiting') ? : }

{stageLabel(tx.stage)}

{tx.package.name}

- {transfer && tx.status === 'running' &&
{transfer.name}{Math.floor(transfer.bytes/transfer.total*100)}%
{t.bytes}: {gib(transfer.bytes)} / {gib(transfer.total)} · {t.speed}: {(transfer.bytes_per_second/1048576).toFixed(1)} MiB/s
} + {view === 'progress' && tx && <>
{t.progress} · {tx.device.model}

{tx.status === 'completed' ? tx.choices.method === 'boot' ? t.successBoot : tx.choices.method === 'update' ? t.successUpdate : t.success : manualRestart ? t.rebootNow : waitingForOpenwrt && tx.choices.method === 'update' ? tx.details?.connection_state === 'reconnecting' ? t.updateReconnecting : t.updateReboot : stageLabel(tx.stage)}

{statusLabel(tx.status)}{t.elapsed} {elapsed}s
+ {waitingForOpenwrt &&

{tx.choices.method === 'update' ? t.updateRebootDesc : tx.details?.boot_confirmed ? t.bootConfirmed : manualRestart ? t.rebootManual : t.rebootAutomatic}

} +
{tx.status === 'completed' ?
{t.actual}
{gib(tx.result?.filesystem_bytes)}
{t.visit}
{tx.result?.url}

{t.next}

{tx.choices.method === 'update' ? t.updateNext : t.nextDesc}

: <> + {waitingForOpenwrt ?

{t.waitingOpenwrt}

:
{tx.status === 'failed' ? : tx.status === 'running' ? : tx.status.startsWith('waiting') ? : }

{stageLabel(tx.stage)}

{tx.package.name}{tx.details?.tool ? " · "+tx.details.tool : ""}

+
{t.phase} {Math.min(5,stateGroup(tx.stage)+1)} / 5 · {statusLabel(tx.status)}{(!transfer || tx.status !== 'running') && <>
{tx.status === 'running' ? t.noPercentage : statusLabel(tx.status)}}
+ {transfer && tx.status === 'running' &&
{transfer.name}{Math.floor(transfer.bytes/transfer.total*100)}%
{t.bytes}: {transfer.bytes.toLocaleString()} / {transfer.total.toLocaleString()} B · {t.speed}: {(transfer.bytes_per_second/1048576).toFixed(1)} MiB/s
} {tx.status.startsWith('waiting') && <>

{tx.stage === 'openwrt_boot' ? t.waitingOpenwrt : t.waitingAndroid}

} {tx.unsafe &&

{t.unsafe}

} - {tx.error &&

{tx.error.message}

} -
}
{tx.status !== 'completed' &&
{active ? : }
+ {tx.error &&

{tx.error.message}

} +
}}
+ {waitingForOpenwrt &&
{tx.details?.verification_error &&

{tx.details.verification_error}

}
} + {tx.status !== 'completed' &&
{waitingForOpenwrt && }{active ? : }
}
} -
- {logOpen &&
{logs.join('\n') || '—'}
}
+
+ {logOpen &&
{t.newestFirst}
{[...logs].reverse().join('\n') || '—'}
}
OpenWrt Installer · v1.0USB / SSH · {pkg?.profile || '—'}
{t.running}
}>{helpOpen && } diff --git a/installer/ui/src/protocol.ts b/installer/ui/src/protocol.ts index 5e4e49ed..3d3d30e5 100644 --- a/installer/ui/src/protocol.ts +++ b/installer/ui/src/protocol.ts @@ -4,9 +4,10 @@ export interface Device {serial: string; model?: string; label?: string; state?: export interface Package {path: string; name: string; adapter: string; profile: string; kernel: string} export interface Transaction { id: string; status: string; stage: string; device: Device; package: Package; - choices: {method: string}; plan: {wipe: boolean; two_stage: boolean; offline?: boolean; openwrt_bytes: number; android_bytes?: number; target: string; grow?: boolean; experimental?: boolean; gap_start?: number}; - completed: string[]; unsafe: boolean; updated: number; - details?: {host?: string}; error?: {message: string; retryable: boolean; code: string}; + choices: {method: string; host?: string}; plan: {wipe: boolean; two_stage: boolean; offline?: boolean; openwrt_bytes: number; android_bytes?: number; target: string; grow?: boolean; experimental?: boolean; gap_start?: number}; + completed: string[]; unsafe: boolean; updated: number; revision?: number; + stage_started_at?: number; stage_finished_at?: number; + details?: {host?: string; tool?: string; reboot_manually?: boolean; boot_confirmed?: boolean; verification_error?: string; connection_state?: string}; error?: {message: string; retryable: boolean; code: string}; result?: {filesystem_bytes: number; url: string; backup_directory: string; temporary: boolean}; } export interface Transfer {name: string; bytes: number; total: number; bytes_per_second: number} @@ -17,7 +18,7 @@ export const native = (command: string) => invoke(command) export const gib = (bytes = 0) => (bytes / 1073741824).toFixed(2) + ' GiB'; export function stateGroup(stage: string): number { if (['plan', 'package', 'device', 'environment'].includes(stage)) return 0; - if (['backup', 'prepare'].includes(stage)) return 1; + if (['backup', 'prepare','firmware_extract','firmware_convert'].includes(stage)) return 1; if (['android_boot', 'android_setup', 'usb_debugging', 'debug_authorization', 'magisk', 'root_permission', 'root_ready', 'recheck'].includes(stage)) return 2; if (['transfer_install', 'verify_capacity', 'openwrt_boot'].includes(stage)) return 3; return 4; diff --git a/installer/ui/src/style.css b/installer/ui/src/style.css index 5b936787..0059364d 100644 --- a/installer/ui/src/style.css +++ b/installer/ui/src/style.css @@ -98,6 +98,16 @@ main{position:relative;display:flex;flex-direction:column;padding:28px 36px 18px .activity-heading>svg{color:hsl(var(--primary));flex-shrink:0;} .activity-heading p{font-size:12px;color:hsl(var(--muted-foreground));margin-top:6px;} .waiting-guidance{font-size:13px;line-height:1.9;margin-top:20px;} +.boot-guidance{display:flex;gap:10px;align-items:flex-start;flex-shrink:0;padding:12px 14px;margin:0 0 12px;border:1px solid hsl(var(--primary)/.3);border-radius:8px;background:hsl(var(--primary)/.06);font-size:13px;line-height:1.7;} +.boot-guidance>svg{flex-shrink:0;color:hsl(var(--primary));margin-top:1px;} +.boot-wait .log-inner{height:min(145px,18dvh);} +.boot-wait .status-line{margin:10px 0 14px;} +.verification-controls{flex-shrink:0;} +.verification-controls .form-grid{grid-template-columns:1fr 1fr;gap:12px;margin:8px 0 0;} +.verification-controls input{min-width:0;width:100%;} +.verification-error{font-size:12px;color:hsl(var(--destructive));line-height:1.5;margin-top:6px;} +.network-guidance{font-size:12px;line-height:1.7;} +@media(max-height:720px){.boot-wait .log-inner{height:88px;}.boot-wait .boot-guidance{padding:8px 10px;font-size:12px;line-height:1.6;margin-bottom:6px;}.boot-wait .actions{padding-top:10px;}.boot-wait .backup-actions{margin-top:8px;}.boot-wait .log-panel{margin-top:10px;padding-top:8px;}} .transfer{margin:25px 0 10px;} .transfer>div{display:flex;justify-content:space-between;font-size:12px;} progress{display:block;width:100%;height:7px;margin:13px 0;accent-color:hsl(var(--primary));border-radius:4px;} @@ -115,6 +125,7 @@ progress{display:block;width:100%;height:7px;margin:13px 0;accent-color:hsl(var( .log-toggle>span{margin-left:auto;font-size:11px;} .log-panel pre{min-height:0;flex:1;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;background:hsl(var(--muted));border-radius:6px;padding:14px;font-size:11px;white-space:pre-wrap;overflow-wrap:anywhere;} .log-actions{display:flex;justify-content:flex-end;margin:10px 0;} +.log-actions>small{margin-right:auto;align-self:center;font-size:11px;color:hsl(var(--muted-foreground));} .log-actions button{font-size:11px;height:30px;} footer{flex-shrink:0;border-top:1px solid hsl(var(--border));padding:12px 30px;display:flex;justify-content:space-between;color:hsl(var(--muted-foreground));font-size:10px;} footer span{display:flex;align-items:center;gap:6px;} @@ -135,6 +146,9 @@ h1{font-size:24px;} html,body,#root {width:100%;height:100%;overflow:hidden;} +body {-webkit-user-select:none;user-select:none;} +input:not([type=checkbox]),textarea,[contenteditable=true],.file-path,.device-card strong,.plan-list dd,.log-panel pre,.help-markdown,.help-markdown *,.app-toast .toast-description,.error-message {-webkit-user-select:text;user-select:text;} +.device-hint {font-size:12px;color:hsl(var(--muted-foreground));margin-top:12px;line-height:1.7;} * {box-sizing:border-box;} .page {display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;overflow:hidden;} .page>h1,.page>.eyebrow,.page>.status-line,.page>.resume-tools,.page>.form-grid {flex-shrink:0;} @@ -169,6 +183,13 @@ input:not([type=checkbox]):hover,select:hover {border-color:hsl(var(--primary)/. .log-inner {height:min(190px,24dvh);display:flex;flex-direction:column;} .log-panel pre {margin:0;tab-size:2;} .log-actions {flex-shrink:0;margin:6px 0;} +.stage-progress {margin-top:20px;} +.stage-progress>small {display:block;color:hsl(var(--muted-foreground));font-size:11px;line-height:1.7;} +.indeterminate-progress {height:7px;background:hsl(var(--muted));border-radius:6px;overflow:hidden;margin:10px 0 7px;} +.indeterminate-progress>div {height:100%;width:32%;border-radius:6px;background:hsl(var(--primary)/.4);} +.indeterminate-progress.is-running>div {background:hsl(var(--primary));animation:stage-activity 1.6s ease-in-out infinite;} +.copy-diagnostics {margin-top:12px;} +@keyframes stage-activity {from{transform:translateX(-105%);}to{transform:translateX(320%);}} .backup-actions {flex-shrink:0;margin:14px 0 0;} .resume-tools {margin:0 0 12px;} .resume-password {display:flex;flex-shrink:0;align-items:center;gap:12px;margin:0 0 16px;font-size:12px;} @@ -202,7 +223,7 @@ input:not([type=checkbox]):hover,select:hover {border-color:hsl(var(--primary)/. .help-topics button {width:100%;text-align:left;font-size:13px;line-height:1.6;padding:11px 12px;border-radius:7px;margin-bottom:4px;transition:background-color .15s,color .15s;} .help-topics button:hover {background:hsl(var(--muted));} .help-topics button[aria-current=page] {color:hsl(var(--primary));background:hsl(var(--primary)/.09);font-weight:600;} -.help-article {padding:24px 26px;min-height:0;user-select:text;} +.help-article {padding:24px 26px;min-height:0;} .help-article>h2 {font-size:19px;margin-bottom:18px;} .help-article:focus-visible {outline:2px solid hsl(var(--primary));outline-offset:-4px;} .help-markdown {font-size:13px;line-height:1.85;overflow-wrap:anywhere;} diff --git a/installer/verification/boot-confirm-e5-sizes.json b/installer/verification/boot-confirm-e5-sizes.json new file mode 100644 index 00000000..46b93b98 --- /dev/null +++ b/installer/verification/boot-confirm-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3518464, + "backend_and_tools_bytes": 43109647, + "firmware_payload_bytes": 241030658, + "archive_bytes": 210069950, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "b26c7cccc2269f746f9d2233b6eabcc42903f4471c69f54a11888d5dcf84410d", + "payloads_unchanged": true, + "gui_sha256": "9638d8ac2514aed2caf03b86161f1e8846808d9615d09afc938a49560b3818dd" + }, + { + "gui_bytes": 3518464, + "backend_and_tools_bytes": 43109647, + "firmware_payload_bytes": 240109945, + "archive_bytes": 209648831, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "6ceb5480f8502e9d686fd39bd58c9d04c87d59fa534cffb10af0bf234139e0ce", + "payloads_unchanged": true, + "gui_sha256": "9638d8ac2514aed2caf03b86161f1e8846808d9615d09afc938a49560b3818dd" + }, + { + "gui_bytes": 3518464, + "backend_and_tools_bytes": 43109647, + "firmware_payload_bytes": 240961735, + "archive_bytes": 210092619, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "4e82631c23cb00f77b4613f77b0cd8661234d8e804f600ce84304f8b4ac3ef5f", + "payloads_unchanged": true, + "gui_sha256": "9638d8ac2514aed2caf03b86161f1e8846808d9615d09afc938a49560b3818dd" + } +] diff --git a/installer/verification/boot-confirm-frozen-flows.json b/installer/verification/boot-confirm-frozen-flows.json new file mode 100644 index 00000000..36158a98 --- /dev/null +++ b/installer/verification/boot-confirm-frozen-flows.json @@ -0,0 +1,62 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/boot-confirm-frozen-methods.json b/installer/verification/boot-confirm-frozen-methods.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/boot-confirm-frozen-methods.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/boot-confirm-mu300-sizes.json b/installer/verification/boot-confirm-mu300-sizes.json new file mode 100644 index 00000000..f06e7e08 --- /dev/null +++ b/installer/verification/boot-confirm-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3518464, + "backend_and_tools_bytes": 46045032, + "firmware_payload_bytes": 145582695, + "archive_bytes": 120098354, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "06da3d038f3150b68b2a33bd4d68cd1e1e56f01550bcac4cd877e2fed1da7498", + "payloads_unchanged": true, + "gui_sha256": "9638d8ac2514aed2caf03b86161f1e8846808d9615d09afc938a49560b3818dd" + }, + { + "gui_bytes": 3518464, + "backend_and_tools_bytes": 46045031, + "firmware_payload_bytes": 146076011, + "archive_bytes": 121172883, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "d9a942b06c0d05ccabd7fd606d9767d99aa31bba5e5515e039d264b5c4cd6c29", + "payloads_unchanged": true, + "gui_sha256": "9638d8ac2514aed2caf03b86161f1e8846808d9615d09afc938a49560b3818dd" + } +] diff --git a/installer/verification/boot-confirm-packages.json b/installer/verification/boot-confirm-packages.json new file mode 100644 index 00000000..df4f09f5 --- /dev/null +++ b/installer/verification/boot-confirm-packages.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-boot-confirm\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-boot-confirm\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-boot-confirm\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-boot-confirm\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-boot-confirm\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/boot-confirm-record-compatibility.json b/installer/verification/boot-confirm-record-compatibility.json new file mode 100644 index 00000000..3934de91 --- /dev/null +++ b/installer/verification/boot-confirm-record-compatibility.json @@ -0,0 +1,8 @@ +{ + "package_compatible": true, + "status": "failed", + "stage": "prepare", + "hardware_access": false, + "record_modified": false, + "artifact_sources_match": true +} diff --git a/installer/verification/boot-confirm.json b/installer/verification/boot-confirm.json new file mode 100644 index 00000000..72b01c36 --- /dev/null +++ b/installer/verification/boot-confirm.json @@ -0,0 +1,29 @@ +{ + "revision": "20261015-boot-confirm", + "changes": [ + "Newest-first UI log entries with multiline traceback order preserved; persistent diagnostics remain chronological", + "Pinned manual restart instructions and distinct requested automatic restart guidance", + "Explicit boot confirmation with editable management host and in-memory SSH password", + "Wrong-device, connection and authentication errors permit endpoint correction on the existing worker", + "Persisted endpoint and boot confirmation; original CID and final capacity verification remain mandatory" + ], + "backend_tests": { + "e5": {"run": 70, "passed": 70, "skipped": 0}, + "mu300": {"run": 70, "passed": 68, "skipped": 2}, + "new_cases": [ + "Manual versus automatic restart across methods and application restart", + "Confirmation queues a check without completing or persisting credentials", + "Reject stale transaction, unsafe phase and invalid endpoint requests", + "Two OpenWrt endpoints: reject wrong CID, select original device, then verify capacity", + "Correct SSH authentication failure while waiting", + "Manual confirmation cannot bypass filesystem capacity mismatch" + ] + }, + "browser_suites": {"passed": 6, "report": "ui-regression.json", "minimum_viewport": "800x650", "checked": ["Newest-first multiline logs", "Pinned instructions with logs expanded", "Editable endpoint and boot-confirmation request", "Wrong-device retry", "Chinese/light and English/dark"]}, + "windows_release_build": {"tauri": "passed", "frozen_backend": "passed", "native_webview2_launch": "passed"}, + "frozen_packages": {"count": 5, "cli_protocol_utf8_adb_start": "boot-confirm-packages.json", "method_routing": "boot-confirm-frozen-methods.json", "backup_recovery_explicit_confirmation_capacity": "boot-confirm-frozen-flows.json", "zip_crc_and_single_system_payload": "passed", "critical_firmware_hashes": "unchanged"}, + "original_supplied_record": "boot-confirm-record-compatibility.json", + "hardware_access": false, + "device_reboot_or_install_performed": false, + "size_reports": ["boot-confirm-e5-sizes.json", "boot-confirm-mu300-sizes.json"] +} diff --git a/installer/verification/debug-artifact-flow.json b/installer/verification/debug-artifact-flow.json new file mode 100644 index 00000000..80411128 --- /dev/null +++ b/installer/verification/debug-artifact-flow.json @@ -0,0 +1,13 @@ +[ + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/debug-e5-sizes.json b/installer/verification/debug-e5-sizes.json new file mode 100644 index 00000000..083e64fc --- /dev/null +++ b/installer/verification/debug-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3516416, + "backend_and_tools_bytes": 43104900, + "firmware_payload_bytes": 241030208, + "archive_bytes": 209777381, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "29b773dbcf5f96db8db28dabcb1772f97d702d6a20c860cc96db339bdcf7ca01", + "payloads_unchanged": true, + "gui_sha256": "a8291f39c6eb9b7ce4881d167b7a3caf65d1903505227fd56762f27254e7007a" + }, + { + "gui_bytes": 3516416, + "backend_and_tools_bytes": 43104900, + "firmware_payload_bytes": 240109495, + "archive_bytes": 209356259, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "fbd1620ea1b8ec5d628c65d3fbe5523ab61e5ebaee976d07db232338b033e256", + "payloads_unchanged": true, + "gui_sha256": "a8291f39c6eb9b7ce4881d167b7a3caf65d1903505227fd56762f27254e7007a" + }, + { + "gui_bytes": 3516416, + "backend_and_tools_bytes": 43104900, + "firmware_payload_bytes": 240961285, + "archive_bytes": 209800043, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "1b80f76ddd2c0c452b653ac6212eb26d6692e0b53379f39cdc89ea0e45375f3a", + "payloads_unchanged": true, + "gui_sha256": "a8291f39c6eb9b7ce4881d167b7a3caf65d1903505227fd56762f27254e7007a" + } +] diff --git a/installer/verification/debug-frozen-flows.json b/installer/verification/debug-frozen-flows.json new file mode 100644 index 00000000..a0888b6b --- /dev/null +++ b/installer/verification/debug-frozen-flows.json @@ -0,0 +1,57 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/debug-frozen-methods.json b/installer/verification/debug-frozen-methods.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/debug-frozen-methods.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/debug-mu300-sizes.json b/installer/verification/debug-mu300-sizes.json new file mode 100644 index 00000000..5f3bf2e5 --- /dev/null +++ b/installer/verification/debug-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3516416, + "backend_and_tools_bytes": 46039799, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119805820, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "27c5c26f447d080ece83e8ca4a900c6857ce3104a50a4c72ab6f540034338bc8", + "payloads_unchanged": true, + "gui_sha256": "a8291f39c6eb9b7ce4881d167b7a3caf65d1903505227fd56762f27254e7007a" + }, + { + "gui_bytes": 3516416, + "backend_and_tools_bytes": 46039798, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120880345, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "c6635c9d1feca82523afb75d7df78efa9b4fbeabdfee81b3190421dc8706ee69", + "payloads_unchanged": true, + "gui_sha256": "a8291f39c6eb9b7ce4881d167b7a3caf65d1903505227fd56762f27254e7007a" + } +] diff --git a/installer/verification/debug-packages.json b/installer/verification/debug-packages.json new file mode 100644 index 00000000..86f0950c --- /dev/null +++ b/installer/verification/debug-packages.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-debug\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-debug\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-debug\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-debug\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-debug\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/debug.json b/installer/verification/debug.json new file mode 100644 index 00000000..d67a720c --- /dev/null +++ b/installer/verification/debug.json @@ -0,0 +1,20 @@ +{ + "backend_tests": { + "e5": { + "run": 56, + "passed": 56 + }, + "mu300": { + "run": 56, + "passed": 55, + "skipped": 1 + } + }, + "ui_suites": 6, + "device_script_suites_passed": 27, + "device_script_suites_environment_blocked": 1, + "frozen_packages_passed": 5, + "supplied_m8_transaction_compatible": true, + "hardware_partition_writes": false, + "m8_frozen_backup_seconds": 17.94 +} diff --git a/installer/verification/flow-posix.json b/installer/verification/flow-posix.json new file mode 100644 index 00000000..0dd5e87d --- /dev/null +++ b/installer/verification/flow-posix.json @@ -0,0 +1,201 @@ +[ + { + "repository": "e5-linux", + "test": "openwrt/tests/install-entrypoints.py", + "exit": 0, + "stdout": "\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n\nOpenWrt Installer / \u5b89\u88c5\u52a9\u624b\n 1. Install to TF card / TF \u5361\u9996\u6b21\u5b89\u88c5\uff08\u6e05\u7a7a\u7b2c\u4e00\u5206\u533a\uff0c\u65e0\u5206\u533a\u5219\u6574\u5361\uff09\n 2. Install to internal storage / \u7f29\u5bb9 userdata \u5b89\u88c5\n 3. Reinstall internal system / \u8986\u76d6\u91cd\u88c5\u5df2\u6709\u5185\u7f6e\u7cfb\u7edf\n 4. Resume internal installation / \u7ee7\u7eed\u52a0\u5bc6 data \u7684\u4e24\u9636\u6bb5\u5b89\u88c5\n 5. Boot OpenWrt once / \u4ece Android \u4e34\u65f6\u542f\u52a8\u5df2\u5b89\u88c5\u7684 OpenWrt\uff08\u4ec5\u4fee\u6539 misc\uff09\n 6. Update OpenWrt / \u66f4\u65b0\u5df2\u8fd0\u884c\u7684 OpenWrt\n 7. Install to userdata image [EXPERIMENTAL] / userdata \u955c\u50cf\u5b89\u88c5\u3010\u5b9e\u9a8c\u6027\uff1a\u53ef\u80fd\u635f\u574f Android F2FS\uff0c\u4ec5\u672a\u52a0\u5bc6 data\u3011\n 0. Exit / \u9000\u51fa\n\n", + "stderr": ".......\n----------------------------------------------------------------------\nRan 7 tests in 0.272s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/installed-openwrt.py", + "exit": 0, + "stdout": "", + "stderr": "...\n----------------------------------------------------------------------\nRan 3 tests in 0.021s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/flash-diagnostics.py", + "exit": 0, + "stdout": "Boot control backup: /tmp/tmpm3jo8kk3/backups/before.D9HHhw\n\n\n[4/9] \u8fde\u63a5\u8bbe\u5907 / looking for Android (USB debugging on)\n\n[5/9] \u8fde\u63a5\u8bbe\u5907 / looking for Android (USB debugging on)\n\n[6/9] \u8fde\u63a5\u8bbe\u5907 / looking for Android (USB debugging on)\n", + "stderr": "......................\n----------------------------------------------------------------------\nRan 22 tests in 0.234s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/part-two-stage.py", + "exit": 0, + "stdout": " \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: file; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: file; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u4e24\u9636\u6bb5\u5b89\u88c5\uff1a\u91cd\u5efa\u5206\u533a \u2192 \u539f\u5382 recovery \u6e05\u7a7a\u6570\u636e \u2192 Android \u91cd\u65b0\u6388\u6743 \u2192 \u5b89\u88c5 OpenWrt\u3002\n \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: file; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: file; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u4e24\u9636\u6bb5\u5b89\u88c5\uff1a\u91cd\u5efa\u5206\u533a \u2192 \u539f\u5382 recovery \u6e05\u7a7a\u6570\u636e \u2192 Android \u91cd\u65b0\u6388\u6743 \u2192 \u5b89\u88c5 OpenWrt\u3002\n \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: block; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u68c0\u6d4b\u5230 data \u52a0\u5bc6 / data encryption: block; \u672c\u6b21\u5b89\u88c5\u5fc5\u987b\u683c\u5f0f\u5316 userdata / formatting userdata is required.\n \u8b66\u544a / WARNING: Android \u5e94\u7528\u3001\u8d26\u53f7\u3001\u7167\u7247\u53ca\u5185\u90e8\u5b58\u50a8\u6587\u4ef6\u5c06\u88ab\u6e05\u7a7a\u3002\n ALL Android apps, accounts, photos and internal storage files will be erased.\n \u4e24\u9636\u6bb5\u5b89\u88c5\uff1a\u91cd\u5efa\u5206\u533a \u2192 \u539f\u5382 recovery \u6e05\u7a7a\u6570\u636e \u2192 Android \u91cd\u65b0\u6388\u6743 \u2192 \u5b89\u88c5 OpenWrt\u3002\n \u73b0\u6709\u7cfb\u7edf\u7684\u8bbe\u7f6e\u8bfb\u4e0d\u51fa\u6765\uff08e5root \u6302\u8f7d\u5931\u8d25\uff0c\u591a\u534a\u6587\u4ef6\u7cfb\u7edf\u5df2\u635f\u574f\uff09\uff1b\u6cbf\u7528\u547d\u4ee4\u884c\u4e0e\u9ed8\u8ba4\u503c / could not read the installed settings; using the command line and defaults\n\n \u8986\u76d6\u91cd\u88c5 / rewriting the existing installation\n e5root: mmcblk0p71 (10240 MiB), userdata \u4e0d\u52a8\n Android \u7528\u6237\u6570\u636e\u3001\u5206\u533a\u8868\u3001userdata \u6587\u4ef6\u7cfb\u7edf\u90fd\u4fdd\u7559\uff1b\u4f1a\u91cd\u5199 e5root \u5e76\u5237\u65b0 boot_b\u3002\n hotspot: E5-OpenWrt \u5bc6\u7801 / key: abcdefgh12\n \u4e8b\u52a1\u8bb0\u5f55 / transaction: /tmp/tmp6t3aia3w/package/reinstalls/20261015-190128-bcd7ad03/transaction.json\n", + "stderr": ".\n\u9519\u8bef / error: encrypted userdata requires --format-userdata as explicit erase consent; -y alone is insufficient\n\n\u9519\u8bef / error: encrypted userdata requires --format-userdata as explicit erase consent; -y alone is insufficient\n\n\u9519\u8bef / error: encrypted userdata requires --format-userdata as explicit erase consent; -y alone is insufficient\n........\n----------------------------------------------------------------------\nRan 9 tests in 4.212s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/tf-single-root.py", + "exit": 0, + "stdout": "Creating regular file /tmp/tmpcs3z_wyu/tf.ext4\n", + "stderr": ".....\n----------------------------------------------------------------------\nRan 5 tests in 0.223s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/part-root-boot.py", + "exit": 0, + "stdout": "", + "stderr": ".....\n----------------------------------------------------------------------\nRan 5 tests in 0.038s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/userdata-size.py", + "exit": 0, + "stdout": "", + "stderr": "...\n\u9519\u8bef / error: userdata image sizes must be aligned to MiB\n...\n----------------------------------------------------------------------\nRan 6 tests in 0.006s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/hybrid-package.py", + "exit": 0, + "stdout": "", + "stderr": "./mnt/d/Git/e5-linux/tools/sprd-bt-config.py:26: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmp6iqbzmz9/raw/bt_configure_pskey.xpe.ini' mode='r' encoding='UTF-8'>\n for raw in open(path, errors=\"replace\"):\nResourceWarning: Enable tracemalloc to get the object allocation traceback\n/mnt/d/Git/e5-linux/tools/sprd-bt-config.py:26: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmp6iqbzmz9/raw/bt_configure_rf.xpe.ini' mode='r' encoding='UTF-8'>\n for raw in open(path, errors=\"replace\"):\nResourceWarning: Enable tracemalloc to get the object allocation traceback\n/mnt/d/Git/e5-linux/tools/vbc-profile/vbc-profile.py:92: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/tmp6iqbzmz9/raw/dsp_vbc.xml'>\n head = path.open(\"rb\").read(4096)\nResourceWarning: Enable tracemalloc to get the object allocation traceback\n/mnt/d/Git/e5-linux/tools/vbc-profile/vbc-profile.py:92: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/tmp6iqbzmz9/raw/audio_structure.xml'>\n head = path.open(\"rb\").read(4096)\nResourceWarning: Enable tracemalloc to get the object allocation traceback\n/mnt/d/Git/e5-linux/tools/vbc-profile/vbc-profile.py:92: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/tmp6iqbzmz9/raw/cvs.xml'>\n head = path.open(\"rb\").read(4096)\nResourceWarning: Enable tracemalloc to get the object allocation traceback\n.......\n----------------------------------------------------------------------\nRan 8 tests in 1.175s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/gpt-plan.py", + "exit": 1, + "stdout": "", + "stderr": "Traceback (most recent call last):\n File \"/mnt/d/Git/e5-linux/openwrt/tests/gpt-plan.py\", line 72, in \n check('enough', 16384, [(1, 1, 1024, 'e5root')], True, 'debian-b')\n File \"/mnt/d/Git/e5-linux/openwrt/tests/gpt-plan.py\", line 63, in check\n assert (result.returncode == 0) == success, (name, result.stdout, result.stderr)\nAssertionError: ('enough', '', \"Unable to find image 'e5-openwrt-base:25.12.5' locally\\ndocker: error getting credentials - err: exit status 1, out: ``\\n\\nRun 'docker run --help' for more information\\n\")\nError in sys.excepthook:\nTraceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 76, in apport_excepthook\n binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0]))\nFileNotFoundError: [Errno 2] No such file or directory\n\nOriginal exception was:\nTraceback (most recent call last):\n File \"/mnt/d/Git/e5-linux/openwrt/tests/gpt-plan.py\", line 72, in \n check('enough', 16384, [(1, 1, 1024, 'e5root')], True, 'debian-b')\n File \"/mnt/d/Git/e5-linux/openwrt/tests/gpt-plan.py\", line 63, in check\n assert (result.returncode == 0) == success, (name, result.stdout, result.stderr)\nAssertionError: ('enough', '', \"Unable to find image 'e5-openwrt-base:25.12.5' locally\\ndocker: error getting credentials - err: exit status 1, out: ``\\n\\nRun 'docker run --help' for more information\\n\")\n", + "status": "environment_blocked", + "reason": "Required local e5-openwrt-base:25.12.5 Docker image is missing; no image or Docker installed for this task" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/image-keep-config.py", + "exit": 0, + "stdout": "== keeping the configuration of /tmp/tmp_9v4aiws/old-True\n== keeping the configuration of /tmp/tmp_9v4aiws/old-False\nPASS: bundled phone upgraded; contacts, credentials, settings and other apps preserved; legacy image fallback\n", + "stderr": "" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/update-ssh-host-key.py", + "exit": 0, + "stdout": "", + "stderr": "s\n----------------------------------------------------------------------\nRan 1 test in 0.000s\n\nOK (skipped=1)\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/boot-default.py", + "exit": 0, + "stdout": "", + "stderr": ".........\n----------------------------------------------------------------------\nRan 9 tests in 0.251s\n\nOK\n" + }, + { + "repository": "e5-linux", + "test": "openwrt/tests/android-loop.py", + "exit": 0, + "stdout": "", + "stderr": "..........\n----------------------------------------------------------------------\nRan 10 tests in 0.085s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_desktop_installer.py", + "exit": 0, + "stdout": "Preparing shared rootfs / \u51c6\u5907\u5171\u4eab\u7cfb\u7edf\u5305\uff0c\u5254\u9664\u6784\u5efa\u673a\u56fa\u4ef6\u2026\n Rootfs ready / \u7cfb\u7edf\u5305\u51c6\u5907\u5b8c\u6210: 0.0 s\nCompatible repair package verified / \u4fee\u590d\u7248\u5173\u952e\u5b89\u88c5\u8f7d\u8377\u4e00\u81f4\uff0c\u53ef\u7ee7\u7eed\u7eed\u88c5\u3002\nPreparing shared rootfs / \u51c6\u5907\u5171\u4eab\u7cfb\u7edf\u5305\uff0c\u5254\u9664\u6784\u5efa\u673a\u56fa\u4ef6\u2026\n Rootfs ready / \u7cfb\u7edf\u5305\u51c6\u5907\u5b8c\u6210: 0.0 s\nPreparing shared rootfs / \u51c6\u5907\u5171\u4eab\u7cfb\u7edf\u5305\uff0c\u5254\u9664\u6784\u5efa\u673a\u56fa\u4ef6\u2026\n Rootfs ready / \u7cfb\u7edf\u5305\u51c6\u5907\u5b8c\u6210: 0.0 s\nReboot request sent / \u5df2\u53d1\u9001\u91cd\u542f\u8bf7\u6c42\u3002\nPreparing shared rootfs / \u51c6\u5907\u5171\u4eab\u7cfb\u7edf\u5305\uff0c\u5254\u9664\u6784\u5efa\u673a\u56fa\u4ef6\u2026\n Rootfs ready / \u7cfb\u7edf\u5305\u51c6\u5907\u5b8c\u6210: 0.0 s\nPreparing shared rootfs / \u51c6\u5907\u5171\u4eab\u7cfb\u7edf\u5305\uff0c\u5254\u9664\u6784\u5efa\u673a\u56fa\u4ef6\u2026\n Rootfs ready / \u7cfb\u7edf\u5305\u51c6\u5907\u5b8c\u6210: 0.0 s\nDevice / \u8bbe\u5907: V50 Android a Linux b\n", + "stderr": "................................s.\n----------------------------------------------------------------------\nRan 34 tests in 0.450s\n\nOK (skipped=1)\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_desktop_fsck.py", + "exit": 0, + "stdout": "", + "stderr": "" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_desktop_free_space.py", + "exit": 0, + "stdout": "Device / \u8bbe\u5907: V50 Android a Linux b\neMMC / \u95ea\u5b58: 64.00 GiB; GPT unused / \u672a\u5206\u914d\u53ef\u7528: 32.00 GiB\n", + "stderr": ".....\n----------------------------------------------------------------------\nRan 5 tests in 0.006s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_desktop_free_loop.py", + "exit": 0, + "stdout": "", + "stderr": "sss\n----------------------------------------------------------------------\nRan 3 tests in 0.000s\n\nOK (skipped=3)\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_boot_image.py", + "exit": 0, + "stdout": "", + "stderr": "......\n----------------------------------------------------------------------\nRan 6 tests in 0.368s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_bootchain.py", + "exit": 0, + "stdout": "", + "stderr": ".................................\n----------------------------------------------------------------------\nRan 33 tests in 4.683s\n\nOK\n", + "initial_failure": "BusyBox applet bypassed PATH dd fault injection; fixed fixture to explicitly call injected dd" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_update.py", + "exit": 0, + "stdout": "", + "stderr": "............\n----------------------------------------------------------------------\nRan 12 tests in 1.486s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_update_lock.py", + "exit": 0, + "stdout": "", + "stderr": "" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_tf_format.py", + "exit": 0, + "stdout": "", + "stderr": ".\n----------------------------------------------------------------------\nRan 1 test in 0.002s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_tf_slots.py", + "exit": 0, + "stdout": "", + "stderr": "..\n----------------------------------------------------------------------\nRan 2 tests in 0.082s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_tf_reliability.py", + "exit": 0, + "stdout": "", + "stderr": "..............\n----------------------------------------------------------------------\nRan 14 tests in 13.911s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_installer.py", + "exit": 0, + "stdout": "", + "stderr": ".......\n----------------------------------------------------------------------\nRan 7 tests in 0.513s\n\nOK\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_board_recovery.py", + "exit": 0, + "stdout": "", + "stderr": "sss\n----------------------------------------------------------------------\nRan 3 tests in 0.000s\n\nOK (skipped=3)\n" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_block_probe.py", + "exit": 0, + "stdout": "", + "stderr": "" + }, + { + "repository": "mu300-linux-clean-tf-7.2", + "test": "tests/test_android_loop.py", + "exit": 0, + "stdout": "", + "stderr": "..........\n----------------------------------------------------------------------\nRan 10 tests in 0.081s\n\nOK\n" + } +] diff --git a/installer/verification/helper-real-m8.json b/installer/verification/helper-real-m8.json new file mode 100644 index 00000000..81643cc9 --- /dev/null +++ b/installer/verification/helper-real-m8.json @@ -0,0 +1,30 @@ +{ + "frozen_backend": true, + "real_captured_m8_inputs": true, + "hardware_access": false, + "seconds": 0.562, + "outputs": { + "audio_structure": { + "bytes": 48934, + "matches_reference": true + }, + "cvs": { + "bytes": 55500, + "matches_reference": true + }, + "dsp_vbc": { + "bytes": 124728, + "matches_reference": true + }, + "sprd/marlin3lite_pskey.bin": { + "bytes": 176, + "matches_reference": true + }, + "sprd/marlin3lite_rf.bin": { + "bytes": 252, + "matches_reference": true + } + }, + "converter_stdout_captured": true, + "named_conversion_stage": true +} diff --git a/installer/verification/helpers-e5-sizes.json b/installer/verification/helpers-e5-sizes.json new file mode 100644 index 00000000..fdef35b1 --- /dev/null +++ b/installer/verification/helpers-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3516928, + "backend_and_tools_bytes": 43107925, + "firmware_payload_bytes": 241030321, + "archive_bytes": 209844698, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "abdf4f0ebcae9cc227361456b168b3e39d2837520fb02f43a76ed0f4e609d771", + "payloads_unchanged": true, + "gui_sha256": "d8999b004311a644ae15c0ca8615c4b33c545d3fd01b08b0fc4ea5c4ea7abc97" + }, + { + "gui_bytes": 3516928, + "backend_and_tools_bytes": 43107925, + "firmware_payload_bytes": 240109608, + "archive_bytes": 209423580, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "d5bfa0c260ede177ff49e8b9ee7b1692bbc9f2186103c16bb1d23be5795062f2", + "payloads_unchanged": true, + "gui_sha256": "d8999b004311a644ae15c0ca8615c4b33c545d3fd01b08b0fc4ea5c4ea7abc97" + }, + { + "gui_bytes": 3516928, + "backend_and_tools_bytes": 43107925, + "firmware_payload_bytes": 240961398, + "archive_bytes": 209867358, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "eeecf78e6275b50f4c406552f559f74eb5edb3a6fe9a126296b7679d7a7ff217", + "payloads_unchanged": true, + "gui_sha256": "d8999b004311a644ae15c0ca8615c4b33c545d3fd01b08b0fc4ea5c4ea7abc97" + } +] diff --git a/installer/verification/helpers-frozen-flows.json b/installer/verification/helpers-frozen-flows.json new file mode 100644 index 00000000..a0888b6b --- /dev/null +++ b/installer/verification/helpers-frozen-flows.json @@ -0,0 +1,57 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/helpers-frozen-methods.json b/installer/verification/helpers-frozen-methods.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/helpers-frozen-methods.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/helpers-mu300-sizes.json b/installer/verification/helpers-mu300-sizes.json new file mode 100644 index 00000000..4c3ef38c --- /dev/null +++ b/installer/verification/helpers-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3516928, + "backend_and_tools_bytes": 46042946, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119873074, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "3e985d4d9ea6c39e7cc64e74618b4c817a1d13ef914c50551a88120455ef1c28", + "payloads_unchanged": true, + "gui_sha256": "d8999b004311a644ae15c0ca8615c4b33c545d3fd01b08b0fc4ea5c4ea7abc97" + }, + { + "gui_bytes": 3516928, + "backend_and_tools_bytes": 46042945, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120947596, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "6b01a4fab3e6f94d0530e134ffe3544316fae2b98f4bb15b391d8541d8bfc29b", + "payloads_unchanged": true, + "gui_sha256": "d8999b004311a644ae15c0ca8615c4b33c545d3fd01b08b0fc4ea5c4ea7abc97" + } +] diff --git a/installer/verification/helpers-packages.json b/installer/verification/helpers-packages.json new file mode 100644 index 00000000..19eff954 --- /dev/null +++ b/installer/verification/helpers-packages.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-helpers\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-helpers\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-helpers\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-helpers\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-helpers\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/helpers-record-compatibility.json b/installer/verification/helpers-record-compatibility.json new file mode 100644 index 00000000..1fc3f574 --- /dev/null +++ b/installer/verification/helpers-record-compatibility.json @@ -0,0 +1,8 @@ +{ + "package_compatible": true, + "status": "failed", + "stage": "prepare", + "effects": {}, + "hardware_access": false, + "artifact_sources_match": true +} diff --git a/installer/verification/helpers.json b/installer/verification/helpers.json new file mode 100644 index 00000000..aa00c66c --- /dev/null +++ b/installer/verification/helpers.json @@ -0,0 +1,34 @@ +{ + "revision": "20261015-helpers", + "root_cause": { + "reproduced": "Optimized frozen helper execution strips the VBC converter module docstring; argparse description initialization raises AttributeError.", + "original_hang": "The original converter child remained alive without captured output or an execution timeout; the exact reason it remained alive is not established.", + "supplied_final_error": "Exit 4294967295 followed deliberate termination of the host converter child after verifying that the saved transaction had no partition or boot-write effects." + }, + "backend_tests": { + "e5": {"run": 64, "passed": 64, "skipped": 0}, + "mu300": {"run": 64, "passed": 62, "skipped": 2}, + "new_helper_cases": 8 + }, + "browser_suites": {"passed": 6, "report": "ui-regression.json"}, + "targeted_device_script_tests": { + "environment": "WSL Ubuntu 22.04, simulated commands and temporary files", + "flash-diagnostics": 22, + "part-two-stage": 9, + "hybrid-package": 8, + "install-entrypoints": 7 + }, + "windows_build": {"native_tauri_release": "passed", "pyinstaller_backend": "passed", "native_webview2_launch": "passed"}, + "real_m8_conversion": {"report": "helper-real-m8.json", "inputs": "Previously captured private firmware files; no device access", "reference": "All five output files match normal Python bytes"}, + "frozen_package_checks": { + "packages": 5, + "cli_ndjson_utf8_adb_start": "helpers-packages.json", + "method_isolation": "helpers-frozen-methods.json", + "simulated_backup_recovery_diagnostics_capacity": "helpers-frozen-flows.json", + "zip_crc_and_single_system_payload": "passed for all five archives", + "firmware_payload_hashes": "unchanged" + }, + "user_saved_record": {"report": "helpers-record-compatibility.json", "compatible": true, "partition_or_boot_effects": 0}, + "hardware_installation_performed": false, + "size_reports": ["helpers-e5-sizes.json", "helpers-mu300-sizes.json"] +} diff --git a/installer/verification/m8-frozen-backup.json b/installer/verification/m8-frozen-backup.json new file mode 100644 index 00000000..240c993b --- /dev/null +++ b/installer/verification/m8-frozen-backup.json @@ -0,0 +1,90 @@ +{ + "model": "VIPME M8", + "matched_saved_hardware_identity": true, + "device_partition_writes": false, + "device_temporary_staging": true, + "method": "dd to /data/local/tmp + adb pull", + "frozen_backend": true, + "original_backup_preserved": true, + "seconds": 17.94, + "backups": [ + { + "partition": "misc", + "bytes": 4096, + "seconds": 0.92, + "sha256_readback_verified": true + }, + { + "partition": "boot_a", + "bytes": 67108864, + "seconds": 3.48, + "sha256_readback_verified": true + }, + { + "partition": "boot_b", + "bytes": 67108864, + "seconds": 3.47, + "sha256_readback_verified": true + }, + { + "partition": "uboot_a", + "bytes": 3145728, + "seconds": 0.95, + "sha256_readback_verified": true + }, + { + "partition": "uboot_b", + "bytes": 3145728, + "seconds": 0.97, + "sha256_readback_verified": true + }, + { + "partition": "sml_a", + "bytes": 1048576, + "seconds": 0.88, + "sha256_readback_verified": true + }, + { + "partition": "sml_b", + "bytes": 1048576, + "seconds": 0.84, + "sha256_readback_verified": true + }, + { + "partition": "teecfg_a", + "bytes": 1048576, + "seconds": 0.91, + "sha256_readback_verified": true + }, + { + "partition": "teecfg_b", + "bytes": 1048576, + "seconds": 0.88, + "sha256_readback_verified": true + }, + { + "partition": "trustos_a", + "bytes": 6291456, + "seconds": 1.14, + "sha256_readback_verified": true + }, + { + "partition": "trustos_b", + "bytes": 6291456, + "seconds": 1.11, + "sha256_readback_verified": true + }, + { + "partition": "vbmeta_a", + "bytes": 1048576, + "seconds": 0.95, + "sha256_readback_verified": true + }, + { + "partition": "vbmeta_b", + "bytes": 1048576, + "seconds": 0.89, + "sha256_readback_verified": true + } + ] +} diff --git a/installer/verification/m8-readonly-backup.json b/installer/verification/m8-readonly-backup.json new file mode 100644 index 00000000..026721a8 --- /dev/null +++ b/installer/verification/m8-readonly-backup.json @@ -0,0 +1,89 @@ +{ + "model": "VIPME M8", + "matched_saved_hardware_identity": true, + "device_partition_writes": false, + "device_temporary_staging": true, + "method": "dd to /data/local/tmp + adb pull", + "original_backup_preserved": true, + "seconds": 17.7, + "backups": [ + { + "partition": "misc", + "bytes": 4096, + "seconds": 0.83, + "sha256_readback_verified": true + }, + { + "partition": "boot_a", + "bytes": 67108864, + "seconds": 3.39, + "sha256_readback_verified": true + }, + { + "partition": "boot_b", + "bytes": 67108864, + "seconds": 3.59, + "sha256_readback_verified": true + }, + { + "partition": "uboot_a", + "bytes": 3145728, + "seconds": 0.92, + "sha256_readback_verified": true + }, + { + "partition": "uboot_b", + "bytes": 3145728, + "seconds": 0.97, + "sha256_readback_verified": true + }, + { + "partition": "sml_a", + "bytes": 1048576, + "seconds": 0.91, + "sha256_readback_verified": true + }, + { + "partition": "sml_b", + "bytes": 1048576, + "seconds": 0.88, + "sha256_readback_verified": true + }, + { + "partition": "teecfg_a", + "bytes": 1048576, + "seconds": 0.91, + "sha256_readback_verified": true + }, + { + "partition": "teecfg_b", + "bytes": 1048576, + "seconds": 0.89, + "sha256_readback_verified": true + }, + { + "partition": "trustos_a", + "bytes": 6291456, + "seconds": 1.09, + "sha256_readback_verified": true + }, + { + "partition": "trustos_b", + "bytes": 6291456, + "seconds": 1.06, + "sha256_readback_verified": true + }, + { + "partition": "vbmeta_a", + "bytes": 1048576, + "seconds": 0.86, + "sha256_readback_verified": true + }, + { + "partition": "vbmeta_b", + "bytes": 1048576, + "seconds": 0.86, + "sha256_readback_verified": true + } + ] +} diff --git a/installer/verification/reboot-wait-e5-sizes.json b/installer/verification/reboot-wait-e5-sizes.json new file mode 100644 index 00000000..d2a700b3 --- /dev/null +++ b/installer/verification/reboot-wait-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3520000, + "backend_and_tools_bytes": 43111260, + "firmware_payload_bytes": 241030984, + "archive_bytes": 210306332, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "8207e1b3223cc2f38340bca5970ff54a45baa049592292579549dc7c8aa5a1a5", + "payloads_unchanged": true, + "gui_sha256": "c287e39628fe20a42d563f9b8b8272f8dd3bf19a0cb7134285e450dbfdc92f7e" + }, + { + "gui_bytes": 3520000, + "backend_and_tools_bytes": 43111260, + "firmware_payload_bytes": 240110271, + "archive_bytes": 209885205, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "6e79a2f88489a7c1cd4a6b346974dd656899c57515de3a6c2aa8eafe5568b773", + "payloads_unchanged": true, + "gui_sha256": "c287e39628fe20a42d563f9b8b8272f8dd3bf19a0cb7134285e450dbfdc92f7e" + }, + { + "gui_bytes": 3520000, + "backend_and_tools_bytes": 43111260, + "firmware_payload_bytes": 240962061, + "archive_bytes": 210328993, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "a28770c4a19bbeee3958dafdb0d27cf5ad02415789c2e809db3e0f8eea514043", + "payloads_unchanged": true, + "gui_sha256": "c287e39628fe20a42d563f9b8b8272f8dd3bf19a0cb7134285e450dbfdc92f7e" + } +] diff --git a/installer/verification/reboot-wait-frozen-flows.json b/installer/verification/reboot-wait-frozen-flows.json new file mode 100644 index 00000000..15b2f71d --- /dev/null +++ b/installer/verification/reboot-wait-frozen-flows.json @@ -0,0 +1,67 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; EOF/refused connections remain normal waits; old boot rejected; new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/reboot-wait-frozen-methods.json b/installer/verification/reboot-wait-frozen-methods.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/reboot-wait-frozen-methods.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/reboot-wait-mu300-sizes.json b/installer/verification/reboot-wait-mu300-sizes.json new file mode 100644 index 00000000..36c2c811 --- /dev/null +++ b/installer/verification/reboot-wait-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3520000, + "backend_and_tools_bytes": 46046998, + "firmware_payload_bytes": 145582695, + "archive_bytes": 120334718, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "18f7722af55444398b2fe042098f3835d1d89f8cda8a5d9459fdb11c246da47d", + "payloads_unchanged": true, + "gui_sha256": "c287e39628fe20a42d563f9b8b8272f8dd3bf19a0cb7134285e450dbfdc92f7e" + }, + { + "gui_bytes": 3520000, + "backend_and_tools_bytes": 46046997, + "firmware_payload_bytes": 146076011, + "archive_bytes": 121409251, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "fffe5c806787569e2b24fd185e9e3d5b086e15db90ef2e4be85b5b35c0359fa9", + "payloads_unchanged": true, + "gui_sha256": "c287e39628fe20a42d563f9b8b8272f8dd3bf19a0cb7134285e450dbfdc92f7e" + } +] diff --git a/installer/verification/reboot-wait-packages.json b/installer/verification/reboot-wait-packages.json new file mode 100644 index 00000000..781e45a0 --- /dev/null +++ b/installer/verification/reboot-wait-packages.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-reboot-wait\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-reboot-wait\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-reboot-wait\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-reboot-wait\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-reboot-wait\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/reboot-wait.json b/installer/verification/reboot-wait.json new file mode 100644 index 00000000..08873e7c --- /dev/null +++ b/installer/verification/reboot-wait.json @@ -0,0 +1,19 @@ +{ + "revision": "20261015-reboot-wait", + "root_cause": "Expected SSH transport loss during reboot was converted to a user-facing connection warning and waiting_user, despite the worker continuing to retry.", + "behavior": { + "expected_disconnect": "Normal waiting_device on automatic reboot, connection_state=reconnecting, no verification_error or warning/error toast", + "transports": ["Connection refused", "Timeout", "Temporarily absent USB network", "SSH EOF", "SSH banner interruption", "Disconnect during remote read", "SSH close without exit status"], + "diagnostics": "Sanitized DEBUG entries retain transport exception details", + "retry": "No overall deadline; endpoint/password correction and explicit verification remain available", + "real_errors": "Wrong hardware identity and SSH authentication retain actionable corrections", + "completion": "Bound CID, changed update boot UUID and measured capacity remain required" + }, + "backend_tests": {"e5": {"run": 79, "passed": 79}, "mu300": {"run": 79, "passed": 77, "skipped": 2}}, + "browser_suites": {"passed": 7, "report": "ui-regression.json", "reconnect_checks": "Neutral bilingual heading, no warning/error toast, repeated retries deduplicated, bounded 800x650 layout, retained endpoint controls and frozen terminal clock"}, + "windows_release_build": {"tauri": "passed", "frozen_backend": "passed", "native_webview2_launch": "passed"}, + "frozen_packages": {"count": 5, "cli_protocol_utf8_adb_start": "reboot-wait-packages.json", "method_routing": "reboot-wait-frozen-methods.json", "backup_recovery_and_update_disconnect_sequence": "reboot-wait-frozen-flows.json", "zip_crc_and_single_system_payload": "passed", "critical_firmware_hashes": "unchanged"}, + "hardware_access": false, + "device_update_reboot_or_install_performed": false, + "size_reports": ["reboot-wait-e5-sizes.json", "reboot-wait-mu300-sizes.json"] +} diff --git a/installer/verification/refresh-e5-packages.json b/installer/verification/refresh-e5-packages.json new file mode 100644 index 00000000..8d19729e --- /dev/null +++ b/installer/verification/refresh-e5-packages.json @@ -0,0 +1,41 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.5 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-refresh\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-refresh\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-refresh\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/refresh-e5-sizes.json b/installer/verification/refresh-e5-sizes.json new file mode 100644 index 00000000..10fc513b --- /dev/null +++ b/installer/verification/refresh-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 241029755, + "archive_bytes": 209491549, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "a25ea2fb3e630714a0440826be3b3aadf0d020d1021825ce86f70f8571ed399b", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 240109042, + "archive_bytes": 209070422, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "2bcc3edb4474ab69a7608a1b53e9f6cc4c9286d949bce04d361b18917d96abda", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 240960832, + "archive_bytes": 209514209, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "a408e6d6ce73cb833c6c4ba02d024aa1aa1cc9eb424e38218e7e5e9d35cc136b", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + } +] diff --git a/installer/verification/refresh-enumeration-artifact.json b/installer/verification/refresh-enumeration-artifact.json new file mode 100644 index 00000000..4643a05e --- /dev/null +++ b/installer/verification/refresh-enumeration-artifact.json @@ -0,0 +1,25 @@ +[ + { + "package": "windows", + "commands": [ + "hello", + "devices", + "devices", + "list" + ], + "verified_package_required": false, + "device_counts": [ + 1, + 1 + ], + "states": [ + [ + "device" + ], + [ + "device" + ] + ], + "device_writes": false + } +] diff --git a/installer/verification/refresh-enumeration-packages.json b/installer/verification/refresh-enumeration-packages.json new file mode 100644 index 00000000..19941727 --- /dev/null +++ b/installer/verification/refresh-enumeration-packages.json @@ -0,0 +1,48 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": [ + "hello", + "devices", + "devices", + "list" + ], + "verified_package_required": false, + "device_counts": [ + 1, + 1 + ], + "states": [ + [ + "device" + ], + [ + "device" + ] + ], + "device_writes": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": [ + "hello", + "devices", + "devices", + "list" + ], + "verified_package_required": false, + "device_counts": [ + 1, + 1 + ], + "states": [ + [ + "device" + ], + [ + "device" + ] + ], + "device_writes": false + } +] diff --git a/installer/verification/refresh-mu300-packages.json b/installer/verification/refresh-mu300-packages.json new file mode 100644 index 00000000..5fdade45 --- /dev/null +++ b/installer/verification/refresh-mu300-packages.json @@ -0,0 +1,38 @@ +[ + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-refresh\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-refresh\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/refresh-mu300-sizes.json b/installer/verification/refresh-mu300-sizes.json new file mode 100644 index 00000000..53602c02 --- /dev/null +++ b/installer/verification/refresh-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 46028331, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119519970, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "04d1a418fdd4004078f14e7be74295c4b52809a85f2bbf0290539447ad570385", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 46028330, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120594495, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "4cb6c382e1de61467f871e5e07451128d83920bb74709a6541249f9c33470f2a", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + } +] diff --git a/installer/verification/refresh.json b/installer/verification/refresh.json new file mode 100644 index 00000000..61abcbfd --- /dev/null +++ b/installer/verification/refresh.json @@ -0,0 +1,121 @@ +{ + "date": "2026-10-15", + "revision": "device-refresh-and-selective-copy", + "backend_tests": { + "e5": 30, + "mu300": 30 + }, + "refresh_smoke": "passed: empty lists before verification, repeated refresh/error retry, multiple/unauthorized states, stale root cleared, install/advanced/boot, text selection styles and actual double-click copying", + "existing_ui_smoke": "passed", + "help_smoke": "passed", + "native_release_launch": "passed with system WebView2", + "real_adb_enumeration": [ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": [ + "hello", + "devices", + "devices", + "list" + ], + "verified_package_required": false, + "device_counts": [ + 1, + 1 + ], + "states": [ + [ + "device" + ], + [ + "device" + ] + ], + "device_writes": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": [ + "hello", + "devices", + "devices", + "list" + ], + "verified_package_required": false, + "device_counts": [ + 1, + 1 + ], + "states": [ + [ + "device" + ], + [ + "device" + ] + ], + "device_writes": false + } + ], + "frozen_packages": "five passed CLI and protocol; MU300 boot checks passed", + "payload_invariance": "five unchanged critical payload maps", + "zip_integrity": "five CRC passes and one system payload each", + "hardware_writes": false, + "packages": [ + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 241029755, + "archive_bytes": 209491549, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "a25ea2fb3e630714a0440826be3b3aadf0d020d1021825ce86f70f8571ed399b", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 240109042, + "archive_bytes": 209070422, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "2bcc3edb4474ab69a7608a1b53e9f6cc4c9286d949bce04d361b18917d96abda", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 43093921, + "firmware_payload_bytes": 240960832, + "archive_bytes": 209514209, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "a408e6d6ce73cb833c6c4ba02d024aa1aa1cc9eb424e38218e7e5e9d35cc136b", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 46028331, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119519970, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "04d1a418fdd4004078f14e7be74295c4b52809a85f2bbf0290539447ad570385", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + }, + { + "gui_bytes": 3514368, + "backend_and_tools_bytes": 46028330, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120594495, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "4cb6c382e1de61467f871e5e07451128d83920bb74709a6541249f9c33470f2a", + "payloads_unchanged": true, + "gui_sha256": "4751d9f97e88f56c42a9a5160bb79527ef7b09fdad0f8b2a689517821ad2a036" + } + ] +} diff --git a/installer/verification/routing-e5-packages.json b/installer/verification/routing-e5-packages.json new file mode 100644 index 00000000..8d8d954f --- /dev/null +++ b/installer/verification/routing-e5-packages.json @@ -0,0 +1,41 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-routing\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-routing\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-routing\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/routing-e5-sizes.json b/installer/verification/routing-e5-sizes.json new file mode 100644 index 00000000..48f81315 --- /dev/null +++ b/installer/verification/routing-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 241029868, + "archive_bytes": 209562610, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "63a28b3716bc4e3fb418da1abc3975942b19a5395db053d611998edc5fc62bd2", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 240109155, + "archive_bytes": 209141485, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "a727de349cbac2359787d2ef9363f3f70f711f8ad22f12dc2b11963de4d3b9d8", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 240960945, + "archive_bytes": 209585272, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "78b4f85a96149d64ed87bbb4c7bcf03459b38b9c588b27d35d425217d2305d11", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + } +] diff --git a/installer/verification/routing-frozen-probes.json b/installer/verification/routing-frozen-probes.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/routing-frozen-probes.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/routing-mu300-packages.json b/installer/verification/routing-mu300-packages.json new file mode 100644 index 00000000..0d683ec9 --- /dev/null +++ b/installer/verification/routing-mu300-packages.json @@ -0,0 +1,38 @@ +[ + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 2 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-routing\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-routing\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/routing-mu300-sizes.json b/installer/verification/routing-mu300-sizes.json new file mode 100644 index 00000000..44cf8ac5 --- /dev/null +++ b/installer/verification/routing-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 46028634, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119591056, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "1e4ba32269d3e20cfa507cb8151f46ebd4f24d04512135d0bbbbce559d63770b", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 46028633, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120665581, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "602f5d7e6750f36d4dac18453796cde168c9a3a6752e3ca40d5d2cab0dbbb9d0", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + } +] diff --git a/installer/verification/routing.json b/installer/verification/routing.json new file mode 100644 index 00000000..d50dd279 --- /dev/null +++ b/installer/verification/routing.json @@ -0,0 +1,166 @@ +{ + "date": "2026-10-15", + "revision": "internal-reinstall-method-routing", + "root_cause": "Shared E5 probe unconditionally called mandatory SD detector; GUI die raises ValueError but code caught only SystemExit. UI also changed methods after probing and reset Advanced/review-back mode.", + "fixes": [ + "Strict TF detection/capacity only for TF mode", + "No silent method changes on inspection", + "Advanced defaults to reinstall", + "Review shows method and preserves origin/choice on return", + "Execution refuses method/plan mismatch before probing/writing" + ], + "backend_tests": { + "e5": { + "run": 36, + "passed": 36 + }, + "mu300": { + "run": 36, + "passed": 35, + "skipped": 1, + "skip_reason": "E5 real legacy source tested in E5 repository" + } + }, + "ui_method_smoke": "passed: exact probe/plan method, no-card reinstall, explicit choices with a card, review impact/target and back behavior", + "existing_ui_smoke": "passed", + "help_smoke": "passed", + "frozen_method_smoke": [ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } + ], + "hardware_writes": false, + "simulated_transport": true, + "zip_crc": "five passed; exactly one system payload each", + "payload_invariance": "all five critical payload maps unchanged", + "source_and_gui_fingerprints": "all five match", + "packages": [ + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 241029868, + "archive_bytes": 209562610, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "63a28b3716bc4e3fb418da1abc3975942b19a5395db053d611998edc5fc62bd2", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 240109155, + "archive_bytes": 209141485, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "a727de349cbac2359787d2ef9363f3f70f711f8ad22f12dc2b11963de4d3b9d8", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 43094102, + "firmware_payload_bytes": 240960945, + "archive_bytes": 209585272, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "78b4f85a96149d64ed87bbb4c7bcf03459b38b9c588b27d35d425217d2305d11", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 46028634, + "firmware_payload_bytes": 145582695, + "archive_bytes": 119591056, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "1e4ba32269d3e20cfa507cb8151f46ebd4f24d04512135d0bbbbce559d63770b", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + }, + { + "gui_bytes": 3514880, + "backend_and_tools_bytes": 46028633, + "firmware_payload_bytes": 146076011, + "archive_bytes": 120665581, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "602f5d7e6750f36d4dac18453796cde168c9a3a6752e3ca40d5d2cab0dbbb9d0", + "payloads_unchanged": true, + "gui_sha256": "7911c9c86dc0aaca3cd67b4805180b36d55837dae77491049ea5e5fb02a68193" + } + ] +} diff --git a/installer/verification/ui-regression.json b/installer/verification/ui-regression.json new file mode 100644 index 00000000..751d87f5 --- /dev/null +++ b/installer/verification/ui-regression.json @@ -0,0 +1,44 @@ +[ + { + "test": "ui_smoke", + "exit": 0, + "output": "UI smoke passed: fixed 800x650/1120x900 layout, 120 records, 500 log cap, independent scrolling, toast errors/status deduplication, multi-device selection, confirmation, waits/completion, themes/languages/reduced motion; no device transport\r\n", + "error": "" + }, + { + "test": "help_smoke", + "exit": 0, + "output": "Help smoke passed: first launch/replay/skip/persistence, saved-record suppression, offline search/manual, focus trapping/restore/Escape/F1, contextual help without backend operations, languages/themes and bounded 800x650 dialogs\r\n", + "error": "" + }, + { + "test": "refresh_smoke", + "exit": 0, + "output": "Refresh smoke passed: unverified package, repeated empty-list retry, error retry, multiple/unauthorized devices, stale-root clearing, install/advanced/boot pages, bounded layout and selective copying; no device writes\r\n", + "error": "" + }, + { + "test": "method_smoke", + "exit": 0, + "output": "Method smoke passed: no-card reinstall, explicit part/reinstall/TF/image preserved, exact probe/plan parameters, review target/impact and return-to-origin; no device writes\r\n", + "error": "" + }, + { + "test": "ordering_smoke", + "exit": 0, + "output": "Ordering smoke passed: saved plans require confirmation, no stale response/event regression, 20 late events ignored, rejected pause has no success toast\r\n", + "error": "" + }, + { + "test": "diagnostics_smoke", + "exit": 0, + "output": "Diagnostics smoke passed: newest-first multiline logs, pinned manual/automatic restart guidance with logs expanded at 800x650, persistent collapse/reopen, real byte progress, honest activity, traceback copying and bounded bilingual layout\r\n", + "error": "" + }, + { + "test": "update_smoke", + "exit": 0, + "output": "Update smoke passed: plan/reboot guidance, reconnects stay neutral without error/warning toasts, repeated waits deduplicated, active clock advances, terminal clocks freeze, bilingual update result at 800x650\r\n", + "error": "" + } +] diff --git a/installer/verification/update-reboot-e5-sizes.json b/installer/verification/update-reboot-e5-sizes.json new file mode 100644 index 00000000..16b9f896 --- /dev/null +++ b/installer/verification/update-reboot-e5-sizes.json @@ -0,0 +1,35 @@ +[ + { + "gui_bytes": 3519488, + "backend_and_tools_bytes": 43111085, + "firmware_payload_bytes": 241030874, + "archive_bytes": 210222816, + "package": "e5-openwrt-gui-1.0.0", + "archive": "e5-openwrt-gui-1.0.0-windows.zip", + "sha256": "1731f20cf57416d85f3f00c32a58f22c82ee56e59e9b3540a9be9b89e03ba887", + "payloads_unchanged": true, + "gui_sha256": "043821e34e7249eb7d59f1e5749d58133226299b2b3172fc5174d34a9f046f59" + }, + { + "gui_bytes": 3519488, + "backend_and_tools_bytes": 43111085, + "firmware_payload_bytes": 240110161, + "archive_bytes": 209801698, + "package": "m8-openwrt-gui-1.0.0", + "archive": "m8-openwrt-gui-1.0.0-windows.zip", + "sha256": "b5b9ed83f1ae67ec7fa71a3aafe0dc63bf6c181abe29aac85e7743b1776fdcb0", + "payloads_unchanged": true, + "gui_sha256": "043821e34e7249eb7d59f1e5749d58133226299b2b3172fc5174d34a9f046f59" + }, + { + "gui_bytes": 3519488, + "backend_and_tools_bytes": 43111085, + "firmware_payload_bytes": 240961951, + "archive_bytes": 210245483, + "package": "t551m-openwrt-gui-1.0.0", + "archive": "t551m-openwrt-gui-1.0.0-windows.zip", + "sha256": "8d3605ac356b0eb88ce88e71451568391713ec8c7460e9b790c15d27e5928920", + "payloads_unchanged": true, + "gui_sha256": "043821e34e7249eb7d59f1e5749d58133226299b2b3172fc5174d34a9f046f59" + } +] diff --git a/installer/verification/update-reboot-frozen-flows.json b/installer/verification/update-reboot-frozen-flows.json new file mode 100644 index 00000000..ba8db7de --- /dev/null +++ b/installer/verification/update-reboot-frozen-flows.json @@ -0,0 +1,67 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; old boot rejected and new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; old boot rejected and new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; old boot rejected and new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; old boot rejected and new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "checks": [ + "device dd -> adb pull, full hash and staging cleanup", + "restart during final verification and final commit without replay", + "explicit boot confirmation retargets wrong-CID endpoint and verifies capacity without replay", + "committed update resumes without replay; old boot rejected and new boot capacity verified; phase clock frozen", + "persistent redacted diagnostic sharing" + ], + "hardware_access": false + } +] diff --git a/installer/verification/update-reboot-frozen-methods.json b/installer/verification/update-reboot-frozen-methods.json new file mode 100644 index 00000000..8b01d3fa --- /dev/null +++ b/installer/verification/update-reboot-frozen-methods.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "m8-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "frozen_backend": true, + "simulated_transport": true, + "non_tf_probes": [ + "part", + "reinstall", + "image", + "boot" + ], + "reinstall_target": "mmcblk1p20", + "reinstall_bytes": 4294967296, + "tf_missing_card_rejected": true, + "hardware_access": false + } +] diff --git a/installer/verification/update-reboot-mu300-sizes.json b/installer/verification/update-reboot-mu300-sizes.json new file mode 100644 index 00000000..6cb5158f --- /dev/null +++ b/installer/verification/update-reboot-mu300-sizes.json @@ -0,0 +1,24 @@ +[ + { + "gui_bytes": 3519488, + "backend_and_tools_bytes": 46046704, + "firmware_payload_bytes": 145582695, + "archive_bytes": 120251211, + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "archive": "mu300-openwrt-6.18.54-gui-1.0.0-windows.zip", + "sha256": "144f9aa3b1c5552590bf546e9ce880f9a155189537cc42de5826262733520aad", + "payloads_unchanged": true, + "gui_sha256": "043821e34e7249eb7d59f1e5749d58133226299b2b3172fc5174d34a9f046f59" + }, + { + "gui_bytes": 3519488, + "backend_and_tools_bytes": 46046703, + "firmware_payload_bytes": 146076011, + "archive_bytes": 121325732, + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "archive": "mu300-openwrt-7.2.8-gui-1.0.0-windows.zip", + "sha256": "35c1995470e469cf4647e871365f68e2a67d82a21768d761b8d686d9570a40b9", + "payloads_unchanged": true, + "gui_sha256": "043821e34e7249eb7d59f1e5749d58133226299b2b3172fc5174d34a9f046f59" + } +] diff --git a/installer/verification/update-reboot-packages.json b/installer/verification/update-reboot-packages.json new file mode 100644 index 00000000..79516e67 --- /dev/null +++ b/installer/verification/update-reboot-packages.json @@ -0,0 +1,77 @@ +[ + { + "package": "e5-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n e5-openwrt-25.12.5-tf-20261015-030543 (6.18.54-e5-mobile4-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.4 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-update-reboot\\e5-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "m8-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n m8-openwrt-25.12.5-tf-20261015-030719 (6.18.54-m8-probe12-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-update-reboot\\m8-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "t551m-openwrt-gui-1.0.0", + "commands": { + "--verify-package": { + "exit": 0, + "stdout": "\r\n== 检查刷机包 / checking the package\r\n\r | 校验文件 / verifying the files 0 s \r OK 校验文件 / verifying the files 0 s \r\n t551m-openwrt-25.12.5-tf-20261015-030630 (6.18.54-t551m-otg10-g020b970e351e-dirty)\r\nPackage verified / 安装包校验通过,未连接设备。\r\n\r\n============================================================\r\n[SUCCESS / 成功] 0.3 s\r\n============================================================\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\e5-linux\\out\\gui-releases\\20261015-update-reboot\\t551m-openwrt-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-6.18.54-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 6.18\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-update-reboot\\mu300-openwrt-6.18.54-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + }, + { + "package": "mu300-openwrt-7.2.8-gui-1.0.0", + "commands": { + "--check": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Package checksums passed / 安装包校验通过。\r\nElapsed / 总耗时: 0 s\r\n", + "stderr": "" + }, + "--check-boot": { + "exit": 0, + "stdout": "MU300 desktop package verified; kernel 7.2\r\nDesktop boot build verified: sd Android slot a (no device writes)\r\nDesktop boot build verified: install-part Android slot b (no device writes)\r\n\r\n========================================================\r\n[CHECK PASSED / 校验通过] Desktop boot construction passed / 桌面启动镜像构建检查通过。\r\nElapsed / 总耗时: 1 s\r\n", + "stderr": "" + } + }, + "protocol_ok": true, + "utf8_error": "ValueError: Select a device / 请选择设备", + "adb_version": "Android Debug Bridge version 1.0.41\r\nVersion 37.0.1-15733141\r\nInstalled as D:\\Git\\mu300-linux-clean-tf-7.2\\release\\gui-20261015-update-reboot\\mu300-openwrt-7.2.8-gui-1.0.0\\tools\\adb.exe\r\nRunning on Windows 10.0.26100\r\n" + } +] diff --git a/installer/verification/update-reboot.json b/installer/verification/update-reboot.json new file mode 100644 index 00000000..6c59858a --- /dev/null +++ b/installer/verification/update-reboot.json @@ -0,0 +1,31 @@ +{ + "revision": "20261015-update-reboot", + "fixes": [ + "Plans, persistent progress guidance and toast explain that update submission triggers an automatic restart to apply the update", + "Capture the actual pre-update boot UUID on the validated SSH connection before uploading/writing", + "A responsive old runtime before scheduled reboot cannot complete an update", + "Original CID, changed boot UUID and actual filesystem capacity are required after reboot; manual boot acknowledgement retains these checks", + "A completed update-commit checkpoint resumes verification without replaying an update", + "Persist phase start/end timestamps and stop UI ticking on completed, failed and paused states" + ], + "backend_tests": {"e5": {"run": 76, "passed": 76}, "mu300": {"run": 76, "passed": 74, "skipped": 2}}, + "browser_tests": { + "passed": 7, + "report": "ui-regression.json", + "execution": "Six existing suites passed in the full run. The new update suite initially used the encrypted-install fixture's wipe flag; correcting it to an actual update plan passed an isolated rerun.", + "coverage": "Update plan/reboot/toast/result copy; active timer advances; completed/failed/paused timers remain fixed after waiting and rerendering; Chinese/light and English/dark at 800x650" + }, + "windows_release_build": {"tauri": "passed", "frozen_backend": "passed", "native_webview2_launch": "passed"}, + "frozen_packages": { + "count": 5, + "cli_protocol_utf8_adb_start": "update-reboot-packages.json", + "method_routing": "update-reboot-frozen-methods.json", + "backup_recovery_explicit_confirmation_update_boot_and_timing": "update-reboot-frozen-flows.json", + "zip_crc_and_single_system_payload": "passed", + "critical_firmware_hashes": "unchanged" + }, + "compatibility_limit": "Older update records without pre-update boot evidence require manual review; they are not guessed complete.", + "hardware_access": false, + "device_update_reboot_or_install_performed": false, + "size_reports": ["update-reboot-e5-sizes.json", "update-reboot-mu300-sizes.json"] +} diff --git a/openwrt/build-rootfs.sh b/openwrt/build-rootfs.sh index 9a5b6c7d..6e42c17c 100755 --- a/openwrt/build-rootfs.sh +++ b/openwrt/build-rootfs.sh @@ -150,7 +150,7 @@ apk_retry update >/dev/null # i2c-tools, gpiod-tools: mu300-usb (the charger of the U30 Air) and mu300-nfc (its NFC tag) apk_retry add --allow-untrusted /in/wifi-sae/*.apk >/dev/null apk_retry add iwinfo wireless-regdb iw bash ip-full coreutils-stty openssl-util curl ca-bundle msmtp ucode ucode-mod-fs ucode-mod-ubus ucode-mod-uci ucode-mod-uloop ucode-mod-socket \ - i2c-tools gpiod-tools >/dev/null + i2c-tools gpiod-tools flock >/dev/null apk_retry add --allow-untrusted /in/block-mount-mu300.apk >/dev/null apk_retry add --allow-untrusted /in/luci-theme-aurora.apk >/dev/null apk_retry add --allow-untrusted /in/luci-app-aurora-config.apk /in/aurora-config-zh-cn.apk /in/aurora-config-tr.apk >/dev/null @@ -182,6 +182,12 @@ for f in sbin/block lib/libblkid-tiny.so etc/init.d/fstab; do [ -s "$R/$f" ] || { echo "patched block-mount required file missing: $f" >&2; exit 1; } done chmod 0755 $R/opt/mu300/bin/cpu-voltage-platform $R/etc/init.d/mu300-cpu-driver +for helper in mu300-data-sim-u30 mu300-sim-u30 mu300-sim2-start mu300-sim2-warmup; do + [ -s "$R/opt/mu300/bin/$helper" ] || { echo "missing U30 helper: $helper" >&2; exit 1; } + chmod 0755 "$R/opt/mu300/bin/$helper" +done +chroot "$R" /bin/sh -c 'command -v flock >/dev/null' || { echo 'missing native SIM flock dependency' >&2; exit 1; } +[ -s "$R/opt/mu300/lib/sim-config.sh" ] || { echo 'missing U30 SIM configuration library' >&2; exit 1; } chmod 0755 $R/opt/mu300/bin/mu300-platform-config chmod 0755 $R/opt/mu300/bin/v50-led-status chmod 0755 $R/opt/mu300/bin/openwrt-board-check diff --git a/openwrt/luci-app-mu300/htdocs/luci-static/resources/mu300/common.js b/openwrt/luci-app-mu300/htdocs/luci-static/resources/mu300/common.js index c5ec3528..0c4e246a 100644 --- a/openwrt/luci-app-mu300/htdocs/luci-static/resources/mu300/common.js +++ b/openwrt/luci-app-mu300/htdocs/luci-static/resources/mu300/common.js @@ -415,6 +415,39 @@ var DASH_I18N = { 'SIM 卡管理': ['SIM management', 'SIM yönetimi'], '切换上网卡后,看板、锁定和 AT 的查看卡槽会同步;仍可手动查看另一张卡。': ['Switching the data SIM also updates the SIM viewed by the dashboard, network locks and AT terminal. You can still view the other SIM manually.', 'Veri SIM kartı değiştirildiğinde panel, ağ kilitleri ve AT terminalinde görüntülenen SIM de güncellenir. Diğer SIM kartını yine elle görüntüleyebilirsiniz.'], '切换上网卡': ['Switch data SIM', 'Veri SIM kartını değiştir'], + "U30 Air 原生双卡": ["U30 Air native dual SIM", "U30 Air yerel çift SIM"], + "启用双卡热切换(首次启用后需重启)": ["Enable live SIM switching (reboot after first enabling)", "Canlı SIM geçişini etkinleştir (ilk etkinleştirmede yeniden başlatın)"], + "仅保存为下次开机默认卡": ["Save as next-boot default only", "Yalnızca sonraki açılış varsayılanı olarak kaydet"], + "关闭热切换时仍可选择下次开机使用的 SIM。此设置不会立即切卡或重启。": ["With live switching off, you can still select the SIM for the next boot. Saving does not switch or reboot now.", "Canlı geçiş kapalıyken sonraki açılış SIM kartını seçebilirsiniz. Kaydetmek hemen geçiş veya yeniden başlatma yapmaz."], + "U30 Air 每次仅启用一张卡的射频。目标卡无数据且原卡有数据时,会恢复原卡;开机默认卡只在连接成功后自动保存。": ["U30 Air uses one active radio at a time. If the target gets no data and the previous SIM had data, it is restored. The boot default is saved automatically only after a successful connection.", "U30 Air aynı anda tek radyo kullanır. Hedefte veri yoksa ve önceki SIM veri taşıyorsa önceki karta dönülür. Açılış varsayılanı yalnızca bağlantı başarılı olduğunda otomatik kaydedilir."], + "双卡开机设置已保存;需要时请手动重启": ["SIM boot settings saved; reboot manually when needed", "SIM açılış ayarları kaydedildi; gerektiğinde elle yeniden başlatın"], + "请先启用双卡热切换": ["Enable hot switching first", "Önce canlı SIM geçişini etkinleştirin"], + "双卡通道尚未准备完成,请先重启": ["Persistent dual-SIM brokers unavailable; reboot first", "Çift SIM kanalları hazır değil; önce yeniden başlatın"], + "当前上网卡状态未知,请重启": ["Unknown active SIM; reboot first", "Etkin SIM bilinmiyor; yeniden başlatın"], + "射频状态异常,请先重启": ["Unexpected radio state; reboot first", "Beklenmeyen radyo durumu; önce yeniden başlatın"], + "目标卡槽未检测到 SIM,未进行切换": ["No card answers in the target SIM position; nothing was changed", "Hedef yuvada SIM bulunamadı; geçiş yapılmadı"], + "目标 SIM 需要 PIN,未进行切换": ["The target SIM is locked by its PIN; nothing was changed", "Hedef SIM için PIN gerekli; geçiş yapılmadı"], + "目标卡未建立数据连接,已恢复原卡": ["Target SIM got no data within the time; previous SIM restored", "Hedef SIM veri alamadı; önceki SIM geri yüklendi"], + "两卡均暂无数据连接,保留当前选卡,开机默认卡未更改": ["Target SIM has no data yet and the previous SIM had none either; staying on the target, boot default unchanged", "İki SIM de veri alamadı. Hedef seçili kalır; açılış varsayılanı değişmez"], + "当前卡暂无数据连接,可单独保存为下次开机默认卡": ["Active SIM has no data; use default for next-boot selection", "Etkin SIM veri alamıyor; sonraki açılış varsayılanı olarak kaydedebilirsiniz"], + "无法停止蜂窝连接,已取消切换": ["Cannot stop WAN", "Hücresel bağlantı durdurulamadı; geçiş iptal edildi"], + "上次切卡被中断,请先重启": ["Interrupted switch; reboot first", "Önceki SIM geçişi kesildi; önce yeniden başlatın"], + "网络锁定正在应用,请稍后再试": ["Network locks are being applied", "Ağ kilitleri uygulanıyor; daha sonra yeniden deneyin"], + "已恢复原卡,但蜂窝连接未能启动": ["Previous SIM restored but WAN could not be started", "Önceki SIM geri yüklendi ancak hücresel bağlantı başlatılamadı"], + "请先恢复基带运行再切卡": ["Resume the modem before switching", "SIM değiştirmeden önce modemi devam ettirin"], + "另一项 SIM 设置正在执行": ["SIM control is busy", "Başka bir SIM ayarı uygulanıyor"], + "上网卡已切换,但开机默认卡保存失败": ["SIM switched but the boot default could not be saved", "SIM değiştirildi ancak açılış varsayılanı kaydedilemedi"], + "切卡失败,已恢复原卡": ["Switch failed; previous SIM restored", "SIM geçişi başarısız; önceki SIM geri yüklendi"], + "切卡失败且射频状态未知,需要重启": ["Switch failed; radio state unknown, reboot required", "SIM geçişi başarısız ve radyo durumu bilinmiyor; yeniden başlatın"], + "目标卡无数据且原卡恢复失败,需要重启": ["Target SIM got no data and the previous one could not be restored; reboot required", "Hedefte veri yok ve önceki SIM geri yüklenemedi; yeniden başlatın"], + "目标卡无数据,已恢复原卡但蜂窝连接未启动": ["Target SIM got no data; previous SIM restored but WAN could not be started", "Hedefte veri yok; önceki SIM geri yüklendi ancak hücresel bağlantı başlatılamadı"], + "基带正忙,未进行切换,请重试": ["The modem is busy; nothing was changed, try again", "Modem meşgul; geçiş yapılmadı, yeniden deneyin"], + "目标 SIM 无法上电,未进行切换": ["The target SIM could not be powered; nothing was changed", "Hedef SIM açılamadı; geçiş yapılmadı"], + "射频状态未知,请先重启": ["Unknown radio state; reboot first", "Radyo durumu bilinmiyor; önce yeniden başlatın"], + "缺少 SIM 互斥组件,请更新完整系统": ["flock is required for SIM control", "SIM kilitleme bileşeni eksik; tam sistemi güncelleyin"], + "射频状态需要重启恢复,请保留当前开机默认卡": ["Reboot to recover the radio; keep the current boot default", "Radyoyu kurtarmak için yeniden başlatın; mevcut açılış varsayılanını koruyun"], + "上次双卡启动未完成,已回退 SIM1": ["The previous dual-SIM startup failed; reverted to SIM1", "Önceki çift SIM açılışı başarısız; SIM1 kartına dönüldü"], + "双卡通道尚未就绪;首次启用后请重启": ["Dual-SIM channels are not ready; reboot after first enabling", "Çift SIM kanalları hazır değil; ilk etkinleştirmeden sonra yeniden başlatın"], '默认上网卡': ['Default data SIM', 'Varsayılan veri SIM kartı'], '当前上网卡': ['Active data SIM', 'Etkin veri SIM kartı'], '欠费或无信号不影响选卡;数据连接失败不会自动切回。': ['A SIM can be selected without credit or signal. A data connection failure does not switch back automatically.', 'Bakiye veya sinyal olmadan SIM seçilebilir. Veri bağlantısı başarısız olursa otomatik geri geçiş yapılmaz.'], diff --git a/openwrt/luci-app-mu300/htdocs/luci-static/resources/view/mu300/sim.js b/openwrt/luci-app-mu300/htdocs/luci-static/resources/view/mu300/sim.js index c5f70141..25db7fbb 100644 --- a/openwrt/luci-app-mu300/htdocs/luci-static/resources/view/mu300/sim.js +++ b/openwrt/luci-app-mu300/htdocs/luci-static/resources/view/mu300/sim.js @@ -9,6 +9,7 @@ var start=rpc.declare({object:'mu300dash',method:'data_sim_set',params:['target' var status=rpc.declare({object:'mu300dash',method:'data_sim_status',params:['id'],nobatch:true,expect:{'':{}}}); var errors={dual_sim_unavailable:'当前配置不支持双卡切换',invalid_sim:'SIM 卡槽无效',modem_busy:'另一项模组操作正在执行',sim_read_failed:'无法核验当前上网卡',sim_not_ready:'目标 SIM 尚未就绪',data_disconnect_failed:'旧数据连接未停止,已取消切换',sim_switch_failed_restored:'切换失败,已恢复原上网卡',sim_rollback_failed:'切换失败且恢复不完整,请检查 SIM 和信号',storage_failed:'设置保存失败'}; errors.dual_boot_required='双卡尚未共同初始化,请重启后检查状态'; +Object.assign(errors,{"Enable hot switching first": "请先启用双卡热切换", "Persistent dual-SIM brokers unavailable; reboot first": "双卡通道尚未准备完成,请先重启", "Unknown active SIM; reboot first": "当前上网卡状态未知,请重启", "Unexpected radio state; reboot first": "射频状态异常,请先重启", "No card answers in the target SIM position; nothing was changed": "目标卡槽未检测到 SIM,未进行切换", "The target SIM is locked by its PIN; nothing was changed": "目标 SIM 需要 PIN,未进行切换", "Target SIM got no data within the time; previous SIM restored": "目标卡未建立数据连接,已恢复原卡", "Target SIM has no data yet and the previous SIM had none either; staying on the target, boot default unchanged": "两卡均暂无数据连接,保留当前选卡,开机默认卡未更改", "Active SIM has no data; use default for next-boot selection": "当前卡暂无数据连接,可单独保存为下次开机默认卡", "Cannot stop WAN": "无法停止蜂窝连接,已取消切换", "Interrupted switch; reboot first": "上次切卡被中断,请先重启", "Network locks are being applied": "网络锁定正在应用,请稍后再试", "Previous SIM restored but WAN could not be started": "已恢复原卡,但蜂窝连接未能启动", "Resume the modem before switching": "请先恢复基带运行再切卡", "SIM control is busy": "另一项 SIM 设置正在执行", "SIM switched but the boot default could not be saved": "上网卡已切换,但开机默认卡保存失败", "Switch failed; previous SIM restored": "切卡失败,已恢复原卡", "Switch failed; radio state unknown, reboot required": "切卡失败且射频状态未知,需要重启", "Target SIM got no data and the previous one could not be restored; reboot required": "目标卡无数据且原卡恢复失败,需要重启", "Target SIM got no data; previous SIM restored but WAN could not be started": "目标卡无数据,已恢复原卡但蜂窝连接未启动", "The modem is busy; nothing was changed, try again": "基带正忙,未进行切换,请重试", "The target SIM could not be powered; nothing was changed": "目标 SIM 无法上电,未进行切换", "Unknown radio state; reboot first": "射频状态未知,请先重启", "flock is required for SIM control": "缺少 SIM 互斥组件,请更新完整系统"}); function message(s){return M.translate(errors[s]||s);} function el(tag,text,cls) { var n=document.createElement(tag); if(text!=null)n.textContent=text; if(cls)n.className=cls; return n; } function card(n) { return n===0||n===1 ? 'SIM '+(n+1) : M.translate('未连接'); } @@ -19,6 +20,7 @@ var CSS = ` .mud-sim-page .mud-data-sim{display:grid;gap:10px;margin:0;padding:14px;border:1px solid var(--hairline,var(--border-color,#ddd));border-radius:10px;min-width:0} .mud-sim-page .mud-data-sim-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px} .mud-sim-page .mud-data-sim-controls label{flex:1;min-width:110px;font-weight:600;margin:0;color:var(--text,#222)} +.mud-sim-page .mud-data-sim-controls input[type="checkbox"]{width:18px;height:18px;min-height:0;margin:0;flex:none;accent-color:var(--brand,var(--primary,#2f7bf6))} .mud-sim-page .mud-data-sim-controls select{width:auto;min-width:100px;max-width:100%;margin:0} .mud-sim-page .mud-data-sim-controls .mud-btn{margin:0;max-width:100%;white-space:normal} .mud-sim-page .mud-sim-status{display:flex;flex-wrap:wrap;gap:6px 18px;padding:10px 0 0;border-top:1px solid var(--hairline,var(--border-color,#ddd));font-size:.8rem;line-height:1.6;color:var(--text-muted,#777)} @@ -45,20 +47,43 @@ return view.extend({ row.append(label,select,button); controls.append(row); var summary=el('div',null,'mud-sim-status'); summary.append(actual,connection,saved); controls.append(summary); controls.append(el('p',M.translate('切换会短暂中断蜂窝网络,成功后作为开机默认上网卡;不会切换 USB 或 Wi-Fi。'),'mud-note')); - controls.append(el('p',M.translate('欠费或无信号不影响选卡;数据连接失败不会自动切回。'),'mud-note')); + controls.append(el('p',M.translate(data[1].native ? 'U30 Air 每次仅启用一张卡的射频。目标卡无数据且原卡有数据时,会恢复原卡;开机默认卡只在连接成功后自动保存。' : '欠费或无信号不影响选卡;数据连接失败不会自动切回。'),'mud-note')); + var nativeBox=null, nativeHot=null, nativeSave=null, nativeNote=null, last=data[1]; + if(data[1].native) { + nativeBox=el('div',null,'mud-data-sim'); panel.append(nativeBox); + nativeBox.append(el('h3',M.translate('U30 Air 原生双卡'))); + var hotLabel=el('label',null,'mud-data-sim-controls'); nativeHot=el('input'); nativeHot.type='checkbox'; + hotLabel.append(nativeHot,el('span',M.translate('启用双卡热切换(首次启用后需重启)'))); nativeBox.append(hotLabel); + nativeNote=el('p',null,'mud-note'); nativeBox.append(nativeNote); + nativeSave=el('button',M.translate('仅保存为下次开机默认卡'),'mud-btn'); nativeSave.type='button'; nativeBox.append(nativeSave); + nativeBox.append(el('p',M.translate('关闭热切换时仍可选择下次开机使用的 SIM。此设置不会立即切卡或重启。'),'mud-note')); + nativeHot.onchange=function(){configure('u30-hot-'+(nativeHot.checked?'1':'0'),nativeHot);}; + nativeSave.onclick=function(){configure('u30-default-'+select.value,nativeSave);}; + } function paint(r,initial) { + last=r; + button.disabled=data[0].slots!==2 || !r.ok || r.ready===false || !!self.busy; + if(nativeHot)nativeHot.checked=r.hot===1; + if(nativeNote) { + var ns=r.native_status||{}, note=''; + if(ns.result==='reboot_required'||ns.result==='restarting')note='射频状态需要重启恢复,请保留当前开机默认卡'; + else if(ns.fallback)note='上次双卡启动未完成,已回退 SIM1'; + else if(r.hot===1 && r.ready===false)note='双卡通道尚未就绪;首次启用后请重启'; + nativeNote.textContent=M.translate(note); nativeNote.hidden=!note; + } actual.textContent=M.translate('当前上网卡')+':'+card(r.actual_sim); saved.textContent=M.translate('开机默认')+':'+card(r.saved_sim); connection.textContent=M.translate('数据连接')+':'+M.translate(r.data_connected?'已连接':'未连接'); if(initial)select.value=r.saved_sim===1?'1':'0'; } paint(data[1],true); - button.disabled=select.disabled=data[0].slots!==2 || !data[1].ok || data[1].ready===false; - if(button.disabled)panel.append(el('p',message(data[1].ready===false && data[0].slots===2?'dual_boot_required':'dual_sim_unavailable'),'mud-note')); + button.disabled=data[0].slots!==2 || !data[1].ok || data[1].ready===false; + select.disabled=data[0].slots!==2 || !data[1].ok; + if(button.disabled && !data[1].native)panel.append(el('p',message(data[1].ready===false && data[0].slots===2?'dual_boot_required':'dual_sim_unavailable'),'mud-note')); function wait(id) { return new Promise(function(resolve,reject) { self.cancelWait=function(){reject(new Error('页面已关闭'));}; - var deadline=performance.now()+240000; + var deadline=performance.now()+(data[1].native?360000:240000); function next() { if(!root.isConnected)return reject(new Error('页面已关闭')); if(performance.now()>deadline)return reject(new Error('应用超时,请刷新确认模组状态')); @@ -71,12 +96,23 @@ return view.extend({ next(); }); } + function configure(target,control) { + if(self.busy)return; + self.busy=true; control.disabled=true; button.disabled=true; select.disabled=true; + if(nativeHot)nativeHot.disabled=true; + if(nativeSave)nativeSave.disabled=true; + start(target).then(function(r){if(!r.ok||!r.id)throw new Error(r.error||'网络设置提交失败');return wait(r.id);}) + .then(function(){M.toast('双卡开机设置已保存;需要时请手动重启',{type:'success'});}) + .catch(function(e){if(root.isConnected)M.toast(message(e.message),{type:'error'});}) + .finally(function(){self.busy=false;select.disabled=false;if(nativeHot)nativeHot.disabled=false;if(nativeSave)nativeSave.disabled=false; + if(root.isConnected)get().then(function(r){if(root.isConnected)paint(r,true);}).catch(function(){});}); + } button.onclick=function() { if(self.busy)return; var target=select.value; self.busy=true; M.confirmBox('切换上网卡?',M.translate('目标卡槽')+':'+card(Number(target)),{danger:true}).then(function(yes) { if(!yes || !root.isConnected)return; - M.busy(button,true); select.disabled=true; + M.busy(button,true); select.disabled=true; if(nativeHot)nativeHot.disabled=true; if(nativeSave)nativeSave.disabled=true; var toast=M.toast('正在切换上网卡…',{type:'busy',timeout:0}); return start(target).then(function(r) { if(!r.ok || !r.id)throw new Error(r.error||'网络设置提交失败'); @@ -84,7 +120,7 @@ return view.extend({ }).then(function() { M.selectViewedSlot(target); M.toast('上网卡切换完成',{type:'success'}); }) .catch(function(e) { if(root.isConnected)M.toast(message(e.message),{type:'error'}); }) .finally(function() { toast.close(); M.busy(button,false); select.disabled=false; if(root.isConnected)return get().then(function(r){if(root.isConnected)paint(r,true);}).catch(function(){}); }); - }).finally(function(){self.busy=false;}); + }).finally(function(){self.busy=false; if(nativeHot)nativeHot.disabled=false; if(nativeSave)nativeSave.disabled=false; button.disabled=last.ready===false;}); }; this.refresh=function() { if(document.hidden||!root.isConnected||self.busy||self.inflight)return Promise.resolve(); diff --git a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/dashboard-info b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/dashboard-info index 8a47987a..7b9d961f 100644 --- a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/dashboard-info +++ b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/dashboard-info @@ -173,17 +173,26 @@ T_SOC=$1; T_CPU=$2; T_NR=$3; T_BRD=$4 T_HOT=$(temp_hottest) # ------------------------------------------------------------------- power -# The F50 has a battery; the V50 (same SoC) does not - a missing capacity file -# simply means "no battery" and the page hides the tile. voltage_now is -# microvolts on this PMIC; current_now microamps (negative = charging on some -# firmwares, positive on others - the sign is reported raw and the page only -# shows magnitude + charging state from `status`). -P_CAP=$(rd /sys/class/power_supply/battery/capacity) -P_STATUS=$(rd /sys/class/power_supply/battery/status) -P_V=$(rd /sys/class/power_supply/battery/voltage_now) -P_I=$(rd /sys/class/power_supply/battery/current_now) -P_USB=$(rd /sys/class/power_supply/usb/online) -case "$P_CAP" in ''|*[!0-9]*) P_PRESENT=0 ;; *) P_PRESENT=1 ;; esac +# Vendor kernels use battery; mainline UMP9620 uses sc27xx-fgu. The shared +# selector also excludes F50/V50's synthetic FGU, and validates 0..100 percent. +POWER_LIB=${MU300_POWER_LIB:-${0%/*}/power-supply.sh} +[ -r "$POWER_LIB" ] || POWER_LIB=/usr/libexec/unisoc-modem/power-supply.sh +. "$POWER_LIB" +PSY=${MU300_POWER_SUPPLY_DIR:-/sys/class/power_supply} +P_DIR=$(power_battery_dir) || P_DIR= +P_PRESENT=0 P_CAP= P_STATUS= P_V= P_I= P_USB= +if [ -n "$P_DIR" ]; then + P_PRESENT=1 + P_CAP=$(rd "$P_DIR/capacity") + P_STATUS=$(rd "$P_DIR/status") + P_V=$(rd "$P_DIR/voltage_now") + P_I=$(rd "$P_DIR/current_now") +fi +# Mainline reports external power on bq256xx-charger, rather than usb/ac. +for d in "$PSY/usb" "$PSY/ac" "$PSY/bq256xx-charger" "$PSY"/*; do + case "${d##*/}" in usb|ac|bq256xx-charger) ;; *) case "$(rd "$d/type")" in USB*|Mains) ;; *) continue ;; esac ;; esac + case "$(rd "$d/online")" in 1) P_USB=1; break ;; 0) P_USB=0 ;; esac +done P_V=$(n_or_null "$(awk -v v="$P_V" 'BEGIN{if(v+0>0)printf "%.2f",v/1000000}')") P_I=$(n_or_null "$(awk -v v="$P_I" 'BEGIN{if(v!="")printf "%d",v}')") diff --git a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/data-sim b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/data-sim index 4c17462e..5cce13a2 100644 --- a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/data-sim +++ b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/data-sim @@ -7,9 +7,16 @@ adapter=${MU300_DATA_SIM_ADAPTER:-$(uci -q get unisoc_modem.main.data_sim_comman [ -n "$adapter" ] || adapter=/opt/mu300/bin/mu300-data-sim qs() { [ -n "$1" ] && printf '"%s"' "$(printf '%s' "$1" | sed 's/\\/\\\\/g;s/"/\\"/g' | tr -d '\r\n')" || echo null; } validate_apply() { - [ "$1" = data ] && { [ "$2" = 0 ] || [ "$2" = 1 ]; } || { echo invalid_sim >&2; return 1; } + [ "$1" = data ] || { echo invalid_sim >&2; return 1; } + case "$2" in + 0|1) ;; + u30-hot-[01]|u30-default-[01]) + [ "$(mu300-device 2>/dev/null)" = u30air ] || { echo dual_sim_unavailable >&2; return 1; } ;; + *) echo invalid_sim >&2; return 1 ;; + esac [ "$(uci -q get unisoc_modem.main.sim_slots)" = 2 ] && [ -x "$adapter" ] || { echo dual_sim_unavailable >&2; return 1; } } +[ "$(mu300-device 2>/dev/null)" != u30air ] || MU300_JOB_TIMEOUT=360 . "$LIB/lock-jobs.sh" case ${1:-} in get) [ -x "$adapter" ] && "$adapter" get || printf '{"ok":0,"error":"dual_sim_unavailable"}\n' ;; diff --git a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/lock-jobs.sh b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/lock-jobs.sh index b50ac183..83e1fe5f 100644 --- a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/lock-jobs.sh +++ b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/lock-jobs.sh @@ -17,7 +17,7 @@ job_status() { if ! grep -Eq '"state":"(done|error)"' "$JOBDIR/result"; then started=$(cat "$JOBDIR/started"); age=$(( $(job_uptime) - started )) pid=$(cat "$JOBDIR/pid" 2>/dev/null) - if [ "$age" -gt 240 ]; then + if [ "$age" -gt "${MU300_JOB_TIMEOUT:-240}" ]; then job_write error 0 '应用超时,请刷新确认模组状态' elif [ "$age" -gt 2 ] && { [ -z "$pid" ] || ! kill -0 "$pid" 2>/dev/null; }; then job_write error 0 '设置进程已中断,请刷新确认模组状态' @@ -71,7 +71,7 @@ job_worker() { # verification, never cached timestamps, determine this job's result. "$0" apply "$2" "$3" >/dev/null 2> "$JOBDIR/error" rc=$? - if [ $(( $(job_uptime) - $(cat "$JOBDIR/started") )) -gt 240 ]; then + if [ $(( $(job_uptime) - $(cat "$JOBDIR/started") )) -gt "${MU300_JOB_TIMEOUT:-240}" ]; then job_write error 0 '应用超时,请刷新确认模组状态' elif [ "$rc" = 0 ]; then job_write done 1 '' diff --git a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/power-supply.sh b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/power-supply.sh new file mode 100644 index 00000000..a6f08e07 --- /dev/null +++ b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/power-supply.sh @@ -0,0 +1,33 @@ +# Shared power-supply discovery. Reading never changes calibration or charging. +power_supply_read() { + local value= + [ -r "$1" ] || return 0 + IFS= read -r value < "$1" || : + printf '%s\n' "$value" +} +power_battery_valid() { + local path=$1 capacity present + [ -d "$path" ] || return 1 + present=$(power_supply_read "$path/present") + [ "$present" != 0 ] || return 1 + capacity=$(power_supply_read "$path/capacity") + case "$capacity" in ''|*[!0-9]*) return 1 ;; esac + [ "$capacity" -le 100 ] || return 1 +} +power_battery_dir() { + local root=${MU300_POWER_SUPPLY_DIR:-/sys/class/power_supply} board path + # Preserve an explicit adapter/test override, including an unavailable one. + if [ -n "${1:-}" ]; then + power_battery_valid "$1" || return 1 + printf '%s\n' "$1"; return 0 + fi + board=${MU300_POWER_DEVICE:-$(mu300-device 2>/dev/null || true)} + # These battery-less boards expose the same FGU with synthetic readings. + case "$board" in f50|v50) return 1 ;; esac + for path in "$root/battery" "$root/sc27xx-fgu" "$root"/*; do + power_battery_valid "$path" || continue + case "${path##*/}" in battery|sc27xx-fgu) ;; *) [ "$(power_supply_read "$path/type")" = Battery ] || continue ;; esac + printf '%s\n' "$path"; return 0 + done + return 1 +} diff --git a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/sms-forward b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/sms-forward index d04b3d08..98b04c68 100644 --- a/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/sms-forward +++ b/openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem/sms-forward @@ -19,7 +19,10 @@ RENDERER=${MU300_FORWARD_RENDERER:-/usr/libexec/unisoc-modem/forward-template.uc SMS=${MU300_SMS_BIN:-$(uci -q get unisoc_modem.main.sms_command 2>/dev/null)} [ -n "$SMS" ] || SMS=$(command -v mu300-sms 2>/dev/null || true) case "$SMS" in */*) ;; *) SMS=$(command -v "$SMS" 2>/dev/null || true) ;; esac -BATTERY=${MU300_FORWARD_BATTERY:-/sys/class/power_supply/battery} +POWER_LIB=${MU300_POWER_LIB:-${0%/*}/power-supply.sh} +[ -r "$POWER_LIB" ] || POWER_LIB=${RENDERER%/*}/power-supply.sh +[ -r "$POWER_LIB" ] || POWER_LIB=/usr/libexec/unisoc-modem/power-supply.sh +. "$POWER_LIB" NL=' ' CR=$(printf '\r') @@ -313,9 +316,10 @@ read_result() { } power_read() { power_ok=0 current_percent=-1 current_status=none - [ -r "$BATTERY/present" ] && [ "$(cat "$BATTERY/present" 2>/dev/null)" = 1 ] || return 0 - current_percent=$(cat "$BATTERY/capacity" 2>/dev/null) - current_status=$(cat "$BATTERY/status" 2>/dev/null) + local battery + battery=$(power_battery_dir "${MU300_FORWARD_BATTERY:-}") || return 0 + current_percent=$(power_supply_read "$battery/capacity") + current_status=$(power_supply_read "$battery/status") number "$current_percent" && [ "$current_percent" -le 100 ] || return 0 case "$current_status" in Charging|Discharging|Not\ charging|Full) power_ok=1 ;; esac } diff --git a/openwrt/overlay/etc/init.d/mu300-atd b/openwrt/overlay/etc/init.d/mu300-atd index 9db10aea..52442a20 100755 --- a/openwrt/overlay/etc/init.d/mu300-atd +++ b/openwrt/overlay/etc/init.d/mu300-atd @@ -26,10 +26,21 @@ export PATH="$PATH:/opt/mu300/busybox-bin" wait_and_exec() { # $1 = tty node, $2.. = the daemon and its env is set by the caller local dev=$1; shift - echo "n=0; while [ ! -c $dev ]; do n=\$((n+1)); if [ \"\$n\" -gt 240 ]; then echo 'mu300-atd: $dev never appeared' >&2; exit 1; fi; sleep 1; done; exec $*" + local ready="[ -c $dev ]" + if [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ]; then + ready="$ready && [ -c /dev/sipc_sbuf ] && grep -q '^sbuf_5_006, state: 1,' /dev/sipc_sbuf" + fi + echo "n=0; until $ready; do n=\$((n+1)); if [ \"\$n\" -gt 240 ]; then echo 'mu300-atd: $dev never appeared' >&2; exit 1; fi; sleep 1; done; exec $*" } -start_service() { +start_legacy() { + if [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ]; then + mkdir -p /run/mu300 + : > /run/mu300/u30-native + # The missing-policy-library path must also pin SIM1, regardless of + # an old saved SIM2 preference. No fallback may dial an unprepared RF. + [ -s /run/mu300/sim-slot ] || printf '0\n' > /run/mu300/sim-slot + fi # Do not migrate NR3 ownership after daemons have opened the SIPC ttys. [ ! -x /opt/mu300/bin/mu300-platform-config ] || /opt/mu300/bin/mu300-platform-config # Optional plugin handshake: reserve nr1's first-command window for the @@ -37,8 +48,9 @@ start_service() { [ ! -x /usr/libexec/unisoc-modem/lock ] || : > /run/unisoc-modem-early-hook-pending [ -x /opt/mu300/bin/bootmark ] && /opt/mu300/bin/bootmark S19-atd-init procd_open_instance atd + procd_set_param env MU300_AT_DISABLE_REOPEN="$([ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] && echo 1 || echo 0)" procd_set_param command /bin/sh -c "$(wait_and_exec /dev/stty_nr1 /opt/mu300/bin/mu300-atd)" - procd_set_param respawn 3600 10 0 + [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] || procd_set_param respawn 3600 10 0 procd_set_param stdout 1 procd_set_param stderr 1 procd_close_instance @@ -46,8 +58,8 @@ start_service() { # second instance on nr2 (mobile-data's dedicated channel) procd_open_instance atd2 procd_set_param command /bin/sh -c "$(wait_and_exec /dev/stty_nr2 /opt/mu300/bin/mu300-atd)" - procd_set_param env MU300_AT_DEV=/dev/stty_nr2 MU300_AT_DIR=/run/mu300-at2 MU300_AT_URC_CHANNELS= MU300_AT_ALIVE_LOG=/run/mu300-at/urc/stty_nr0.log - procd_set_param respawn 3600 10 0 + procd_set_param env MU300_AT_DISABLE_REOPEN="$([ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] && echo 1 || echo 0)" MU300_AT_DEV=/dev/stty_nr2 MU300_AT_DIR=/run/mu300-at2 MU300_AT_URC_CHANNELS= MU300_AT_ALIVE_LOG=/run/mu300-at/urc/stty_nr0.log + [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] || procd_set_param respawn 3600 10 0 procd_set_param stdout 1 procd_set_param stderr 1 procd_close_instance @@ -71,8 +83,8 @@ start_service() { esac # Set the env table ONCE. Adding another table with the same JSON key # can leave procd with only MU300_AT_DEV and the wrong owner directory. - procd_set_param env MU300_AT_DEV=/dev/stty_nr$n MU300_AT_DIR=/run/mu300-at$n MU300_AT_URC_CHANNELS=$urc MU300_SMS_POOL=$pool MU300_AT_ALIVE_LOG=$alive_log - procd_set_param respawn 3600 10 0 + procd_set_param env MU300_AT_DISABLE_REOPEN="$([ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] && echo 1 || echo 0)" MU300_AT_DEV=/dev/stty_nr$n MU300_AT_DIR=/run/mu300-at$n MU300_AT_URC_CHANNELS=$urc MU300_SMS_POOL=$pool MU300_AT_ALIVE_LOG=$alive_log + [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] || procd_set_param respawn 3600 10 0 procd_set_param stdout 1 procd_set_param stderr 1 procd_close_instance @@ -88,3 +100,114 @@ start_service() { procd_set_param stderr 1 procd_close_instance } + +# broker NAME CHANNEL DIR URC-CHANNELS LIVE-URC-LOG [WAIT]: one persistent owner of a SIPC tty. WAIT is a shell +# condition the instance waits for (bounded) before it opens the channel: the second group's channels have a node +# before the CP is up, and spipe_open returns ENODEV until the sbuf is READY, which the driver's seqfile shows. +# The wait is inside the instance, never in start_service: an init script that waits returns without instances +# when the wait fails, and a boot without AT brokers is a boot without WAN. +broker() { + local name=$1 channel=$2 directory=$3 urc=$4 live=$5 wait=${6:-} condition= pool=/etc/mu300/sms + [ "$channel" -lt 3 ] || pool=/etc/mu300/sms/sim1 + # A literal brace inside ${...:+...} closes the expansion early in ash. Build it separately. + [ -z "$wait" ] || condition=" && { $wait; }" + procd_open_instance "$name" + procd_set_param command /bin/sh -c "n=0; until [ -c /dev/stty_nr$channel ]$condition; do n=\$((n+1)); [ \"\$n\" -gt 240 ] && { echo 'mu300-atd: /dev/stty_nr$channel never became ready' >&2; exit 1; }; sleep 1; done; exec /opt/mu300/bin/mu300-atd" + procd_set_param env "MU300_AT_DEV=/dev/stty_nr$channel" "MU300_AT_DIR=$directory" \ + "MU300_AT_URC_CHANNELS=$urc" "MU300_AT_ALIVE_LOG=$live" "MU300_SMS_POOL=$pool" \ + MU300_AT_DISABLE_REOPEN=1 + # A failed owner stays failed during this boot (no respawn): restarting it would reopen a SIPC channel, and + # the cold start / the switch refuse to run without all four owners rather than talk to a reopened one. + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_close_instance +} + +SBUF_READY="[ -c /dev/sipc_sbuf ] && grep -q '^sbuf_5_006, state: 1,' /dev/sipc_sbuf" +start_sim2() { + mkdir -p /run/mu300 + [ ! -x /usr/libexec/unisoc-modem/lock ] || : > /run/unisoc-modem-early-hook-pending + # Before S20network or any radio-warmup process: inhibit automatic SIM1 bring-up for this entire boot. + : > /run/mu300-radio-freeze + : > /run/mu300/sim-active-unknown + [ "$hot" != 1 ] || : > /run/mu300/sim-managed + broker atd 1 /run/mu300-at 0 /run/mu300-at/urc/stty_nr0.log "$SBUF_READY" + broker atd2 2 /run/mu300-at2 '' /run/mu300-at/urc/stty_nr0.log "$SBUF_READY" + broker atd4 4 /run/mu300-at4 3 /run/mu300-at4/urc/stty_nr3.log "$SBUF_READY" + broker atd5 5 /run/mu300-at5 '' /run/mu300-at4/urc/stty_nr3.log "$SBUF_READY" + # The cold start (and its fallback to SIM1 when it cannot be done): mu300-sim2-warmup confirms the boot. + procd_open_instance sim2-cold-start + procd_set_param command /bin/bash /opt/mu300/bin/mu300-sim2-warmup + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_close_instance +} + +# sim_fallback REASON: back to SIM1 without live switching, the reason kept for the Dual SIM page (mu300-sim status). +# It never fails its caller: settings that cannot be written (a full or read-only filesystem) leave the pending +# marker, and the caller makes this boot a SIM1 boot either way. +sim_fallback() { + echo "mu300-atd: dual SIM: $1; SIM1 without live switching from now on" >&2 + printf '%s\n' "$1" > /etc/mu300-sim-fallback 2>/dev/null + sim_cfg_save_default 0 && sim_cfg_save_hot 0 && rm -f /etc/mu300-sim-pending + return 0 +} +# sim1_only: this boot is a plain SIM1 boot, whatever was chosen. The pin says so to every reader (mu300-sim active): +# without it start_legacy would take a saved second card for the F50's kind and open nr4/nr5 under SIM1's names. +sim1_only() { + mkdir -p /run/mu300 + printf '0\n' > /run/mu300/sim-slot + start_legacy +} + +# Every path through here ends with AT owners started: a return without instances is a boot without modem control, +# and nothing starts this service a second time. Whatever cannot be read, written or understood is a SIM1 boot. +start_service() { + [ ! -x /opt/mu300/bin/mu300-platform-config ] || /opt/mu300/bin/mu300-platform-config + local slot hot temporary lib=${MU300_SIM_CONFIG_LIB:-/opt/mu300/lib/sim-config.sh} + # Only the U30 Air has the second group and the validated sequences; everywhere else the files are ignored. + [ "$(/opt/mu300/bin/mu300-device 2>/dev/null)" = u30air ] || { start_legacy; return; } + [ -r "$lib" ] || { start_legacy; return; } + mkdir -p /run/mu300 + : > /run/mu300/u30-native + SIM_CONFIG_U30=1 + . "$lib" + mkdir -p /run/mu300 + # mu300-sim2-warmup gave the dual-SIM start up in this boot and started the service over: SIM1, nothing else + [ ! -e /run/mu300/sim-fallback-boot ] || { sim1_only; return; } + sim_cfg_migrate || sim_fallback invalid-settings + slot=$(cat /run/mu300/sim-slot 2>/dev/null || sim_cfg_default) || slot=invalid + hot=$(sim_cfg_hot) || hot=invalid + case "$hot" in 0|1) ;; *) sim_fallback invalid-hot; slot=0; hot=0;; esac + case "$slot" in 0|1) ;; *) sim_fallback invalid-slot; slot=0; hot=0 ;; esac + # One boot at a time: the dual-SIM path leaves a pending marker that mu300-sim2-warmup removes once the radio + # is up (or it falls back itself). A marker still there at the next boot means that boot never confirmed + # (a broker that never came up, a warm-up that died): this boot is a plain SIM1 boot, and the page says why. + if [ ! -e /run/mu300/sim-boot-policy ] && [ -e /etc/mu300-sim-pending ]; then + sim_fallback unconfirmed + : > /run/mu300/sim-boot-policy + sim1_only; return + fi + : > /run/mu300/sim-boot-policy + # Pin the active slot for this boot; changing network.wan.sim_slot only affects the next boot. + if [ ! -e /run/mu300/sim-slot ]; then + temporary=$(mktemp /run/mu300/sim-slot.XXXXXX) || { sim1_only; return; } + printf '%s\n' "$slot" > "$temporary" + ln "$temporary" /run/mu300/sim-slot 2>/dev/null + rm -f "$temporary" + fi + slot=$(cat /run/mu300/sim-slot 2>/dev/null) || slot=invalid + case "$slot:$hot" in + 0:0) start_legacy ;; + 0:1|1:[01]) + # The dual-SIM path's helpers are bash, and its one-boot guarantee needs the marker on the disk: without + # either this is a SIM1 boot, and the settings go back so that the next one does not try again. + if command -v bash >/dev/null 2>&1 && touch /etc/mu300-sim-pending 2>/dev/null; then + start_sim2 + else + sim_fallback not-startable + sim1_only + fi ;; + *) echo "mu300-atd: invalid SIM slot $slot; SIM1" >&2; sim1_only ;; + esac +} diff --git a/rootfs/overlay/opt/mu300/bin/mobile-data b/rootfs/overlay/opt/mu300/bin/mobile-data index 5a364d87..49b4ade8 100755 --- a/rootfs/overlay/opt/mu300/bin/mobile-data +++ b/rootfs/overlay/opt/mu300/bin/mobile-data @@ -69,6 +69,7 @@ at() { # at CMD [timeout] -> response lines up to the final result code MU300_AT_DIR=$MU300_SIM_SHARED /opt/mu300/bin/mu300-at -t "$t" "$cmd" return fi + [ "$DEVICE" != u30air ] || return 1 # never reopen a failed native SIPC owner # No direct tty fallback for SIM 2; in particular never open slot 0. [ "$MU300_SIM_SLOT" = 0 ] || return 1 [ -c "$DEV" ] || return 1 # never let the redirection create a regular file in /dev @@ -245,6 +246,12 @@ v6_off() { # 实测那一步会把刚起来的 CP 又清一次,白等一整轮 CP 启动(12 s 起)。SFUN=4 之后要等 # 射频真正上来,而不是问一次就走。 radio_on_locked() { + if [ "$DEVICE" = u30air ] && [ -e /run/mu300-radio-freeze ]; then + [ ! -e /run/mu300/sim-switching ] && [ ! -e /run/mu300/sim-active-unknown ] && + [ -e /run/mu300/sim-radio-ready ] || return 1 + at 'AT+CFUN?' 4 | tr -d '\r' | grep -Eq '^\+CFUN: *1$' + return $? + fi local i=0 out silent=0 answered=0 urclog=/run/mu300-at/urc/stty_nr0.log local ready_deadline=$((SECONDS + ${MU300_CFUN_WAIT:-30})) mark radio-on-enter @@ -280,7 +287,7 @@ radio_on_locked() { ;; esac fi - if [ "$(uci -q get unisoc_modem.main.sim_slots 2>/dev/null || true)" = 2 ]; then + if [ "$DEVICE" != u30air ] && [ "$(uci -q get unisoc_modem.main.sim_slots 2>/dev/null || true)" = 2 ]; then /opt/mu300/bin/mu300-dual-radio return $? fi @@ -389,33 +396,74 @@ queue_data_priority() { return 0 } -# The early radio warm-up and netifd may meet at the boundary. Serialize that -# small window so they never run two CFUN/SFUN state machines in parallel. -# The collision wait is capped at eight seconds; netifd can retry later. -radio_on() { - local lock=/run/mu300-radio-on.lock owner= n=0 rc - while ! mkdir "$lock" 2>/dev/null; do - owner=$(cat "$lock/pid" 2>/dev/null || true) - if [ -z "$owner" ] || [ ! -d "/proc/$owner" ] || - ! tr '\0' ' ' < "/proc/$owner/cmdline" 2>/dev/null | grep -q mobile-data; then - rm -rf "$lock" - continue - fi - n=$((n + 1)) - [ "$n" -gt 80 ] && return 1 - /opt/mu300/bin/busybox sleep 0.1 2>/dev/null || sleep 1 +# Shared RF mutex: atomic ownership and serialized stale-owner recovery on every board. +RADIOLOCK=/run/mu300-radio-on.owner +lock_owner_alive() { + [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null || return 1 + # the number may have been reused by something else + [ -r "/proc/$1/cmdline" ] || return 0 + { tr '\0' ' ' < "/proc/$1/cmdline"; } 2>/dev/null | grep mobile-data >/dev/null +} +# lock_reap LINK DEADPID ME: remove LINK if it still names the dead process DEADPID. Only one process at a time may +# do that for one (LINK, DEADPID): the one that makes the marker LINK.dead.DEADPID (made in one step, naming ME), and +# it looks again under the marker. Nothing else removes a link that names a dead process, so the link cannot change +# between that look and the rm: two waiters that both saw the same dead owner can no longer remove, the second one, +# the lock the first had just taken. A marker whose maker died is reaped the same way, one level down. +lock_reap() { + local m="$1.dead.$2" t + until ln -sn "$3" "$m" 2>/dev/null; do + t=$(readlink "$m" 2>/dev/null || true) + [ -n "$t" ] || return 1 # its maker has just finished: the caller looks again + lock_owner_alive "$t" && return 1 # another waiter is taking over; leave it to that one + lock_reap "$m" "$t" "$3" || return 1 done - echo $$ > "$lock/pid" - # Explicit status handling also releases our mutex under bash -e when - # radio initialization fails; netifd can retry without a stale owner. - rc=0 + if [ "$(readlink "$1" 2>/dev/null || true)" = "$2" ] && ! lock_owner_alive "$2"; then rm -f "$1"; fi + rm -f "$m" +} +# lock_take LINK SECONDS: take LINK for this process, waiting up to SECONDS (real seconds, not polls) for its holder; +# a dead holder is taken over. Returns 1 when the wait is over, with the holder's pid in LOCK_HOLDER. +# lock_drop LINK: release it, if it is still this process's. +# The owner is this process's own pid (see at()): two callers in subshells of one script are two owners. +lock_take() { + local owner me end=$((SECONDS + $2)) + me=${BASHPID:-$(exec sh -c 'echo $PPID')} + until ln -sn "$me" "$1" 2>/dev/null; do + owner=$(readlink "$1" 2>/dev/null || true) + # empty: released in between, and the next try comes after the pause below + if [ -n "$owner" ] && ! lock_owner_alive "$owner"; then + lock_reap "$1" "$owner" "$me" && continue + fi + if [ "$SECONDS" -ge "$end" ]; then + LOCK_HOLDER=$owner + return 1 + fi + /opt/mu300/bin/busybox sleep 0.2 2>/dev/null || sleep 1 + done +} +lock_drop() { + if [ "$(readlink "$1" 2>/dev/null || true)" = "${BASHPID:-$(exec sh -c 'echo $PPID')}" ]; then rm -f "$1"; fi +} +radio_locked() { + local rc=0 + lock_take "$RADIOLOCK" "${MU300_RADIO_LOCK_WAIT:-30}" || return 75 + trap 'lock_drop "$RADIOLOCK"' EXIT + trap 'exit 143' TERM INT + "$@" || rc=$? + lock_drop "$RADIOLOCK" + trap - EXIT TERM INT + return "$rc" +} + +# Warm-up, netifd and recovery share one atomic RF owner on every board. +# Preserve the previous eight-second normal wait and all AT command ordering. +radio_on() { + local rc=0 + if ! lock_take "$RADIOLOCK" "${MU300_RADIO_LOCK_WAIT:-8}"; then return 1; fi radio_on_locked || rc=$? + lock_drop "$RADIOLOCK" if [ "$rc" = 0 ]; then queue_data_priority || true; fi - [ "$(cat "$lock/pid" 2>/dev/null)" = $$ ] && rm -rf "$lock" - # Keep the generic worker away from nr1 until the handshake/radio sequence - # has actually completed. A failed round is retried by netifd/watch. [ "$rc" = 0 ] && rm -f /run/unisoc-modem-early-hook-pending - return $rc + return "$rc" } # 取 PDP 地址。AT+CGACT? 回答 1,1 并不等于地址已经下发:实测在 NR 上有过「CGACT 通了之后 @@ -490,6 +538,7 @@ modem_stack() { [ -e /dev/modem ] || [ -e /dev/pmsys ] || [ -c "$DEV" ]; } # "stty -F" opens and closes the tty, which desynchronises the SIPC channel (docs/FINDINGS.md 13b). When # mu300-atd owns the device it has already set the flags on its own descriptor, so leave the tty alone. tty_setup() { + [ "$DEVICE" != u30air ] || return 0 # persistent owners configure their own descriptors [ "$MU300_SIM_SLOT" = 0 ] || return 0 [ -p /run/mu300-at/cmd ] && return 0 # same for a daemon whose fifo has gone missing: its descriptor is still the one the modem talks to @@ -499,28 +548,16 @@ tty_setup() { # Only one bring-up at a time: the watchdog and the service can both decide to reconnect, and two of them race for # every AT command (each losing the channel lock in turn, so neither finishes). -UPLOCK=/run/mu300-mobile-data-up.lock +UPLOCK=/run/mu300-mobile-data-up.owner up() { # Wait for a bring-up that is already running instead of returning: the netifd protocol handler reads the # address out of our output, so an early return reads as "attach failed" and netifd tears the interface # down and tries again every 20 s, which piles up half-finished bring-ups and teardowns. - local n=0 p= - while ! mkdir "$UPLOCK" 2>/dev/null; do - p=$(cat "$UPLOCK/pid" 2>/dev/null || true) - if [ -z "$p" ] || ! kill -0 "$p" 2>/dev/null; then rm -rf "$UPLOCK"; continue; fi - n=$((n + 1)) - if [ "$n" -gt 150 ]; then - echo "another bring-up has been running for over two minutes (pid $p)" >&2 - return 1 - fi - sleep 1 - done - echo $$ > "$UPLOCK/pid" - release_up_lock() { - if [ "$(cat "$UPLOCK/pid" 2>/dev/null)" = $$ ]; then - rm -f "$UPLOCK/pid"; rmdir "$UPLOCK" 2>/dev/null || true - fi - } + if ! lock_take "$UPLOCK" "${MU300_UP_LOCK_WAIT:-150}"; then + echo "another bring-up has been running for over two minutes (pid ${LOCK_HOLDER:-?})" >&2 + return 1 + fi + release_up_lock() { lock_drop "$UPLOCK"; } trap release_up_lock EXIT trap 'exit 143' TERM trap 'exit 130' INT @@ -614,11 +651,30 @@ configure_initial_apn() { } up_locked() { + if [ "$DEVICE" = u30air ] && [ -e /run/mu300-radio-freeze ]; then + # The cold-start process needs the RF mutex. Wait outside it, so a + # first dial does not fail and incur netifd's normal retry delay. + local native_end=$((SECONDS + ${MU300_NATIVE_RADIO_WAIT:-40})) boot_slot + until [ -e /run/mu300/sim-radio-ready ] || [ ! -e /run/mu300-radio-freeze ] || [ "$SECONDS" -ge "$native_end" ]; do sleep 1; done + boot_slot=$(cat /run/mu300/sim-slot 2>/dev/null || true) + # A fallback changed this protocol task's card. Let netifd re-evaluate + # its per-SIM APN and teardown owner instead of dialing the old choice. + [ "$boot_slot" = "$MU300_SIM_SLOT" ] || return 1 + fi modem_stack || { echo "no modem stack in this kernel ($(uname -r))" >&2; exit 3; } rm -f /run/mu300-mobile-data-down tty_setup radio_on || return $? - if [ "$(uci -q get unisoc_modem.main.sim_slots 2>/dev/null || true)" = 2 ]; then + if [ "$DEVICE" = u30air ] && [ "$MU300_SIM_SLOT" = 0 ] && [ ! -e /run/mu300-radio-freeze ] && [ -e /etc/mu300/sim-data-route-2 ]; then + current=$(at 'AT+SPSWDATA?' 4 | tr -d '\r' | sed -n 's/^+SPSWDATA: *\([01]\) *$/\1/p' | head -n1) || current= + if [ "$current" = 1 ]; then + at 'AT+SPSWDATA' 8 | tr -d '\r' | grep -qx OK || return 1 + current=$(at 'AT+SPSWDATA?' 4 | tr -d '\r' | sed -n 's/^+SPSWDATA: *\([01]\) *$/\1/p' | head -n1) || current= + [ "$current" != 1 ] || return 1 + fi + [ "$current" != 0 ] || rm -f /etc/mu300/sim-data-route-2 + fi + if [ "$DEVICE" != u30air ] && [ "$(uci -q get unisoc_modem.main.sim_slots 2>/dev/null || true)" = 2 ]; then # Select the data card once, before activation; never use SMMSWAP to # implement viewing or data selection. Confirm even an omitted OK. current=$(at 'AT+SPSWDATA?' 3 | sed -n 's/^+SPSWDATA: *\([01]\).*/\1/p' | head -n1) @@ -779,6 +835,7 @@ down() { } sim_reset() { + [ ! -e /run/mu300/sim-managed ] || { echo "Native dual-SIM RF is managed; use SIM control or reboot" >&2; return 1; } tty_setup at 'AT+SFUN=5' 20; at 'AT+SFUN=3' 10; sleep 2; at 'AT+SFUN=2' 10; at 'AT+SFUN=4' 30 for _ in $(seq 1 30); do at 'AT+CPIN?' | grep -q READY && break; sleep 2; done @@ -827,6 +884,7 @@ watch() { modem_stack || { echo "no modem stack in this kernel ($(uname -r)), not watching" >&2; exit 0; } while :; do sleep "${MU300_WATCH_INTERVAL:-30}" + [ ! -e /run/mu300/sim-switching ] && [ ! -e /run/mu300/sim-active-unknown ] || continue [ ! -d /run/unisoc-data-sim-switch ] || continue [ -e /run/mu300-mobile-data-down ] && continue # A daemon started with SIM 1 must not keep polling/reconnecting SIM 1 @@ -942,7 +1000,15 @@ status() { ip -br addr show "$IFACE" } + case "${1:-status}" in + radio-locked) + [ "$DEVICE" = u30air ] || exit 2 + shift + case "$*" in + '/bin/bash /opt/mu300/bin/mu300-sim2-start --cold-start'|'/opt/mu300/bin/mu300-sim-u30 --sequence 0'|'/opt/mu300/bin/mu300-sim-u30 --sequence 1') radio_locked "$@" ;; + *) exit 2 ;; + esac ;; up) up "${2:-}" ;; data-priority) data_priority ;; radio-on) diff --git a/rootfs/overlay/opt/mu300/bin/mu300-at b/rootfs/overlay/opt/mu300/bin/mu300-at index 73c66bb7..1a8e8094 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-at +++ b/rootfs/overlay/opt/mu300/bin/mu300-at @@ -16,8 +16,19 @@ if [ -n "$(read -t 1 _probe &1)" ]; then done echo "mu300-at: need bash or busybox ash (this shell has no 'read -t')" >&2; exit 1 fi +native_gate() { + if { [ -e /run/mu300/sim-sequence ] || [ -e /run/mu300/sim-active-unknown ]; } && [ "${MU300_SIM_CONTROL:-0}" != 1 ]; then + echo 'mu300-at: busy (SIM radio transaction)' >&2; return 1 + fi +} +native_gate || exit 1 +[ ! -e /run/mu300/u30-native ] || MU300_AT_DAEMON_ONLY=1 DIR=${MU300_AT_DIR:-/run/mu300-at} DEV=${MU300_AT_DEV:-/dev/stty_nr1} +if [ -z "${MU300_AT_DIR:-}" ] && [ -e /run/mu300-radio-freeze ]; then + selected=${MU300_SIM_SLOT:-$(cat /run/mu300/sim-slot 2>/dev/null || true)} + if [ "$selected" = 1 ]; then DIR=/run/mu300-at4; DEV=${MU300_AT_DEV:-/dev/stty_nr4}; fi +fi CR=$(printf '\r') T=6 if [ "${1:-}" = -t ]; then @@ -118,6 +129,7 @@ if [ -p "$DIR/cmd" ]; then # that open, the client and the new daemon wait forever on two different, # unlinked FIFOs while this client keeps the global command lock. O_RDWR # never blocks; with no daemon the answer timeout below releases the lock. + native_gate || exit 1 exec 9<> "$DIR/cmd" 2>/dev/null || { echo "mu300-at: the daemon is not reading commands" >&2; exit 1; } printf '%s %s %s\n' "$T" "$answer" "$cmd" >&9 || { diff --git a/rootfs/overlay/opt/mu300/bin/mu300-atd b/rootfs/overlay/opt/mu300/bin/mu300-atd index ed54c5b9..0df79176 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-atd +++ b/rootfs/overlay/opt/mu300/bin/mu300-atd @@ -258,7 +258,7 @@ while :; do # gone away, and then there is nothing left to lose. if [ -z "$reply" ]; then silent=$((silent + 1)) - if [ "$silent" -ge 5 ] && [ $(( $(now) - last_reopen )) -ge 300 ] && ! modem_alive; then + if [ "${MU300_AT_DISABLE_REOPEN:-0}" != 1 ] && [ "$silent" -ge 5 ] && [ $(( $(now) - last_reopen )) -ge 300 ] && ! modem_alive; then echo "mu300-atd: no reply and no URCs either, the modem looks gone; reopening $DEV" >&2 last_reopen=$(now) if open_tty; then diff --git a/rootfs/overlay/opt/mu300/bin/mu300-data-sim b/rootfs/overlay/opt/mu300/bin/mu300-data-sim index 0deb6a47..6954646f 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-data-sim +++ b/rootfs/overlay/opt/mu300/bin/mu300-data-sim @@ -1,6 +1,10 @@ #!/bin/sh # MU300 netifd adapter. No tty opens, RIL handshake changes or USB operations. export PATH="$PATH:/opt/mu300/bin:/opt/mu300/busybox-bin:/usr/sbin:/sbin" +# The U30 has one active RF stack; a V50-style SPSWDATA-only switch is unsafe. +if [ "$(mu300-device 2>/dev/null)" = u30air ]; then + exec /opt/mu300/bin/mu300-data-sim-u30 "$@" +fi . "${MU300_SIM_ENV_LIB:-/opt/mu300/bin/mu300-sim-env}" cfg() { uci -q get "unisoc_modem.main.$1" 2>/dev/null || true; } wan=$(cfg data_interface); wan=${wan:-wan} diff --git a/rootfs/overlay/opt/mu300/bin/mu300-data-sim-u30 b/rootfs/overlay/opt/mu300/bin/mu300-data-sim-u30 new file mode 100644 index 00000000..1a3a399b --- /dev/null +++ b/rootfs/overlay/opt/mu300/bin/mu300-data-sim-u30 @@ -0,0 +1,39 @@ +#!/bin/sh +# Native U30 controller adapted to the shared dashboard's zero-based SIM API. +export PATH="$PATH:/opt/mu300/bin:/usr/sbin:/sbin" +[ "$(mu300-device 2>/dev/null)" = u30air ] || exit 1 +NATIVE=${MU300_NATIVE_SIM_CMD:-/opt/mu300/bin/mu300-sim-u30} +field() { printf '%s' "$view" | jsonfilter -e "@.$1" 2>/dev/null; } +case ${1:-} in +get) + view=$("$NATIVE" status) || { printf '{"ok":0,"error":"dual_sim_unavailable"}\n'; exit 1; } + actual=$(field active); saved=$(field default); hot=$(field hot) + case "$actual" in 1|2) actual=$((actual-1));; *) actual=null;; esac + case "$saved" in 1|2) saved=$((saved-1));; *) saved=0;; esac + case "$hot" in 0|1) ;; *) hot=0;; esac + ready=false; [ "$(field available)" != 1 ] || ready=true + connected=false; [ "$(field wan_up)" != true ] || connected=true + printf '{"ok":1,"native":true,"ready":%s,"saved_sim":%s,"actual_sim":%s,"hot":%s,"data_connected":%s,"devices":["sipa_eth0","sipa_eth8"],"native_status":%s}\n' "$ready" "$saved" "$actual" "$hot" "$connected" "$view" + ;; +apply) + case ${2:-} in + 0|1) operation=switch; value=$(( $2+1 ));; + u30-hot-[01]) operation=hot; value=${2##*-};; + u30-default-[01]) operation=default; value=$(( ${2##*-}+1 ));; + *) echo invalid_sim >&2; exit 1;; + esac + mutex=${MU300_SIM_MUTEX:-/run/unisoc-data-sim-switch} + mkdir "$mutex" 2>/dev/null || { echo modem_busy >&2; exit 1; } + echo $$ > "$mutex/pid" + trap 'rm -f "$mutex/pid"; rmdir "$mutex" 2>/dev/null || true' EXIT + trap 'exit 143' INT TERM + [ ! -d /run/unisoc-modem-lock-apply ] || { echo modem_busy >&2; exit 1; } + rc=0; view=$("$NATIVE" "$operation" "$value") || rc=$? + if [ "$rc" != 0 ]; then + reason=$(field error) + printf '%s\n' "${reason:-sim_rollback_failed}" >&2 + fi + exit "$rc" + ;; +*) exit 2;; +esac diff --git a/rootfs/overlay/opt/mu300/bin/mu300-platform-config b/rootfs/overlay/opt/mu300/bin/mu300-platform-config index 0c6ddd70..aefe6bff 100644 --- a/rootfs/overlay/opt/mu300/bin/mu300-platform-config +++ b/rootfs/overlay/opt/mu300/bin/mu300-platform-config @@ -3,10 +3,16 @@ # Same-board preferences, APNs, SMS and traffic history remain user-owned. export PATH="$PATH:/opt/mu300/bin:/usr/sbin:/sbin" device=$(mu300-device 2>/dev/null) -case $device in v50) slots=2 ;; f50|u30air) slots=1 ;; *) exit 1 ;; esac +case $device in v50|u30air) slots=2 ;; f50) slots=1 ;; *) exit 1 ;; esac [ "$(uci -q get unisoc_modem.main)" = core ] || exit 0 previous=$(uci -q get unisoc_modem.main.platform_defaults) -[ "$previous" != "$device" ] || exit 0 +if [ "$previous" = "$device" ]; then + # Upgrade existing U30 profiles once; never reset APNs or the selected card. + [ "$device" = u30air ] && [ "$(uci -q get unisoc_modem.main.u30_native_version)" != 1 ] || exit 0 + uci -q set unisoc_modem.main.sim_slots=2 && + uci -q set unisoc_modem.main.u30_native_version=1 && uci -q commit unisoc_modem + exit $? +fi { if [ -n "$previous" ]; then # A different board's backup must not select a nonexistent data SIM or @@ -16,9 +22,10 @@ previous=$(uci -q get unisoc_modem.main.platform_defaults) for key in data_sim_command sim0_device sim1_device; do printf "set unisoc_modem.main.%s=''\n" "$key" done - elif [ "$device" = v50 ]; then + elif [ "$slots" = 2 ]; then printf "set unisoc_modem.main.sim_slots='2'\n" fi + if [ "$device" = u30air ]; then printf "set unisoc_modem.main.u30_native_version='1'\n"; fi printf "set unisoc_modem.main.platform_defaults='%s'\n" "$device" printf 'commit unisoc_modem\n' } | uci -q batch diff --git a/rootfs/overlay/opt/mu300/bin/mu300-sim-env b/rootfs/overlay/opt/mu300/bin/mu300-sim-env index 847d115d..0a0a5806 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-sim-env +++ b/rootfs/overlay/opt/mu300/bin/mu300-sim-env @@ -2,6 +2,9 @@ # Source this platform mapping. The standalone plugin never assumes SIPA names. mu300_sim_env() { local selected=${1:-} device + if [ -z "$selected" ] && [ "$("${MU300_DEVICE_CMD:-/opt/mu300/bin/mu300-device}" 2>/dev/null)" = u30air ]; then + selected=$(cat /run/mu300/sim-slot 2>/dev/null || true) + fi [ -n "$selected" ] || selected=$(uci -q get unisoc_modem.main.data_sim 2>/dev/null || true) selected=${selected:-0} case "$selected" in 0|1) ;; *) return 1 ;; esac diff --git a/rootfs/overlay/opt/mu300/bin/mu300-sim-u30 b/rootfs/overlay/opt/mu300/bin/mu300-sim-u30 new file mode 100644 index 00000000..25c82b8f --- /dev/null +++ b/rootfs/overlay/opt/mu300/bin/mu300-sim-u30 @@ -0,0 +1,439 @@ +#!/bin/bash +# OpenWrt SIM policy and a bounded, broker-only live switch. Public slots are 1/2. +# U30 Air on OpenWrt only: the cold start and the live switch were validated on that firmware alone; everywhere +# else every command (status included) answers ok:0, and nothing is written. +# +# Nothing a caller passes ever reaches an AT command: the arguments are checked against a fixed list below, and the +# commands are built from the two slot numbers alone. Replies are never logged (CCID, cell, numbers). +set -euo pipefail +export PATH="$PATH:/opt/mu300/busybox-bin" +umask 077 +R=/run/mu300 +FALLBACK=/etc/mu300-sim-fallback +AT=/opt/mu300/bin/mu300-at +MD=/opt/mu300/bin/mobile-data +DEVICE=/opt/mu300/bin/mu300-device +REBOOT=${MU300_REBOOT_CMD:-reboot} +supported() { [ -e /etc/openwrt_release ] && [ "$("$DEVICE" 2>/dev/null)" = u30air ]; } +supported || { printf '{"ok":0,"supported":0,"error":"Dual SIM control is only for the U30 Air on OpenWrt"}\n'; exit 1; } +SIM_CONFIG_U30=1 +. "${MU300_SIM_CONFIG_LIB:-/opt/mu300/lib/sim-config.sh}" +LOCKED=${MU300_SIM_LOCKED:-0} +mkdir -p "$R" +uptime_s() { cut -d' ' -f1 /proc/uptime 2>/dev/null || date +%s; } +active() { cat "$R/sim-slot" 2>/dev/null || echo unknown; } +policy() { sim_cfg_hot; } +main() { [ "$1" = 0 ] && echo /run/mu300-at || echo /run/mu300-at4; } +data() { [ "$1" = 0 ] && echo /run/mu300-at2 || echo /run/mu300-at5; } +bearer() { [ "$1" = 0 ] && echo sipa_eth0 || echo sipa_eth8; } +owner() { + local pid + [ -p "$1/cmd" ] && [ -s "$1/owner/pid" ] || return 1 + pid=$(cat "$1/owner/pid") + [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null +} +available() { + [ -e /run/mu300-radio-freeze ] || return 1 + local d + for d in /run/mu300-at /run/mu300-at2 /run/mu300-at4 /run/mu300-at5; do owner "$d" || return 1; done +} +atomic() { local t; t=$(mktemp "$1.XXXXXX"); printf '%s\n' "$2" > "$t"; mv -f "$t" "$1"; } +fail() { + if [ "${LOCKED:-0}" = 1 ]; then + case "$(cat "$R/sim-result" 2>/dev/null || true)" in rolled_back|reboot_required|restarting|no_data|no_data_kept) ;; *) atomic "$R/sim-result" failed;; esac + fi + printf '{"ok":0,"error":"%s"}\n' "$1"; return 1; } +status() { + local slot boot hot can=0 busy=0 result=idle fallback=null phase=idle radio=null wan=null error=null + local check=null left=null word end + slot=$(active); boot=$(sim_cfg_default); hot=$(policy) + case "$slot" in 0|1) slot=$((slot+1));; *) slot=null;; esac + [ ! -e "$R/sim-active-unknown" ] || slot=null + case "$boot" in 0|1) boot=$((boot+1));; *) boot=null;; esac + [ "$hot" = 1 ] || hot=0 + if [ "$hot" = 1 ] && available && [ ! -e "$R/sim-switching" ] && [ ! -e "$R/sim-active-unknown" ]; then can=1; fi + # Kernel flock is released on exit, including SIGKILL; a leftover file is harmless. The holder of the lock + # (this process, reporting after its own change) is not "busy" to itself. + if [ "${LOCKED:-0}" != 1 ] && command -v flock >/dev/null; then + (exec 9>"$R/sim-control.lock"; flock -n 9) || busy=1 + fi + result=$(cat "$R/sim-result" 2>/dev/null || echo idle) + case "$result" in idle|switching|switched|rolled_back|reboot_required|restarting|failed|no_data|no_data_kept) ;; *) result=idle;; esac + # A switch marker nobody holds the lock for is a switch that was killed: the radio is where it was left. + if [ -e "$R/sim-switching" ] && [ "$busy" = 0 ]; then + slot=null + [ "$result" = restarting ] || result=reboot_required + fi + # The last boot's cold start failed and the settings went back to SIM1 (mu300-sim2-warmup): say why until the + # user chooses again. Reasons are identifiers, never modem output. + if [ -s "$FALLBACK" ]; then + fallback=$(head -c 40 "$FALLBACK" | tr -cd 'a-z0-9_-') + [ -n "$fallback" ] && fallback="\"$fallback\"" || fallback=null + fi + phase=$(cat "$R/sim-phase" 2>/dev/null || echo idle) + case "$phase" in idle|switching|waiting_for_data|rolling_back) ;; *) phase=idle;; esac + [ ! -e "$R/sim-radio-ready" ] || radio=true + if [ "$slot" != null ]; then + observed_wan=$(ubus call network.interface.$sim_wan status 2>/dev/null | tr -d ' \n\t') || observed_wan= + if [ -n "$observed_wan" ]; then + if wan_up; then wan=true; else wan=false; fi + fi + fi + # The boot check of a second card that never had data (mu300-sim2-warmup): "waiting" with the seconds left, + # then confirmed, kept (the connection was off), off (no check) or failed (the device restarts into SIM1). + if [ -s "$R/sim-boot-check" ]; then + read -r word end < "$R/sim-boot-check" || true + case "$word" in + waiting) + check='"waiting"' + case "${end:-}" in ''|*[!0-9]*) ;; *) left=$(( end - $(cut -d. -f1 /proc/uptime 2>/dev/null || echo "$end") )); [ "$left" -gt 0 ] || left=0 ;; esac ;; + confirmed|kept|off|failed) check="\"$word\"" ;; + esac + fi + case "$result" in failed|no_data|no_data_kept|reboot_required|restarting|rolled_back) error="\"$result\"";; esac + [ "$busy" = 0 ] || can=0 + printf '{"version":1,"ok":1,"supported":1,"slot1_supported":1,"active":%s,"default":%s,"hot":%s,"available":%s,"busy":%s,"phase":"%s","result":"%s","error":%s,"fallback":%s,"boot_check":%s,"boot_check_left":%s,"capabilities":{"boot_selection":true,"live_switch":true},"radio_ready":%s,"registered":null,"wan_up":%s}\n' \ + "$slot" "$boot" "$hot" "$can" "$busy" "$phase" "$result" "$error" "$fallback" "$check" "$left" "$radio" "$wan" +} +# raw DIRECTORY COMMAND: one command through a persistent owner; prints the answer whatever its result code. +# 75: not sent at all (the channel's client lock was busy the whole wait); 1: no owner, or no completed answer. +# MU300_SIM_CONTROL=1 lets these through mu300-at's gate, which keeps every other client off the modem while the +# sequence runs (see run_sequence). +raw() { + local directory=$1 command=$2 seconds=${3:-8} output rc=0 + owner "$directory" || return 1 + # Do not log replies: CCID, subscriber or cell identifiers never belong in switch logs. + printf '%s %s %s\n' "$(uptime_s)" "$directory" "$command" >> "$R/sim-switch.log" + output=$(MU300_SIM_CONTROL=1 MU300_AT_DAEMON_ONLY=1 MU300_AT_DIR="$directory" MU300_AT_LOCK_WAIT="${MU300_SIM_AT_LOCK_WAIT:-20}" \ + MU300_AT_BUDGET=$((seconds + 4)) "$AT" -t "$seconds" "$command" 2>&1) || rc=$? + if [ "$rc" != 0 ]; then + case "$output" in *'mu300-at: busy'*) return 75 ;; esac + return 1 + fi + printf '%s\n' "$output" | tr -d '\r' +} +# cmd DIRECTORY COMMAND: raw, and the modem must have said OK +cmd() { + local output rc=0 + output=$(raw "$@") || rc=$? + [ "$rc" = 0 ] || return "$rc" + [ "$(printf '%s\n' "$output" | tail -1)" = OK ] || return 1 + printf '%s\n' "$output" +} +# (The answer is taken whole before it is looked at. Piped into a reader that stops at its first match - grep -q, +# head - the writer can be left with a closed pipe, and under pipefail that reads as "the modem said no": seen in +# the tests as a switch that rolled back after a radio that had come on.) +check() { + local output + output=$(cmd "$(main "$1")" 'AT+CFUN?') || return 1 + grep -Eq "^\+CFUN: *$2$" <<< "$output" +} +ready() { + local output + output=$(cmd "$(main "$1")" 'AT+CPIN?') || return 1 + grep -Eq '^\+CPIN: *READY$' <<< "$output" +} +# card SLOT: what the card says of itself: ready, sim-pin, no-sim or unknown. "no-sim" (+CME ERROR: 10) is also +# what a position answers whose SIM power is off: see preflight. +card() { + local output + output=$(raw "$(main "$1")" 'AT+CPIN?') || { echo unknown; return 0; } + if [[ "$output" == *'+CPIN: READY'* ]]; then echo ready + elif [[ "$output" == *'+CPIN: SIM PIN'* || "$output" == *'+CPIN: SIM PUK'* ]]; then echo sim-pin + elif [[ "$output" =~ \+CME\ ERROR:\ (10($|[^0-9])|SIM\ not\ inserted) ]]; then echo no-sim + else echo unknown; fi +} +# preflight TARGET: is there a card to switch to? Asked before the connection in use is touched. The target's SIM +# power is switched on for the question (AT+SPACTCARD=;+SFUN=2, the sequence's own first command): with it +# off the position answers "no card" whatever is in it (measured on our U30 Air, whose second position does that at +# every boot), and SIM power moves no radio - the card in use does not notice (measured, with its data up). A +# card that still does not answer, or is locked, gets its power switched off again and the switch is refused: one +# second, and the WAN never went down. Prints the reason when it refuses. +preflight() { + local target=$1 state attempt + cmd "$(main "$target")" "AT+SPACTCARD=$target;+SFUN=2" 10 >/dev/null || { echo 'The target SIM could not be powered; nothing was changed'; return 1; } + for ((attempt=0; attempt<8; attempt++)); do + state=$(card "$target") + case "$state" in ready) return 0 ;; sim-pin) break ;; esac + sleep 1 + done + cmd "$(main "$target")" "AT+SPACTCARD=$target;+SFUN=3" 10 >/dev/null || true + case "$state" in + sim-pin) echo 'The target SIM is locked by its PIN; nothing was changed' ;; + *) echo 'No card answers in the target SIM position; nothing was changed' ;; + esac + return 1 +} +# route SLOT: the card the modem says has the packet-data route (0 or 1), asked on SLOT's command channel; nothing +# when this firmware does not answer the question. +route() { + local output + output=$(cmd "$(main "$1")" 'AT+SPSWDATA?') || return 1 + sed -n 's/^+SPSWDATA: *\([01]\) *$/\1/p' <<< "$output" | sed -n 1p +} +# sequence TARGET: the radio from the other card to TARGET, the card in use first off, then the other one on. +# +# The order is the measured one (our U30 Air, 7.2.10, 2026-10-13; docs/FINDINGS.md 74). The factory selector +# (VendorTelephonyManager.setProtocolStack) and this script's first version switch the target's radio on while the +# other card is still on, and on the unit the sequence came from that worked in both directions. On ours the +# target's AT+SFUN=4 then never answered (30 s), the card in use lost its radio meanwhile, and the way back could +# not be verified. With the card in use switched off first, every step answered within a second, in both +# directions: it is the cold start's situation, one card on while the other is off, which both units have shown. +# +# Every command names its card (AT+SPACTCARD=;+...): the selection holds for that command line only. A +# line with AT+SPACTCARD=0 alone, which the first version sent "to reset the channel", changes nothing (measured: +# AT+SPACTCARD? keeps answering the channel's own card, and the channel keeps reading it). +# The first command alone may say "not sent" (75): after it the radio has been told something. +sequence() { + local target=$1 old=$((1-$1)) got attempt + cmd "$(main "$old")" "AT+SPACTCARD=$old;+SFUN=5" 20 >/dev/null || return $? + cmd "$(main "$old")" "AT+SPACTCARD=$old;+SFUN=3" 10 >/dev/null || return 1 + check "$old" 0 || return 1 + # the target: SIM power, the card, the data route, the radio - the cold start's order (mu300-sim2-start) + cmd "$(main "$target")" "AT+SPACTCARD=$target;+SFUN=2" 10 >/dev/null || return 1 + for ((attempt=0; attempt<8; attempt++)); do + if ready "$target"; then break; fi + sleep 1 + done + ready "$target" || return 1 + # the mark that makes a later plain SIM1 dial take the data route back (lib/sim-config.sh) + [ "$target" != 1 ] || sim_route_mark_set || return 1 + cmd "$(data "$target")" 'AT+SPSWDATA' >/dev/null || return 1 + # Read back which card has the route (after kanoqwq's mu300-data-sim): the other card is a failure; a firmware + # that does not answer the question is not. + got=$(route "$target") || got= + case "$got" in "$target"|'') ;; *) return 1 ;; esac + [ "$target:$got" != 0:0 ] || rm -f "$sim_route_mark" + if [ -x /usr/libexec/unisoc-modem/lock ]; then + ( + . /usr/libexec/unisoc-modem/sim-scope.sh + sim_scope "$target" || exit 1 + [ ! -e "${UNISOC_REPLAY_MARKER:-/run/unisoc-modem-lock-replay-done}" ] || exit 0 + MU300_SIM_CONTROL=1 /usr/libexec/unisoc-modem/lock replay early + ) || logger -t mu300-sim 'Early lock replay unconfirmed; late worker remains armed' + fi + cmd "$(data "$target")" 'AT+SFUN=4' 30 >/dev/null || return 1 + for ((attempt=0; attempt<15; attempt++)); do + if check "$target" 1; then break; fi + sleep 1 + done + check "$target" 1 && check "$old" 0 +} +publish() { + atomic "$R/sim-slot" "$1" + : > "$R/sim-managed" + : > "$R/sim-radio-ready" + if [ "$1" = 1 ]; then : > "$R/sim2-radio-ready"; else rm -f "$R/sim2-radio-ready"; fi + rm -f "$R/sim-active-unknown" + # The dashboard caches are shared across cards; identity caches remain per card. + rm -f /run/unisoc-modem/cell.json /run/unisoc-modem/sig.json +} +# wan_up: netifd applies the selected SIM profile and has an address on that exact bearer. A radio-only +# transition does not change the next-boot preference; the boot default +# is saved only once this says yes (MU300_SIM_WAN_WAIT seconds at most, 60 by default), else the switch is undone. +wan_up() { sim_wan_up "$(bearer "$(active)")"; } +wan_wait() { + local deadline=$(( $(date +%s) + ${MU300_SIM_WAN_WAIT:-60} )) + while :; do + wan_up && return 0 + [ "$(date +%s)" -lt "$deadline" ] || return 1 + sleep 1 + done +} +# unknown_radio: nobody can say which card the radio is on (a sequence that stopped half way and could not be +# undone, a controller that was killed). Nothing dials or resets a radio in that state, so it would stay without +# data until somebody restarts the device by hand: the device restarts itself, into the saved boot default, which +# a failed switch never changes. network.wan.sim_restart '0' leaves it at "reboot required" instead. +unknown_radio() { + : > "$R/sim-active-unknown" + if [ "$(sim_cfg_auto_restart)" = 1 ]; then + atomic "$R/sim-result" restarting + logger -t mu300-sim "the radio state is unknown after a SIM switch: restarting" 2>/dev/null || true + ( sleep "${MU300_SIM_RESTART_DELAY:-20}"; sync 2>/dev/null; exec $REBOOT ) 9>&- /dev/null 2>&1 & + else + atomic "$R/sim-result" reboot_required + fi +} +SEQPID= +interrupt_switch() { + [ -z "$SEQPID" ] || kill -TERM -- "-$SEQPID" 2>/dev/null || true + exit 143 +} +# run_sequence TARGET: the sequence in a process of its own, under mobile-data's radio lock (the dial's radio-on, +# the watchdog and the lock helper's SFUN restart take the same one; 75 when it stays busy) and behind mu300-at's +# gate ($R/sim-sequence: every other AT client is told "busy" meanwhile - SMS, USSD, the panel's terminal). +run_sequence() { + local rc=0 + : > "$R/sim-sequence" + MU300_RADIO_LOCK_WAIT="${MU300_SIM_RADIO_LOCK_WAIT:-20}" setsid "$MD" radio-locked "$0" --sequence "$1" & + SEQPID=$! + # A shell waiting on a builtin wait runs TERM traps immediately; a foreground child delays them. + wait "$SEQPID" || rc=$? + SEQPID= + rm -f "$R/sim-sequence" + return "$rc" +} +# roll_back OLD: the one guarded return to the previous card. Only if BOTH brokers still answer: a silent CP must +# not receive blind restart loops. True when the old card is back; false leaves the radio state unknown. +roll_back() { + local old=$1 + atomic "$R/sim-phase" rolling_back + if cmd "$(main 0)" 'AT+CFUN?' >/dev/null && cmd "$(main 1)" 'AT+CFUN?' >/dev/null && run_sequence "$old"; then + publish "$old" + atomic "$R/sim-phase" idle + return 0 + fi + unknown_radio + return 1 +} +wait_wan_down() { + local n st + for ((n=0; n<15; n++)); do + st=$(ubus call network.interface.$sim_wan status 2>/dev/null) || { sleep 1; continue; } + if [[ $(jsonfilter -s "$st" -e '@.up') == false && $(jsonfilter -s "$st" -e '@.pending') != true ]]; then return 0; fi + sleep 1 + done + return 1 +} +live_switch() { + local target=$1 old had_data=0 rc=0 held_down=0 + old=$(active); case "$old" in 0|1) ;; *) fail 'Unknown active SIM; reboot first'; return 1;; esac + [ ! -e "$R/sim-switching" ] || { fail 'Interrupted switch; reboot first'; return 1; } + [ ! -e "$R/sim-active-unknown" ] || { fail 'Unknown radio state; reboot first'; return 1; } + [ "$(policy)" = 1 ] || { fail 'Enable hot switching first'; return 1; } + available || { fail 'Persistent dual-SIM brokers unavailable; reboot first'; return 1; } + [ ! -e /run/mu300-mobile-data.suspend ] || { fail 'Resume the modem before switching'; return 1; } + [ ! -d /run/unisoc-modem-lock-apply ] || { fail 'Network locks are being applied'; return 1; } + if [ "$old" = "$target" ]; then + wan_wait || { atomic "$R/sim-result" no_data; fail 'Active SIM has no data; use default for next-boot selection'; return 1; } + sim_cfg_save_default "$target" || return 1 + sim_seen_add "$target" || true + atomic "$R/sim-result" switched + rm -f "$FALLBACK"; status; return 0 + fi + # A card whose SIM power is off answers CME ERROR 10 whatever is in its position: the starting RF state is + # validated here, the card itself only once its power is on (preflight). + check "$old" 1 && check "$target" 0 || { fail 'Unexpected radio state; reboot first'; return 1; } + local refusal + refusal=$(preflight "$target") || { fail "$refusal"; return 1; } + # Did the card in use have data? It decides what a target without data means, below. + if wan_up; then had_data=1; fi + if sim_wan_held_down; then held_down=1; fi + # Prevent new dial/watch rounds before netifd cancels the old protocol task. + : > "$R/sim-switching" + atomic "$R/sim-result" switching + atomic "$R/sim-phase" switching + # However this ends, the markers go; a result still "switching" then is a switch that was cut short (the + # deadline, a TERM): which card the radio is on is not known. + trap 'atomic "$R/sim-phase" idle; rm -f "$R/sim-sequence" "$R/sim-switching"; if [ "$(cat "$R/sim-result")" = switching ]; then unknown_radio; fi' EXIT + trap interrupt_switch INT TERM + ifdown "$sim_wan" || { atomic "$R/sim-result" failed; fail 'Cannot stop WAN'; return 1; } + if ! wait_wan_down; then + atomic "$R/sim-result" failed + rm -f "$R/sim-switching" + [ "$held_down" = 1 ] || ifup "$sim_wan" || true + fail 'data_disconnect_failed'; return 1 + fi + # Serialize the whole protocol-stack transaction against radio-on and manual resets. + run_sequence "$target" || rc=$? + if [ "$rc" = 75 ]; then + # nothing was sent: the radio lock or the AT channel stayed busy. The previous card is as it was. + atomic "$R/sim-result" failed + rm -f "$R/sim-switching" /run/mu300-mobile-data-down + [ "$held_down" = 1 ] || ifup "$sim_wan" || true + fail 'The modem is busy; nothing was changed, try again'; return 1 + fi + if [ "$rc" != 0 ]; then + if roll_back "$old"; then + atomic "$R/sim-result" rolled_back + rm -f "$R/sim-switching" /run/mu300-mobile-data-down + if [ "$held_down" != 1 ]; then + ifup "$sim_wan" || { fail 'Previous SIM restored but WAN could not be started'; return 1; } + fi + fail 'Switch failed; previous SIM restored'; return 1 + fi + fail 'Switch failed; radio state unknown, reboot required'; return 1 + fi + # The target card is up: let netifd dial it, and keep the boot default where it was until the bearer is + # there. The published slot is this boot's; the saved one is tomorrow's. + publish "$target" + rm -f "$R/sim-switching" /run/mu300-mobile-data-down + atomic "$R/sim-phase" waiting_for_data + if [ "$held_down" = 1 ]; then + sim_cfg_save_default "$target" || { atomic "$R/sim-result" failed; fail storage_failed; return 1; } + atomic "$R/sim-result" switched + atomic "$R/sim-phase" idle + status; return 0 + fi + if ifup "$sim_wan" && wan_wait; then + if ! sim_cfg_save_default "$target"; then + atomic "$R/sim-result" failed + fail 'SIM switched but the boot default could not be saved'; return 1 + fi + sim_seen_add "$target" || true + rm -f "$FALLBACK" + atomic "$R/sim-result" switched + atomic "$R/sim-phase" idle + # Existing watcher reloads its slot itself; never restart AT owners or the whole mu300-post service. + status; return 0 + fi + # No bearer on the target within the time. When the previous card had data, back to it, the boot default + # untouched. When it had none either (a first card without a data plan, a boot onto a card with no service), + # going back restores nothing and undoes what the user asked for: the target stays, netifd keeps dialling it, + # and the boot default is still not saved - "use at next boot" is the user's to press. + if [ "$had_data" = 0 ]; then + atomic "$R/sim-result" no_data_kept + atomic "$R/sim-phase" idle + fail 'Target SIM has no data yet and the previous SIM had none either; staying on the target, boot default unchanged'; return 1 + fi + : > "$R/sim-switching" + ifdown "$sim_wan" || true + if roll_back "$old"; then + atomic "$R/sim-result" no_data + rm -f "$R/sim-switching" /run/mu300-mobile-data-down + ifup "$sim_wan" || { fail 'Target SIM got no data; previous SIM restored but WAN could not be started'; return 1; } + fail 'Target SIM got no data within the time; previous SIM restored'; return 1 + fi + fail 'Target SIM got no data and the previous one could not be restored; reboot required'; return 1 +} +case ${1:-status} in + status) status; exit 0;; + --sequence) + # Only the parent holding BOTH locks may enter this internal operation. + [[ ${2:-} =~ ^[01]$ ]] && [ -e "$R/sim-switching" ] && + [ "$(readlink /run/mu300-radio-on.owner 2>/dev/null)" = "$PPID" ] || exit 2 + sequence "$2"; exit $?;; + default|hot|switch) ;; + *) fail 'Usage: mu300-sim status | default 1|2 | hot 0|1 | switch 1|2'; exit 2;; +esac +[ "$#" = 2 ] || { fail 'Exactly one value is required'; exit 2; } +case $1:$2 in default:1|default:2|switch:1|switch:2|hot:0|hot:1) ;; *) fail 'Invalid SIM setting'; exit 2;; esac +command -v flock >/dev/null || { fail 'flock is required for SIM control'; exit 1; } +exec 9>"$R/sim-control.lock" +flock -n 9 || { fail 'SIM control is busy'; exit 1; } +LOCKED=1 +case $1 in + # A choice of the user's ends the last fallback's notice: the next boot tries what was chosen. + default) sim_cfg_save_default "$(( $2-1 ))"; rm -f "$FALLBACK"; status;; + hot) sim_cfg_save_hot "$2"; rm -f "$FALLBACK"; status;; + switch) + # The whole operation is bounded: switch (about 15 s of AT), the wait for a bearer (60 s), one rollback + # (15 s) and two dials fit in 300 s; past it the switch is ended and the radio state declared unknown. + # The same guard watches this process: killed outright (SIGKILL, out of memory) it can clean nothing up - + # the markers stay, or the radio is left on a card nobody confirmed and nobody will switch back from. A + # result still "switching" with this process gone is that case: the guard clears the markers and declares + # the radio unknown, as this process's own exit would have. + ( trap 'kill "$sleeper" 2>/dev/null || true; exit 0' TERM INT + end=$(( $(date +%s) + ${MU300_SIM_DEADLINE:-300} )) + while kill -0 "$$" 2>/dev/null && [ "$(date +%s)" -lt "$end" ]; do sleep 2 & sleeper=$!; wait "$sleeper"; done + if kill -0 "$$" 2>/dev/null; then kill -TERM "$$" 2>/dev/null + elif [ "$(cat "$R/sim-result" 2>/dev/null || true)" = switching ]; then + rm -f "$R/sim-sequence" "$R/sim-switching"; atomic "$R/sim-phase" idle; unknown_radio + fi + ) 9>&- /dev/null 2>&1 & + deadline=$! + rc=0; live_switch "$(( $2-1 ))" || rc=$? + kill "$deadline" 2>/dev/null || true + wait "$deadline" 2>/dev/null || true + exit "$rc";; +esac diff --git a/rootfs/overlay/opt/mu300/bin/mu300-sim2-start b/rootfs/overlay/opt/mu300/bin/mu300-sim2-start new file mode 100644 index 00000000..742a778a --- /dev/null +++ b/rootfs/overlay/opt/mu300/bin/mu300-sim2-start @@ -0,0 +1,169 @@ +#!/bin/bash +# Native selected-SIM cold-start sequence verified on this U30 Air firmware; once per boot. +# Run once during Linux boot, through: mobile-data radio-locked /path/to/this/script --cold-start +# Existing nr0/nr1/nr2 and nr3/nr4/nr5 owners must already be running; this opens no modem device. +# +# What it leaves for its caller (mu300-sim2-warmup), all under /run/mu300: +# sim2-cold-start.log every command sent and why it stopped; never a reply (no CCID, no cell, no number) +# sim2-cold-start.reason one word when it stops before the radio is up: no-sim, sim-pin, sim-not-ready, +# wrong-card, not-cold, modem-silent, modem-refused, data-route, no-radio +# sim2-cold-start.sent the radio has been told something: a failure after it is not undone within this boot +set -euo pipefail +export PATH="$PATH:/opt/mu300/busybox-bin" +umask 077 # the logs and markers under /run/mu300 are root's alone +DEVICE=${MU300_DEVICE_CMD:-/opt/mu300/bin/mu300-device} +[ -e /etc/openwrt_release ] && [ "$("$DEVICE" 2>/dev/null)" = u30air ] || { + echo 'Native SIM startup requires U30 Air on OpenWrt' >&2 + exit 1 +} +[[ ${1:-} == --cold-start ]] || { echo 'Requires an explicitly prepared cold-start boot.' >&2; exit 2; } +[[ -e /run/mu300-radio-freeze ]] || { echo 'Automatic radio bring-up must be inhibited before cold-start.' >&2; exit 2; } +[[ ! -e /run/mu300/charging-boot ]] || exit 0 +SLOT=${MU300_SIM_SLOT:-$(cat /run/mu300/sim-slot 2>/dev/null || echo 1)} +case "$SLOT" in 0|1) ;; *) exit 2;; esac +SIM_CONFIG_U30=1 +. "${MU300_SIM_CONFIG_LIB:-/opt/mu300/lib/sim-config.sh}" +LOG=/run/mu300/sim2-cold-start.log +REASON=/run/mu300/sim2-cold-start.reason +mkdir -p /run/mu300 +say() { printf '%s %s\n' "$(cut -d' ' -f1 /proc/uptime 2>/dev/null || date +%s)" "$*" >> "$LOG"; } +# stop REASON TEXT [RC]: the word for the page, the line for the log +stop() { printf '%s\n' "$1" > "$REASON"; say "$2"; exit "${3:-1}"; } +trap 'result=$?; say "EXIT rc=$result; no further radio commands will be sent"' EXIT +at() { + local slot=$1 command=$2 seconds=${3:-6} directory + case "$slot" in main0) directory=/run/mu300-at ;; main1) directory=/run/mu300-at4 ;; data0) directory=/run/mu300-at2 ;; data1) directory=/run/mu300-at5 ;; *) return 2 ;; esac + # mu300-at has a direct-device fallback: never allow this probe to take it. + [[ -p "$directory/cmd" && -s "$directory/owner/pid" ]] || return 2 + local owner + owner=$(cat "$directory/owner/pid") + [[ "$owner" =~ ^[0-9]+$ ]] && kill -0 "$owner" 2>/dev/null || return 2 + say "TX $slot $command" + MU300_SIM_CONTROL=1 MU300_AT_DAEMON_ONLY=1 MU300_AT_DIR="$directory" /opt/mu300/bin/mu300-at -t "$seconds" "$command" +} +expect_ok() { + local output + output=$(at "$@") || { say "FAILED $1 $2 (no completed response)"; return 1; } + [[ $(printf '%s\n' "$output" | tr -d '\r' | tail -n 1) == OK ]] || { say "FAILED $1 $2 (modem rejected command)"; return 1; } +} + +[[ ! -e /run/mu300/sim2-cold-start.attempted ]] || { say 'Refusing a second attempt in this boot'; exit 2; } +: > /run/mu300/sim2-cold-start.attempted +rm -f "$REASON" +for directory in /run/mu300-at /run/mu300-at2 /run/mu300-at4 /run/mu300-at5; do + [[ -p "$directory/cmd" ]] || stop modem-silent "Missing broker $directory" 2 +done +# Wait for actual CP output, not merely a FIFO created before open_tty completes. +for ((attempt=0; attempt<60; attempt++)); do + [[ -s /run/mu300-at/urc/stty_nr0.log ]] && break + sleep 1 +done +[[ -s /run/mu300-at/urc/stty_nr0.log ]] || stop modem-silent 'No CP unsolicited output; refusing to send bring-up commands' +# Verified Android SIM2-primary handshake: nr1, SMMSWAP=0. SMMSWAP=1 is not a slot selector. +expect_ok main0 'AT+SMMSWAP=0' || stop modem-refused 'The RIL handshake was not taken' +: > /run/mu300-ril-handshake +for slot in main0 main1; do + response=$(at "$slot" 'AT+CFUN?') || stop modem-silent "$slot does not answer" + [[ "$response" == *'+CFUN: 0'* ]] || stop not-cold "$slot was already active; this is not the required cold baseline" 2 +done +# The card. What it is not is told apart, for the page and the log (the answer itself is never logged): +# +CPIN: SIM PIN / SIM PUK locked; nothing here ever enters a PIN +# +CME ERROR: 10 no card - or a position whose SIM power is off. Measured on our U30 Air (7.2.10, +# 2026-10-13): its second position answers exactly this at every cold boot, and +# READY, with a card identity of its own, one second after its SIM power is switched +# on. (On the unit the sequence came from it answered READY at once; the modem +# seems to power at boot the cards Android had in use.) So that answer is not +# believed before the power has been on: AT+SPACTCARD=;+SFUN=2, the live +# switch's own first command. It moves no radio, and the other card does not +# notice it (measured, with SIM1's data up). When the card still does not answer, +# the power goes off again (SFUN=3): the position is left as it was found. +# ask_card TRIES: sets card to ready, sim-pin, no-sim or sim-not-ready; a just-powered card may need a moment +card=sim-not-ready +ask_card() { + local attempt + for ((attempt=0; attempt<$1; attempt++)); do + response=$(at main$SLOT 'AT+CPIN?' | tr -d '\r') || stop modem-silent "SIM$((SLOT+1)): no answer to the card query" + if [[ "$response" == *'+CPIN: READY'* ]]; then card=ready; return 0 + elif [[ "$response" == *'+CPIN: SIM PIN'* || "$response" == *'+CPIN: SIM PUK'* ]]; then card=sim-pin; return 0 + elif [[ "$response" =~ \+CME\ ERROR:\ (10($|[^0-9])|SIM\ not\ inserted) ]]; then card=no-sim + else card=sim-not-ready; fi + sleep 1 + done +} +powered=0 +# give_up REASON TEXT: stop, with the SIM power this script switched on switched off again +give_up() { + if [[ $powered == 1 ]]; then at main$SLOT "AT+SPACTCARD=$SLOT;+SFUN=3" 10 >/dev/null 2>&1 || true; fi + stop "$@" +} +ask_card 2 +if [[ $card == no-sim || $card == sim-not-ready ]]; then + expect_ok main$SLOT "AT+SPACTCARD=$SLOT;+SFUN=2" 10 || stop modem-refused "SIM$((SLOT+1)): its SIM power could not be switched on" + powered=1 + say "SIM$((SLOT+1)): SIM power switched on" + ask_card 10 +fi +case $card in + ready) ;; + sim-pin) give_up sim-pin "SIM$((SLOT+1)) is locked by its PIN or PUK" ;; + no-sim) give_up no-sim "SIM$((SLOT+1)): no card answers in this position, with its SIM power on" ;; + *) give_up sim-not-ready "SIM$((SLOT+1)) is not ready" ;; +esac +response=$(at main$SLOT 'AT+CCID') || give_up modem-silent "SIM$((SLOT+1)): no answer to the identity query" +identity=$(printf '%s\n' "$response" | sed -n 's/^+CCID: *//p' | tr -d '\r" ') +[[ -n "$identity" && ( -z ${MU300_EXPECT_CCID:-} || "$identity" == "$MU300_EXPECT_CCID" ) ]] || + give_up wrong-card "SIM$((SLOT+1)) identity did not match the recorded card" +# The work modes (network mode per card) are the modem's own, kept: read, and written back as they are, so a mode +# the user locked on the Locks page is not replaced by this start (as kanoqwq's mu300-dual-radio does). Only when +# the modem does not say is it the pair this firmware's RIL sends, 134,134 (s_modemConfig=7: buildWorkModeCmd +# does NOT append the primary SIM argument used by mode 6). +modes=134,134 +response=$(at main0 'AT+SPTESTMODE?' | tr -d '\r') || response= +pair=$(sed -n 's/^+SPTESTMODE: *\([0-9][0-9]*\), *\([0-9][0-9]*\).*/\1,\2/p' <<< "$response" | sed -n 1p) +if [[ "$pair" =~ ^[0-9]{1,3},[0-9]{1,3}$ ]]; then modes=$pair; say "work modes kept ($modes)" +else say "work modes not readable; using $modes"; fi +# Native-RIL-derived sequence validated by cold-start registration and data traffic on this device. +# From here on the radio has been told something: a failure past this marker is not undone within this boot +# (mu300-sim2-warmup falls back to SIM1 in this boot only when nothing was sent). +: > /run/mu300/sim2-cold-start.sent +# the data route goes to the second card: the mark that makes a later SIM1 dial put it back (sim-config.sh) +[[ "$SLOT" != 1 ]] || sim_route_mark_set || stop modem-refused 'Cannot record the data route; not giving it to SIM2' +expect_ok data$SLOT "AT+SPTESTMODEM=$modes" || stop modem-refused 'The work modes were refused' +expect_ok data$SLOT 'AT+SPSWDATA' || stop modem-refused 'The data route was refused' +# Read back which card has the data route (after kanoqwq's mu300-dual-radio). Another card than the one asked for +# is a failure; a firmware that does not answer the question is not. +response=$(at main$SLOT 'AT+SPSWDATA?' | tr -d '\r') || response= +route=$(sed -n 's/^+SPSWDATA: *\([01]\) *$/\1/p' <<< "$response" | sed -n 1p) +case "$route" in + "$SLOT") say "data route read back: SIM$((SLOT+1))" ;; + 0|1) stop data-route "the data route is on SIM$((route+1)), not on SIM$((SLOT+1))" ;; + *) say 'data route read-back not available on this firmware' ;; +esac +[[ "$SLOT:$route" != 0:0 ]] || rm -f "$sim_route_mark" + if [ -x /usr/libexec/unisoc-modem/lock ]; then + ( + . /usr/libexec/unisoc-modem/sim-scope.sh + sim_scope "$SLOT" || exit 1 + [ ! -e "${UNISOC_REPLAY_MARKER:-/run/unisoc-modem-lock-replay-done}" ] || exit 0 + MU300_SIM_CONTROL=1 /usr/libexec/unisoc-modem/lock replay early + ) || logger -t mu300-sim 'Early lock replay unconfirmed; late worker remains armed' + fi +expect_ok data$SLOT 'AT+SFUN=4' 20 || stop no-radio "SIM$((SLOT+1)): the radio-on command was refused" + +for ((attempt=0; attempt<15; attempt++)); do + response=$(at main$SLOT 'AT+CFUN?') || stop no-radio "SIM$((SLOT+1)) stopped answering" + if [[ "$response" == *'+CFUN: 1'* ]]; then break; fi + sleep 1 +done +[[ "$response" == *'+CFUN: 1'* ]] || stop no-radio "SIM$((SLOT+1)) did not reach CFUN=1" +# CFUN=1 is the radio ready, for either card, exactly as the SIM1 path marks it: no service on a card does not +# invalidate its RF bring-up, and registration is netifd's to wait for and retry (a slow registration used to +# fail this gate and leave the whole boot without WAN). +: > /run/mu300/sim-radio-ready +if [[ "$SLOT" == 0 ]]; then + say 'SIM1 native RF ready; data registration belongs to netifd' + exit 0 +fi +: > /run/mu300/sim2-radio-ready +say 'SIM2 native RF ready (CFUN=1); registration and data attachment belong to netifd on sipa_eth8' +exit 0 diff --git a/rootfs/overlay/opt/mu300/bin/mu300-sim2-warmup b/rootfs/overlay/opt/mu300/bin/mu300-sim2-warmup new file mode 100644 index 00000000..5314724b --- /dev/null +++ b/rootfs/overlay/opt/mu300/bin/mu300-sim2-warmup @@ -0,0 +1,149 @@ +#!/bin/bash +# One native bring-up of the selected card per Linux boot; all modem I/O stays in persistent brokers. +# procd instance of init.d/mu300-atd's dual-SIM path. Three things, in this order: +# +# 1. The cold start (mu300-sim2-start). When the radio is up the boot is confirmed: /etc/mu300-sim-pending goes. +# 2. When the cold start cannot be done, the settings go back to SIM1 without live switching and the reason is +# kept in /etc/mu300-sim-fallback for the Dual SIM page. Then this boot is made a SIM1 boot: +# - nothing was sent to the radio yet (no card, a PIN, the channels never came up): the pin, the freeze and the +# markers go and the ordinary SIM1 warm-up runs, through the owner of nr1 that is already there; without one, +# the AT service starts over as the ordinary SIM1 service (nothing holds a channel then). +# - the radio had been told to start the other card: that is not undone in a running modem, so the device +# restarts once, into a plain SIM1 boot (the settings are SIM1's by then; it cannot repeat). +# 3. The second card's first data. A SIM2 that has never had mobile data under Linux gets a time to get it +# (network.wan.sim_data_wait, 300 s; 0: no check). With data it is remembered (/etc/mu300/sim-data-seen) and +# never checked again: an outage is not the card's failure. Without, the choice is given up as in 2 (reason +# no-data) and the device restarts into SIM1 - a card chosen from far away that turns out to have no service +# must not keep the device off the network until somebody walks up to it. Whether SIM1 has data is not asked: +# a user whose SIM1 has none is at the device and reads the reason on the page. +set -euo pipefail +export PATH="$PATH:/opt/mu300/busybox-bin" +umask 077 # the logs and markers under /run/mu300 are root's alone +DEVICE=${MU300_DEVICE_CMD:-/opt/mu300/bin/mu300-device} +[ -e /etc/openwrt_release ] && [ "$("$DEVICE" 2>/dev/null)" = u30air ] || { + echo 'Native SIM startup requires U30 Air on OpenWrt' >&2 + exit 1 +} +PENDING=/etc/mu300-sim-pending +FALLBACK=/etc/mu300-sim-fallback +CHECK=/run/mu300/sim-boot-check +MD=/opt/mu300/bin/mobile-data +ATD_INIT=${MU300_ATD_INIT:-/etc/init.d/mu300-atd} +REBOOT=${MU300_REBOOT_CMD:-reboot} +SIM_CONFIG_U30=1 +. "${MU300_SIM_CONFIG_LIB:-/opt/mu300/lib/sim-config.sh}" +# Preserve the charging-only boot's promise to leave both radios off (the pending marker stays for the real boot). +[[ ! -e /run/mu300/charging-boot ]] || exit 0 +SLOT=$(cat /run/mu300/sim-slot 2>/dev/null || echo 1) +case "$SLOT" in 0|1) ;; *) SLOT=1 ;; esac +say() { logger -t mu300-sim "$*" 2>/dev/null || true; } +# A second run in one boot is the AT service restarted by hand: the owners were closed and opened again, and the +# cold start cannot be repeated. Nothing is concluded from it and no setting is changed. +if [[ -e /run/mu300/sim2-cold-start.attempted ]]; then + : > /run/mu300/sim-active-unknown + say "the AT service was restarted in a dual-SIM boot: the radio state is unknown, reboot" + exit 1 +fi +MU300_EXPECT_CCID=$(cat /etc/mu300/sim$((SLOT+1))-iccid 2>/dev/null || true) +export MU300_EXPECT_CCID +atomic() { local t; t=$(mktemp "$1.XXXXXX") && printf '%s\n' "$2" > "$t" && mv -f "$t" "$1"; } +uptime_s() { cut -d. -f1 /proc/uptime 2>/dev/null || date +%s; } +broker_ready() { + local directory=$1 owner + [[ -p "$directory/cmd" && -s "$directory/owner/pid" ]] || return 1 + owner=$(cat "$directory/owner/pid") + [[ "$owner" =~ ^[0-9]+$ ]] && kill -0 "$owner" 2>/dev/null +} +# settings_to_sim1 REASON: SIM1 without live switching from the next boot on, the reason for the page. The pending +# marker goes only when both settings were written: left there, it makes the next boot a SIM1 boot all the same. +settings_to_sim1() { + local saved=1 + atomic "$FALLBACK" "$1" || true + sim_cfg_save_default 0 || saved=0 + sim_cfg_save_hot 0 || saved=0 + [[ $saved == 0 ]] || rm -f "$PENDING" +} +# restart_for_sim1 WHY: the one restart into a plain SIM1 boot. Not before the boot has been marked good (S99 and +# 30 s: mu300-next-boot --rearm), so that it is never counted as a failed boot; nothing dials meanwhile. +restart_for_sim1() { + : > /run/mu300/sim-active-unknown + if [[ "$(sim_cfg_auto_restart)" != 1 ]]; then + say "$1: reboot for SIM1 (network.wan.sim_restart is 0: not restarting by itself)" + exit 1 + fi + say "$1: restarting into SIM1" + while [[ -r /proc/uptime && $(uptime_s) -lt ${MU300_SIM_REBOOT_AFTER:-120} ]]; do sleep 5; done + sync 2>/dev/null || true + exec $REBOOT +} +fallback() { # fallback REASON: see 2. above + local reason=$1 + settings_to_sim1 "$reason" + say "SIM$((SLOT+1)) cold start failed ($reason): SIM1 without live switching from now on" + if [[ -e /run/mu300/sim2-cold-start.sent ]]; then + restart_for_sim1 "the radio was already told to start SIM$((SLOT+1))" + fi + # Nothing reached the radio: this boot can still be an ordinary SIM1 boot. The pinned slot becomes 0, the + # freeze and the managed marker go; sim-fallback-boot keeps init.d/mu300-atd on the SIM1 path for this boot + # whatever the settings say. + : > /run/mu300/sim-fallback-boot + atomic /run/mu300/sim-slot 0 || printf '0\n' > /run/mu300/sim-slot + rm -f /run/mu300/sim-managed /run/mu300-radio-freeze /run/mu300/sim2-radio-ready /run/mu300/sim-active-unknown + if broker_ready /run/mu300-at; then + # a data owner that died left its fifo behind: without it the dial goes through nr1 + broker_ready /run/mu300-at2 || rm -f /run/mu300-at2/cmd + say "nothing was sent to the radio: starting SIM1 in this boot" + exec "$MD" radio-on + fi + say "nothing was sent to the radio and nr1 has no owner: the AT service starts over for SIM1" + setsid "$ATD_INIT" restart /dev/null 2>&1 & + exit 1 +} +for ((attempt=0; attempt<90; attempt++)); do + ready=1 + for directory in /run/mu300-at /run/mu300-at2 /run/mu300-at4 /run/mu300-at5; do + broker_ready "$directory" || ready=0 + done + [[ $ready == 1 ]] && break + sleep 1 +done +[[ $ready == 1 ]] || fallback brokers-missing +# (the radio lock is waited for: netifd's first dial takes it for a moment at about the same time, only to find +# the radio not ready, and "busy" here would be a cold start that never ran) +if ! MU300_RADIO_LOCK_WAIT=30 "$MD" radio-locked /bin/bash /opt/mu300/bin/mu300-sim2-start --cold-start; then + reason=$(head -c 40 /run/mu300/sim2-cold-start.reason 2>/dev/null | tr -cd 'a-z0-9-') + fallback "${reason:-cold-start-failed}" +fi +rm -f "$PENDING" /run/mu300/sim-active-unknown /run/unisoc-modem-early-hook-pending + +# 3. the second card's first data +[[ "$SLOT" == 1 ]] || exit 0 +if sim_seen 1; then atomic "$CHECK" confirmed; exit 0; fi +wait=$(sim_cfg_data_wait) +if [[ "$wait" == 0 ]]; then atomic "$CHECK" off; exit 0; fi +end=$(( $(uptime_s) + wait )) +atomic "$CHECK" "waiting $end" +while :; do + if sim_wan_up sipa_eth8; then + sim_seen_add 1 || true + atomic "$CHECK" confirmed + say "SIM2 has mobile data: remembered, and not checked again" + exit 0 + fi + # the user moved on: another card now (a live switch), or SIM1 chosen for the next boot + [[ "$(cat /run/mu300/sim-slot 2>/dev/null)" == 1 && "$(sim_cfg_default 2>/dev/null)" == 1 ]] || { + atomic "$CHECK" off; exit 0; } + [[ $(uptime_s) -lt $end ]] || break + sleep 2 +done +# No verdict on a card whose data nobody was trying to bring up: taken down by hand, switched off in the settings, +# suspended by mu300-power, or in the middle of a live switch. +if sim_wan_held_down || [[ -s /run/mu300-mobile-data.suspend || -e /run/mu300/sim-switching ]] || + [[ "$(uci -q get network.$sim_wan.auto 2>/dev/null || true)" == 0 || "$(uci -q get network.$sim_wan.disabled 2>/dev/null || true)" == 1 ]]; then + atomic "$CHECK" kept + say "SIM2 has no mobile data, but the connection was off: the choice is kept" + exit 0 +fi +atomic "$CHECK" failed +settings_to_sim1 no-data +restart_for_sim1 "SIM2 got no mobile data within $wait s of being chosen" diff --git a/rootfs/overlay/opt/mu300/bin/mu300-usb b/rootfs/overlay/opt/mu300/bin/mu300-usb index ded93aa1..a7dd146d 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-usb +++ b/rootfs/overlay/opt/mu300/bin/mu300-usb @@ -6,14 +6,13 @@ # mu300-usb device back to the USB network / serial console to a computer (the default at every boot) # mu300-usb boot at boot (mu300-fixups, OpenWrt's mu300-hw): boost off. The charger runs on the battery, # so its registers outlive a reboot, and a boost left on would meet a computer's 5 V. -# There is no Type-C driver under mainline to see what is plugged in, so the role is chosen here. The 5 V come from -# the charger IC (SGM41511, bq2560x-compatible, I2C 0x6b), which has no driver either: only its OTG_CONFIG bit is -# switched, charging stays on the chip's own settings. Its watchdog puts it back to those defaults (boost off) 40 s -# after an I2C write unless it is kept alive, so host mode turns the watchdog off and device mode back on. -# The F50 has no battery: its USB port is its power supply, so it cannot be a host. +# The role is explicit; the charger driver manages charge current and disables +# its watchdog. Never re-enable that watchdog while the driver owns the chip. +# Battery-less F50/V50 boards never enter this helper's charger register path. export PATH="$PATH:/opt/mu300/bin:/usr/sbin:/sbin" R=${MU300_SYSROOT:-} # (for tests/: a fake /sys) ADDR=0x6b +FORCE= REG_CTRL1=0x01 # bit 5 OTG_CONFIG REG_TIMER=0x05 # bits 5:4 WATCHDOG (00 off, 01 40 s) REG_STATUS=0x08 # bits 7:5 VBUS_STAT (111: OTG), bit 2 PG_STAT (an outside supply on VBUS) @@ -22,9 +21,9 @@ REG_PART=0x0b die() { echo "mu300-usb: $*" >&2; exit 1; } i2c() { # i2c get|set ARGS: i2c-tools when there, else busybox's op=$1; shift - if command -v "i2c$op" >/dev/null 2>&1 && [ "$(command -v "i2c$op")" != /usr/bin/busybox ]; then "i2c$op" -y "$@" - elif [ -z "$R" ] && [ -x /opt/mu300/bin/busybox ]; then /opt/mu300/bin/busybox "i2c$op" -y "$@" - else busybox "i2c$op" -y "$@"; fi + if command -v "i2c$op" >/dev/null 2>&1 && [ "$(command -v "i2c$op")" != /usr/bin/busybox ]; then "i2c$op" -y $FORCE "$@" + elif [ -z "$R" ] && [ -x /opt/mu300/bin/busybox ]; then /opt/mu300/bin/busybox "i2c$op" -y $FORCE "$@" + else busybox "i2c$op" -y $FORCE "$@"; fi } bus() { # the I2C bus of the charger: the controller at 22a0000 on the UMS9620 for a in "$R"/sys/bus/i2c/devices/i2c-*; do @@ -32,6 +31,21 @@ bus() { # the I2C bus of the charger: the controller at 22a0000 on the UMS9620 done return 1 } +charger_address() { + # No bus scan: only the two charger addresses validated on battery boards. + # The 0x1a variant is a dummy I2C client owned by the bound 0x6b driver. + [ ! -L "$R/sys/bus/i2c/devices/$BUS-006b/driver" ] || FORCE=-f + local part + part=$(i2c get "$BUS" 0x6b $REG_PART 2>/dev/null) || part= + if [ -n "$part" ] && [ $(( (part >> 3) & 15 )) = 2 ]; then return 0; fi + part=$(i2c get "$BUS" 0x1a $REG_PART 2>/dev/null) || return 1 + [ $(( (part >> 3) & 15 )) = 0 ] || return 1 + ADDR=0x1a +} +watchdog_restore() { + # Old kernels without the charger driver retain the previous 40s policy. + [ -n "$FORCE" ] || setbits $REG_TIMER 0x30 0x10 +} role_switch() { for r in "$R"/sys/class/usb_role/*; do [ -e "$r/role" ] && { echo "$r/role"; return 0; }; done; return 1; } reg() { i2c get "$BUS" $ADDR "$1" 2>/dev/null; } setbits() { # setbits REG MASK VALUE @@ -42,9 +56,10 @@ setbits() { # setbits REG MASK VALUE if [ "${1:-}" = boot ]; then # quietly, on whatever kernel: the 5.4 one has its own charger driver and no I2C device node for this [ "$(mu300-device)" = u30air ] && BUS=$(bus) || exit 0 + charger_address || exit 0 v=$(reg $REG_CTRL1) || exit 0 if [ $(( v & 0x20 )) -ne 0 ]; then - i2c set "$BUS" $ADDR $REG_CTRL1 $(( v & ~0x20 )) && setbits $REG_TIMER 0x30 0x10 + i2c set "$BUS" $ADDR $REG_CTRL1 $(( v & ~0x20 )) && watchdog_restore echo "mu300-usb: the charger's boost was still on from before the reboot: switched off" fi exit 0 @@ -52,6 +67,7 @@ fi [ "$(mu300-device)" = u30air ] || die "only the U30 Air can be a USB host: the F50 is powered through that port" ROLE=$(role_switch) || die "no USB role switch (this needs a mainline kernel with dual-role USB, v2026.10.03 or newer)" BUS=$(bus) || die "the charger's I2C bus is not there (a kernel without I2C)" +charger_address || die "no supported charger at 0x6b or 0x1a" boost() { [ "$(id -u)" = 0 ] || { echo "(run as root to read the charger)"; return; } @@ -74,17 +90,24 @@ case ${1:-status} in host) [ "$(id -u)" = 0 ] || die "run as root (sudo mu300-usb host)" # the boost drives VBUS: never against a computer or a charger that drives it already - powered && die "something powers the USB port (a computer or a charger): unplug it first, then run this again" - setbits $REG_TIMER 0x30 0x00 # watchdog off, or the boost goes off by itself after 40 s - setbits $REG_CTRL1 0x20 0x20 # OTG boost on - echo host > "$ROLE" || die "could not switch the role" + setbits $REG_TIMER 0x30 0x00 + if powered; then + # A powered hub supplies VBUS itself. Never drive boost against it. + setbits $REG_CTRL1 0x20 0x00 + else + setbits $REG_CTRL1 0x20 0x20 + fi + if ! echo host > "$ROLE"; then + setbits $REG_CTRL1 0x20 0x00 + die "could not switch the role" + fi sleep 1 - echo "USB host: 5 V on, plug in the OTG adapter (the USB network is off until: sudo mu300-usb device)" ;; + echo "USB host: VBUS supplied by boost or the powered hub, plug in the OTG adapter (the USB network is off until: sudo mu300-usb device)" ;; device) [ "$(id -u)" = 0 ] || die "run as root (sudo mu300-usb device)" + setbits $REG_CTRL1 0x20 0x00 # boost off before attaching a computer echo device > "$ROLE" || die "could not switch the role" - setbits $REG_CTRL1 0x20 0x00 # boost off - setbits $REG_TIMER 0x30 0x10 # watchdog back (40 s): the chip returns to its own defaults + watchdog_restore sleep 1 # the role switch works in the background echo "USB device: the USB network and serial console are back" ;; *) sed -n '2,6s/^# \{0,1\}//p' "$0" >&2; exit 2 ;; diff --git a/rootfs/overlay/opt/mu300/lib/sim-config.sh b/rootfs/overlay/opt/mu300/lib/sim-config.sh new file mode 100644 index 00000000..59e48975 --- /dev/null +++ b/rootfs/overlay/opt/mu300/lib/sim-config.sh @@ -0,0 +1,156 @@ +# U30 Air native dual-SIM policy, ported from upstream 0d520f4. +# This fork stores boot intent with the shared per-SIM APN/traffic configuration. +sim_wan=$(uci -q get unisoc_modem.main.data_interface 2>/dev/null || true) +sim_wan=${sim_wan:-wan} +case "$sim_wan" in *[!a-zA-Z0-9_]*) return 1;; esac +# Shared SIM preference storage. Runtime routing uses /run/mu300/sim-slot, never this preference. +# The caller sets SIM_CONFIG_U30=1 only after positive U30 Air/OpenWrt identification. +sim_config_root=${MU300_SIM_ROOT:-} +sim_cfg_valid() { case "$1" in 0|1) return 0;; *) echo 'SIM slot must be 0 or 1' >&2; return 1;; esac; } +sim_cfg_default() { + local slot + if command -v uci >/dev/null 2>&1; then + if slot=$(uci -q get unisoc_modem.main.data_sim); then : + elif [ "${SIM_CONFIG_U30:-0}" = 1 ]; then + slot=$(cat "$sim_config_root/etc/mu300-sim-slot" 2>/dev/null || true) + fi + else + slot=$(cat "$sim_config_root/etc/mu300/sim-slot" 2>/dev/null || true) + fi + slot=${slot:-0} + sim_cfg_valid "$slot" || return 1 + printf '%s\n' "$slot" +} +sim_cfg_hot() { + local hot + [ "${SIM_CONFIG_U30:-0}" = 1 ] || { echo 0; return 0; } + if hot=$(uci -q get unisoc_modem.main.u30_sim_hot); then : + else hot=$(cat "$sim_config_root/etc/mu300-sim-hot" 2>/dev/null || true); fi + hot=${hot:-0} + case "$hot" in 0|1) printf '%s\n' "$hot";; *) echo 'Invalid SIM hot-switch policy' >&2; return 1;; esac +} +sim_cfg_write() { + local option=$1 value=$2 old present=0 + case "$option" in data_sim|u30_sim_hot) ;; *) return 1;; esac + if old=$(uci -q get "unisoc_modem.main.$option"); then present=1; fi + uci set "unisoc_modem.main.$option=$value" || return 1 + if uci commit unisoc_modem; then return 0; fi + # A failed commit must not advertise the unsaved staged value as the next-boot preference. + if [ "$present" = 1 ]; then uci set "unisoc_modem.main.$option=$old" || true + else uci -q delete "unisoc_modem.main.$option" || true; fi + return 1 +} +sim_cfg_save_default() { + local tmp + sim_cfg_valid "$1" || return 1 + if command -v uci >/dev/null 2>&1; then + sim_cfg_write data_sim "$1" + else + mkdir -p "$sim_config_root/etc/mu300" || return 1 + tmp=$(mktemp "$sim_config_root/etc/mu300/sim-slot.XXXXXX") || return 1 + printf '%s\n' "$1" > "$tmp" && mv -f "$tmp" "$sim_config_root/etc/mu300/sim-slot" + fi +} +sim_cfg_save_hot() { + sim_cfg_valid "$1" || return 1 + [ "${SIM_CONFIG_U30:-0}" = 1 ] && command -v uci >/dev/null 2>&1 || return 1 + sim_cfg_write u30_sim_hot "$1" +} +sim_cfg_unstage_added() { + local key + for key in "$@"; do + case "$key" in data_sim|u30_sim_hot) uci -q delete "unisoc_modem.main.$key" || true;; esac + done +} +sim_cfg_migrate() { + local slot hot saved_slot saved_hot slot_present=0 hot_present=0 touched= key value old destination + [ "${SIM_CONFIG_U30:-0}" = 1 ] || return 0 + command -v uci >/dev/null 2>&1 || return 1 + if saved_slot=$(uci -q get unisoc_modem.main.data_sim); then slot_present=1; fi + if saved_hot=$(uci -q get unisoc_modem.main.u30_sim_hot); then hot_present=1; fi + [ "$slot_present" = 0 ] || sim_cfg_valid "${saved_slot:-0}" || return 1 + [ "$hot_present" = 0 ] || sim_cfg_valid "${saved_hot:-0}" || return 1 + slot=$(cat "$sim_config_root/etc/mu300-sim-slot" 2>/dev/null || true) + hot=$(cat "$sim_config_root/etc/mu300-sim-hot" 2>/dev/null || true) + # Validate every legacy value before making any staged change. + [ "$slot_present" = 1 ] || [ -z "$slot" ] || sim_cfg_valid "$slot" || return 1 + [ "$hot_present" = 1 ] || [ -z "$hot" ] || sim_cfg_valid "$hot" || return 1 + if [ "$slot_present" = 0 ] && [ -n "$slot" ]; then + uci set "unisoc_modem.main.data_sim=$slot" || { sim_cfg_unstage_added $touched; return 1; } + touched="data_sim" + fi + if [ "$hot_present" = 0 ] && [ -n "$hot" ]; then + uci set "unisoc_modem.main.u30_sim_hot=$hot" || { sim_cfg_unstage_added $touched; return 1; } + touched="$touched u30_sim_hot" + fi + if [ -n "$touched" ] && ! uci commit unisoc_modem; then + sim_cfg_unstage_added $touched + return 1 + fi + for old in "$sim_config_root/etc/mu300-sim-slot" "$sim_config_root/etc/mu300-sim-hot"; do + [ -e "$old" ] || continue + mkdir -p "$sim_config_root/etc/mu300/sim-migration" || return 1 + destination=$sim_config_root/etc/mu300/sim-migration/${old##*/}.migrated + [ ! -e "$destination" ] || destination=$destination.$(date +%s).$$ + mv "$old" "$destination" || return 1 + done +} + +# --- which cards have had mobile data under Linux (U30 Air dual SIM) --- +# /etc/mu300/sim-data-seen: one stored slot number (0 or 1) per line, root's alone; it holds no identity. A card is +# written here the first time netifd has an address on its bearer. The boot check (mu300-sim2-warmup) reads it: a +# second card that has never had data and gets none within the time is given up for SIM1; one that has had data +# before is never taken away for an outage. +sim_seen_file=$sim_config_root/etc/mu300/sim-data-seen +sim_seen() { + case "$1" in 0|1) ;; *) return 1 ;; esac + grep -qx "$1" "$sim_seen_file" 2>/dev/null +} +sim_seen_add() { + local tmp + case "$1" in 0|1) ;; *) return 1 ;; esac + if sim_seen "$1"; then return 0; fi + mkdir -p "${sim_seen_file%/*}" || return 1 + tmp=$(umask 077; mktemp "$sim_seen_file.XXXXXX") || return 1 + { grep -x '[01]' "$sim_seen_file" 2>/dev/null || true; printf '%s\n' "$1"; } > "$tmp" && + mv -f "$tmp" "$sim_seen_file" || { rm -f "$tmp"; return 1; } +} +# sim_cfg_data_wait: the seconds a second card chosen for the boot has to get its first data +# (network.$sim_wan.sim_data_wait, 300 by default; 0: never give it up). Anything else is the default. +sim_cfg_data_wait() { + local wait + wait=$(uci -q get network.$sim_wan.sim_data_wait 2>/dev/null || true) + case $wait in ''|*[!0-9]*|??????*) wait=300 ;; esac + printf '%s\n' "$wait" +} +# sim_cfg_auto_restart: 1 unless network.$sim_wan.sim_restart is '0'. The dual-SIM path restarts the device by itself in +# the two cases where nothing else brings the data back: a radio left in an unknown state, and a second card that +# was given up after the radio had been told to start it. With 0 those stay as they are until somebody reboots. +sim_cfg_auto_restart() { + if [ "$(uci -q get network.$sim_wan.sim_restart 2>/dev/null || true)" = 0 ]; then echo 0; else echo 1; fi +} +# sim_wan_up BEARER: netifd has the wan up, on BEARER, with an address. Reads netifd's status; no AT command. +sim_wan_up() { + local st + st=$(ubus call network.interface.$sim_wan status 2>/dev/null | tr -d ' \n\t') || return 1 + case $st in *'"up":true'*) ;; *) return 1 ;; esac + case $st in *\"l3_device\":\"$1\"*|*\"device\":\"$1\"*) ;; *) return 1 ;; esac + case $st in *'"ipv4-address":[{'*|*'"ipv6-address":[{'*) return 0 ;; esac + return 1 +} +# sim_wan_held_down: somebody took the wan down and it stays down until somebody brings it up (ifdown, the page's +# button): netifd's "autostart" is false then. Not the marker mobile-data leaves (/run/mu300-mobile-data-down): every +# failed dial of netifd's own goes through a teardown that leaves it for a moment (measured: a boot check that +# looked in that moment took a card netifd was dialling every minute for one nobody was dialling). +sim_wan_held_down() { + local st + st=$(ubus call network.interface.$sim_wan status 2>/dev/null | tr -d ' \n\t') || return 1 + case $st in *'"autostart":false'*) return 0 ;; esac + return 1 +} +# The data route. AT+SPSWDATA tells the modem which card carries packet data, and whether the modem forgets that +# at a restart was never measured. So the dual-SIM path leaves this mark before it gives the route to the second +# card, and the SIM1 dial (mobile-data) asks the modem, puts the route back and removes the mark. Without the mark +# nothing asks and nothing is sent: a device that never used the second card sees none of it. +sim_route_mark=$sim_config_root/etc/mu300/sim-data-route-2 +sim_route_mark_set() { mkdir -p "${sim_route_mark%/*}" && : > "$sim_route_mark"; } diff --git a/tests/dashboard_sim.js b/tests/dashboard_sim.js index 78439ad0..9eee67d3 100644 --- a/tests/dashboard_sim.js +++ b/tests/dashboard_sim.js @@ -40,5 +40,45 @@ const tick=async()=>{for(let i=0;i<30;i++)await Promise.resolve();}; assert(!view.busy && !find(root,'button').busy,outcome+' left loading active'); view.unload(); } - console.log('SIM UI: success follows selected data SIM; failure/cancel stay put; scoped RPC captures slot'); + { + common.selectViewedSlot('0'); + const state={ok:1,native:true,hot:0,ready:false,saved_sim:0,actual_sim:0,data_connected:true}; + const requests=[]; + const M={injectCss(){},localizeMenu(){},translate:s=>s, + selectViewedSlot:common.selectViewedSlot, + confirmBox:()=>Promise.resolve(true),busy:(b,v)=>b.busy=v,toast:()=>({close(){}})}; + const rpc={declare:o=>(target)=>{ + if(o.method==='data_sim_get')return Promise.resolve({...state}); + if(o.method==='data_sim_set') { + requests.push(target); + if(target.startsWith('u30-hot-'))state.hot=Number(target.slice(-1)); + else if(target.startsWith('u30-default-'))state.saved_sim=Number(target.slice(-1)); + else {state.actual_sim=Number(target);state.saved_sim=Number(target);} + return Promise.resolve({ok:1,id:'abcdefghij'}); + } + return Promise.resolve({id:'abcdefghij',state:'done',ok:1}); + }}; + const view=new Function('view','rpc','poll','M','document',fs.readFileSync(dir+'/view/mu300/sim.js','utf8'))( + {extend:o=>o},rpc,{add(){},remove(){}},M,{createElement:element}); + const root=view.render([{slots:2},{...state}]); + function all(n,tag){return (n.tag===tag?[n]:[]).concat(...n.children.map(c=>all(c,tag)));} + const [switchButton,saveButton]=all(root,'button'); + const select=find(root,'select'), hot=find(root,'input'); + assert(switchButton.disabled,'cold SIM1 boot must not offer an unprepared live switch'); + assert(!select.disabled,'next-boot selection must remain available'); + select.value='1';saveButton.onclick();await tick(); + assert.deepEqual(requests,['u30-default-1']); + assert.equal(state.actual_sim,0,'saving boot preference must not change current radio'); + assert.equal(common.selectedSlot(),'0','configuration does not change viewed slot'); + hot.checked=true;hot.onchange();await tick(); + assert.equal(requests[1],'u30-hot-1'); + assert(switchButton.disabled,'enabling policy alone is not broker initialization'); + state.ready=true;await view.refresh(); + assert(!switchButton.disabled,'ready state must enable the live control without a page reload'); + select.value='1';switchButton.onclick();await tick(); + assert.equal(requests[2],'1'); + assert.equal(common.selectedSlot(),'1'); + view.unload(); + } + console.log('SIM UI: scoped RPC and native U30 boot/live controls pass'); })().catch(e=>{console.error(e);process.exitCode=1;}); diff --git a/tests/test_bootchain.py b/tests/test_bootchain.py index 814c5c83..ebf8bcb7 100644 --- a/tests/test_bootchain.py +++ b/tests/test_bootchain.py @@ -101,6 +101,12 @@ class Fixture(ShellTest): def run_bc(self, shell, *args, **env): e = dict(MU300_BY_NAME=self.by, MU300_SKIP_ROOT_CHECK=1, MU300_DROP_CACHES=self.tmp / 'no-drop-caches') e.update(env) + if (self.stubs/'dd').is_file(): + # BusyBox ash may prefer its built-in applet over PATH. Force the + # injected dd so corruption/target-audit tests actually exercise + # readback/restore rather than silently running the real applet. + return subprocess.run(shell+['-c','dd() { "$STUBLOG/stubs/dd" "$@"; }; . "$0"',str(SCRIPT)]+[str(a) for a in args], + capture_output=True,text=True,env=self.env(**e),timeout=60) return self.script(shell, SCRIPT, *args, **e) diff --git a/tests/test_data_priority.py b/tests/test_data_priority.py index aae92809..b494bea7 100644 --- a/tests/test_data_priority.py +++ b/tests/test_data_priority.py @@ -13,7 +13,7 @@ class DataPriority(ShellTest): self.pending = self.tmp / 'early-pending' self.code = self.source[self.source.index('data_priority() {'): self.source.index('\n# 取 PDP 地址')] - self.code = self.code.replace('/run/mu300-radio-on.lock', str(self.mutex)) + self.code = self.code.replace('/run/mu300-radio-on.owner', str(self.mutex)) self.code = self.code.replace('/run/mu300-data-priority-', str(self.tmp / 'priority-')) self.code = self.code.replace('/run/unisoc-modem-early-hook-pending', str(self.pending)) self.code = self.code.replace('/opt/mu300/bin/mu300-at', str(self.stubs / 'client')) @@ -177,10 +177,26 @@ esac self.assertNotIn('using /dev/null directly', r.stderr) def test_shared_build_inputs_and_no_new_startup_sleep(self): - helper = self.code[:self.code.index('\nradio_on() {')] + helper = self.code[:self.code.index('\nqueue_data_priority() {')] self.assertNotIn('sleep ', helper) self.assertNotIn('SFUN=', helper) self.assertIn('$TOP/rootfs/overlay/opt/mu300', (TOP / 'openwrt/build-rootfs.sh').read_text()) self.assertIn('cp -a /w/overlay/. $R/', (TOP / 'rootfs/assemble.sh').read_text()) for path in ('tools/build-openwrt-tf-magisk.sh', 'tools/make-release.sh'): self.assertIn('./opt/mu300/bin/mobile-data ', (TOP / path).read_text()) + + +class AtomicModemLocks(ShellTest): + def test_concurrent_stale_owner_recovery_never_enters_twice(self): + import subprocess + source=(BIN/'mobile-data').read_text() + code=source[source.index('RADIOLOCK='):source.index('radio_locked() {')] + code=code.replace('/opt/mu300/bin/busybox sleep 0.2 2>/dev/null || sleep 1','sleep 0.05') + script=self.tmp/'mobile-data-lock-fixture' + script.write_text('#!/bin/bash\nset -eu\n'+code+'\nlock_take "$TEST_LOCK" 8 || exit 91\ntrap \'lock_drop "$TEST_LOCK"\' EXIT\nmkdir "$TEST_CRITICAL" || exit 92\nsleep 0.04\nrmdir "$TEST_CRITICAL"\nlock_drop "$TEST_LOCK"\n') + lock=self.tmp/'owner';lock.symlink_to('99999999') + procs=[subprocess.Popen(['bash',str(script)],env=self.env(TEST_LOCK=lock,TEST_CRITICAL=self.tmp/'critical'),stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True) for _ in range(8)] + results=[(p.communicate(timeout=12),p.returncode) for p in procs] + self.assertTrue(all(rc==0 for _,rc in results),results) + self.assertFalse(lock.is_symlink()) + self.assertFalse((self.tmp/'critical').exists()) diff --git a/tests/test_device_scripts.py b/tests/test_device_scripts.py index ece3c518..a3220cfa 100644 --- a/tests/test_device_scripts.py +++ b/tests/test_device_scripts.py @@ -769,15 +769,14 @@ class Usb(ShellTest): self.assertEqual(self.reg('0x01'), 0x1a) self.assertEqual(self.reg('0x05'), (0x9f & ~0x30) | 0x10) - def test_refuses_while_powered(self): + def test_powered_hub_uses_external_supply_without_boost(self): for shell in self.each_shell(): self.regs(r01='0x1a', r05='0x9f', r08='0x24') # power good, a USB host drives VBUS (self.tmp / 'writes').unlink(missing_ok=True) r = self.usb(shell, 'host') - self.assertEqual(r.returncode, 1) - self.assertIn('unplug it first', r.stderr) - self.assertFalse((self.tmp / 'writes').exists()) # not a single register written - self.assertEqual(self.role(), 'device') + self.assertEqual(r.returncode, 0, r.stderr) + self.assertEqual(self.reg('0x01') & 0x20, 0) + self.assertEqual(self.role(), 'host') def test_boot_switches_a_leftover_boost_off(self): for shell in self.each_shell(): diff --git a/tests/test_platform_config.py b/tests/test_platform_config.py index a4a5d82e..128247e7 100644 --- a/tests/test_platform_config.py +++ b/tests/test_platform_config.py @@ -11,9 +11,11 @@ class PlatformConfig(ShellTest): if [ "$2" = get ]; then case "$3" in unisoc_modem.main) echo core ;; + *.u30_native_version) echo "${TEST_NATIVE_VERSION:-1}" ;; *.platform_defaults) echo "${TEST_DEFAULTS:-}" ;; esac -elif [ "$2" = batch ]; then cat > "$STUBLOG/batch"; fi +elif [ "$2" = batch ]; then cat > "$STUBLOG/batch" +elif [ "$2" = set ] || [ "$2" = commit ]; then echo "$*" >> "$STUBLOG/direct"; fi ''') def test_initial_defaults_and_same_board_preferences(self): @@ -27,13 +29,13 @@ elif [ "$2" = batch ]; then cat > "$STUBLOG/batch"; fi if changes: commands=batch.read_text() self.assertIn("platform_defaults='"+device+"'",commands) - if device=='v50':self.assertIn("sim_slots='2'",commands) + if device in ('v50','u30air'):self.assertIn("sim_slots='2'",commands) else:self.assertNotIn('sim_slots=',commands) self.assertNotIn('data_sim=',commands) def test_cross_board_restore_resets_only_adapter_configuration(self): for shell in self.each_shell(): - for device,marker,slots in [('f50','v50',1),('u30air','v50',1),('v50','f50',2),('f50','u30air',1)]: + for device,marker,slots in [('f50','v50',1),('u30air','v50',2),('v50','f50',2),('f50','u30air',1)]: batch=self.tmp/'batch';batch.unlink(missing_ok=True) r=self.script(shell,SCRIPT,TEST_DEVICE=device,TEST_DEFAULTS=marker) self.assertEqual(r.returncode,0,r.stderr) @@ -57,3 +59,14 @@ elif [ "$2" = batch ]; then cat > "$STUBLOG/batch"; fi self.assertLess(source.index('/mu300-platform-config'),source.index('procd_open_instance atd')) for file in ['tools/build-openwrt-tf-magisk.sh','tools/make-release.sh','openwrt/build-rootfs.sh']: self.assertIn('mu300-platform-config',(TOP/file).read_text()) + + def test_existing_u30_profile_gets_capability_once_without_changing_data_sim(self): + for shell in self.each_shell(): + commands=self.tmp/'direct';commands.unlink(missing_ok=True) + r=self.script(shell,SCRIPT,TEST_DEVICE='u30air',TEST_DEFAULTS='u30air',TEST_NATIVE_VERSION='0') + self.assertEqual(r.returncode,0,r.stderr) + self.assertIn('sim_slots=2',commands.read_text()) + self.assertNotIn('data_sim=',commands.read_text()) + commands.unlink() + self.assertEqual(self.script(shell,SCRIPT,TEST_DEVICE='u30air',TEST_DEFAULTS='u30air').returncode,0) + self.assertFalse(commands.exists()) diff --git a/tests/test_power_supply.py b/tests/test_power_supply.py new file mode 100644 index 00000000..93059a04 --- /dev/null +++ b/tests/test_power_supply.py @@ -0,0 +1,88 @@ +"""Battery percentage paths shared by the dashboard and power notifications.""" +from helpers import TOP, ShellTest + +LIB = TOP/'openwrt/luci-app-mu300/root/usr/libexec/unisoc-modem' + + +class PowerSupply(ShellTest): + def setUp(self): + super().setUp() + self.root = self.tmp/'supply' + self.root.mkdir() + self.extra = dict(MU300_POWER_SUPPLY_DIR=self.root, + MU300_POWER_DEVICE='u30air', + MU300_POWER_LIB=LIB/'power-supply.sh') + + def supply(self, name, **values): + path = self.root/name + path.mkdir(exist_ok=True) + for key, value in values.items(): + (path/key).write_text(str(value)+'\n') + return path + + def snapshot(self, shell, **env): + source = (LIB/'dashboard-info').read_text() + helpers = source[source.index('rd() {'):source.index('# JSON string escaping')] + power = source[source.index('POWER_LIB='):source.index('# ------------------------------------------------------- interface counters')] + code = helpers+power+'\nprintf "%s|%s|%s|%s|%s|%s" "$P_PRESENT" "$P_CAP" "$P_STATUS" "$P_V" "$P_I" "$P_USB"' + return self.sh(shell, code, **(self.extra | env)) + + def notification(self, shell, **env): + source = (LIB/'sms-forward').read_text() + number = source[source.index('number() {'):source.index('bool() {')] + power = source[source.index('power_read() {'):source.index('add_status() {')] + code = f'. "{LIB}/power-supply.sh"\n'+number+power+'\npower_read; printf "%s|%s|%s" "$power_ok" "$current_percent" "$current_status"' + return self.sh(shell, code, **(self.extra | env)) + + def test_mainline_percentage_and_charger_online_reach_both_consumers(self): + self.supply('sc27xx-fgu', type='Battery', present=1, capacity=63, + status='Charging', voltage_now=4200000, current_now=1000000) + self.supply('bq256xx-charger', type='USB', online=1) + for shell in self.each_shell(): + result = self.snapshot(shell) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout, '1|63|Charging|4.20|1000000|1') + result = self.notification(shell) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout, '1|63|Charging') + + def test_vendor_battery_is_preferred_and_zero_percent_is_valid(self): + self.supply('battery', present=1, capacity=0, status='Discharging') + self.supply('sc27xx-fgu', present=1, capacity=63, status='Charging') + self.supply('usb', online=0) + for shell in self.each_shell(): + self.assertTrue(self.snapshot(shell).stdout.startswith('1|0|Discharging|')) + self.assertEqual(self.notification(shell).stdout, '1|0|Discharging') + + def test_invalid_capacity_or_removed_battery_is_not_a_full_battery(self): + path = self.supply('sc27xx-fgu', present=1, capacity=63, status='Full') + for shell in self.each_shell(): + for value in ('575', '-1', 'garbage', ''): + (path/'capacity').write_text(value+'\n') + self.assertTrue(self.snapshot(shell).stdout.startswith('0||')) + self.assertEqual(self.notification(shell).stdout, '0|-1|none') + (path/'capacity').write_text('100\n') + (path/'present').write_text('0\n') + self.assertTrue(self.snapshot(shell).stdout.startswith('0||')) + self.assertEqual(self.notification(shell).stdout, '0|-1|none') + (path/'present').write_text('1\n') + + def test_batteryless_f50_and_v50_do_not_show_phantom_fgu_percentages(self): + self.supply('sc27xx-fgu', present=1, capacity=100, status='Full') + for shell in self.each_shell(): + for board in ('f50', 'v50'): + self.assertTrue(self.snapshot(shell, MU300_POWER_DEVICE=board).stdout.startswith('0||')) + self.assertEqual(self.notification(shell, MU300_POWER_DEVICE=board).stdout, '0|-1|none') + + def test_other_battery_name_and_optional_present_attribute(self): + self.supply('actual-cell', type='Battery', capacity=81, status='Not charging') + for shell in self.each_shell(): + self.assertTrue(self.snapshot(shell).stdout.startswith('1|81|Not charging|')) + self.assertEqual(self.notification(shell).stdout, '1|81|Not charging') + + def test_explicit_notification_override_is_respected_without_fallback(self): + path = self.supply('private-battery', type='Battery', capacity=42, status='Full') + self.supply('sc27xx-fgu', present=1, capacity=100, status='Charging') + for shell in self.each_shell(): + self.assertEqual(self.notification(shell, MU300_FORWARD_BATTERY=path).stdout, '1|42|Full') + self.assertEqual(self.notification(shell, MU300_FORWARD_BATTERY=self.tmp/'missing').stdout, '0|-1|none') diff --git a/tests/test_u30air_cold.py b/tests/test_u30air_cold.py new file mode 100644 index 00000000..cb7b2218 --- /dev/null +++ b/tests/test_u30air_cold.py @@ -0,0 +1,503 @@ +"""SIM2 boot gates with fake AT brokers; no modem devices or host /run writes. The cold start, its warm-up wrapper +(the fallback to SIM1 when it cannot be done, the first-data check of a second card) and init.d/mu300-atd's dual-SIM +path, on macOS too.""" +import os +import subprocess +import time +import unittest + +from helpers import BIN, TOP, ShellTest + + +class Sim2ColdStart(ShellTest): + def setUp(self): + super().setUp() + self.run = self.tmp / 'run' + self.etc = self.tmp / 'etc' + self.etc.mkdir() + (self.etc / 'openwrt_release').touch() + (self.run / 'mu300').mkdir(parents=True) + (self.run / 'mu300-radio-freeze').touch() + for name in ('mu300-at', 'mu300-at2', 'mu300-at4', 'mu300-at5'): + d = self.run / name + (d / 'owner').mkdir(parents=True) + (d / 'owner/pid').write_text(str(os.getpid())) + os.mkfifo(d / 'cmd') + urc = self.run / 'mu300-at/urc' + urc.mkdir() + (urc / 'stty_nr0.log').write_text('CP ready\n') + self.stub('mu300-device', 'echo "${T_DEVICE-u30air}"') + # network.wan options other than the two the selector writes: files named uci-