【Zynq】PetaLinux 2019.2使用USB口虚拟化网口
这里记录一下 Zynq7020 使用 USB 口作为从机,在 PC 上虚拟一个网口。
参考Zynq Linux USB Device Driver
参考Zynq-7000 AP SoC USB Mass Storage Device Class Design Example Techtip
PetaLinux 设置
确保在 Vivado 中使能了 USB PHY 并配置正确
内核配置
1
petalinux-config -c kernel
1
2
3
4
5
6
7
8Device Drivers --->
[*] USB support --->
<*> ChipIdea Highspeed Dual Role Controller
[*] ChipIdea device controller
<*> USB Gadget Support --->
<M> USB Gadget Drivers(这个我没找到)
<*> USB Gadget functions configurable through configfs
[*] RNDIS设备树配置
1
vim project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19/ {
usb_0: usb@e0002000 {
compatible = "xlnx,zynq-usb-2.20.a", "chipidea,usb2";
clocks = <&clkc 28>;
dr_mode = "peripheral";
interrupt-parent = <&intc>;
interrupts = <0 21 4>;
reg = <0xe0002000 0x1000>;
usb-phy = <&usb_phy0>;
};
usb_phy0: phy0 {
compatible = "ulpi-phy";
reg = <0xe0002000 0x1000>;
view-port = <0x170>;
drv-vbus;
};
};设备树配置
1
vim ./components/plnx_workspace/device-tree/device-tree/system-top.dts
1
rootfs配置(启用 lsusb 命令行工具)
1
petalinux-config -c rootfs
1
2
3
4
5
6
7
8
9Filesystem Packages --->
base --->
usbutils --->
[*] usbutils
libs --->
libusb-compat --->
[*] libusb-compat
libusb1 --->
[*] libusb1编译
1
petalinux-build
启动系统
1
2
3
4
5# 预构建镜像
petalinux-package --prebuilt --force
# 通过JTAG启动到U-BOOT
petalinux-boot --jtag --prebuilt 3将内核模块上传到板卡
1
2
3
4
5# 安装传输明文密码的插件
# sudo apt install -y sshpass
# 查找 .ko 文件并发送
find ./build/tmp/work/plnx_zynq7-xilinx-linux-gnueabi/linux-xlnx/4.19-xilinx-v2019.2+git999-r0/linux-xlnx-4.19-xilinx-v2019.2+git999/drivers/usb/ -name '*.ko' -type f -print -exec scp {} root@192.168.2.32:~/ \;查看模块加载情况
编译未加载的内核模块存放在
/lib/modules/
目录下1
2
3
4
5ls /sys/kernel/config/usb_gadget
lsmod
【Zynq】PetaLinux 2019.2使用USB口虚拟化网口