USB Host 配置
USB Host Contoller 配置
配置好 USB Host Contoller ,ArtinChip 在 1 个 USB Host 端口中提供了 2 类 Host
Contoller,在软件上需要需要分开配置:
- 针对 USB 2.0 (High Speed) 的 EHCI 控制器
-
在 Menuconfig 中配置设备。使能 USB 端口,并且配置当前 USB 端口为 Host 模式:
> Board options [*] Using Usb0 Select Usb0 mode (Host) --->
-
在 Menuconfig 中配置 CherryUSB 驱动。使能 CherryUSB 驱动,并且使能 Host 模式:
> Local packages options > Third-party packages options [*] CherryUSB: tiny and portable USB host/device stack for embedded system with USB IP ---> [*] Enable usb host mode --->
-
-
针对 USB 1.0/1.1 (Low/Full Speed) 的 OHCI 控制器
USB Interface 驱动配置
完成 USB Host Contoller 配置后,就能够正确识别插入 USB 总线的 Device 设备了。
但是 USB Device 有很多不同类型 (例如:U 盘、键盘鼠标、无线网卡 …) ,这些功能都是在 USB Device 中以 Interface
为单位提供的。所以要使用 USB Device 的具体功能,还需要配置不同类型 USB Interface 的驱动。
- U 盘 配置
-
在 Menuconfig 中使能 CherryUSB 中 msc 类型的 Host Class 驱动,并且使能对应实例模板:
> Local packages options > Third-party packages options [*] CherryUSB: tiny and portable USB host/device stack for embedded system with USB IP ---> [*] Enable usb host mode ---> [*] Enable usb msc driver ---> [*] Use msc template
-
插入 U 盘,会自动挂载到
/disk
目录:[I/USB] New high-speed device on Hub 1, Port 1 connected [I/USB] New device found,idVendor:30de,idProduct:6544,bcdDevice:0100 [I/USB] The device has 1 interfaces [I/USB] Enumeration success, start loading class driver [I/USB] Loading msc class driver [I/USB] Get max LUN:1 [I/USB] Ep=81 Attr=02 Mps=512 Interval=255 Mult=00 [I/USB] Ep=02 Attr=02 Mps=512 Interval=255 Mult=00 [I/USB] Capacity info: [I/USB] Block num:30274560,block size:512 [I/USB] Register MSC Class:/dev/sda found part[0], begin: 32256, size: 14.446GB [I] udisk_init()122 Found partition 0: type = 11, offet=0x3f, size=0x1cdf2a1 01-01 08:00:06 I/NO_TAG: try to mount file system!
-
- USB 键盘/鼠标 配置
-
U 盘是 USB 1.0/1.1 设备,所以首先得配置好上节中的 OHCI,再进行下面的配置。
-
在 Linux Kernel Kconfig 中使能对 USB HID 类型的 USB Interface 驱动的支持。
> Device Drivers > HID support > USB HID support <*> USB HID transport layer
-
插入键盘鼠标,可以通过
/dev/input/event
文件读取到键盘鼠标上报的数据:[aic@] # [ 14.210983] usb 2-1: new low-speed USB device number 2 using aic-ohci [ 14.478006] random: fast init done [ 14.497013] input: PixArt Dell MS116 USB Optical Mouse as /devices/platform/soc/10220400.usb/usb2/2-1/2-1:1.0/0003:413C:301A.0001/input/input2 [ 14.510871] hid-generic 0003:413C:301A.0001: input: USB HID v1.11 Mouse [PixArt Dell MS116 USB Optical Mouse] on usb-10220400.usb-1/input0 [aic@] # hexdump /dev/input/event2 0000000 e138 5e0b 4c30 0004 0004 0004 0001 0009 0000010 e138 5e0b 4c30 0004 0001 0110 0001 0000 0000020 e138 5e0b 4c30 0004 0000 0000 0000 0000 0000030 e138 5e0b d657 0007 0004 0004 0001 0009 0000040 e138 5e0b d657 0007 0001 0110 0000 0000 0000050 e138 5e0b d657 0007 0000 0000 0000 0000 0000060 e139 5e0b 9085 0003 0004 0004 0001 0009 0000070 e139 5e0b 9085 0003 0001 0110 0001 0000 0000080 e139 5e0b 9085 0003 0000 0000 0000 0000 0000090 e139 5e0b a3bc 0005 0004 0004 0001 0009 00000a0 e139 5e0b a3bc 0005 0001 0110 0000 0000 00000b0 e139 5e0b a3bc 0005 0000 0000 0000 0000
-