移植过程中参考了http://blog.csdn.net/jason6765599/article/details/19838621#comments,表示感谢!
开发板OK6410
开发板内核linux3.0.1,是下载的网友稍作修改的飞凌提供的内核,内核的下载地址http://download.csdn.net/detail/improve_perfect/7627083
用的usb摄像头zc301.下载的内核中已经配置好了。
PC虚拟机机Ubuntu12 系统
一、jpeg库的移植
1. 下载源码
MJPG-streamer程序调用了jpeg库文件,因此在进行移植之前,我们需要先移植jpeg库。从网站http://www.ijg.org/files/jpegsrc.v8b.tar.gz下载源码包,代码如下:
tar xvf jpegsrc.v8b.tar.gz
#cd jpeg-8b
2. 修改配置
#./configure--prefix=/home/linux/6410/video/jpeg --host=arm-none-linux-gnueabi
注:/home/linux/6410/video/jpeg是自己规定的,别的目录也可以,但要与后面匹配。
3. 编译与安装
#make
#make install
在/home/linux/64105/video/jpeg/lib目录下会生成如下文件
libjpeg.a libjpeg.so libjpeg.so.8.0.2
libjpeg.la libjpeg.so.8
4.拷贝文件
拷贝libjpeg.s0.8链接和 libjpeg.so.8.0.2库到开发板文件系统lib下中
二、 MJPG-streamer的移植
1.下载源码
安装好jpeg库后即可进行MJPG-streamer的移植,源码包下载地址为http://sourceforge.net/projects/mjpg-streamer/,但源码不能直接编译,结合ARM11的硬件设备以及烧写的Linux 3.0.1系统,需对源码做一定修改,主要如下:
#tar zxvf mjpg-streamer-r63.tar.gz
#cd mjpg-streamer-r63
2.修改源码
2.1 修改顶层makefile及plugins目录中的下层各个目录的各级makefile:(我做的过程中就只是修改了*和input_uvc下的makefile结果给自己招来很多的麻烦)
将所有CC=gcc修改为CC=arm-linux-gcc 或arm-none-linux-gnueabi-gcc。(我写的前者)
2.2 修改plugins/input_uvc/Makfile:(就这个makefile修改的多一点,其他的都只是修改CC=arm-linux-gcc)
修改$(CC) $(CFLAGS)-ljpeg -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.l o dynctrl.lo
为$(CC) $(CFLAGS) -ljpeg-L/home/linux/s3c2410-2.6.35/video/jpeg/lib -o $@ input_uvc.c v4l2uvc.lojpeg_utils.lo dynctrl.lo
修改CFLAGS += -O2-DLINUX -D_GNU_SOURCE -Wall -shared –fPIC
为CFLAGS+=-O2 -DLINUX-D_GNU_SOURCE -Wall -shared -fPIC - I /home/linux/s3c2410-2.6.35/video/jpeg/include(是大写的i)3.编译
#make
4.测试
4.1 在开发板上mkdir /mjpg
4.2 拷贝*.so到开发板的mjpg目录下,mjpg_streamer到开发板的bin下并改变权限
(我是拷贝的编译后的mjpg-streamer整个文件夹的内容复制到开发板的/mjpg目录下,并且把mjpg_streamer放到开发板的bin下,一定要注意当从pc机复制到开发板的过程中如果是用ftp的话,文件的权限会发生改变,一定要在运行之前修改权限,chmod -R 755 /mjpg)
4.3 打开开开发板运行
#mjpg_streamer -i "/mjpg/input_uvc.so -d /dev/video2" -o "/mjpg/output_http.so"
4.4 验证
用火狐浏览器打开一个网页输入下面地址就能够看到一个视频(开发板的IP为192.168.0.232):
http://192.168.0.232:8080/?action=stream
打开一个网页输入下面地址就能够看到一个静态图片:
http://192.168.0.232:8080/?action=snapshot
在调试过程中遇到的问题及解决方法:
1:飞凌的官方提供的usb摄像头是罗技的,自己买的是中星微的zc301p,后来搜索确定这种摄像头能用。如果用飞凌提供的测试程序luvcview,会出现像下面这样的错误:
luvcview version v0.1 [CAM]s3c_fimc_open.id=0
ctrl->in_cam=c0736110[CAM]ctrl->in_cam->width=640
s3c_fimc_v4l2_querycap 0
s3c_fimc_v4l2_querycap 1
ctrl->vd->name = s3c-fimc0
s3c_fimc_v4l2_querycap 2
s3c_fimc_v4l2_querycap 3
s3c_fimc_v4l2_querycap 4
s3c_fimc_v4l2_querycap 5
s3c_fimc_v4l2_s_fmt_vid_cap filp=cbd35e00,fh=c07b1588,f=cbd6c200
s3c-fimc: changing to default resolution
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = cbdf8000
[00000000] *pgd=5bd0e831, *pte=00000000, *ppte=00000000
Internal error: Oops: 80000007 [#5]
Modules linked in:
CPU: 0 Tainted: G D W (3.0.1 #448)
PC is at 0x0
LR is at s3c_fimc_i2c_command+0x2c/0x40
pc : [<00000000>] lr : [<c0345cb0>] psr: a0000013
sp : cbd73c00 ip : cbd73c10 fp : cbd73c0c
r10: 00000000 r9 : c0735c38 r8 : cbd6c200
r7 : 00000000 r6 : c0736110 r5 : c07b1588 r4 : ffffffff
r3 : c073624c r2 : 00000000 r1 : 00000001 r0 : cc45fb00
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 00c5387d Table: 5bdf8008 DAC: 00000015
Process luvcview (pid: 188, stack limit = 0xcbd72268)
Stack: (0xcbd73c00 to 0xcbd74000)
3c00: cbd73c2c cbd73c10 c0347ac4 c0345c90 c07b1588 c0cc5616 00000000 00000000
3c20: cbd73c44 cbd73c30 c0346a88 c0347aa0 c0346a24 c0cc5616 cbd73e24 cbd73c48
3c40: c02fd660 c0346a30 000000d8 00000000 000000dc 00000000 000000e0 00000000
3c60: 000000e4 00000000 000000e8 00000000 000000ec 00000000 000000f0 00000000
3c80: 000000f4 00000000 000000f8 00000000 000000fc 00000000 00000100 00000000
3ca0: 00000104 00000000 00000108 00000000 0000010c 00000000 00000110 00000000
3cc0: 00000114 00000000 00000118 00000000 0000011c 00000000 00000120 00000000
3ce0: 00000124 00000000 00000128 00000000 0000012c 00000000 00000130 00000000
3d00: 00000134 00000000 00000138 00000000 0000013c 00000000 00000140 00000000
3d20: 00000000 c07b1588 cbd73d4c cbd73d38 c0349a68 c03488ec c07b1588 00000000
3d40: cbd73d6c cbd73d50 c0345d40 c04a931c c0735c38 cbd35e00 c0735c40 cc123d68
3d60: cbd73d8c cbd73d70 c02f9fe4 c0345cd0 00000000 00000000 cc542fc0 cc123d68
3d80: cbd73dbc cbd73d90 c00ed5b0 cbd6c200 c0cc5616 cbd35e00 c0735c38 c051ed40
3da0: c07b1588 cc123d68 c00ed490 cc124580 cbd73df4 cbd73dc0 c00e8dcc c00bd2a0
3dc0: cc081180 cc40fb40 cc123d68 cbd73ed0 cbd35e00 00000000 cbd36480 cbd73ed0
3de0: cc402380 c0cc5616 cbd73e24 cbd73df8 c00e68a8 c04a8a80 cbd73e1c 000000cc
3e00: c0cc5616 00000000 00000000 cbd6c200 cbd6c200 00000000 cbd73eec cbd73e28
3e20: c02ff978 c02fae84 cbd73e64 003b82f8 cbd35e00 00000003 cbd73e64 736d6153
3e40: 20676e75 434d4946 69724420 2d633373 636d6966 00000030 00000000 00000000
3e60: 00000000 00000000 00000000 434d4946 42484120 7375622d 00000000 00000000
3e80: 00000000 00000000 00000000 00000000 04000005 00000000 00000000 00000000
3ea0: 00000000 cbd73ed0 ffffff9c cbd59000 cbd72000 00000f8b cbd73f54 713cfc23
3ec0: c00f7d04 c051ec98 003b82f8 00000003 003b82f8 c0034ce8 cbd72000 00000000
3ee0: cbd73f04 cbd73ef0 c02f9de4 c02ff8c8 cbd35e00 003b82f8 cbd73f7c cbd73f08
3f00: c00f8f54 c02f9db4 cbd73fac cbd73f18 c04a86f4 c004bfd4 00000000 00000000
3f20: 00000000 00000000 c0034ba0 cbd72000 ecefa880 00000f8b cbd35e08 00000003
3f40: cbd59000 cbd72000 cbd73f94 cbd73f58 c00e8ae0 00000003 003b82f8 c0cc5616
3f60: cbd35e00 c0034ce8 cbd72000 00000000 cbd73fa4 cbd73f80 c00f9484 c00f8ed4
3f80: c0034ce8 00000000 003b82f8 003b8190 003b8008 00000036 00000000 cbd73fa8
3fa0: c0034b40 c00f9450 003b82f8 003b8190 00000003 c0cc5616 003b82f8 0000000f
3fc0: 003b82f8 003b8190 003b8008 00000036 00000000 00000140 00000000 000000f0
3fe0: 00000001 be8a4c98 0000ddec 401dc00c 80000010 00000003 5fffe821 5fffec21
[<c0345cb0>] (s3c_fimc_i2c_command+0x2c/0x40) from [<c0347ac4>] (s3c_fimc_change_resolution+0x30/0xf0)
[<c0347ac4>] (s3c_fimc_change_resolution+0x30/0xf0) from [<c0346a88>] (s3c_fimc_v4l2_s_parm+0x64/0x70)
[<c0346a88>] (s3c_fimc_v4l2_s_parm+0x64/0x70) from [<c02fd660>] (__video_do_ioctl+0x27e8/0x4a44)
[<c02fd660>] (__video_do_ioctl+0x27e8/0x4a44) from [<c02ff978>] (video_ioctl2+0xbc/0x594)
[<c02ff978>] (video_ioctl2+0xbc/0x594) from [<c02f9de4>] (v4l2_ioctl+0x3c/0x5c)
[<c02f9de4>] (v4l2_ioctl+0x3c/0x5c) from [<c00f8f54>] (do_vfs_ioctl+0x8c/0x57c)
[<c00f8f54>] (do_vfs_ioctl+0x8c/0x57c) from [<c00f9484>] (sys_ioctl+0x40/0x68)
[<c00f9484>] (sys_ioctl+0x40/0x68) from [<c0034b40>] (ret_fast_syscall+0x0/0x30)
Code: bad PC value
---[ end trace da227214a82491bd ]---
video /dev/video0
Segmentation fault
请注意下面这个video /dev/video0 这是打开的video0这个设备。而在ok6410中,zc301摄像头是添加的video2设备,我估计改成把测试程序默认启动的设备号改成video2就可以了,当然这只是个推测,我还没测试。
2.如果在编译mjpeg_streamer时,没有按照像上面所说的,把plugins目录中的下层的各个文件夹下的makefile修改,当运行
#mjpg_streamer -i "/mjpg/input_uvc.so -d /dev/video2" -o "/mjpg/output_http.so"命令时,会出现类似这样的错误
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video2
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPEG
ERROR: could not find output plugin /mjpeg111/output_http.so
Perhaps you want to adjust the search path with:
# export LD_LIBRARY_PATH=/path/to/plugin/folder
dlopen: /mjpeg111/output_http.so: cannot open shared object file: No such file or directory
网上提供的解决办法是敲入如下命令:export LD_LIBRARY_PATH=/mjpg:$ LD_LIBRARY_PATH(我的共享库文件时放在/mjpg目录里的),设定共享库的搜索路径就可以了!但是你会发现这样修改后还是不行,因为在你进行编译的时候output_http.so是按照gcc编译完成的没有进行交叉编译,所以在开发板上市无法识别的。当重新进行交叉编译后,再运行刚才的命令,就会出现这样的结果
当运行#mjpg_streamer -i "/mjpg/input_uvc.so -d /dev/video2" -o "/mjpg/output_http.so"命令时,一定要加-d /dev/video2,否则会默认启动video0设备,就会出现类似这样的错误:
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i[CAM]s3c_fimc_open.id=0
ctrl->in_cam=c0727e10[CAM]ctrl->in_cam->width=640
s3c_fimc_v4l2_querycap 0
s3c_fimc_v4l2_querycap 1
ctrl->vd->name = s3c-fimc0
s3c_fimc_v4l2_querycap 2
s3c_fimc_v4l2_querycap 3
s3c_fimc_v4l2_querycap 4
s3c_fimc_v4l2_querycap 5
s3c_fimc_v4l2_s_fmt_vid_cap filp=ce00b980,fh=c07afb38,f=ceb0e700
s3c-fimc: changing to default resolution
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = ce09c000
[00000000] *pgd=5e089031, *pte=00000000, *ppte=00000000
Internal error: Oops: 80000007 [#1]
last sysfs file: /sys/class/graphics/fb0/virtual_size
Modules linked in:
CPU: 0 Not tainted (2.6.36.2 #382)
PC is at 0x0
LR is at s3c_fimc_i2c_command+0x2c/0x40
pc : [<00000000>] lr : [<c03650d8>] psr: a0000013
sp : ce097b90 ip : ce097ba0 fp : ce097b9c
r10: c0cc5616 r9 : c0519c98 r8 : ceb0e700
r7 : c07277a0 r6 : c0727e10 r5 : c07afb38 r4 : ffffffff
r3 : c0727da0 r2 : 00000000 r1 : 00000001 r0 : ce851900
Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 00c5387d Table: 5e09c008 DAC: 00000015
Process mjpg_streamer (pid: 114, stack limit = 0xce096268)
Stack: (0xce097b90 to 0xce098000)
7b80: ce097bbc ce097ba0 c0366fd0 c03650b8
7ba0: ce097bd4 c07afb38 000000cc ceb0e700 ce097bd4 ce097bc0 c0365ecc c0366fa8
7bc0: 000000cc c0365e88 ce097dfc ce097bd8 c02dd814 c0365e94 00000048 00000000
7be0: 0000004c 00000000 00000050 00000000 00000054 00000000 00000058 18000000
7c00: 0000005c 00000000 00000068 00000000 0000006c 00000000 00000070 00000000
7c20: 00000074 00000000 00000078 18000000 0000007c 00000000 00000080 00000000
7c40: 00000084 00000000 00000088 00000000 0000008c 00000000 00000090 00000000
7c60: 00000094 00000000 00000098 18000000 000000a0 00000000 000000a4 00000000
7c80: 000000a8 00000000 000000ac 18000000 000000b0 00000000 000000c0 00000000
7ca0: 000000c4 ffffffff 000000d0 00100080 000000d4 00000000 000000d8 00000000
7cc0: 000000dc 00000000 000000e0 00000000 000000e4 00000000 000000e8 00000000
7ce0: 000000ec 00000000 000000f0 00000000 000000f4 00000000 000000f8 00000000
7d00: 000000fc 00000000 00000100 00000000 00000104 00000000 00000108 00000000
7d20: 0000010c 00000000 00000110 00000000 00000114 00000000 00000118 00000000
7d40: 0000011c 00000000 00000120 ceb0e700 ce00b980 00000000 00000128 c07277a0
7d60: c07afb38 00000000 00000130 00000000 00000134 00000000 00000138 00000000
7d80: 0000013c 00000000 00000140 00000000 c07afb38 c07afb70 ce097dc4 ce097da8
7da0: c0365168 c04a17dc c07277a0 ce00b980 c07277a8 ce00b980 ce097dfc ce097dc8
7dc0: c00d34ec c04a0ec4 ce00b980 00000000 ce963c80 00000000 000000cc c0cc5616
7de0: 00000000 ceb0e700 002da828 00000000 ce097ec4 ce097e00 c02dfda4 c02daf38
7e00: ce4ee380 ce00b980 00000003 ceb0e700 c00d56a8 736d6153 20676e75 434d4946
7e20: 69724420 2d633373 636d6966 00000030 00000000 00000000 00000000 00000000
7e40: 00000000 434d4946 42484120 7375622d 00000000 00000000 00000000 00000000
7e60: 00000000 00000000 04000005 00000000 00000000 00000000 00000000 c00ee88c
7e80: 00000000 ce00b980 ce097f5c ce097e98 c00e26d8 85104d64 00000000 ce00b980
7ea0: c0cc5616 002da828 ce00b980 c0032b68 ce096000 00000000 ce097ee4 ce097ec8
7ec0: c02da130 c02dfc6c ce805c80 ce00b980 00000004 002da828 ce097ef4 ce097ee8
7ee0: c00e46b8 c02da0fc ce097f7c ce097ef8 c00e4980 c00e4694 c0032234 c04a4a4c
7f00: ce097f3c ce097f10 c00d4d3c c04a0ec4 cebc9730 ce00b988 ce805c80 ce00b980
7f20: 00000005 00000000 00000000 00000000 c00ecba8 ce00b988 ce00b980 ce061000
7f40: 00000004 ce00b988 ce00b980 ce061000 ce097f94 00000004 002da828 c0cc5616
7f60: ce00b980 c0032b68 ce096000 00000000 ce097fa4 ce097f80 c00e4ec8 c00e4918
7f80: ce096000 00000000 002da828 002da6e0 002da558 00000036 00000000 ce097fa8
7fa0: c00329c0 c00e4e94 002da828 002da6e0 00000004 c0cc5616 002da828 00000005
7fc0: 002da828 002da6e0 002da558 00000036 40034160 4002b498 00000000 00000000
7fe0: 00000001 bebff348 4002a55c 4020600c 80000010 00000004 ffffffff ffffffff
[<c03650d8>] (s3c_fimc_i2c_command+0x2c/0x40) from [<c0366fd0>] (s3c_fimc_change_resolution+0x34/0xf4)
[<c0366fd0>] (s3c_fimc_change_resolution+0x34/0xf4) from [<c0365ecc>] (s3c_fimc_v4l2_s_parm+0x44/0x80)
[<c0365ecc>] (s3c_fimc_v4l2_s_parm+0x44/0x80) from [<c02dd814>] (__video_do_ioctl+0x28e8/0x49bc)
[<c02dd814>] (__video_do_ioctl+0x28e8/0x49bc) from [<c02dfda4>] (video_ioctl2+0x144/0x4ac)
[<c02dfda4>] (video_ioctl2+0x144/0x4ac) from [<c02da130>] (v4l2_ioctl+0x40/0x68)
[<c02da130>] (v4l2_ioctl+0x40/0x68) from [<c00e46b8>] (vfs_ioctl+0x30/0x44)
[<c00e46b8>] (vfs_ioctl+0x30/0x44) from [<c00e4980>] (do_vfs_ioctl+0x74/0x57c)
[<c00e4980>] (do_vfs_ioctl+0x74/0x57c) from [<c00e4ec8>] (sys_ioctl+0x40/0x68)
[<c00e4ec8>] (sys_ioctl+0x40/0x68) from [<c00329c0>] (ret_fast_syscall+0x0/0x30)
Code: bad PC value
---[ end trace 31663f2bbbf6916f ]---
: Format............: MJPEG
Segmentation fault
以上就是我在调试过程中,遇到的主要的问题。敬请参考!