AIGC标识 1、imx6ull环境配置

WSL2 + i.MX6ULL 开发环境搭建总结

技术栈

组件 说明
宿主系统 Windows 11 Home (24H2)
WSL WSL2 (Ubuntu)
开发板 100ask i.MX6ULL Pro
交叉工具链 arm-buildroot-linux-gnueabihf- (韦东山 SDK)
同步方式 rsync over SSH
文件监控 inotify-tools → rsync 自动推送
代码管理 repo (git-repo)

网络拓扑

i.MX6ULL (eth1)          Windows (以太网)           WSL2
192.168.xxx.xxx ────网线──── 192.168.xxx.1               172.17.x.x
                             │
                             ├── WLAN: 192.168.xxx.xxx
                             └── vEthernet (WSL): 172.17.xxx.xxx

WSL2 通过 Windows NAT 访问板子,SSH 直连 rsync 同步。没有用 NFS。

完整配置步骤

1. WSL2 确认

uname -r
# 应为 5.x.x-microsoft-standard-WSL2

2. 安装依赖

sudo apt update
sudo apt install inotify-tools rsync python-is-python3

3. 硬件连接

  • 板子用网线直连电脑以太网口
  • eth1 口(板子有两个网口,eth0 可能不通)
  • 检查链路:cat /sys/class/net/eth1/carrier 返回 1

4. Windows 以太网卡配置

管理员 PowerShell

netsh interface ip set address name="以太网" static 192.168.xxx.1 255.255.255.0

5. 防火墙(仅首次测试)

# 关防火墙测试
netsh advfirewall set allprofiles state off
# 测试完记得开
netsh advfirewall set allprofiles state on

6. 同步脚本

~/sync-board.sh

#!/bin/bash
WATCH_DIR="/nfs/rootfs"
BOARD_IP="192.168.xxx.xxx"
BOARD_DIR="/mnt/rootfs"

inotifywait -m -r -e modify,create,delete,move "$WATCH_DIR" --format '%w%f' |
while read file; do
    rsync -av --delete "$WATCH_DIR/" "root@$BOARD_IP:$BOARD_DIR/"
done

开机自启(~/.bashrc):

~/sync-board.sh > /dev/null 2>&1 &

7. 下载 SDK

mkdir -p ~/im6ull && cd ~/im6ull
curl -sSL 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo' -o repo
chmod +x repo
mkdir 100ask_imx6ull-sdk && cd 100ask_imx6ull-sdk
~/im6ull/repo init -u https://gitee.com/weidongshan/manifests.git \
  -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml \
  --no-repo-verify
~/im6ull/repo sync

踩坑记录

坑1:WSL1 不能跑 nfs-kernel-server

  • 问题sudo service nfs-kernel-server start → "no support in current kernel"
  • 原因:WSL1 没有内核 NFS 模块
  • 解决:换 WSL2 + rsync,不用 NFS

坑2:WSL1 转换失败

  • 问题wsl --set-version Ubuntu 1 → "WSL_E_WSL1_NOT_SUPPORTED"

  • 原因:Windows 未启用 WSL1 可选组件

  • 解决

    dism /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    

坑3:WSL2 桥接不可用

  • 问题:Windows Home 版没有 Hyper-V,WSL2 只能 NAT
  • 解决:NAT 模式下 rsync 也可用(WSL2→Windows→局域网)

坑4:Windows 和板子 IP 不在同一网段

  • 问题:Windows 以太网卡自动获取了 169.254.x.x(APIPA)
  • 原因:未配静态 IP
  • 解决:手动设为 192.168.xxx.1/24

坑5:板子 ping 不通,链路却显示 up

  • 问题carrier=1RX packets=0,互 ping 超时
  • 原因:插了 eth0 而非 eth1(板子有两个网口)
  • 解决:换到 eth1 口

坑6:repo 工具太旧不兼容 Python 3.14

  • 问题ModuleNotFoundError: No module named 'formatter'
  • 原因:Python 3.14 移除了 formatter,旧版 repo 依赖它
  • 解决:从清华镜像下载新版 repo

坑7:rsync 压缩参数报错

  • 问题rsync: This rsync lacks old-style --compress due to its external zlib
  • 原因:板子上 rsync 3.1.3 太旧,不支持新版 -z
  • 解决:去掉 -z,用 rsync -av --delete

坑8:/mnt/rootfs/ 不存在

  • 问题ls: cannot access '/mnt/rootfs/': No such file or directory
  • 解决:先 mkdir -p /mnt/rootfs

经验与心流

核心原则:先让数据过去,再管协议

配置嵌入式开发环境最容易掉进的坑:一开始就想用最优雅的方案(NFS、NFS over bridge),结果卡一晚上。正确顺序是:

  1. 先让两台机器能 ping 通 — 这是所有后续的前提。网线直连配静态 IP,防火墙全关先验证链路。
  2. 选最简单的传输方式走通 — scp 能传了再考虑自动化。不要一步到位上 NFS。
  3. 再考虑效率和自动化 — 文件能传了,再上 inotify + rsync。

网络排查心流

双向不通时按这个顺序查:

硬件连接 → 网口插对了吗 → IP 同一网段 → 防火墙 → ARP 表 → 网卡驱动

具体落地:

  • 先看灯 — 板子网口灯亮不亮
  • cat /sys/class/net/ethX/carrier — 1 表示物理层通,0 表示线/口/驱动问题
  • ifconfig 看 RX 包数 — 链路通但 RX=0,说明对面没发数据过来
  • arp -a — 看有没有学到对方 MAC,没学到说明广播不通
  • 关防火墙 — 排除干扰项(记得开回来)

选型心流

遇到问题先判断这是 Linux 的问题还是 Windows 的问题

症状 大概率根在
内核模块加载失败 WSL1(换 WSL2 或换方案)
网段/路由问题 Windows 网络栈
防火墙拦了 Windows Defender
包版本过旧 板子上的 busybox/工具链
Python 模块找不到 宿主机 Python 太新

避坑直觉

  • 不要和 Windows Home 的 Hyper-V 较劲 — 没有就是没有,换方案不换思路
  • 板子上的老旧工具(busybox、rsync、openssh)是常态 — 兼容模式而非升级模式思考
  • WSL1 vs WSL2 的核心差别:WSL1 共享 Windows 网络栈(适合直连设备),WSL2 有完整内核但 NAT 隔离(适合 Docker)
  • 嵌入式同步的黄金组合交叉编译 + rsync/ssh + inotifywait — 不用 NFS 也能达到同样体验

新手最容易忽略的事

  1. 板子有两个网口 — eth0 和 eth1 可能只有一个能用
  2. Windows 网线直连要配静态 IP — 否则自动变成 169.254.x.x
  3. /mnt/rootfs/ 默认不存在 — 板子上没有这个目录,需要先 mkdir
  4. WSL 防火墙关不关 — 要关的是 Windows 防火墙,不是 WSL 的
  5. ~/.bashrc 加后台脚本 — 注意不要重复启动(每次 source 都会 fork 一个)

日常用法

操作 命令
手动同步一次 rsync -av --delete /nfs/rootfs/ root@192.168.xxx.xxx:/mnt/rootfs/
启动自动同步 ~/sync-board.sh &
重新加载 bashrc source ~/.bashrc
板子 SSH ssh root@192.168.xxx.xxx
查看同步进程 ps aux | grep sync-board
查看同步日志 输出在终端 (stderr)
posted on 2026-07-12 00:00  三分流水  阅读(14)  评论(0)    收藏  举报