docs: 将 imeitool 注释改为中文

This commit is contained in:
2026-11-26 17:57:53 +08:00
parent c409ac3154
commit 9ca63770b6
+18 -18
View File
@@ -1,17 +1,17 @@
#!/usr/bin/perl
# imeitool - Read or write IMEI on Qualcomm MSM8916 via DIAG over RPMSG.
# imeitool - 通过 DIAG over RPMSG 在高通 MSM8916 上读取或写入 IMEI。
#
# Usage:
# imeitool read Read current modem IMEI
# imeitool save <15-digit-IMEI> Write new IMEI to modem
# 用法:
# imeitool read 读取当前基带 IMEI
# imeitool save <15位IMEI> 将新 IMEI 写入基带
#
# The IMEI is written via the DIAG protocol to baseband NV item 550.
# On this firmware (UFI003_CT), NV writes go to baseband RAM only;
# the OEM firmware blocks EFS-level persistence for NV 550.
# IMEI 通过 DIAG 协议写入基带 NV 项 550。
# 在本固件(UFI003_CT)上,NV 写入仅生效于基带 RAM;
# OEM 固件阻止了对 NV 550 的 EFS 级持久化。
#
# To make the IMEI survive reboots, save it to /etc/imei.conf and
# enable the imei-manager systemd service, which re-applies it at
# every boot before ModemManager starts.
# 若要让 IMEI 在重启后仍生效,请写入 /etc/imei.conf,
# 并启用 imei-manager 的 systemd 服务;该服务会在每次开机、
# ModemManager 启动之前重新写入 IMEI。
use strict;
use warnings;
@@ -22,7 +22,7 @@ my $RPMSG_CTRL = "/dev/rpmsg_ctrl2";
my $RPMSG_CREATE_EPT_IOCTL = 0x4028b501;
my $IMEI_CONF = "/etc/imei.conf";
# ── BCD codec ────────────────────────────────────────────────────────
# ── BCD 编解码 ───────────────────────────────────────────────────────
sub imei_to_nv550 {
my ($imei) = @_;
die "IMEI must be exactly 15 digits\n" unless $imei =~ /^\d{15}$/;
@@ -48,7 +48,7 @@ sub nv550_to_imei {
return join("", @d[0..14]);
}
# ── RPMSG DIAG channel ──────────────────────────────────────────────
# ── RPMSG DIAG 通道 ─────────────────────────────────────────────────
sub open_diag {
sysopen(my $ctrl, $RPMSG_CTRL, O_RDWR)
or die "Cannot open $RPMSG_CTRL: $!\n";
@@ -83,7 +83,7 @@ sub diag_cmd {
return undef;
}
# ── DIAG NV operations ──────────────────────────────────────────────
# ── DIAG NV 读写 ────────────────────────────────────────────────────
sub nv_read {
my ($fd, $item) = @_;
my $pkt = pack("Cv", 0x26, $item) . ("\x00" x 128) . pack("v", 0);
@@ -116,7 +116,7 @@ sub spc_unlock {
return (length($r) >= 2 && ord(substr($r, 1, 1)) == 1) ? 1 : 0;
}
# ── Write IMEI and persist config ────────────────────────────────────
# ── 写入 IMEI 并持久化配置 ──────────────────────────────────────────
sub do_save {
my ($new_imei) = @_;
@@ -143,13 +143,13 @@ sub do_save {
}
close $fd;
# Persist to config so imei-manager reapplies on every boot
# 写入配置文件,供 imei-manager 每次开机重新应用
open my $fh, ">", $IMEI_CONF or die "Cannot write $IMEI_CONF: $!\n";
print $fh "$new_imei\n";
close $fh;
printf STDERR "Saved to %s (will auto-apply on every boot)\n", $IMEI_CONF;
# Restart ModemManager so the network re-registers with the new IMEI
# 重启 ModemManager,使网络以新 IMEI 重新注册
print STDERR "Restarting ModemManager...\n";
system("systemctl restart ModemManager 2>/dev/null");
@@ -157,7 +157,7 @@ sub do_save {
print "$new_imei\n";
}
# ── main ─────────────────────────────────────────────────────────────
# ── 主入口 ───────────────────────────────────────────────────────────
my $cmd = shift @ARGV // "";
if ($cmd eq "read") {
@@ -173,7 +173,7 @@ if ($cmd eq "read") {
}
} elsif ($cmd eq "save") {
my $new_imei = shift @ARGV;
# If no argument, read from config file
# 未传参数时,从配置文件读取
if (!defined $new_imei && -f $IMEI_CONF) {
open my $fh, "<", $IMEI_CONF or die "Cannot read $IMEI_CONF: $!\n";
$new_imei = <$fh>;