iMX6 USB OTG功能开发与测试


USB接口上有4个管脚,OTG功能有5个。原来4个分别是电 D+ D- 地。 现在增加了一个ID。这个ID线就决定了自己做主设备还是从设备。如果ID线是高则自己是从设备,反之是主设备。

USB_OTG_ID定义为W23,即GPIO1_IO24

/test/gpio_get.sh24用来读出gpio value。读出来总是0:低电平。所以也不知道前面这句描述是对是错了。

 

imx6 kernel configas:

-> USB GadgetDrivers (<choice> [=m])

->File-backedStorage Gadget(USB_FILE_STORAGE [=m]) 。记得:不是选massstorage. 而且选模块方式,以方便安装模块时输入参数。

 

内置驱动时,测试打印:

g_file_storagegadget: controller 'fsl-usb2-udc' not recognized

g_file_storagegadget: No serial-number string provided!

g_file_storagegadget: no file given for LUN0

显然,这就是模块参数未给定导致的。

 

编译模块:

makeM=drivers/usb/gadget/ modules

得到

root@ubuntu:/home/imx6s/linux-3.0.101#make M=drivers/usb/gadget/ modules

  Building modules, stage 2.

  MODPOST 1 modules

  LD [M] drivers/usb/gadget/g_file_storage.ko

 

root@imx6s ~$insmod /lib/modules/g_file_storage.ko file=/dev/mmcblk0

g_file_storagegadget: controller 'fsl-usb2-udc' not recognized

g_file_storagegadget: No serial-number string provided!

g_file_storagegadget: File-backed Storage Gadget, version: 1 September 2010

g_file_storagegadget: Number of LUNs=1

g_file_storagegadget-lun0: ro=0, nofua=0, file: /dev/mmcblk0

Suspend udc forOTG auto detect

fsl-usb2-udc: bindto driver g_file_storage

root@imx6s ~$g_file_storage gadget: high speed config #1

 

win7也同时显示说找到设备驱动,磁盘驱动器:linux File-Stor Gadget USB Device

下面反复插拔USB-PC线几次,然后换成USB-SD卡,都是可以的。但再换回USB-PC线就不行了,找不见设备。

root@imx6s ~$g_file_storage gadget: high speed config #1

 

root@imx6s ~$g_file_storage gadget: high speed config #1

 

root@imx6s ~$

root@imx6s ~$g_file_storage gadget: high speed config #1

 

root@imx6s ~$

root@imx6s ~$ usb1-1: new high speed USB device number 2 using fsl-ehci

usb 1-1: devicev0930 p6545 is not supported

scsi0 :usb-storage 1-1:1.0

scsi 0:0:0:0:Direct-Access     TOSHIBA  TransMemory      PMAP PQ: 0 ANSI: 4

sd 0:0:0:0: [sda]30489408 512-byte logical blocks: (15.6 GB/14.5 GiB)

sd 0:0:0:0: [sda]Write Protect is off

sd 0:0:0:0: [sda]No Caching mode page found

sd 0:0:0:0: [sda]Assuming drive cache: write through

sd 0:0:0:0: [sda]No Caching mode page found

sd 0:0:0:0: [sda]Assuming drive cache: write through

 sda: sda1

sd 0:0:0:0: [sda]No Caching mode page found

sd 0:0:0:0: [sda]Assuming drive cache: write through

sd 0:0:0:0: [sda]Attached SCSI removable disk

 

root@imx6s ~$ usb1-1: USB disconnect, device number 2

wait otg vbuschange timeout!

 

root@imx6s ~$ usb1-1: new high speed USB device number 3 using fsl-ehci

usb 1-1: devicev0930 p6545 is not supported

scsi1 :usb-storage 1-1:1.0

scsi 1:0:0:0:Direct-Access     TOSHIBA TransMemory      PMAP PQ: 0 ANSI:4

sd 1:0:0:0: [sda]30489408 512-byte logical blocks: (15.6 GB/14.5 GiB)

sd 1:0:0:0: [sda]Write Protect is off

sd 1:0:0:0: [sda]No Caching mode page found

sd 1:0:0:0: [sda]Assuming drive cache: write through

sd 1:0:0:0: [sda]No Caching mode page found

sd 1:0:0:0: [sda]Assuming drive cache: write through

 sda: sda1

sd 1:0:0:0: [sda]No Caching mode page found

sd 1:0:0:0: [sda]Assuming drive cache: write through

sd 1:0:0:0: [sda]Attached SCSI removable disk

 

root@imx6s ~$

root@imx6s ~$ usb1-1: USB disconnect, device number 3

wait otgvbus change timeout!

 

root@imx6s ~$

root@imx6s ~$ usb1-1: new high speed USB device number 4 using fsl-ehci

usb 1-1: devicev0930 p6545 is not supported

scsi2 :usb-storage 1-1:1.0

scsi 2:0:0:0:Direct-Access     TOSHIBA  TransMemory      PMAP PQ: 0 ANSI: 4

sd 2:0:0:0: [sda]30489408 512-byte logical blocks: (15.6 GB/14.5 GiB)

sd 2:0:0:0: [sda]Write Protect is off

sd 2:0:0:0: [sda]No Caching mode page found

sd 2:0:0:0: [sda]Assuming drive cache: write through

sd 2:0:0:0: [sda]No Caching mode page found

sd 2:0:0:0: [sda]Assuming drive cache: write through

 sda: sda1

sd 2:0:0:0: [sda]No Caching mode page found

sd 2:0:0:0: [sda]Assuming drive cache: write through

sd 2:0:0:0: [sda]Attached SCSI removable disk

usb 1-1: USBdisconnect, device number 4

wait otg vbuschange timeout!

 

USB在host模式时,才需要对外输出电源。slave mode时,不需要输出电源,但也不影响工作。

电源管脚:

IMX_GPIO_NR(4, 15),111

/test/gpio_set.sh111 0 //关pwr      

实测不影响工作。其实,我觉得USB_ID和USB_VBUS就没什么关系。

 

 

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

草根大哥

进军大神程序员路上,谢谢支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值