iMX6 USB OTG功能開發與測試

iMX6 USB OTG功能開發與測試

 

本文轉自:http://blog.chinaunix.net/uid-9688646-id-5602722.html



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 ( [=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就沒什麼關係。

發佈了8 篇原創文章 · 獲贊 25 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章