首页 > 系统相关 >zynq7010,petalinux, USB-wifi测试

zynq7010,petalinux, USB-wifi测试

时间:2023-04-17 19:35:20浏览次数:79  
标签:zynq7010 USB ci interface xilinx petalinux CONFIG usb

zynq7010, 基于linux 验证 USB-wifi 功能

1. 相关电路图, 这里貌似复位键默认上电开启的, 引脚并没有印出来

需要注意的地方

  • 注意芯片型号 "USB3320", 这个在linux内核中如果USB配置正确的话是会被打印出来的
usbcore: registered new interface driver usb-storage
chipidea-usb2 e0002000.usb: e0002000.usb supply vbus not found, using dummy regulator
ULPI transceiver vendor/product ID 0x0424/0x0007
Found SMSC USB3320 ULPI transceiver.
ULPI integrity check: passed.
ci_hdrc ci_hdrc.0: doesn't support gadget
ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
  • 内核日志中凡是关于 usbcore: registered xxx 的都是开始注册了一个相关USB的驱动程序
  • 注意芯片复位引脚接法 "OTG_RESETN", 当前是接在 "PSMIO9" 的, 如果芯片没有复位
  • 需要注意 "host", "otg", "peripheral"(从设备), 设备树需要设置 dr_mode对应参数,当前使用 "otg", 即可主又可从
    image
    image
    image

2. 引脚约束了寄存器配置

  • 其它引脚约束
    image
  • 复位引脚
    image

3. 设备树

	usb_phy0: phy0@e0002000 {
		compatible = "ulpi-phy";
		#phy-cells = <0>;
		reg = <0xe0002000 0x1000>;
		view-port = <0x0170>;
		drv-vbus;
	};
&usb0 {
	status = "okay";
	dr_mode = "otg";
	usb-phy = <&usb_phy0>;
};

完整的设备树

点击查看代码
/*
 * CAUTION: This file is automatically generated by Xilinx.
 * Version: HSI 
 * Today is: Thu Dec 15 17:28:45 2022
 */
#define GPIO_ACTIVE_HIGH 0
#define GPIO_ACTIVE_LOW 1

/dts-v1/;
#include "zynq-7000.dtsi"
#include "pl.dtsi"
#include "pcw.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/input/input.h>
/ {
	model = "Alientek ZYNQ Development Board";
	chosen {
		bootargs = "console=ttyPS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait";
		stdout-path = "serial0:115200n8";
	};
   
	aliases {
		ethernet0 = &gem0;
		i2c0 = &i2c0;
		i2c1 = &i2c1;
		i2c2 = &i2c2;
		serial0 = &uart0;
		serial1 = &uart1;
		spi0 = &qspi;
	};
	memory {
		device_type = "memory";
		reg = <0x0 0x20000000>;
	};
    // led {
    //     compatible = "alientek,led";
    //     status = "okay";
    //     default-state = "on";
    //     reg = < 0xE000A040 0x4
    //             0xE000A204 0x4
    //             0xE000A208 0x4
    //             0xE000A214 0x4
    //             0xF800012C 0x4
    //         >;
    // };
	led1 {
		compatible = "test_gpio_led";
		state = "okay";
		label = "ps_led0";
		default-state = "on";
		led-gpio = <&gpio0 7 GPIO_ACTIVE_HIGH>;
	};

	key1 {
		compatible = "test_ps_key1";
		state = "okay";
		lable = "ps_key1";
		key-gpio = <&gpio0 12 GPIO_ACTIVE_LOW>;
		interrupt-parent = <&gpio0>;
		interrupts = <12 IRQ_TYPE_EDGE_BOTH>;  //上升沿和下降沿都有效
	};
	key {
		compatible = "gpio-keys";
		autorepeat; //按键支持连续按
		
		key@0 {
			label = "GPIO Key DOWN";
			linux,code = <KEY_ENTER>;
			gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
			debounce-interval = <15>;
		};
	};
	usb_phy0: phy0@e0002000 {
		compatible = "ulpi-phy";
		#phy-cells = <0>;
		reg = <0xe0002000 0x1000>;
		view-port = <0x0170>;
		drv-vbus;
	};
};
// USB HOST 接口工作
// 需要通过两个跳线帽将 P4 端子的 DN 与 HN 相连、DP 与 HP 相连(如图 55.2.1),注意先
// 连接 DN 与 HN。
// USB OTG 接口工作
// 需要通过两个跳线帽将 P4 端子的 DN 与 SN 相连、DP 与 SP 相连,注意先连接 DN 与 SN。
// 我们依次来看一下这两部分的硬件原理图。
// Documentation/devicetree/bindings/usb/generic.txt
// Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
&usb0 {
	status = "okay";
	dr_mode = "otg";
	usb-phy = <&usb_phy0>;
};

