ok6410 3.0.1内核调用V4L接口出错,解决方法

    xiaoxiao2025-11-05  9

    最近在做一个远程监控的一套东西,要用到v4l2编码获取摄像头的图像,先介绍一下我所用到的开发环境:

    开发版:ok6410 

    linux操作系统:redhat  

    内核:linux-3.0.1

    摄像头:ZC301P(免驱)

    因为摄像头是免驱的,所以只需要进行引用程序的编写,而不需要进行驱动的编写,但是,运行应用程序时,oops报错如下:

    ./v4l2 v4l2_open id=2 Unable to handle kernel NULL pointer dereference at virtual address 00000060 pgd = cbc08000 [00000060] *pgd=5c7d6831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#2] Modules linked in: CPU: 0 Tainted: G D W (3.0.1 #676) PC is at video_devdata+0x18/0x30 LR is at dev_open+0x28/0x194 pc : [<c0352fbc>] lr : [<c036359c>] psr: 60000013 sp : cc7f5d30 ip : cc7f5d40 fp : cc7f5d3c r10: c081b880 r9 : 00000026 r8 : cc7e78c8 r7 : cc423008 r6 : cc7e78c8 r5 : cc7bc200 r4 : cc423000 r3 : 00000003 r2 : c089e880 r1 : 00000000 r0 : cc7e78c8 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 00c5387d Table: 5bc08008 DAC: 00000015 Process test_usb_camera (pid: 77, stack limit = 0xcc7f4268) Stack: (0xcc7f5d30 to 0xcc7f6000) 5d20: cc7f5d6c cc7f5d40 c036359c c0352fb0 5d40: c0363574 cc423000 cc7bc200 cc7e78c8 cc423008 cc7bc200 00000026 cc127180 5d60: cc7f5d8c cc7f5d70 c035333c c0363580 00000000 00000000 cc721ac0 cc7e78c8 5d80: cc7f5dbc cc7f5d90 c00ef5b0 c0353298 cc7f5e2c cc7f5ed0 00000000 cc7bc200 5da0: 00000000 cc7e78c8 c00ef490 cc127180 cc7f5df4 cc7f5dc0 c00ead14 c00ef49c 5dc0: cc080800 cc40ff00 cc7e78c8 cc7f5ed0 cc7bc200 00000000 cc7bce80 00000802 5de0: 00000026 00000000 cc7f5e1c cc7f5df8 c00eaf50 c00eabb4 cc7bce80 cc7f5e8c 5e00: cc7e78c8 cc7f5ed0 00000000 cc7f5e8c cc7f5e64 cc7f5e20 c00f8488 c00eaef4 5e20: cc7a3005 c088a480 cc7f5e64 cc40ff00 cc080800 cc7e78c8 cc7f5e64 cc7f5ed0 5e40: ffffff9c cc7f5f60 cc7f4000 cc7a3000 cc7f4000 cc7f5e8c cc7f5ec4 cc7f5e68 5e60: c00f992c c00f830c cc7f5e94 00000000 33db2580 00000000 66340397 bee98b70 5e80: 00000068 00000000 00000000 cc40ff00 cc127180 00000000 00000000 00000001 5ea0: cc7f5f60 cc7f5ed0 ffffff9c cc7a3000 cc7f4000 ffffff9c cc7f5f54 cc7f5ec8 5ec0: c00f9d04 c00f9874 00000041 00000000 cc40ff00 cc127180 d9d3cea0 00000006 5ee0: cc7a3005 cc40f820 cc07cc00 cc7e78c8 00000101 00000000 00000000 00000000 5f00: 00000000 00000000 00000004 cc7b50c0 cc7b50c8 cc7b50c4 00000000 cc7f4000 5f20: cc7f5f54 00000803 00000000 00000000 00000001 00000001 00000802 00000000 5f40: 00000004 cc7a3000 cc7f5f94 cc7f5f58 c00eaa78 c00f9cd8 00000000 00000000 5f60: 00000802 00000000 00000026 00000100 00000001 bee98e84 00067ecc 00000005 5f80: c0036ce8 00000000 cc7f5fa4 cc7f5f98 c00eab84 c00ea988 00000000 cc7f5fa8 5fa0: c0036b40 c00eab6c 00000001 bee98e84 000681c8 00000802 00000000 00085c8c 5fc0: 00000001 bee98e84 00067ecc 00000005 bee98d0c 00000000 000874b8 0000000a 5fe0: 00067ed4 bee98be0 000089b4 0001fe4c 40000010 000681c8 00000000 00000000 [<c0352fbc>] (video_devdata+0x18/0x30) from [<c036359c>] (dev_open+0x28/0x194) [<c036359c>] (dev_open+0x28/0x194) from [<c035333c>] (v4l2_open+0xb0/0xd8) [<c035333c>] (v4l2_open+0xb0/0xd8) from [<c00ef5b0>] (chrdev_open+0x120/0x1a4) [<c00ef5b0>] (chrdev_open+0x120/0x1a4) from [<c00ead14>] (__dentry_open+0x16c/0x2c4) [<c00ead14>] (__dentry_open+0x16c/0x2c4) from [<c00eaf50>] (nameidata_to_filp+0x68/0x70) [<c00eaf50>] (nameidata_to_filp+0x68/0x70) from [<c00f8488>] (do_last+0x188/0x6b0) [<c00f8488>] (do_last+0x188/0x6b0) from [<c00f992c>] (path_openat+0xc4/0x3a4) [<c00f992c>] (path_openat+0xc4/0x3a4) from [<c00f9d04>] (do_filp_open+0x38/0x8c) [<c00f9d04>] (do_filp_open+0x38/0x8c) from [<c00eaa78>] (do_sys_open+0xfc/0x1d0) [<c00eaa78>] (do_sys_open+0xfc/0x1d0) from [<c00eab84>] (sys_open+0x24/0x28) [<c00eab84>] (sys_open+0x24/0x28) from [<c0036b40>] (ret_fast_syscall+0x0/0x30) Code: e24cb004 e590200c e5921020 e59f2010 (e5913060) ---[ end trace da227214a82491ba ]--- Segmentation fault这个问题真的困扰了我好久,而且一直以为是我应用程序代码的问题,引用了空的地址指针。

    最后在网上找到了解决方法,真的好棒,是内核代码的问题,具体修改如下:

    进入到内核中:

    1、/include/v4l2-dev.h 中struct v4l2_file_operations 修改为 int (*open) (struct file *) int (*release) (struct file *) 2./driver/media/video/uvc/uvc_v4l2.c中 uvc_v4l2_open(struct inode *inode,struct file *file)函数 和uvc_v4l2_release(struct inode *inode,struct file *file)函数, 改后为: uvc_v4l2_open(struct file *file) uvc_v4l2_release(struct file *file) 3./driver/media/video/v4l2-dev.c v4l2_open()函数下打开文件一行修改为ret = vdev->fops->open(filp) v4l2_release()函数下释放文件一行修改为vdev->fops->release(filp); 然后重新编译内核代码,移植到开发板,再次进行应用程序的运行,成功!!!

    转载请注明原文地址: https://ju.6miu.com/read-1303861.html
    最新回复(0)