RTU/mimo/plan/远程调试环境迁移指南.md

97 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# RTU 远程调试 RK3568 环境迁移指南
> 将当前 WSL 环境中的 RTU 远程调试体系迁移到另一台电脑。
---
## 零、哪些是必须的?
| 组件 | 必要性 | F5 调试用到? |
|------|--------|---------------|
| ARM 交叉工具链 `/opt/atk-dlrk356x-toolchain/` | 🔴 必须 | ✅ 编译 + GDB 连接 |
| `sshpass` (`apt install sshpass`) | 🔴 必须 | ✅ tasks.json 的 sshpass 命令 |
| RTU 项目代码 | 🔴 必须 | ✅ 编译源码 + launch.json 指向 |
| `.vscode/launch.json` `.vscode/tasks.json` | 🔴 必须 | ✅ preLaunchTask + GDB 配置 |
| **rk-mcp** | 🟢 非必须 | ❌ 仅 Copilot AI 诊断用F5 调试完全不走它 |
| `mcp.json` | 🟢 非必须 | ❌ 无 rk-mcp 则删掉此文件即可 |
| Node.js | 🟢 非必须 | ❌ 仅 rk-mcp 依赖它 |
| `~/.ssh/rk_ssh` `~/.ssh/rk_scp` | 🟢 非必须 | ❌ tasks.json 直接用 sshpass不依赖这两个脚本 |
**结论:你只需要 工具链 + sshpass + 代码 + .vscode/ 就能在新电脑上 F5 远程调试。**
---
## 一、最小安装步骤(共 4 步)
### 1. 安装 sshpass
```bash
sudo apt update && sudo apt install sshpass
```
### 2. 安装 ARM 交叉工具链
```bash
# 旧电脑上打包
cd /opt
tar czf atk-dlrk356x-toolchain.tar.gz atk-dlrk356x-toolchain/
# 传到新电脑后解压
sudo tar xzf atk-dlrk356x-toolchain.tar.gz -C /opt/
# 验证
/opt/atk-dlrk356x-toolchain/bin/aarch64-buildroot-linux-gnu-gcc --version
/opt/atk-dlrk356x-toolchain/bin/aarch64-buildroot-linux-gnu-gdb --version
```
### 3. 克隆 RTU 项目
```bash
mkdir -p ~/RTU && cd ~/RTU
git clone <RTU_REPO_URL> RTU
cd RTU
```
### 4. 验证
```bash
# 测试编译
./release/build.sh arm
# 测试 RK 连接
sshpass -p 'root' ssh -o StrictHostKeyChecking=no root@198.120.0.100 'echo OK'
# VS Code 中 F5 → "ARM 编译+部署+调试 (RK3568)"
# Ctrl+Shift+P → Run Task → "tail-rtu-output" 查看实时打印
```
---
## 二、可选:安装 rk-mcp让 Copilot 帮诊断 RK
```bash
# 1. 安装 Node.js
nvm install 20 && nvm use 20
# 2. 克隆 rk-mcp和 RTU 平级目录)
cd ~/RTU
git clone <rk-mcp_REPO_URL> rk-mcp
cd rk-mcp
npm install && npm run build
# 3. 确保 ~/RTU/RTU/.vscode/mcp.json 存在即可
```
---
## 三、硬编码路径速查
| 文件 | 关键路径 | 何时需改 |
|------|----------|----------|
| `launch.json` → miDebuggerPath | `/opt/atk-dlrk356x-toolchain/bin/...` | 工具链路径变化时 |
| `launch.json` → miDebuggerServerAddress | `198.120.0.100:2345` | RK IP 变化时 |
| `launch.json` → sourceFileMap | `/home/ypc/RTU/RTU` | 用户名变化时 |
| `tasks.json` → sshpass 命令 | `root@198.120.0.100` | RK IP 变化时 |
| `mcp.json` | `/home/ypc/RTU/...` | 用户名变化时(无 rk-mcp 可删) |
| `tasks.json` 其他 | `${workspaceFolder}` | ✅ 无需改动 |