&i2c0 {								//这里引用了 i2c0 的地址 0xe0004000
	clock-frequency = <100000>; 	//i2c 通信速率 100KHz

	rtc@51 {
		compatible = "zynq-pcf8563";
		reg = <0x51>;
	};
};

&gem0 {
	local-mac-address = [00 0a 35 00 1e 53];
};

&qspi {
	#address-cells = <1>;
	#size-cells = <0>;
	flash0: flash@0 {
		compatible = "n25q512a","micron,m25p80";
		reg = <0x0>;
		#address-cells = <1>;
		#size-cells = <1>;
		spi-max-frequency = <50000000>;
		partition@0x00000000 {
			label = "boot";
			reg = <0x00000000 0x00500000>;
		};
		partition@0x00500000 {
			label = "bootenv";
			reg = <0x00500000 0x00020000>;
		};
		partition@0x00520000 {
			label = "kernel";
			reg = <0x00520000 0x00a80000>;
		};
		partition@0x00fa0000 {
			label = "spare";
			reg = <0x00fa0000 0x00000000>;
		};
	};
};

4. 内核驱动配置

官方文档 https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842272/Zynq+Linux+USB+Device+Driver

Device Drivers
USB support
    <*> ChipIdea Highspeed Dual Role Controller
    <*> ChipIdea device controller
    <*> USB Gadget Support
          <M> USB Gadget Drivers
          <M> USB functions configurable through configfs
          [*] Mass storage
  • 需要注意的点, 在选择 USB Gadget Support, 如果选择 M, 则 ChipIdea Highspeed Dual Role Controller也会编程 M, 然后 M 是编译不到内核镜像 zImage 中的. 所以开机之后, 会发现 lsusb 检测不到设备
  • 如何查看设备树是否配置正确, 在系统启动之后
    • 查看 /sys/bus/platform/devices 目录中是否存在 e0002000.phy0
    • 查看 /sys/bus/platform/drivers 目录中 是否有 ulpi-phy, 且 ulpi-phy 目录中是否存在对应的驱动 e0002000.phy0
root@ALIENTEK-ZYNQ:/sys/bus/platform/drivers# ls
Xilinx Watchdog      imx_usb              snd-soc-dummy        xilinx-cresample     xilinx_axienet
alarmtimer           leds-gpio            soc-audio            xilinx-drm           xilinx_can
armv7-pmu            macb                 sram                 xilinx-drm-dp        xilinx_emaclite
axi-i2s              msm_hsusb            synopsys-edac        xilinx-drm-dp-sub    xilinx_spi
axi-spdif            of-flash             syscon               xilinx-frmbuf        xlnx_pr_decoupler
basic-mmio-gpio      of_fixed_clk         tegra-udc            xilinx-gpio          xuartps
cdns-i2c             of_fixed_factor_clk  uio_pdrv_genirq      xilinx-pcie          zevio_usb
cdns-spi             physmap-flash        ulpi-phy             xilinx-remapper      zynq-gpio
cdns-wdt             pl35x-nand           usbmisc_imx          xilinx-rgb2yuv       zynq-ocm
chipidea-usb2        pl35x-smc            vexpress-osc         xilinx-scaler        zynq-pinctrl
ci_hdrc              pwrseq_emmc          vexpress-reset       xilinx-switch        zynq-qspi
cpuidle-zynq         pwrseq_simple        vexpress-syscfg      xilinx-tpg           zynq_fpga_manager
fpga-region          reg-dummy            vexpress-sysreg      xilinx-trafgen
gpio-clk             reg-fixed-voltage    xadc                 xilinx-vdma
gpio-keys            reset_zynq           xilinx-axipmon       xilinx-video
gpio-keys-polled     sdhci-arasan         xilinx-cfa           xilinx-vtc
root@ALIENTEK-ZYNQ:/sys/bus/platform/drivers# ls ulpi-phy/
bind           e0002000.phy0  uevent         unbind

