feat(device): 新增 set-eth-dhcp.ps1,X9R 有线网默认改为 DHCP
根因:本 ROM 的以太网服务把配置存在 /system/etc/ipconfig.txt(不是常见的 /data/misc/ethernet/),该文件位于只读 /system,在安卓设置里改成 DHCP 无法保存,重启后照旧读回出厂静态记录(STATIC 10.10.1.100/24)。 - 新增 scripts/set-eth-dhcp.ps1:adb root/remount 后按 AOSP IpConfigStore v2 格式写入 DHCP 记录;写入前把原文件备份到 /data/local/tmp 与 PC,-Restore 可回滚 - README「机型注意:X9R」新增该条目,排查工具表加入该脚本 实测 W2ACWX7T44:连续重启后 IP assignment: DHCP,租约 192.168.11.101/22
This commit is contained in:
parent
56341ddc35
commit
dcbf6e3b1f
@ -343,6 +343,7 @@ adb shell "dmesg | grep -E 'USB disconnect|error -71' | tail -20"
|
||||
| **扫码枪身份** | USB HID 键盘(`Newtologic DW-8200`,VID_060E:PID_0960),挂在 `usb-1.4` → `/dev/input/event4`,供后续排查对照 |
|
||||
| **散热** | 4 核满载实测 75℃(室温环境、无散热片);7×24 使用建议加散热片/小风扇,否则会热降频 |
|
||||
| **网络** | 建议走网线(`eth0` 存在但默认无链路,先确认机器有没有 RJ45 口);WiFi 是 Broadcom SDIO,做常驻服务不稳 |
|
||||
| **有线网重启后变回静态 IP** | 出厂默认就是 `STATIC 10.10.1.100/24`。本 ROM 的以太网服务把配置存在 **`/system/etc/ipconfig.txt`**(不是常见的 `/data/misc/ethernet/`),该文件在只读 `/system` 上,**在安卓设置里改成 DHCP 不会保存**,重启照旧读回静态。改法:`powershell -ExecutionPolicy Bypass -File scripts\set-eth-dhcp.ps1`(自动备份原文件、写入 DHCP 记录、重启并核对),恢复出场值用 `-Restore` |
|
||||
|
||||
### 四、现场排查工具
|
||||
|
||||
@ -351,6 +352,7 @@ adb shell "dmesg | grep -E 'USB disconnect|error -71' | tail -20"
|
||||
| 诊断面板 | 打包页标题**3 秒内连点 5 次**(退件页为「拆包工作台」同操作):实时看按键到达 / 丢弃原因 / 门控快照 / 自愈次数,可复制与一键上报 |
|
||||
| `scripts/scan-forensics.ps1` | 故障**当场**一键取证:内核按键流 + dmesg + App 心跳 + 自动判据(内核有事件而 App `keys=0` → 上层;内核无事件 → 枪/线/供电) |
|
||||
| `scripts/power-probe.sh`、`scripts/power-load-test.sh` | 电源/负载对比实测(采样 ADC、温度、CPU 频率、扫码枪是否仍在总线) |
|
||||
| `scripts/set-eth-dhcp.ps1` | 把有线网默认改成 DHCP(重写 `/system/etc/ipconfig.txt` 后重启),带 `-Restore` 回滚;开机后网口要约 20s 才 Link Up,属正常 |
|
||||
| logcat | `adb logcat -s WMSScan`(扫码链路)、`WMSPage`(页面生命周期)、`UniConsole` / `UniViewConsole`(JS 日志) |
|
||||
|
||||
> 日志上行已做降噪(2026-09-25):本地明细全部保留(面板 + logcat + 环形缓存),**只有异常才上报服务端**(主线程卡顿、真自愈、活动突然中断),正常扫码不再产生上行记录。
|
||||
|
||||
197
scripts/set-eth-dhcp.ps1
Normal file
197
scripts/set-eth-dhcp.ps1
Normal file
@ -0,0 +1,197 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Set the default wired-ethernet IP assignment of the X9R / RK3288 tablets to DHCP.
|
||||
|
||||
.DESCRIPTION
|
||||
Why the wired network keeps coming back as STATIC after every reboot:
|
||||
|
||||
The ROM's ethernet service (android.net.IEthernetManager) does NOT use the
|
||||
usual /data/misc/ethernet/ipconfig.txt path. Its EthernetConfigStore is
|
||||
built with Environment.getRootDirectory() + "/etc/ipconfig.txt", i.e.
|
||||
|
||||
/system/etc/ipconfig.txt
|
||||
|
||||
(verified by searching the string table of
|
||||
/data/dalvik-cache/arm/system@framework@ethernet-service.jar@classes.dex)
|
||||
|
||||
That file lives on the read-only /system partition, so the Android
|
||||
Settings UI can never persist a change - it writes, the write fails and
|
||||
after the next reboot the baked-in STATIC record is read back again.
|
||||
|
||||
This script rewrites that file with a DHCP record in the AOSP IpConfigStore
|
||||
version-2 format (big-endian 2-byte length prefixed UTF-8 strings):
|
||||
|
||||
int version = 2
|
||||
utf "ipAssignment" utf "DHCP"
|
||||
utf "proxySettings" utf "NONE"
|
||||
utf "id" int 0
|
||||
utf "eos"
|
||||
|
||||
The original file is backed up on the device (/data/local/tmp/ipconfig.txt.bak)
|
||||
and on the PC before it is replaced.
|
||||
|
||||
.PARAMETER Serial
|
||||
adb device serial (e.g. SCOPAU6MNZ). Omit when exactly one device is attached.
|
||||
|
||||
.PARAMETER NoReboot
|
||||
Write the file but do not reboot (the new value only takes effect at boot).
|
||||
|
||||
.PARAMETER Restore
|
||||
Put the on-device backup back instead of writing the DHCP record.
|
||||
|
||||
.PARAMETER Static
|
||||
Skip the DHCP rewrite and only show instructions (reserved for future use).
|
||||
|
||||
.EXAMPLE
|
||||
powershell -ExecutionPolicy Bypass -File scripts\set-eth-dhcp.ps1
|
||||
|
||||
.EXAMPLE
|
||||
powershell -ExecutionPolicy Bypass -File scripts\set-eth-dhcp.ps1 -Restore
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Serial,
|
||||
[switch]$NoReboot,
|
||||
[switch]$Restore
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$CONFIG_PATH = '/system/etc/ipconfig.txt'
|
||||
$BACKUP_PATH = '/data/local/tmp/ipconfig.txt.bak'
|
||||
$LOCAL_BACKUP_DIR = Join-Path $env:TEMP 'eth-ipconfig-backup'
|
||||
|
||||
function Find-Adb {
|
||||
$candidates = @()
|
||||
if ($env:ADB) { $candidates += $env:ADB }
|
||||
$sdk = if ($env:ANDROID_HOME) { $env:ANDROID_HOME } elseif ($env:ANDROID_SDK_ROOT) { $env:ANDROID_SDK_ROOT } else { '' }
|
||||
if ($sdk) { $candidates += (Join-Path $sdk 'platform-tools\adb.exe') }
|
||||
if ($env:LOCALAPPDATA) { $candidates += (Join-Path $env:LOCALAPPDATA 'Android\Sdk\platform-tools\adb.exe') }
|
||||
$candidates += 'adb.exe'
|
||||
foreach ($c in $candidates) {
|
||||
try {
|
||||
$out = & $c version 2>$null
|
||||
if ($LASTEXITCODE -eq 0 -and ($out -join ' ') -match 'Android Debug Bridge') { return $c }
|
||||
} catch { }
|
||||
}
|
||||
throw 'adb.exe not found. Install platform-tools or pass its folder via the PATH / ANDROID_HOME environment variable.'
|
||||
}
|
||||
|
||||
function Invoke-Adb {
|
||||
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Args)
|
||||
$all = @()
|
||||
if ($Serial) { $all += @('-s', $Serial) }
|
||||
$all += $Args
|
||||
& $script:Adb @all
|
||||
if ($LASTEXITCODE -ne 0) { throw ("adb " + ($all -join ' ') + " failed with exit code $LASTEXITCODE") }
|
||||
}
|
||||
|
||||
function New-DhcpConfigBytes {
|
||||
$buf = New-Object 'System.Collections.Generic.List[byte]'
|
||||
$addInt = {
|
||||
param([int]$v)
|
||||
foreach ($shift in 24, 16, 8, 0) {
|
||||
$buf.Add([byte](($v -shr $shift) -band 0xFF))
|
||||
}
|
||||
}
|
||||
$addUtf = {
|
||||
param([string]$s)
|
||||
$b = [Text.Encoding]::UTF8.GetBytes($s)
|
||||
$buf.Add([byte](($b.Length -shr 8) -band 0xFF))
|
||||
$buf.Add([byte]($b.Length -band 0xFF))
|
||||
$buf.AddRange($b)
|
||||
}
|
||||
& $addInt 2
|
||||
& $addUtf 'ipAssignment'
|
||||
& $addUtf 'DHCP'
|
||||
& $addUtf 'proxySettings'
|
||||
& $addUtf 'NONE'
|
||||
& $addUtf 'id'
|
||||
& $addInt 0
|
||||
& $addUtf 'eos'
|
||||
return $buf.ToArray()
|
||||
}
|
||||
|
||||
$script:Adb = Find-Adb
|
||||
Write-Host "[adb] $script:Adb"
|
||||
|
||||
# Resolve the target device
|
||||
$devices = @()
|
||||
(& $script:Adb devices) | Select-Object -Skip 1 | ForEach-Object {
|
||||
if ($_ -match '^(\S+)\s+device') { $devices += $Matches[1] }
|
||||
}
|
||||
if ($devices.Count -eq 0) { throw 'No adb device connected.' }
|
||||
if (-not $Serial) {
|
||||
if ($devices.Count -gt 1) { throw ("More than one device connected (" + ($devices -join ', ') + '). Use -Serial <serial>.') }
|
||||
$Serial = $devices[0]
|
||||
}
|
||||
Write-Host "[device] $Serial"
|
||||
|
||||
if ($Restore) {
|
||||
Invoke-Adb shell "ls -l $BACKUP_PATH" | Out-Null
|
||||
Invoke-Adb root | Out-Null
|
||||
Invoke-Adb wait-for-device | Out-Null
|
||||
Invoke-Adb remount | Out-Null
|
||||
Invoke-Adb shell "cp -a $BACKUP_PATH $CONFIG_PATH" | Out-Null
|
||||
Invoke-Adb shell "sync" | Out-Null
|
||||
Write-Host "[ok] restored $CONFIG_PATH from $BACKUP_PATH"
|
||||
} else {
|
||||
Invoke-Adb root | Out-Null
|
||||
Invoke-Adb wait-for-device | Out-Null
|
||||
|
||||
# Keep a copy of the current file on the PC (never overwrite an existing one)
|
||||
New-Item -ItemType Directory -Force -Path $LOCAL_BACKUP_DIR | Out-Null
|
||||
$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
$localBackup = Join-Path $LOCAL_BACKUP_DIR ("ipconfig-$Serial-$stamp.txt")
|
||||
& $script:Adb -s $Serial pull $CONFIG_PATH $localBackup | Out-Null
|
||||
if (Test-Path $localBackup) {
|
||||
Write-Host "[backup] $localBackup ($((Get-Item $localBackup).Length) bytes)"
|
||||
} else {
|
||||
Write-Host '[backup] no existing file on device'
|
||||
}
|
||||
|
||||
# Never clobber an earlier backup - it holds the factory STATIC record.
|
||||
# The existence check runs on the host: shell operators such as "||" inside an
|
||||
# adb shell one-liner are not reliably preserved by the Windows argument handling.
|
||||
$probe = (& $script:Adb -s $Serial shell "ls $BACKUP_PATH") -join ''
|
||||
if ($probe -notmatch 'ipconfig') {
|
||||
Invoke-Adb shell "cp -a $CONFIG_PATH $BACKUP_PATH" | Out-Null
|
||||
Write-Host "[backup] $BACKUP_PATH (on device, factory default)"
|
||||
} else {
|
||||
Write-Host "[backup] $BACKUP_PATH (on device, already exists - kept)"
|
||||
}
|
||||
|
||||
Invoke-Adb remount | Out-Null
|
||||
|
||||
$tmp = Join-Path $env:TEMP 'ipconfig-dhcp.txt'
|
||||
[IO.File]::WriteAllBytes($tmp, (New-DhcpConfigBytes))
|
||||
Invoke-Adb push $tmp $CONFIG_PATH | Out-Null
|
||||
Invoke-Adb shell "chmod 644 $CONFIG_PATH" | Out-Null
|
||||
Invoke-Adb shell "chown root:root $CONFIG_PATH" | Out-Null
|
||||
Invoke-Adb shell "chcon u:object_r:system_file:s0 $CONFIG_PATH" | Out-Null
|
||||
Invoke-Adb shell "sync" | Out-Null
|
||||
Write-Host "[ok] wrote DHCP record to $CONFIG_PATH"
|
||||
}
|
||||
|
||||
if ($NoReboot) {
|
||||
Write-Host '[done] reboot skipped - run "adb reboot" or re-run without -NoReboot to apply'
|
||||
exit 0
|
||||
}
|
||||
|
||||
Invoke-Adb reboot | Out-Null
|
||||
Write-Host '[reboot] waiting for boot_completed ...'
|
||||
Invoke-Adb wait-for-device | Out-Null
|
||||
& $script:Adb -s $Serial shell 'while ! getprop sys.boot_completed | grep -q 1; do sleep 2; done; echo READY' | Out-Null
|
||||
Write-Host '[reboot] up'
|
||||
|
||||
# The PHY needs ~20 s to negotiate the link and DHCP runs right after that,
|
||||
# so poll before reporting instead of printing a half-initialised state.
|
||||
$deadline = (Get-Date).AddSeconds(90)
|
||||
do {
|
||||
Start-Sleep -Seconds 3
|
||||
$report = & $script:Adb -s $Serial shell dumpsys ethernet
|
||||
$text = $report -join "`n"
|
||||
if ($text -match 'mEthernetCurrentState: CONNECTED') { break }
|
||||
} while ((Get-Date) -lt $deadline)
|
||||
|
||||
$report | Select-String -Pattern 'Current Ethernet state', 'Link state', 'LinkAddresses', 'IP assignment' -Context 0, 1
|
||||
Loading…
x
Reference in New Issue
Block a user