本文基于韦东山老师配套教程MVware Ubuntu环境用于记录学习过程及遇到的一些问题实验班资料的Ubuntu的内资资料都下好了每次下载都提示文件夹已创造且不为空00 资料获取100ask myir imx6ull mini - 百问网嵌入式Linux wiki100ASK_IMX6ULL_PRO开发板 — 百问网资料下载中心 3.0 文档01 环境搭建1.VMWare安装Vmware Workstation 16 Player是免费的2.使用Ubuntu映像文件解压分区最好有 200G的空闲空间解压Ubuntu 18.04_x64任务管理器3.网卡配置NAT虚拟网卡验证能否联通外网ping news.qq.com桥接使用硬件网卡对Ubuntu要遇到问题插上USB没反应似乎是没有自动下载驱动下载驱动精灵手动安装——无果换了一个USB网卡好了另外还有可能连接到虚拟机了配置window静态IPIP地址“192.168.5.10”、子网掩码 “255.255.255.0”、默认网关“192.168.5.1”、DNS8.8.8.8设置Ubuntu的静态IP选择USB网卡VirtualNetworkEditor一般输入vmnet即可这里是一个关键点用哪个方式就要选择对应使用的网卡如果使用USB网卡则使用路由器设置Ubuntu的静态IP192.168.5.11、255.225.225.0、192.168.5.1设置开发板的静态IP通过串口对开发板操作一次性修改网卡IPifconfig eth0 192.168.5.9通过串口连接修改开发板的配置文件设置IP修改一次即可无需重复配置vi /etc/network/interfaces再在文档里添加;auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.5.9 netmask 255.255.255.0 gateway 192.168.5.1执行重启网络服务:/etc/init.d/S40network restart4.三者互ping验证windows ip192.168.5.10 ubuntu ip192.168.5.11 开发板 ip192.168.5.95.开发板上另一个网口可以用来上网开发板上另一个网口可以用来上网使用网线连接至可以上网的路由器然后在开发板终端上执行udhcpc -i eth1等待eth1网卡获得IP后就可以访问外网了。6.补充按下键盘ESC然后输入执行:wq保存并退出获取root权限su -退出root权限——ctrlDUbuntu通信异常关掉防火墙试试02安装软件1.window需要安装2.Ubuntu内确保Ubuntu能上网ping news.qq.com注意如果Ubuntu无法上网请参考手册《1.1添加NAT网卡》进行设置。如果执行该命令出现如图所示的错误可以先执行下面的命令后再重新执行前面的命令sudo apt-get update可以上网则可以执行git clone https://e.coding.net/weidongshan/DevelopmentEnvConf.git cd DevelopmentEnvConf sudo ./Configuring_ubuntu.sh下载完成提示补充可以先执行下面的命令后再重新执行前面的命令sudo apt-get update3.使用MobaXterm远程登录Ubuntu先确认Ubuntu的IP可以使用它的NAT网卡IP也可以使用它的桥接网卡IP。建议使用NAT网卡IP因为使用桥接网卡的话必须启动开发板。在Ubuntu终端执行ifconfig命令确定NAT 网卡 IP成功如此4.使用FileZilla在Windows和Ubuntu之间传文件5.使用FileZilla 上传源码并在Ubuntu编译、运行程序window上hello.c的源码如下#include stdio.h int main(int argc, char **argv) { printf(hello, world!\n); return 0; }Ubuntu上book100ask:~$ ls-l hello.c ls-l: command not found book100ask:~$ ls -l hello.c -rw-rw-r-- 1 book book 100 Dec 27 01:09 hello.c book100ask:~$ gcc -o hello hello.c book100ask:~$ ./hello hello, world!git config --global user.name 相醉为友 git config --global user.email 2796920378qq.comgit config --list5.下载BSPgit clone https://e.coding.net/codebug8/repo.git mkdir -p 100ask_imx6ull-sdk cd 100ask_imx6ull-sdk ../repo/repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify ../repo/repo init -u https://e.coding.net/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify ../repo/repo sync -j4下载失败不知为啥tar cjf Linux-4.9.88.tar.bz2 Linux-4.9.886.配置交叉编译工具如需永久修改请修改用户配置文件vim ~/.bashrc在行尾添加或修改加上下面几行export ARCHarm export CROSS_COMPILEarm-buildroot-linux-gnueabihf- export PATH$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin设置完毕后关掉窗口重新开一个arm-【Tab键】查看其是否生效arm-buildroot-linux-gnueabihf-gcc -v测试交叉编译工具链执行以下命令测试环境变量book100ask:~$ echo $ARCH arm book100ask:~$ echo $CROSS_COMPILE arm-buildroot-linux-gnueabihf-arm-buildroot-linux-gnueabihf-gcc -v这句执行命令测试工具链结果7使用Source Insight阅读Linux内核源码前面章节《2.6.2下载BSP》里下载到内核后在Ubuntu下压缩了内核把压缩文件通过FileZilla传回Windows并解压03 开发板使用1 串口打开板子电源页面备注P1062.挂载Ubuntu的NFS目录用于我们在前期进行调试时可以直接让开发板使用 ubuntu 的 nfs 目录下文件系统来进行远程调试用以提高调试效率加快研发 速度1确定ubuntu的桥接网卡IP先确认网卡IP使用 ifconfigNAT192.168.32.128桥接 192.168.5.112在开发板上执行 mount nfs 命令mount -t nfs -o nolock,vers3 192.168.5.11:/home/book/nfs_rootfs /mnt获取Root二选一即可su rootsudo -i再输入密码密码输入不显示正常现象Linux没有消息就是最好的消息3.使用FileZilla在Windows和开发板之间传文件192.168.32.1284.使用TFTP服务传输文件1在Ubuntu安装TFTP服务在 Ubuntu 中执行以下命令安装 TFTP 服务 sudo apt-get install tftp-hpa tftpd-hpa 然后创建 TFTP 服务器工作目录并打开 TFTP 服务配置文件如下: mkdir -p /home/book/tftpboot sudo chmod 777 /home/book/tftpboot sudo vim /etc/default/tftpd-hpa 在配置文件/etc/default/tftpd-hpa 中添加以下字段 TFTP_DIRECTORY/home/book/tftpboot TFTP_OPTIONS-l -c -s 最后重启 TFTP 服务: sudo service tftpd-hpa reststart 查看 tftp 服务是否在运行,运行如下命令即可查看是否在后台运行。 ps -aux | grep tftptftpd-hpa配置文件中输入wq并按下回车键保存修改并退出配置文件效果演示牛魔的这怎么和老师的 不一样。尝试检查以上无果最后发现。是标点符号输错了好了2在Windows安装TFTP服务使用配套APP即可3开发板通过tftp传输文件这时——需要确保TFTP服务已经在虚拟机上正确配置并启动TFTP_USERNAMEtftp TFTP_DIRECTORY/var/lib/tftpboot TFTP_ADDRESS:192.168.5.11 TFTP_OPTIONS--secure TFTP_DIRECTORY/home/book/tftpboot TFTP_OPTIONS-l -c -sWindows或Ubuntu传到开发板book100ask:~$ cd /home/book/tftpboot/ book100ask:~/tftpboot$ vi 1.txt book100ask:~/tftpboot$ ls 1.txt [rootimx6ull:~]# tftp -g -r 1.txt 192.168.5.11开发板传到Windows或Ubuntu[rootimx6ull:~]# vi 2.txt [rootimx6ull:~]# tftp -p -l 2.txt 192.168.5.11 book100ask:~/tftpboot$ ls 1.txt 2.txt5.开发板挂载Ubuntu的NFS目录mount -t nfs -o nolock,vers3 192.168.5.11:/home/book/nfs_rootfs /mnt在Ubuntu中编译好程序后放入/home/book/nfs_rootfs 目录开发板 mount nfs后就可以直接通过/mnt访问Ubuntu中的文件04 WSL2 替代MVware前期跟着练的时候用MV是最好有教程。后期嫌弃打开速度后我换上了WSL2但发现有很多不便……以下为记录笔记不建议特别点桥接网口需要Hyper-V该流程没实现我也很奇怪开启Hyper-Vwindows 家庭版原不支持解决方案如下以管理员身份运行 PowerShell运行下面的命令Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All后续输入Y确认重启另外还有一些GitHub开源方案可供选择。搜索Hyper-V即可手动配置虚拟交换机以管理员身份运行 PowerShell运行下面的命令PS C:\Users\27969 Get-NetAdapter Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- 以太网 2 ASIX AX88772C USB2.0 to Fast Etherne... 21 Up 00-00-12-04-76-03 100 Mbps 蓝牙网络连接 Bluetooth Device (Personal Area Netw... 11 Disconnected 00-93-37-F0-3F-6F 3 Mbps WLAN Intel(R) Wi-Fi 6 AX201 160MHz 8 Up 00-93-37-F0-3F-6B 72.2 Mbps vEthernet (Default Swi... Hyper-V Virtual Ethernet Adapter 27 Up 00-15-5D-01-1D-DC 10 Gbps vEthernet (FSE HostVnic) Hyper-V Virtual Ethernet Container A... 51 Disconnected 00-15-5D-46-1C-5D 0 bps vEthernet (FSE Switch) Hyper-V Virtual Ethernet Adapter #2 37 Disconnected D4-93-90-16-B9-38 0 bps 以太网 Realtek PCIe GbE Family Controller 4 Disconnected D4-93-90-16-B9-38 0 bps PS C:\Users\27969 Get-VMSwitch Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ Default Switch Internal FSE Switch External Realtek PCIe GbE Family Controller PS C:\Users\27969 Set-VMSwitch FSE Switch -SwitchType Internal PS C:\Users\27969 Get-VMSwitch Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ Default Switch Internal FSE Switch Internal PS C:\Users\27969 Set-VMSwitch FSE Switch -NetAdapterName 以太网 2 PS C:\Users\27969 Get-VMSwitch Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ Default Switch Internal FSE Switch External ASIX AX88772C USB2.0 to Fast Ethernet Adapter PS C:\Users\27969 ipconfig以太网 2不同网段我直接手动给它设静态 IP和开发板统一网段配置“.wslconfig”networkingModebridged vmSwitchFSE Switch dhcptrue firewallfalse autoProxyfalsewsl --shutdown我卡在了此处后续全清换镜像网络wsl: 找不到 VmSwitch“FSE Switch”。可用开关: WSL (Hyper-V firewall),Default Switch,FSE Switch (以太网),FSE Switch (WLAN),FSE Switch (Loopback Pseudo-Interface 1),WSL,FSE Switch (vEthernet (FSE Switch))往下理论流程手动设置一下静态IP手动过渡解决方案sudo ifconfig eth1 192.168.5.11 netmask 255.255.255.0 upWSL2中 添加本地路由确保网段内通信缺一不可sudo route add -net 192.168.5.0 netmask 255.255.255.0 dev eth1开发板ifconfig eth1 down ifconfig eth1 192.168.5.9 netmask 255.255.255.0 ifconfig eth1 up关闭防火墙还是不通临时关一下防火墙测试# 关闭所有网络的防火墙临时测试后续可单独开192.168.5.x网段规则 Set-NetFirewallProfile -All -Enabled False# 1. 放行 ping (ICMP) New-NetFirewallRule -DisplayName 允许Ping开发板 -Direction Inbound -Protocol ICMPv4 -RemoteAddress 192.168.5.0/24 -Action Allow -Profile Any # 2. 放行 TCP 协议 (SSH/NFS/网页都用这个) New-NetFirewallRule -DisplayName 允许192.168.5.xTCP -Direction Inbound -Protocol TCP -RemoteAddress 192.168.5.0/24 -Action Allow -Profile Any # 3. 放行 UDP 协议 New-NetFirewallRule -DisplayName 允许192.168.5.xUDP -Direction Inbound -Protocol UDP -RemoteAddress 192.168.5.0/24 -Action Allow -Profile Any偶尔错误又网卡接触不良的问题Windows 桥接网卡192.168.5.10开发板192.168.5.9WSL2192.168.5.11随机变化有以下对策1.用的时候临时调用一下ifconfig eth0 | grep inet # 输出里的inet后面就是IP比如172.25.110.54我的 Ubuntu版本24.04系统不支持rc.local 开机自启2.长期方案WSL2 里编辑开机自启脚本没有就新建sudo vim /etc/rc.local粘贴下面内容把172.25.110.54改成你现在的 WSL2 IP子网掩码不用改#!/bin/sh -e # 固定WSL2的eth0 IP ifconfig eth0 172.25.110.54 netmask 255.255.240.0 up # 添加到192.168.5.x网段的路由确保和开发板互通 route add -net 192.168.5.0 netmask 255.255.255.0 dev eth0 exit 0给脚本加执行权限确保开机自启sudo chmod x /etc/rc.local sudo systemctl enable rc-local重启 WSL2 验证wsl --shutdown后重新打开执行ifconfigIP 还是你设的固定值开发板直接 ping 这个固定 IP 就行。镜像网络挂载NFS需要Hyper-VWSL2使用镜像网络配置NFS很简单关于hyper-V开启同桥接网络开启流程windows下内容如下[wsl2] networkingModemirrored firewalltrue防火墙先全部关掉后续通了之后再配置放行——重启WSL2WSLsudo apt-get install nfs-kernel-server rpcbind很奇怪一直打不开被占用——发现是2049被windows占用因为桥接——改一下NFS的端口sudo nano /etc/nfs.conf# 重启依赖服务 sudo systemctl restart rpcbind # 重启 NFS sudo systemctl restart nfs-kernel-server # 查看状态看是不是变成 active 了 sudo systemctl status nfs-kernel-serverluoLuo1469:/mnt$ sudo exportfs -r luoLuo1469:/mnt$ sudo exportfs -v /home/luo/nfs 192.168.5.0/24(sync,wdelay,hide,no_subtree_check,secsys,rw,insecure,no_root_squash,no_all_squash) luoLuo1469:/mnt$ sudo cat /etc/exports # /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid0,crossmnt,no_subtree_check) # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) # # 格式共享目录 允许访问的网段(权限参数) /home/luo/nfs 192.168.5.0/24(rw,sync,no_subtree_check,no_root_squash,insecure) #/home/luo/nfs *(rw,sync,no_root_squash,no_subtree_check)sudo systemctl is-enabled nfs-server输出enabled开机自动启动 NFS永久生效不用你管输出 disabled 不会自启sudo systemctl enable nfs-kernel-server可开启开发板mkdir -p /mnt/nfsmount -t nfs -o nolock,port2050 192.168.5.10:/home/luo/nfs /mnt下载BSP要求repo 必须是最新的版本curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo chmod x repo sudo mv repo /usr/local/bin/ source ~/.bashrc repo --versionluoLuo1469:~/linux/6ull/100ask_imx6ull-sdk$ git config --global http.postBuffer 524288000luoLuo1469:~/linux/6ull/100ask_imx6ull-sdk$ git config --global http.lowSpeedLimit 0luoLuo1469:~/linux/6ull/100ask_imx6ull-sdk$ git config --global http.lowSpeedTime 999999WSL2 是新版 Python3.10官方删除了formatter模块git clone https://e.coding.net/codeb mkdir -p 100ask_imx6ull-sdk cd 100ask_imx6ull-sdk sed -i 20,21d ~/linux/6ull/100ask_imx6ull-sdk/.repo/repo/subcmds/help.py作用直接删除报错的那两行 formatter 导入代码这两行完全没用只是帮助文档格式化删了不影响下载代码重新执行你的初始化命令repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify # 下面备用 # repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify --repo-urlhttps://mirrors.tuna.tsinghua.edu.cn/git/git-repo成功后同步代码repo sync # 单链更稳 # repo sync -c -j1 --no-tagsTFTP 传输Ubuntu tftp环境准备sudo apt-get install tftp-hpa tftpd-hpa luoLuo1469:~$ mkdir -p /home/luo/tftp luoLuo1469:~$ sudo chmod 777 /home/luo/tftp luoLuo1469:~$ sudo vim /etc/default/tftpd-hpaTFTP_DIRECTORY/home/luo/tftp TFTP_OPTIONS-l -c -sluoLuo1469:~$ sudo service tftpd-hpa restart luoLuo1469:~$ ps -aux | grep “tftp” luo 1047 0.0 0.0 4092 2048 pts/0 S 14:19 0:00 grep --colorauto “tftp”开发板操作[root100ask:~]# tftp -g -r zImage 192.168.5.10 [root100ask:~]# ls ntp.aliyun.com zImage [root100ask:~]# vi 1.txt [root100ask:~]# # tftp -p -l 1.txt 192.168.5.10 [root100ask:~]# ls 1.txt ntp.aliyun.com zImage3 种100% 可用替代方案FileZilla适合中等文件mbU盘、SD卡适合大文件gb串口 / USB 传输开发板标配零网络适合小文件kb直接开始写代码吧以后发达了装个Linux系统到备用机或者整个服务器