• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : 求教:android 下USB设备驱动的问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
楼主  发表于: 2012-10-08 16:55

 求教:android 下USB设备驱动的问题

哦是菜鸟啊,求大神指教

我要做一个android下的usb驱动,驱动一个usb读卡器
内核驱动在百度上COPY的,驱动名称为stigreader,编译什么的也都没出错,

在windows下用adb shell连接到开发板,cat /proc/kmsg,将设备插到开发板上,显示下面的信息
<7>hub 1-1:1.0: state 7 ports 4 chg 0000 evt 0008
<7>hub 1-1:1.0: port 3, status 0301, change 0001, 1.5 Mb/s
<7>hub 1-1:1.0: debounce: port 3: total 100ms stable 100ms status 0x301
<6>usb 1-1.3: new low speed USB device using s3c2410-ohci and address 10
<7>usb 1-1.3: default language 0x0409
<7>usb 1-1.3: udev 10, busnum 1, minor = 9
<6>usb 1-1.3: New USB device found, idVendor=10c4, idProduct=11c4
<6>usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
<6>usb 1-1.3: Product: Reader 134.2K
<6>usb 1-1.3: Manufacturer: STIG INC.
<7>usb 1-1.3: usb_probe_device
<7>usb 1-1.3: configuration #1 chosen from 1 choice
<7>usb 1-1.3: adding 1-1.3:1.0 (config #1, interface 0)
<7>usbserial_generic 1-1.3:1.0: usb_probe_interface
<7>usbserial_generic 1-1.3:1.0: usb_probe_interface - got id
<7>STIG Reader USB Device For Android 1-1.3:1.0: usb_probe_interface
<7>STIG Reader USB Device For Android 1-1.3:1.0: usb_probe_interface - got id
<1>stigreader_probe::probe a usb device
<7>STIG Reader USB Device For Android 1-1.3:1.0: looking for a minor, starting a
t 192
<1>stigreader usb device register ok.
<7>drivers/usb/core/inode.c: creating file '010'
<7>hub 1-1:1.0: state 7 ports 4 chg 0000 evt 0008

使用cat /proc/bus/usb/devices 得到如下信息
T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=01 Dev#= 10 Spd=1.5 MxCh= 0
D:  Ver= 0.02 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=10c4 ProdID=11c4 Rev= 0.00
S:  Manufacturer=STIG INC.
S:  Product=Reader 134.2K
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 30mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=00(>ifc ) Sub=00 Prot=00 Driver=STIG Reader USB Device For Android
E:  Ad=81(I) Atr=03(Int.) MxPS=   8 Ivl=10ms
E:  Ad=02(O) Atr=03(Int.) MxPS=  64 Ivl=10ms

但是在 ls -l /dev时,没有找到stigreader这个设备,
求教这是怎么回事
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
1楼  发表于: 2012-10-08 16:59
补充一下我的开发板是tiny6410
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
2楼  发表于: 2012-10-09 08:14
有没有大神在呀,给看一下,多些
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2012-10-09 09:14

 回 楼主(hatherlea) 的帖子

为什么你会认为有/dev/stigreader这样的设备文件?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 68677
精华: 0
发帖: 50
金钱: 255 两
威望: 51 点
综合积分: 100 分
注册时间: 2012-04-25
最后登录: 2016-04-02
4楼  发表于: 2012-10-09 09:52
读卡器是标准设备

看看有没有sdX之类的……
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
5楼  发表于: 2012-10-09 10:56
在HAL层open设备时,我要打开哪个设备
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
6楼  发表于: 2012-10-09 11:05
就是在HAL层打开设备
int fd = open('/dev/stigreader', 0_RDWR);
fd 总是等于-1
然后我查/dev时没有stigreader,
那么我open时需要打开哪个设备,
下面是ls -l /dev时的现实
crw------- root     root       7, 135 2012-10-09 09:35 vcsa7
crw------- root     root       7,   7 2012-10-09 09:35 vcs7
crw-rw---- root     radio    188,   6 2012-10-09 09:34 ttyUSB6
crw-rw---- root     radio    188,   5 2012-10-09 09:34 ttyUSB5
crw-rw---- root     radio    188,   4 2012-10-09 09:34 ttyUSB4
crw-rw---- root     radio    188,   3 2012-10-09 09:34 ttyUSB3
crw-rw---- root     radio    188,   2 2012-10-09 09:34 ttyUSB2
crw-rw---- root     radio    188,   1 2012-10-09 09:34 ttyUSB1
crw-rw---- root     radio    188,   0 2012-10-09 09:34 ttyUSB0
drwxr-xr-x system   system            2012-10-09 09:34 cpuctl
crw-rw-rw- root     root      81,  14 2012-10-09 09:34 video14
crw-rw-rw- root     root      81,   1 2012-10-09 09:34 video1
crw-rw-rw- root     root      81,   0 2012-10-09 09:34 video0
crw-rw---- radio    vpn      108,   0 2012-10-09 09:34 ppp
crw------- root     root     253,   1 2012-10-09 09:34 ubi0_0
crw------- root     root     253,   0 2012-10-09 09:34 ubi0
drwxr-xr-x root     root              2012-10-09 09:34 mtd
drwxr-xr-x root     root              2012-10-09 09:34 block
drwxr-xr-x root     root              2012-10-09 09:34 graphics
crw------- root     root      10,  46 2012-10-09 09:34 network_throughput
crw------- root     root      10,  47 2012-10-09 09:34 network_latency
crw------- root     root      10,  48 2012-10-09 09:34 cpu_dma_latency
drwxr-xr-x root     root              2012-10-09 09:34 log
crw-rw-rw- root     root      10,  53 2012-10-09 09:34 binder
crw-rw-rw- system   graphics  10, 249 2012-10-09 09:34 s3c-g3d
crw-rw-rw- system   graphics  10, 220 2012-10-09 09:34 s3c-g2d
crw-rw-rw- system   graphics  10, 254 2012-10-09 09:34 s3c-jpg
crw-rw-rw- system   graphics  10, 253 2012-10-09 09:34 s3c-pp
crw-rw-r-- system   radio     10,  54 2012-10-09 09:34 alarm
crw------- root     root      10, 185 2012-10-09 09:34 ts-if
crw-rw-rw- root     root      10,  55 2012-10-09 09:34 backlight-1wire
crw------- root     root      10, 181 2012-10-09 09:34 touchscreen-1wire
crw------- root     root      10, 180 2012-10-09 09:34 touchscreen
crw-rw---- adb      adb       10,  56 2012-10-09 09:34 android_adb_enable
crw-rw---- adb      adb       10,  57 2012-10-09 09:34 android_adb
crw------- root     root      10,  58 2012-10-09 09:34 ubi_ctrl
crw-rw---- system   audio     10,   2 2012-10-09 09:34 pmem_adsp
crw-rw-rw- system   graphics  10,   1 2012-10-09 09:34 pmem_gpu1
crw-rw-rw- system   graphics  10,   0 2012-10-09 09:34 pmem
crw-rw-rw- root     root      10,  59 2012-10-09 09:34 adc
crw-rw-rw- root     root      10,  60 2012-10-09 09:34 pwm
crw-rw-rw- root     root      10,  61 2012-10-09 09:34 leds
crw------- root     root      10,  62 2012-10-09 09:34 backlight
crw-rw-rw- root     root      10,  63 2012-10-09 09:34 ashmem
crw------- root     root       7, 129 2012-10-09 09:34 vcsa1
crw------- root     root       7,   1 2012-10-09 09:34 vcs1
crw------- root     root       7, 128 2012-10-09 09:34 vcsa
crw------- root     root       7,   0 2012-10-09 09:34 vcs
crw-rw-rw- root     root       5,   2 2012-10-09 10:50 ptmx
crw------- root     root       3,  15 2012-10-09 09:34 ttypf
crw------- root     root       3,  14 2012-10-09 09:34 ttype
crw------- root     root       3,  13 2012-10-09 09:34 ttypd
crw------- root     root       3,  12 2012-10-09 09:34 ttypc
crw------- root     root       3,  11 2012-10-09 09:34 ttypb
crw------- root     root       3,  10 2012-10-09 09:34 ttypa
crw------- root     root       3,   9 2012-10-09 09:34 ttyp9
crw------- root     root       3,   8 2012-10-09 09:34 ttyp8
crw------- root     root       3,   7 2012-10-09 09:34 ttyp7
crw------- root     root       3,   6 2012-10-09 09:34 ttyp6
crw------- root     root       3,   5 2012-10-09 09:34 ttyp5
crw------- root     root       3,   4 2012-10-09 09:34 ttyp4
crw------- root     root       3,   3 2012-10-09 09:34 ttyp3
crw------- root     root       3,   2 2012-10-09 09:34 ttyp2
crw------- root     root       3,   1 2012-10-09 09:34 ttyp1
crw------- root     root       3,   0 2012-10-09 09:34 ttyp0
crw------- root     root       2,  15 2012-10-09 09:34 ptypf
crw------- root     root       2,  14 2012-10-09 09:34 ptype
crw------- root     root       2,  13 2012-10-09 09:34 ptypd
crw------- root     root       2,  12 2012-10-09 09:34 ptypc
crw------- root     root       2,  11 2012-10-09 09:34 ptypb
crw------- root     root       2,  10 2012-10-09 09:34 ptypa
crw------- root     root       2,   9 2012-10-09 09:34 ptyp9
crw------- root     root       2,   8 2012-10-09 09:34 ptyp8
crw------- root     root       2,   7 2012-10-09 09:34 ptyp7
crw------- root     root       2,   6 2012-10-09 09:34 ptyp6
crw------- root     root       2,   5 2012-10-09 09:34 ptyp5
crw------- root     root       2,   4 2012-10-09 09:34 ptyp4
crw------- root     root       2,   3 2012-10-09 09:34 ptyp3
crw------- root     root       2,   2 2012-10-09 09:34 ptyp2
crw------- root     root       2,   1 2012-10-09 09:34 ptyp1
crw------- root     root       2,   0 2012-10-09 09:34 ptyp0
crw------- root     root       4,  63 2012-10-09 09:34 tty63
crw------- root     root       4,  62 2012-10-09 09:34 tty62
crw------- root     root       4,  61 2012-10-09 09:34 tty61
crw------- root     root       4,  60 2012-10-09 09:34 tty60
crw------- root     root       4,  59 2012-10-09 09:34 tty59
crw------- root     root       4,  58 2012-10-09 09:34 tty58
crw------- root     root       4,  57 2012-10-09 09:34 tty57
crw------- root     root       4,  56 2012-10-09 09:34 tty56
crw------- root     root       4,  55 2012-10-09 09:34 tty55
crw------- root     root       4,  54 2012-10-09 09:34 tty54
crw------- root     root       4,  53 2012-10-09 09:34 tty53
crw------- root     root       4,  52 2012-10-09 09:34 tty52
crw------- root     root       4,  51 2012-10-09 09:34 tty51
crw------- root     root       4,  50 2012-10-09 09:34 tty50
crw------- root     root       4,  49 2012-10-09 09:34 tty49
crw------- root     root       4,  48 2012-10-09 09:34 tty48
crw------- root     root       4,  47 2012-10-09 09:34 tty47
crw------- root     root       4,  46 2012-10-09 09:34 tty46
crw------- root     root       4,  45 2012-10-09 09:34 tty45
crw------- root     root       4,  44 2012-10-09 09:34 tty44
crw------- root     root       4,  43 2012-10-09 09:34 tty43
crw------- root     root       4,  42 2012-10-09 09:34 tty42
crw------- root     root       4,  41 2012-10-09 09:34 tty41
crw------- root     root       4,  40 2012-10-09 09:34 tty40
crw------- root     root       4,  39 2012-10-09 09:34 tty39
crw------- root     root       4,  38 2012-10-09 09:34 tty38
crw------- root     root       4,  37 2012-10-09 09:34 tty37
crw------- root     root       4,  36 2012-10-09 09:34 tty36
crw------- root     root       4,  35 2012-10-09 09:34 tty35
crw------- root     root       4,  34 2012-10-09 09:34 tty34
crw------- root     root       4,  33 2012-10-09 09:34 tty33
crw------- root     root       4,  32 2012-10-09 09:34 tty32
crw------- root     root       4,  31 2012-10-09 09:34 tty31
crw------- root     root       4,  30 2012-10-09 09:34 tty30
crw------- root     root       4,  29 2012-10-09 09:34 tty29
crw------- root     root       4,  28 2012-10-09 09:34 tty28
crw------- root     root       4,  27 2012-10-09 09:34 tty27
crw------- root     root       4,  26 2012-10-09 09:34 tty26
crw------- root     root       4,  25 2012-10-09 09:34 tty25
crw------- root     root       4,  24 2012-10-09 09:34 tty24
crw------- root     root       4,  23 2012-10-09 09:34 tty23
crw------- root     root       4,  22 2012-10-09 09:34 tty22
crw------- root     root       4,  21 2012-10-09 09:34 tty21
crw------- root     root       4,  20 2012-10-09 09:34 tty20
crw------- root     root       4,  19 2012-10-09 09:34 tty19
crw------- root     root       4,  18 2012-10-09 09:34 tty18
crw------- root     root       4,  17 2012-10-09 09:34 tty17
crw------- root     root       4,  16 2012-10-09 09:34 tty16
crw------- root     root       4,  15 2012-10-09 09:34 tty15
crw------- root     root       4,  14 2012-10-09 09:34 tty14
crw------- root     root       4,  13 2012-10-09 09:34 tty13
crw------- root     root       4,  12 2012-10-09 09:34 tty12
crw------- root     root       4,  11 2012-10-09 09:34 tty11
crw------- root     root       4,  10 2012-10-09 09:34 tty10
crw------- root     root       4,   9 2012-10-09 09:34 tty9
crw------- root     root       4,   8 2012-10-09 09:34 tty8
crw------- root     root       4,   7 2012-10-09 09:34 tty7
crw------- root     root       4,   6 2012-10-09 09:34 tty6
crw------- root     root       4,   5 2012-10-09 09:34 tty5
crw------- root     root       4,   4 2012-10-09 09:34 tty4
crw------- root     root       4,   3 2012-10-09 09:34 tty3
crw------- root     root       4,   2 2012-10-09 09:34 tty2
crw------- root     root       4,   1 2012-10-09 09:34 tty1
crw-rw---- root     system     4,   0 2012-10-09 09:34 tty0
crw------- root     root       5,   1 2012-10-09 09:34 console
crw-rw-rw- root     root       5,   0 2012-10-09 09:34 tty
crw------- root     root       1,  11 2012-10-09 09:34 kmsg
crw-rw-rw- root     root       1,   9 2012-10-09 09:34 urandom
crw-rw-rw- root     root       1,   8 2012-10-09 09:34 random
crw-rw-rw- root     root       1,   7 2012-10-09 09:34 full
crw-rw-rw- root     root       1,   5 2012-10-09 09:34 zero
crw-rw-rw- root     root       1,   3 2012-10-09 09:34 null
crw------- root     root       1,   2 2012-10-09 09:34 kmem
crw-rw-rw- root     root       1,   1 2012-10-09 09:34 mem
drwxr-xr-x root     root              2012-10-09 09:34 snd
crw-rw-rw- root     root     204,  67 2012-10-09 09:34 s3c2410_serial3
crw-rw-rw- root     root     204,  66 2012-10-09 09:34 s3c2410_serial2
crw-rw-rw- root     root     204,  65 2012-10-09 09:34 s3c2410_serial1
crw-rw-rw- root     root     204,  64 2012-10-09 09:34 s3c2410_serial0
drwxr-xr-x root     root              2012-10-09 09:34 input
crw------- root     root     254,   0 2012-10-09 09:34 rtc0
drwxr-xr-x root     root              2012-10-09 09:34 bus
crw-rw-rw- root     root      89,   0 2012-10-09 09:34 i2c-0
drwxr-xr-x root     root              2012-10-09 09:34 socket
drwxr-xr-x root     root              1970-01-01 00:00 pts

哪位大神在线,帮帮忙
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
7楼  发表于: 2012-10-09 12:02

 回 6楼(hatherlea) 的帖子

你需要获得一些读卡器上的特定的控制功能吗?
如果你只是想访问读卡器里的卡,也就是存储设备的话,通常是不需要通过HAL的,把它或它其中的某个分区挂载后就可以通过文件系统访问其中的数据了。这和访问Android上其他任何文件是没有区别的。需要注意的是USB存储设备在Android里通常表示为/dev/block/sdX(X=a, b, c ...)或/dev/block/sdXn (n=1, 2, 3 ...), 具体的值可以通过/proc/partitions的输出来查询。
关于Linux系统上的文件系统挂载,参考http://www.jb51.net/os/RedHat/1109.html
[ 此帖被kasim在2012-10-09 12:08重新编辑 ]
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 79057
精华: 0
发帖: 12
金钱: 60 两
威望: 12 点
综合积分: 24 分
注册时间: 2012-09-29
最后登录: 2012-10-23
8楼  发表于: 2012-10-09 13:53
多些版主指点

我用的读卡器是我们公司自己的读卡器,是读RFID标签的,

读卡器通过usb接口(不是usb转串口)连接到android系统上,

我是通过usb操作设备,

如果不打开/dev/stigreader这个设备文件,那需要如何访问这个设备,

我在/dev/block中没有找到对应的设备,连接设备前后,/dev/block中的文件没有改变
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
9楼  发表于: 2012-10-09 16:23

 回 8楼(hatherlea) 的帖子

从你的描述看,这里关心的设备应该是一个由读卡器驱动生成的字符型设备。你能把这个驱动的链接贴出来吗?如果你在它的基础上做过修改的话,把修改也贴出来,谢谢!
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go