android OTG

来源:互联网 发布:宁波用友erp软件 编辑:程序博客网 时间:2024/05/11 05:30

关键词:android 4.0 USB OTG 键盘 鼠标 device  u盘

平台信息:

内核:linux3.0

系统:android4.0.3

平台:S5PV310(samsung exynos 4210)

 

把这一段时间的工作内容记录下

一、OTG的概念

OTG是On-The-Go的缩写,是近年发展起来的技术,2001年12月18日由USB Implementers Forum公布,主要应用于各种不同的设备或移动设备间的联接,进行数据交换。特别是PDA、移动电话、消费类设备。改变如数码照相机、摄像机、打印机等设备间多种不同制式连接器,多达7种制式的存储卡间数据交换的不便。

简单的说,一个OGT口可以做主设备HOST、从设备device。

二、三星平台的伪“OTG”

说到三星平台的OTG,有点坑人,看下面的电路图,芯片是支持USB OTG2.0 和USB HOST2.0的,可是不知道是他们芯片没做好,还是三星给的 BSP不全,反正OTG这个功能不能用。


芯片和软件上都不支持,我们要从硬件上解决了。加入一个IC,通过xuotgid 来判断是那主设备还是从设备,如果是主设备,如平板外接键盘、鼠标,则接USBHOST2.0;如里是从设备,如平板电脑做u盘用,接到这个坑人的USB OTG2.0


三、关于android对键盘、鼠标的支持

Linux本身就支持键盘、鼠标,linux 内核的驱动是完好的,我们只要配置好就可以了,以前的android版本我不太清楚,android4.0是支持键盘、鼠标的。

1、鼠标

device Drivers --->

              Inputdevice support --->

                            <*>Mouse interface 


2、键盘

deviceDrivers --->

              Input device support --->          

                 [*]Keyboards --->

选择AT keyboard    


3、USB中的选项

如下图所示

  Device Drivers --->

               [*] USB support --->

 <*> OHCI HCD support

[*] S5P OHCI support 

完成上面配置后,插入u盘、鼠标、键盘、u盘都可能用

如下插入u盘的信息:

[html] view plaincopy
  1. 插入U盘  
  2. [  138.620396] usb 1-1: new high speed USB device number 4 using s5p-ehci  
  3. [  138.761467] scsi2 : usb-storage 1-1:1.0  
  4. [  139.788733] scsi 2:0:0:0: Direct-Access     Netac    OnlyDisk         PMAP PQ: 0 ANSI: 0 CCS  
  5. [  139.808739] sd 2:0:0:0: Attached scsi generic sg0 type 0  
  6. [  140.228950] sd 2:0:0:0: [sda] 7831552 512-byte logical blocks: (4.00 GB/3.73 GiB)  
  7. [  140.234174] sd 2:0:0:0: [sda] Write Protect is off  
  8.                                                                                          │    
  9. 拔出  u 盘  
  10.   
  11. [  744.728526] usb 1-1: USB disconnect, device number 5  
  12. [  745.765254] FAT-fs (sda1): Directory bread(block 15304) failed  
  13. [  745.765450] FAT-fs (sda1): Directory bread(block 15305) failed  
  14. [  745.780105] FAT-fs (sda1): Directory bread(block 15306) failed  
  15. [  745.780309] FAT-fs (sda1): Directory bread(block 15307) failed  
  16. [  745.786486] FAT-fs (sda1): Directory bread(block 15308) failed  
  17. [  745.795189] FAT-fs (sda1): Directory bread(block 15309) failed  
  18. [  745.808332] FAT-fs (sda1): Directory bread(block 15310) failed  
  19. [  745.808526] FAT-fs (sda1): Directory bread(block 15311) failed  
  20. [  745.814463] FAT-fs (sda1): Directory bread(block 15304) failed  
  21. [  745.820176] FAT-fs (sda1): Directory bread(block 15305) failed  
  22. [  745.825991] FAT-fs (sda1): Directory bread(block 15306) failed  
  23. [  745.831829] FAT-fs (sda1): Directory bread(block 15307) failed  
  24. [  745.837628] FAT-fs (sda1): Directory bread(block 15308) failed  
  25. [  745.843420] FAT-fs (sda1): Directory bread(block 15309) failed  
  26. [  745.849224] FAT-fs (sda1): Directory bread(block 15310) failed  
  27. [  745.855036] FAT-fs (sda1): Directory bread(block 15311) failed  
  28.   
  29.   
  30. 这里可以看到usb的用户为system  
  31. shell@android:/mnt $ ls -l  
  32. drwxr-xr-x root     system            2000-01-01 04:15 asec  
  33. d--------- system   system            2000-01-01 04:15 ext_sd  
  34. drwxr-xr-x root     system            2000-01-01 04:15 obb  
  35. drwxrwxr-x root     sdcard_rw          2000-01-01 03:08 sdcard  
  36. drwx------ root     root              2000-01-01 04:15 secure  
  37. d---rwxr-x system   sdcard_rw          1970-01-01 00:00 usb  
0 0
原创粉丝点击