博文

目前显示的是标签为“usb”的博文

Android7.1 UAS移动硬盘识别问题

在RK3399 Android7.1.2上面的USB3.0口上使用一款SONY移动硬盘,接入时识别信息如下: rk3399_box:/ # [   25.497767] usb 6-1.4: new SuperSpeed USB device number 4 using xhci-hcd [   25.512350] usb 6-1.4: New USB device found, idVendor=2537, idProduct=1068 [   25.513043] usb 6-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [   25.513732] usb 6-1.4: Product: NS1068 [   25.514119] usb 6-1.4: Manufacturer: Norelsys [   25.514189] usb 6-1.4: SerialNumber: 0123456789ABCDE [   25.527826] scsi host0: uas [   29.089929] scsi 0:0:0:0: Direct-Access     ATA      TOSHIBA MQ01ABD1 1U   PQ: 0 ANSI: 6 [   29.100317] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB) [   29.100418] sd 0:0:0:0: [sda] 4096-byte physical blocks [   29.104389] sd 0:0:0:0: [sda] Write Protect is off [   29.105420] sd 0:0:0:0: [sda] Write cache: disab...

Android4.2.2开启USB和Bluetooth Tether功能

     产品研发告一段落,对比着自己做的东西和SAMSUNG的S3,觉得缺了点什么,发现缺了Tether相关的一些功能,只有WIFI,而少了USB和BT的,故而查找了相关资料,发现在frameworks/base/core/res/res/values/config.xml相关的配置还没有添加上,直接查看Android源码里的device/samsung/tuna/overlay/frameworks/base/core/res/res/values/config.xml文件,做了相应对比后,修改该文件,添加了如下内容:       在<string-array translatable="false" name="networkAttributes">中添加:        <item>"bluetooth,7,7,1,60000,true"</item>       在<string-array translatable="false" name="radioAttributes">中添加:        <item>"7,1"</item>       在<string-array translatable="false" name="config_tether_usb_regexs">中添加:        <item>rndis\\d</item>       在<string-array translatable="false" name="config_tether_bluetooth_regexs">中添加:        <item>"bt-pan"</item>       其中第1和...

调试LTE模块碰到的4字节对齐问题

    最近在调试LTE模块,有两个模块,碰到两种4字节对齐问题,其错误提示都是类似如下的内容:        DWC_OTG: dwc_otg_hcd_urb_enqueue urb->transfer_buffer address not align to 4-byte 0xee419e8e       都是USB控制器处理的数据时需要4字节对齐要求。       第一种情况是驱动时处理GPS数据时出现上面的错误提示,处理方法如下:       将原来的:       const char startMessage[] = "$GPS_START";        const char stopMessage[] = "$GPS_STOP";       修改为:       const char startMessage[] __attribute__((aligned (4))) = "$GPS_START";        const char stopMessage[] __attribute__((aligned (4))) = "$GPS_STOP";       第二种情况是模块上网后收发数据时均提示对齐问题,这样模块根本就无法上网了,相应的处理如下:       将相应的rx_submit函数中的skb_reserve (skb, NET_IP_ALIGN);函数注释掉;       在相应的xxxx_start_xmit函数的变量定义后添加如下内容:       length = ((unsigned long)skb->data) & 0x3...

关于USB HID Report Descriptors

图片
  最近有需要调试一款USB HID设备,拿到了该款HID设备的Report Descriptors,找了一些资料学习了下,下面转发讲解清晰易懂的一篇内容(http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/):   Tutorial about USB HID Report Descriptors   A USB HID report descriptor is one of the descriptors that a USB host can request from a USB device. HID devices send data to the host using reports, and the descriptor tells the host how to interpret the data. I will try to show you how to write one of these descriptors.   First, go to this page http://www.usb.org/developers/hidpage/ and find the document titled “Device Class Definition for HID”. What I will be talking about is essentially paraphrasing the important sections of that document.   Second, go get the HID descriptor tool from the same page. You’ll want to play with it as you go through this tutorial. It is an absolute headache to write the HID report descriptors manually (converting between binary and hex and looking up the meanings of the numbers) so...

通过Netlink检测USB设备的插拔

    在Android的Vold里面可以了解到,其检测USB的插拔是通过Netlink机制来实现的,那我们也来尝试下如何在Linux下写个程序检测USB设备的插拔,下面我们将使用Netlink的NETLINK_KOBJECT_UEVENT类型套接字与Kernel进行通信,然后使用setsocketopt()来利用该套接字,再使用select()并发检测相应的套接写是否可操作,具体的代码实现 如下: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/socket.h> #include <linux/netlink.h> #define UEVENT_BUFFER_SIZE 2048 int main(void) {     struct sockaddr_nl client;     struct timeval tv;     int fd, rcvlen, ret;     fd_set fds;     int buffersize = 1024;     fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);     memset(&client, 0, sizeof(client));     client.nl_family = AF_NETLINK;     client.nl_pid = getpid();     client.nl_groups = 1; /* receive broadcast message*/     setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buffe...