关键词: zc0301p s3c2410 linux2.6.11.1
(参考了一个开源的项目,可能有些乱,但是不想整理了)
USB Camera Porting Guide
1、修改drivers/usb/Makefile文件,在
obj-$(CONFIG_USB_W9968CF) += media/
之后添加一行:
obj-$(CONFIG_USB_SPCA5XX) += media/
2、修改drivers/usb/media/Kconfig文件,在最后添加:
config USB_SPCA5XX
tristate "USB SPCA5XX Sunplus/Vimicro/Sonix jpeg Cameras"
depends on USB && VIDEO_DEV
---help---
Say Y or M here if you want to use one of these webcams:
The built-in microphone is enabled by selecting USB Audio support.
This driver uses the Video For Linux API. You must say Y or M to
"Video For Linux" (under Character Devices) to use this driver.
Information on this API and pointers to "v4l" programs may be found
at <file:Documentation/video4linux/API.html>.
To compile this driver as a module, choose M here: the
module will be called spca5xx.
3、修改drivers/usb/media/Makefile,添加:
obj-$(CONFIG_USB_SPCA5XX) += spca5xx/
4、在usb/media目录下建立spca5xx目录
#mkdir drivers/usb/media/spca5xx
5、在drivers/usb/media/spca5xx添加如下文件:这些代码可以从http://mxhaard.free.fr/spca50x/Doc/KernelPatch/usb-2.6.12.patch.tar.gz
中下载
(1)、cs2102.h
(2)、hdcs.h
(3)、hv7131b.h
(4)、hv7131c.h
(5)、icm105a.h
(6)、Makefile
(7)、Makefile.2.4
(8)、
(9)、pas106b.h
(10)、pb0330.h
(11)、sn9cxxx.h
(12)、sp5xxfw2.dat
(13)、sp5xxfw2.h
(14)、spca5xx.h
(15)、spcaCompat.h
(16)、spca_core.c
(17)、spcadecoder.c
(19)、spcadecoder.h
(20)、spcausb.h
(21)、tas5130c.h
(22)、zc3xx.h
6、配置内核
(1)、
Multimedia devices --->
<M> Video For Linux
(2)、
USB support --->
<M> Support for Host-side USB
--- USB Host Controller Drivers
<M> OHCI HCD support
(3)、
--- USB Multimedia devices
<M> USB SPCA5XX Sunplus/Vimicro/Sonix jpeg Cameras
7、编译内核及模块
#make uImage
#make modules
8、拷贝模块文件到开发板文件系统目录下
walker/
walker/module_file
以上两个目录为手动建立的目录
cp drivers/media/video/v4l1-compat.ko /friendly-arm/rootfs_netserv/home/walker/module_file
cp drivers/media/video/v4l2-common.ko /friendly-arm/rootfs_netserv/home/walker/module_file
cp drivers/media/video/videodev.ko /friendly-arm/rootfs_netserv/home/walker/module_file
cp drivers/usb/core/usbcore.ko /friendly-arm/rootfs_netserv/home/walker/module_file
cp drivers/usb/media/spca5xx/spca5xx.ko /friendly-arm/rootfs_netserv/home/walker/module_file
9、将USB摄像头插入开发板(注:必须先插入摄像头才能插入模块文件,否则系统会出现kernel oops)
10、重新启动开发板
11、插入模块文件(注:这里必须注意模块的插入顺序,这是因为模块的依赖关系)
/sbin/insmod /home/walker/usbcore.ko
/sbin/insmod /home/walker/ohci-hcd.ko
/sbin/insmod /home/walker/v4l1-compat.ko
/sbin/insmod /home/walker/v4l2-common.ko
/sbin/insmod /home/walker/videodev.ko
/sbin/insmod /home/walker/spca5xx.ko
插入以上模块之后,建立设备文件
/bin/mknod /dev/video0 c 81 0
或者采用系统默认的设备文件
ln -sf /dev/v4l/video0 /dev/video0
或将以上语句写如etc/init.d/rcS文件中,当开发板启动的时候自动加载模块。
12、用命令测试
cat /dev/video0 > /tmp/a.jpg
或:
cat /dev/v4l/video0 > /tmp/a.jpg
此命令用来抓取一副图像,可以用Ctrl+c来中断该命令
图像抓取后,在PC上可以采用gqview查看
模块问题:
1、在装载摄像头驱动模块之前将摄像头插入开发板USB接口中,然后加载驱动模块文件,这时摄像头可以正常工作;此时拔掉摄像头,接着卸载驱动模块,
rmmod spca5xx
usbcore: deregistering driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: driver spca5xx deregistered
然后插入摄像头
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
装载驱动模块:
~ # insmod /home/walker/module_file/spca5xx.ko
drivers/usb/media/spca5xx/spca_core.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x303b
usbcore: registered new driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: spca5xx driver 00.57.06LE registered
摄像头可以正常工作
2、在装载驱动模块之后再将摄像头插入开发板当中,则会显示:
~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 2
Unable to handle kernel paging request at virtual address bf03b04e
pgd = c0004000
[bf03b04e] *pgd=33e5f011, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1]
Modules linked in: spca5xx videodev v4l2_common v4l1_compat ohci_hcd usbcore
CPU: 0
PC is at usb_match_id+0x14/0x1b0 [usbcore]
LR is at usb_device_match+0x28/0x40 [usbcore]
pc : [<bf0003a8>] lr : [<bf0005c8>] Not tainted
sp : c3e63e4c ip : c3e63e5c fp : c3e63e58
r10: 00000000 r9 : 00000001 r8 : 00000000
r7 : c0018d0c r6 : bf011188 r5 : c0018cb4 r4 : bf038e90
r3 : 00000000 r2 : c0018d0c r1 : bf03b04c r0 : c0018ca0
Flags: NzCv IRQs on FIQs on Mode SVC_32 Segment user
Control: 717F Table: 33DE4000 DAC: 00000015
Process khubd (pid: 22, stack limit = 0xc3e62194)
Stack: (0xc3e63e4c to 0xc3e64000)
3e40: c3e63e68 c3e63e5c bf0005c8 bf0003a4 c3e63e80
3e60: c3e63e6c c0103330 bf0005b0 bf038ec4 c0018cb4 c3e63e9c c3e63e84 c01033d0
3e80: c010330c c0018cb4 bf011128 c0018cd8 c3e63eb4 c3e63ea0 c01036b0 c010338c
3ea0: c0018cb4 c3c5a664 c3e63ed8 c3e63eb8 c0102628 c0103668 c0018ca0 c3c5a600
3ec0: c3c088c8 00000000 c3c5a404 c3e63f24 c3e63edc bf007578 c01025bc 00000001
3ee0: 00000000 00000000 00000000 000003e8 c3e22860 c3c5a400 00000001 c3c5a600
3f00: 00000000 00000001 c3c5a664 00000001 c0018e34 c3c2ea00 c3e63f48 c3e63f28
3f20: bf0026d4 bf007240 00000000 00000000 c3c5a600 c3c5a624 c0018d60 c3e63f7c
3f40: c3e63f4c bf0035dc bf002634 00000000 bf001174 c0018d60 00000001 c3c2ea00
3f60: c0018e34 00000001 00000000 c0018e20 c3e63fac c3e63f80 bf003910 bf003334
3f80: 01010001 c3e63fc0 c3e63fc0 c3e62000 c3e63fc4 bf01122c 00000000 00000000
3fa0: c3e63ff4 c3e63fb0 bf003a0c bf0036cc 00000000 c3c37300 c004e16c c3e63fd0
3fc0: c3e63fd0 00000000 c3c37300 c004e16c c3e63fd0 c3e63fd0 00000000 00000000
3fe0: 00000000 00000000 00000000 c3e63ff8 c003c240 bf0039f4 00400002 084a0024
Backtrace:
[<bf000394>] (usb_match_id+0x0/0x1b0 [usbcore]) from [<bf0005c8>] (usb_device_match+0x28/0x40 [usbcore])
[<bf0005a0>] (usb_device_match+0x0/0x40 [usbcore]) from [<c0103330>] (driver_probe_device+0x34/0x80)
[<c01032fc>] (driver_probe_device+0x0/0x80) from [<c01033d0>] (device_attach+0x54/0x94)
r5 = C0018CB4 r4 = BF038EC4
[<c010337c>] (device_attach+0x0/0x94) from [<c01036b0>] (bus_add_device+0x58/0x88)
r6 = C0018CD8 r5 = BF011128 r4 = C0018CB4
[<c0103658>] (bus_add_device+0x0/0x88) from [<c0102628>] (device_add+0x7c/0x108)
r5 = C3C5A664 r4 = C0018CB4
[<c01025ac>] (device_add+0x0/0x108) from [<bf007578>] (usb_set_configuration+0x348/0x3bc [usbcore])
r8 = C3C5A404 r7 = 00000000 r6 = C3C088C8 r5 = C3C5A600
r4 = C0018CA0
[<bf007230>] (usb_set_configuration+0x0/0x3bc [usbcore]) from [<bf0026d4>] (usb_new_device+0xb0/0x124 [usbcore])
[<bf002624>] (usb_new_device+0x0/0x124 [usbcore]) from [<bf0035dc>] (hub_port_connect_change+0x2b8/0x398 [usbcore])
r7 = C0018D60 r6 = C3C5A624 r5 = C3C5A600 r4 = 00000000
[<bf003324>] (hub_port_connect_change+0x0/0x398 [usbcore]) from [<bf003910>] (hub_events+0x254/0x328 [usbcore])
[<bf0036bc>] (hub_events+0x0/0x328 [usbcore]) from [<bf003a0c>] (hub_thread+0x28/0x104 [usbcore])
[<bf0039e4>] (hub_thread+0x0/0x104 [usbcore]) from [<c003c240>] (do_exit+0x0/0x33c)
r7 = 00000000 r6 = 00000000 r5 = 00000000 r4 = 00000000
Code: e92dd800 e24cb004 e3510000 0a000052 (e1d130b2)
3、实验:在未将scsi_mod.ko、sd_mod.ko、usb-storage.ko等模块加载进内核时,将U盘插入开发板当中,则系统出现如2一样的oops错误。把U盘拔出,并把usb-storage.ko模块卸载掉,然后再次将U盘插入开发板,仍然出现上面一样的oops错误。
4、将所有涉及的功能模块都静态编译进内核,在内核启动之前将摄像头插入开发板,然后启动内核,摄像头正常工作,此时把摄像头拔出,再次插入开发板,则摄像头无法正常工作
~ # cat /dev/video0 > /tmp/tmp.jpg
cat: /dev/video0: No such device
5、要使摄像头能工作,必须在将摄像头插入开发板后加载模块。
(1)、启动内核;
(2)、ls /dev
~ # ls /dev/
console kmem mtd ptmx rd tty vcc
fb kmsg mtdblock pts scsi urandom zero
full mem null pty shm usb
input misc port random tts vc
(3)、将摄像头插入开发板,有如下信息:
~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 2
usb 1-1: Product: PC Camera
usb 1-1: Manufacturer: Vimicro Corp.
(4)、ls /dev
~ # ls /dev
console kmem mtd ptmx rd tty vcc
fb kmsg mtdblock pts scsi urandom zero
full mem null pty shm usb
input misc port random tts vc
(5)、插入摄像头驱动模块
~ # insmod /home/walker/module_file/spca5xx.ko
drivers/usb/media/spca5xx/spca_core.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x303b
usbcore: registered new driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: spca5xx driver 00.57.06LE registered
(6)ls /dev
~ # ls /dev
console kmem mtd ptmx rd tty vc
fb kmsg mtdblock pts scsi urandom vcc
full mem null pty shm usb zero
input misc port random tts v4l
(7)、
~ # ls /dev/v4l/
video0
此时可以正常使用摄像头
(8)、卸载摄像头驱动模块
~ # rmmod spca5xx
usbcore: deregistering driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: driver spca5xx deregistered
(9)、ls /dev/v4l
没有video0设备
(10)、不拔摄像头,再次装载驱动模块
~ # insmod /home/walker/module_file/spca5xx.ko
drivers/usb/media/spca5xx/spca_core.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x303b
usbcore: registered new driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: spca5xx driver 00.57.06LE registered
(11)、~ # ls /dev/v4l/
video0
(12)、卸载驱动模块~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: Product: PC Camera
usb 1-1: Manufacturer: Vimicro Corp.
Unable to handle kernel paging request at virtual address bf05704e
pgd = c0004000
[bf05704e] *pgd=33ec1011, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1]
Modules linked in: spca5xx videodev v4l2_common v4l1_compat usb_storage usbkbd ohci_hcd usbcore
CPU: 0
PC is at usb_match_id+0x14/0x1b0 [usbcore]
LR is at usb_device_match+0x28/0x40 [usbcore]
pc : [<bf000400>] lr : [<bf000620>] Not tainted
sp : c3e4fe24 ip : c3e4fe34 fp : c3e4fe30
r10: 00000000 r9 : 00000001 r8 : 00000000
r7 : c3c5d94c r6 : bf01a5f0 r5 : c3c5d8f4 r4 : bf054e90
r3 : 00000000 r2 : c3c5d94c r1 : bf05704c r0 : c3c5d8e0
Flags: NzCv IRQs on FIQs on Mode SVC_32 Segment user
Control: 717F Table: 3030C000 DAC: 00000015
Process khubd (pid: 22, stack limit = 0xc3e4e194)
Stack: (0xc3e4fe24 to 0xc3e50000)
fe20: c3e4fe40 c3e4fe34 bf000620 bf0003fc c3e4fe58 c3e4fe44 c0104330
fe40: bf000608 bf054ec4 c3c5d8f4 c3e4fe74 c3e4fe5c c01043d0 c010430c c3c5d8f4
fe60: bf01a590 c3c5d918 c3e4fe8c c3e4fe78 c01046b0 c010438c c3c5d8f4 c3c9aa64
fe80: c3e4feb0 c3e4fe90 c0103628 c0104668 c3c5d8e0 c3c9aa00 c3c9aabc 00000000
fea0: c3c5d94c c3e4fefc c3e4feb4 bf0085b0 c01035bc 00000001 00000000 00000000
fec0: 00000000 000003e8 c3e4bda0 c3c9ae00 00000001 00000000 c3c9aa00 00000001
fee0: c3c9aabc c3c9aa64 c3c5da74 c3c9a400 c3e4ff28 c3e4ff00 bf002dc4 bf00823c
ff00: 00000002 00000000 00000000 c3c9aa00 c3c9aa24 00000001 c3c5d9a0 c3e4ff6c
ff20: c3e4ff2c bf003e88 bf002c9c 00000101 00000001 bf01025c c3c5dacc 00000000
ff40: bf001228 00000000 c3c5da74 c3c5d9a0 00000001 c3c9a400 c3c5da60 00000001
ff60: c3e4ffac c3e4ff70 bf00431c bf003b64 00000002 00000000 00000002 01010001
ff80: c3c7b450 c3e4ffc0 c3e4e000 c3e4ffc4 bf01a694 00000000 00000000 00000000
ffa0: c3e4fff4 c3e4ffb0 bf004474 bf003fc8 00000000 c3c7b300 c004f16c c3e4ffd0
ffc0: c3e4ffd0 00000000 c3c7b300 c004f16c c3e4ffd0 c3e4ffd0 00000000 00000000
ffe0: 00000000 00000000 00000000 c3e4fff8 c003d240 bf00445c e3510000 15911000
Backtrace:
[<bf0003ec>] (usb_match_id+0x0/0x1b0 [usbcore]) from [<bf000620>] (usb_device_match+0x28/0x40 [usbcore])
[<bf0005f8>] (usb_device_match+0x0/0x40 [usbcore]) from [<c0104330>] (driver_probe_device+0x34/0x80)
[<c01042fc>] (driver_probe_device+0x0/0x80) from [<c01043d0>] (device_attach+0x54/0x94)
r5 = C3C5D8F4 r4 = BF054EC4
[<c010437c>] (device_attach+0x0/0x94) from [<c01046b0>] (bus_add_device+0x58/0x88)
r6 = C3C5D918 r5 = BF01A590 r4 = C3C5D8F4
[<c0104658>] (bus_add_device+0x0/0x88) from [<c0103628>] (device_add+0x7c/0x108)
r5 = C3C9AA64 r4 = C3C5D8F4
[<c01035ac>] (device_add+0x0/0x108) from [<bf0085b0>] (usb_set_configuration+0x384/0x3fc [usbcore])
r8 = C3C5D94C r7 = 00000000 r6 = C3C9AABC r5 = C3C9AA00
r4 = C3C5D8E0
[<bf00822c>] (usb_set_configuration+0x0/0x3fc [usbcore]) from [<bf002dc4>] (usb_new_device+0x138/0x1cc [usbcore])
[<bf002c8c>] (usb_new_device+0x0/0x1cc [usbcore]) from [<bf003e88>] (hub_port_connect_change+0x334/0x464 [usbcore])
r8 = C3C5D9A0 r7 = 00000001 r6 = C3C9AA24 r5 = C3C9AA00
r4 = 00000000
[<bf003b54>] (hub_port_connect_change+0x0/0x464 [usbcore]) from [<bf00431c>] (hub_events+0x364/0x494 [usbcore])
[<bf003fb8>] (hub_events+0x0/0x494 [usbcore]) from [<bf004474>] (hub_thread+0x28/0x11c [usbcore])
[<bf00444c>] (hub_thread+0x0/0x11c [usbcore]) from [<c003d240>] (do_exit+0x0/0x33c)
r7 = 00000000 r6 = 00000000 r5 = 00000000 r4 = 00000000
Code: e92dd800 e24cb004 e3510000 0a000052 (e1d130b2)
~ # rmmod spca5xx
usbcore: deregistering driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: driver spca5xx deregistered
(13)、拔出摄像头
~ # usb 1-1: USB disconnect, address 2
(14)、再次装载驱动模块
~ # insmod /home/walker/module_file/spca5xx.ko
usbcore: registered new driver spca5xx
drivers/usb/media/spca5xx/spca_core.c: spca5xx driver 00.57.06LE registered
(15)、插入摄像头
~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: Product: PC Camera
usb 1-1: Manufacturer: Vimicro Corp.
Unable to handle kernel paging request at virtual address bf05704e
pgd = c0004000
[bf05704e] *pgd=33ec1011, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1]
Modules linked in: spca5xx videodev v4l2_common v4l1_compat usb_storage usbkbd ohci_hcd usbcore
CPU: 0
PC is at usb_match_id+0x14/0x1b0 [usbcore]
LR is at usb_device_match+0x28/0x40 [usbcore]
pc : [<bf000400>] lr : [<bf000620>] Not tainted
sp : c3e4fe24 ip : c3e4fe34 fp : c3e4fe30
r10: 00000000 r9 : 00000001 r8 : 00000000
r7 : c3c5d94c r6 : bf01a5f0 r5 : c3c5d8f4 r4 : bf054e90
r3 : 00000000 r2 : c3c5d94c r1 : bf05704c r0 : c3c5d8e0
Flags: NzCv IRQs on FIQs on Mode SVC_32 Segment user
Control: 717F Table: 3030C000 DAC: 00000015
Process khubd (pid: 22, stack limit = 0xc3e4e194)
Stack: (0xc3e4fe24 to 0xc3e50000)
fe20: c3e4fe40 c3e4fe34 bf000620 bf0003fc c3e4fe58 c3e4fe44 c0104330
fe40: bf000608 bf054ec4 c3c5d8f4 c3e4fe74 c3e4fe5c c01043d0 c010430c c3c5d8f4
fe60: bf01a590 c3c5d918 c3e4fe8c c3e4fe78 c01046b0 c010438c c3c5d8f4 c3c9aa64
fe80: c3e4feb0 c3e4fe90 c0103628 c0104668 c3c5d8e0 c3c9aa00 c3c9aabc 00000000
fea0: c3c5d94c c3e4fefc c3e4feb4 bf0085b0 c01035bc 00000001 00000000 00000000
fec0: 00000000 000003e8 c3e4bda0 c3c9ae00 00000001 00000000 c3c9aa00 00000001
fee0: c3c9aabc c3c9aa64 c3c5da74 c3c9a400 c3e4ff28 c3e4ff00 bf002dc4 bf00823c
ff00: 00000002 00000000 00000000 c3c9aa00 c3c9aa24 00000001 c3c5d9a0 c3e4ff6c
ff20: c3e4ff2c bf003e88 bf002c9c 00000101 00000001 bf01025c c3c5dacc 00000000
ff40: bf001228 00000000 c3c5da74 c3c5d9a0 00000001 c3c9a400 c3c5da60 00000001
ff60: c3e4ffac c3e4ff70 bf00431c bf003b64 00000002 00000000 00000002 01010001
ff80: c3c7b450 c3e4ffc0 c3e4e000 c3e4ffc4 bf01a694 00000000 00000000 00000000
ffa0: c3e4fff4 c3e4ffb0 bf004474 bf003fc8 00000000 c3c7b300 c004f16c c3e4ffd0
ffc0: c3e4ffd0 00000000 c3c7b300 c004f16c c3e4ffd0 c3e4ffd0 00000000 00000000
ffe0: 00000000 00000000 00000000 c3e4fff8 c003d240 bf00445c e3510000 15911000
Backtrace:
[<bf0003ec>] (usb_match_id+0x0/0x1b0 [usbcore]) from [<bf000620>] (usb_device_match+0x28/0x40 [usbcore])
[<bf0005f8>] (usb_device_match+0x0/0x40 [usbcore]) from [<c0104330>] (driver_probe_device+0x34/0x80)
[<c01042fc>] (driver_probe_device+0x0/0x80) from [<c01043d0>] (device_attach+0x54/0x94)
r5 = C3C5D8F4 r4 = BF054EC4
[<c010437c>] (device_attach+0x0/0x94) from [<c01046b0>] (bus_add_device+0x58/0x88)
r6 = C3C5D918 r5 = BF01A590 r4 = C3C5D8F4
[<c0104658>] (bus_add_device+0x0/0x88) from [<c0103628>] (device_add+0x7c/0x108)
r5 = C3C9AA64 r4 = C3C5D8F4
[<c01035ac>] (device_add+0x0/0x108) from [<bf0085b0>] (usb_set_configuration+0x384/0x3fc [usbcore])
r8 = C3C5D94C r7 = 00000000 r6 = C3C9AABC r5 = C3C9AA00
r4 = C3C5D8E0
[<bf00822c>] (usb_set_configuration+0x0/0x3fc [usbcore]) from [<bf002dc4>] (usb_new_device+0x138/0x1cc [usbcore])
[<bf002c8c>] (usb_new_device+0x0/0x1cc [usbcore]) from [<bf003e88>] (hub_port_connect_change+0x334/0x464 [usbcore])
r8 = C3C5D9A0 r7 = 00000001 r6 = C3C9AA24 r5 = C3C9AA00
r4 = 00000000
[<bf003b54>] (hub_port_connect_change+0x0/0x464 [usbcore]) from [<bf00431c>] (hub_events+0x364/0x494 [usbcore])
[<bf003fb8>] (hub_events+0x0/0x494 [usbcore]) from [<bf004474>] (hub_thread+0x28/0x11c [usbcore])
[<bf00444c>] (hub_thread+0x0/0x11c [usbcore]) from [<c003d240>] (do_exit+0x0/0x33c)
r7 = 00000000 r6 = 00000000 r5 = 00000000 r4 = 00000000
Code: e92dd800 e24cb004 e3510000 0a000052 (e1d130b2)
(16)、ls /dev/v4l
没有看到video0设备文件
怀疑是本版本内核的USB CORE的机制问题
(1)、将U盘插入开发板
(2)、插入驱动模块
(3)、可以正常mount U盘
(4)、卸载U盘驱动模块
~ # rmmod usb_storage
usbcore: deregistering driver usb-storage
(5)、 ls /dev/scsi/host0/bus0/target0/
没有设备节点
(6)、再次装载驱动模块
~ # insmod /home/walker/module_file/usb-storage.ko
Initializing USB Mass Storage driver...
scsi1 : SCSI emulation for USB Mass Storage devices
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
(7)、~ # ls /dev/scsi/host0/bus0/target0/
没有设备节点
过了一会,发现节点
~ # usb 1-1: reset full speed USB device using s3c2410-ohci and address 2
Vendor: USB-DISK Model: FREEDIK-LWFORMAT Rev: 2.23
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
/dev/scsi/host1/bus0/target0/lun0:<7>usb-storage: queuecommand called
p1
Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0
(8)、~ # ls /dev/scsi/host1/bus0/target0/lun0/
/dev/scsi/host1/bus0/target0/lun0/disc
/dev/scsi/host1/bus0/target0/lun0/part1
(9)、卸载驱动模块
~ # rmmod usb_storage
usbcore: deregistering driver usb-storage
(10)、将U盘拔出
~ # usb 1-1: USB disconnect, address 2
(11)、装载驱动模块
~ # insmod /home/walker/module_file/usb-storage.ko
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
(12)、将U盘插入
~ # insmod /home/walker/module_file/usb-storage.ko
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1: Product: YOUR_PRODUCT
usb 1-1: Manufacturer: YOUR_COMPANY
usb 1-1: SerialNumber: SN12345678901
scsi2 : SCSI emulation for USB Mass Storage devices
Vendor: USB-DISK Model: FREEDIK-LWFORMAT Rev: 2.23
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
/dev/scsi/host2/bus0/target0/lun0:<7>usb-storage: queuecommand called
p1
Attached scsi removable disk sda at scsi2, channel 0, id 0, lun 0
(12)、卸载驱动模块
~ # rmmod usb_storage
usbcore: deregistering driver usb-storag
(13)、将U盘插入
~ # usb 1-1: new full speed USB device using s3c2410-ohci and address 4
usb 1-1: Product: YOUR_PRODUCT
usb 1-1: Manufacturer: YOUR_COMPANY
usb 1-1: SerialNumber: SN12345678901
(14)、装载驱动模块
~ # insmod /home/walker/module_file/usb-storage.ko
Initializing USB Mass Storage driver...
scsi4 : SCSI emulation for USB Mass Storage devices
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
~ # Vendor: USB-DISK Model: FREEDIK-LWFORMAT Rev: 2.23
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
SCSI device sda: 260032 512-byte hdwr sectors (133 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
/dev/scsi/host4/bus0/target0/lun0:<7>usb-storage: queuecommand called
p1
Attached scsi removable disk sda at scsi4, channel 0, id 0, lun 0
(15)、卸载scsi_mod.ko以及sd_mod.ko
(16)、将U盘拔出
~ # usb 1-1: USB disconnect, address 4
(17)、将U盘插入
~ # usb 1-1: USB disconnect, address 4
usb 1-1: new full speed USB device using s3c2410-ohci and address 5
usb 1-1: Product: YOUR_PRODUCT
usb 1-1: Manufacturer: YOUR_COMPANY
usb 1-1: SerialNumber: SN12345678901
问题解决:
我才看usb core的代码,才看了几行代码,就突然想到内核的hotplug的机制,然后又联想到内核好像有这个选项,查看内核配置选项
找到
General setup --->
Generic Driver Options --->
<*> Hotplug firmware loading support
把这个选项选上,然后重新编译内核及驱动模块。这样再重新试验:
(1)、先插入摄像头驱动模块,再把摄像头插入开发板,ok
(2)、接着把摄像头拔出,卸载驱动模块,插入摄像头,装载驱动模块,ok。
(3)、把摄像头拔下,卸载驱动模块,装载驱动模块,插入摄像头,ok。
/4918763.html