5. 验证 USB 接口

  • 内核日志有打印
usbcore: registered new interface driver usb-storage
chipidea-usb2 e0002000.usb: e0002000.usb supply vbus not found, using dummy regulator
ULPI transceiver vendor/product ID 0x0424/0x0007
Found SMSC USB3320 ULPI transceiver.
ULPI integrity check: passed.
ci_hdrc ci_hdrc.0: doesn't support gadget
ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
  • lsusb能检测到设备
root@ALIENTEK-ZYNQ:/sys/bus/platform/devices# lsusb 
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 05e3:0608
  • 插上键盘, USB等设备有检测的打印信息
usb 1-1.4: new low-speed USB device number 3 using ci_hdrc
input: Logitech USB Optical Mouse as /devices/soc0/amba/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C077.0001/input/input1
hid-generic 0003:046D:C077.0001: input: USB HID v1.11 Mouse [Logitech USB Optical Mouse] on usb-ci_hdrc.0-1.4/input0
  • 插上鼠标键盘, 在输入监听设备当中会多出 /dev/input/event*, 然后使用 hexdump /dev/input/event*, 这个时候移动鼠标和键盘会有对应的打印信息
    这里需要配置USB鼠标键盘驱动:
Device Drivers --->
   HID support  --->
      USB HID support --->
	     <*> USB HID transport layer
  • 如果是其他的驱动,, 比如wifi, 就得自行加载对应的驱动才是

6. USB-wifi 驱动, wifi芯片 RTL8188EU

6.1 镜像驱动配置

[*] Networking support --->
  -*- Wireless --->
    <*> cfg80211 - wireless configuration API
    [*] cfg80211 wireless extensions compatibility
    <*> Generic IEEE 802.11 Networking Stack (mac80211)

Device Drivers --->
  [*] Staging drivers --->  //选中
     <M> Realtek RTL8188EU Wireless LAN NIC driver  //将 RTL8188EU 驱动编译为模块
     [*] Realtek RTL8188EU AP mode   //自动选中
  • 使用 make zImage 制作镜像
  • 使用 make modules 生成驱动文件 r8188eu.ko
  • 以下是 .config USB相关所有的配置
CONFIG_USB_NET_DRIVERS=y
CONFIG_SND_USB=y
CONFIG_USB_HID=y
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_SUPPORT=y
CONFIG_USB_COMMON=y
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB=y
CONFIG_USB_PCI=y
CONFIG_USB_DEFAULT_PERSIST=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_ROOT_HUB_TT=y
CONFIG_USB_EHCI_PCI=y
CONFIG_USB_STORAGE=y
CONFIG_USB_CHIPIDEA=y
CONFIG_USB_CHIPIDEA_OF=y
CONFIG_USB_CHIPIDEA_PCI=y
CONFIG_USB_CHIPIDEA_UDC=y
CONFIG_USB_CHIPIDEA_HOST=y
CONFIG_USB_PHY=y
CONFIG_NOP_USB_XCEIV=y
CONFIG_USB_ULPI=y
CONFIG_USB_ULPI_VIEWPORT=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
CONFIG_USB_GADGET_XILINX=y
CONFIG_USB_LIBCOMPOSITE=m
CONFIG_USB_F_SS_LB=m
CONFIG_USB_F_MASS_STORAGE=m
CONFIG_USB_CONFIGFS=m
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
CONFIG_USB_ZERO=m
CONFIG_USB_ULPI_BUS=y
  • 系统启动之后, 加载驱动文件, 然后插上 usb-wifi 模块打印信息
