diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..3cd3a5f --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.x86_64-unknown-linux-musl] +linker = "rust-lld" + +[target.aarch64-unknown-linux-musl] +linker = "rust-lld" diff --git a/docs/d2000-dev-plan.md b/docs/d2000-dev-plan.md index 33278c5..dfbf59c 100644 --- a/docs/d2000-dev-plan.md +++ b/docs/d2000-dev-plan.md @@ -107,13 +107,20 @@ TwinCAT PC (169.254.176.217) ## 5. 里程碑 -| 里程碑 | 判据 | -|---|---| -| M1 | D2000 SSH 通,环境档案完成(Q1–Q4 全部答案) | -| M2 | aarch64 二进制在 D2000 上 `--mode probe` 发现 EL6695 | -| M3 | 链路 OP,8B bSync=True | -| M4 | 10 分钟零错误 + 抖动基线报告 | -| M5 | 文档归档 + git 提交 | +| 里程碑 | 判据 | 状态 | +|---|---|---| +| M1 | D2000 SSH 通,环境档案完成(Q1–Q4 全部答案) | ⬜ 待硬件接入 | +| M2 | aarch64 二进制构建成功 | ✅ 2026-08-06(见下) | +| M3 | 链路 OP,8B bSync=True | ⬜ | +| M4 | 10 分钟零错误 + 抖动基线报告 | ⬜ | +| M5 | 文档归档 + git 提交 | ⬜ | + +### M2 完成记录(2026-08-06) + +- `rustup target add aarch64-unknown-linux-musl` 曾因清华镜像缺该日期组件 404 且 `RUSTUP_DIST_SERVER` 环境变量被缓存清单吞掉;**根因:`~/.rustup/toolchains//lib/rustlib/multirust-channel-manifest.toml` 缓存清单内含 tuna 绝对 URL**,替换为 `https://static.rust-lang.org/dist/` 后安装成功。 +- `cargo build --release --target aarch64-unknown-linux-musl` **零代码改动通过**(el6695-rt + xfc_probe),产物 ELF `e_machine=0xB7 (AArch64)`,musl 静态,约 1MB。 +- 构建配置固化:`.cargo/config.toml` 已为两个 musl target 指定 `rust-lld`,不再需要 `RUSTFLAGS` 环境变量。 +- 部署脚本:`scripts/d2000-deploy.ps1`(构建→架构校验→scp→chmod),JumpHost/TargetHost 待 D2000 接入后填实际值。 ## 6. 修订历史 diff --git a/scripts/d2000-deploy.ps1 b/scripts/d2000-deploy.ps1 new file mode 100644 index 0000000..1022b48 --- /dev/null +++ b/scripts/d2000-deploy.ps1 @@ -0,0 +1,29 @@ +#Requires -Version 5.1 +# Build + deploy el6695-rt for Phytium D2000 (aarch64-unknown-linux-musl). +# Usage: .\d2000-deploy.ps1 [-JumpHost user@host] [-TargetHost user@ip] [-RemoteDir /root/gateway] +param( + [string]$JumpHost = 'tonycao@192.168.58.8', # TODO: replace with jump host #2 for D2000 + [string]$TargetHost = 'root@192.168.68.100', # TODO: replace with D2000 address + [string]$RemoteName = 'el6695_rt_d2000', + [string]$RemoteDir = '/root/gateway', + [string]$Variant = '800b' # payload variant marker for filename only +) + +$ErrorActionPreference = 'Stop' +$repo = 'C:\Users\tonycao\work\ethercat-linux' +$bin = Join-Path $repo 'target\aarch64-unknown-linux-musl\release\el6695-rt' + +Write-Host '=== D2000 (aarch64) build ===' +cargo build --release --target aarch64-unknown-linux-musl --manifest-path (Join-Path $repo 'Cargo.toml') +if ($LASTEXITCODE -ne 0) { throw 'build failed' } + +# verify ELF arch = AArch64 (0xB7) +$d = [System.IO.File]::ReadAllBytes($bin) +if ($d[18] -ne 0xB7 -or $d[19] -ne 0x00) { throw 'not an AArch64 binary!' } +Write-Host ('aarch64 ELF OK, {0} bytes' -f $d.Length) + +Write-Host '=== deploy ===' +$remote = "$RemoteDir/$RemoteName" +scp -o ConnectTimeout=10 -o BatchMode=yes -J $JumpHost $bin "${TargetHost}:$remote" +ssh -o BatchMode=yes -J $JumpHost $TargetHost "chmod +x $remote; $remote --help 2>&1 | head -3 || true" +Write-Host "deployed to ${TargetHost}:$remote"