root@ALIENTEK-ZYNQ:~# insmod r8188eu.ko
r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
usbcore: registered new interface driver r8188eu
root@ALIENTEK-ZYNQ:~# usb 1-1.4: new high-speed USB device number 3 using ci_hdrc
Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_UNKNOWN_CUT(10)_1T1R_RomVer(0)
  • 然后使用 ifconfig -a, 能查看到多了个 wlan0 网络

6.2 wpa_supplicant 配置

  • petalinux-config -c rootfs
Filesystem Packages --->
  network --->
    wpa-supplicant --->
      [*] wpa-supplicant	//选中
  • petalinux-build -c rootfs 编译
  • sudo tar -xvf images/linux/rootfs.tar.gz -C $

6.1 RTL8188EU 固件

6.3 wireless tools 工具移植

wireless tools 工具包含:

  • iwconfig: 设置无线网络相关参数
  • iwlist: 扫描, 列出频率, 比特率, 密钥等, 获取 wifi热点
  • iwspy: 获取每个节点链接的质量
  • iwpriv: 操作 WirelessExtensions 特定驱动
  • ifrename: 基于各种静态标准命名接口

工具移植

  • 工具下载: https://hewlettpackard.github.io/wireless-tools/wireless_tools.29.tar.gz

  • 关于 gcc, ar, 以及 ranlib 工具都属于GUN编译的工具, 其中ar和 ranlib属于静态编译的工具

  • 解压后进入目录, 并修改 Makefile, 修改其中编译工具, 并使用 make 编译
    image

  • 将文件 iwlist, iwconfig, iwspy, iwpriv, ifrename 拷贝到开发板中 /usr/bin, 将 libiw.so.29 拷贝到开发板 /usr/lib
    image

  • 然后输入 iwlist 查看工具是否移植成功

root@ALIENTEK-ZYNQ:/usr/lib# iwlist 
Usage: iwlist [interface] scanning [essid NNN] [last]
              [interface] frequency 
              [interface] channel 
              [interface] bitrate 
              [interface] rate 
              [interface] encryption 
              [interface] keys 
              [interface] power 
              [interface] txpower 
              [interface] retry 
              [interface] ap 
              [interface] accesspoints 
              [interface] peers 
              [interface] event 
              [interface] auth 
              [interface] wpakeys 
              [interface] genie 
              [interface] modulation 

6.4 wifi 联网测试

  • ifconfig -a 查看是否有 wlan0
  • ifconfig wlan0 up 打开设备
  • iwlist wlan0 scan 扫描 wifi, 包含wifi的MAC,ESSID(wifi名称),频率, 速率, 信号质量等
  • 修改文件 /etc/wpa_supplicant.conf, 将需要连接的wifi名称和密码写进入, 这里对格式要求比较严格,缩进用空格,等号两边没有空格
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
network={
        ssid="icpc203"
        psk="shenhuashi0401"
}
  • wpa_supplicant -D wext -c /etc/wpa_supplicant.conf -i wlan0 & 连接
  • iwconfig wlan0 查看无线连接状态
  • ifconifg wlan0 192.168.1.100, 设置网络, 并ping下其它的ip 查看网络的连通性
root@ALIENTEK-ZYNQ:~# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"icpc203"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.412 GHz  Access Point: A4:1A:3A:64:50:6B   
          Bit Rate:150 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level=100/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
  • udhcpc -i wlan0 自动获取IP地址, 并 "ping www.baidu.com" 查看网络的连通性
root@ALIENTEK-ZYNQ:~# udhcpc -i wlan0
udhcpc (v1.24.1) started
Sending discover...
Sending select for 192.168.1.18...
Sending select for 192.168.1.18...
Lease of 192.168.1.18 obtained, lease time 172800
/etc/udhcpc.d/50default: Adding DNS 192.168.1.1

6.5 汇总, 可以编写脚本自启动

insmod r8188eu.ko
ifconfig wlan0 up
wpa_supplicant -D wext -c /etc/wpa_supplicant.conf -i wlan0 &
udhcpc -i wlan0
ping www.baidu.com

标签:zynq7010,USB,ci,interface,xilinx,petalinux,CONFIG,usb
From: https://www.cnblogs.com/han-guang-xue/p/17325526.html

相关文章

  • win7怎么usb启动
    有些用户在重装系统时喜欢用u盘来操作,但有些用户却不知道win7系统该怎么用USB启动,这里就给大家简单介绍一下具体的操作方法,希望对您有所帮助。win7怎么usb启动1、首先将U盘插入,开机的时候按住“DEL”按键,进入BIOS启动项设置页面。2、然后在界面中选择“AdvancedBIOSFeatures......
  • 汉源高科VGA光端机+1路立体声音频+USB鼠标键盘控制光纤延长器
    汉源高科VGA光端机+1路立体声音频+USB鼠标键盘控制光纤延长器......
  • 汉源高科高清DVI音视频光端机+USB键盘鼠标KVM控制dvi光纤收发器延长器
    汉源高科高清DVI音视频光端机+USB键盘鼠标KVM控制dvi光纤收发器延长器......
  • usb3.0能插到2.0口用
    usb3.0能插到2.0口用吗的,不过就算插到2.0的口上的话也是只有2.0的传输速率,并不能拥有更快的传输速率,3.0是可以和2.0互相插拔的,还是很方便的。usb3.0能插到2.0口用:答:可以的usb3.0能插到2.0口的,不过速率是一样的,并不会做出改变。我们将3.0插到2.0上的话只有2.0的传输速率。usb......
  • usb3.0u盘写入速度多少正常
    usb3.0u盘写入速度达到320mb/s基本上可以算是一个正常的水平读的速度大概为500MB/s,usb3.0相比2.0提升的非常巨大,极大的提高了带宽,而且更好的实现了电源管理。usb3.0u盘写入速度多少正常:答:320MB/s才算正常一般来说usb3.0u盘写入速度达到320Mb/s,才算正常。相较于2.0,3.0提升的空......
  • Android App状态栏变色:ColorfulStatusBar
    适用于版本大于等于19以上。importandroid.annotation.TargetApi;importandroid.app.Activity;importandroid.content.Context;importandroid.graphics.Color;importandroid.os.Build;importandroid.view.View;importandroid.view.ViewGroup;......
  • ESXI | 6.7-7.0如何强制直通板载USB芯片组
    原文链接:https://www.zccie.com/cloud/vmware/2558/本文目录 [隐藏]一、第一步我们记录下这个设备的供应商ID、设备ID以及类ID二、开启ESXI的SSH功能三、查询确认ID,这一步不是必须的,只是验证一下四、添加直通代码我这里以我们的allinone主板为例,我们主板,查找USB设备......
  • windows 11 联想thinkpad T480S 蓝牙突然没了 设置管理中多了请求usb设备描述符失败代
    选中usb设备描述符失败代码43比如下面的,因为已经好了,所以没有截图了卸载它针对usb设备描述符失败代码这个去选中,以下只是示例重新扫描就有了......
  • Qt for Android QtQuick应用程序 USB连接手机调试运行错误:adb: failed to *.apk: No s
    1.场景Windows11、Qt6.5.0QtQuick应用程序USB连接手机调试运行。2.错误信息adb:failedto*.apk:NosuchfileordirectoryInstallingtodevicefailed!进程"C:\Users\Administrator\Qt\6.5.0\mingw_64\bin\androiddeployqt.exe"退出,退出代码16。安装应用失败,发生未知错......
  • 不同操作环境下,如何制作多重引导USB?
    导读你想不想制作一个多重引导USB?你想在用来安装或者恢复其他系统的USB驱动器上有多个操作系统吗?你想从USB驱动器引导并使用多个操作系统吗?本文都能满足你的要求。不妨看一看这两种实现方法。你想不想制作一个多重引导USB?你想在用来安装或者恢复其他系统的USB驱动器......