設置 | 登錄 | 註冊

目前共有17篇帖子。

瑞芯微RV1106通过MIPI CSI-2 D-PHY接口驱动OV5640摄像头并拍摄照片

11樓 巨大八爪鱼 2025-6-17 18:13

【串口输出】

luckfox login: root
Password:

Login incorrect
luckfox login: root
Password:
[root@luckfox root]#
[root@luckfox root]#
[root@luckfox root]# ls
ov5640  photos
[root@luckfox root]# rm -rf photos
[root@luckfox root]# ls
ov5640
[root@luckfox root]# ./ov5640
interval=1/15
code=0x2006, field=1
Driver: rkcif
Card: rkcif
Bus info: platform:rkcif-mipi-lvds
Version: 330400
VIDIOC_ENUM_FMT start
        1.Y/CbCr 4:2:2
        2.Y/CrCb 4:2:2
        3.Y/CbCr 4:2:0
        4.Y/CrCb 4:2:0
        5.YUYV 4:2:2
        6.YVYU 4:2:2
        7.UYVY 4:2:2
        8.VYUY 4:2:2
VIDIOC_ENUM_FMT end
Size: 2592x1944
Size: 2592x1944
i=0, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=0
i=1, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=101212
16
i=2, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=202424
32
i=3, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=303636
48
i=0, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=1, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=2, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=3, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=4, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=5, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=6, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=7, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=8, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=9, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=10, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=11, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=12, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=13, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=14, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=15, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=16, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=17, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=18, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=19, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=20, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=21, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=22, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=23, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=24, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=25, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=26, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=27, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=28, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=29, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=30, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=31, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=32, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=33, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=34, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=35, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=36, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=37, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=38, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=39, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=40, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=41, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=42, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=43, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=44, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=45, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
i=46, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168
i=47, buf.index=3, buf.length=1, buf.m.planes[0].length=10119168
i=48, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168
i=49, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168
[root@luckfox root]#

 

12樓 巨大八爪鱼 2025-6-17 18:19
照片的采集速度很快,但是板载flash的读写速度很慢。
2592x1944分辨率下,每张bmp照片的大小是14.4MB,保存一张照片到flash上要好几秒。
板载flash空间有限,最多只能采集13张照片(photo0.bmp~photo12.bmp),而且摄像头刚启动时采集的四张照片(photo0~3)是不正确的,从photo4开始才是正确的照片。到最后flash空间满了,photo13.bmp不完整,所以在电脑上无法查看。
13樓 巨大八爪鱼 2025-6-17 18:32

【电路图】

注意13脚MCLK0必须外接24MHz有源晶振,不能用RV1106的I/O口输出的24MHz时钟,否则OV5640 I2C接口无响应。

14樓 巨大八爪鱼 2025-6-17 18:38
16樓 巨大八爪鱼 2025-8-29 17:19

如果启动的是自己的根文件系统,那么要先加载下面的ko模块,才能运行ov5640拍照程序。
insmod /root/test/ov5640/drivers/video_rkcif.ko
insmod /root/test/ov5640/drivers/phy-rockchip-csi2-dphy-hw.ko
insmod /root/test/ov5640/drivers/phy-rockchip-csi2-dphy.ko
echo 1 > /sys/module/video_rkcif/parameters/clr_unready_dev

 

这些驱动文件来自幸狐内核镜像里面生成的output/out/sysdrv_out/kernel_drv_ko文件夹。
加载完这些ko模块,并且执行了echo 1指令后,就会有/dev/video0和/dev/v4l-subdev0这两个设备文件出现。
加载完video_rkcif.ko模块后就会出现/dev/video0设备文件。
执行完echo 1命令后就会出现/dev/v4l-subdev0设备文件。

 

启动ov5640拍照程序后,会有下面的串口打印,不用管。
[   38.503231] mipi-csi2-hw ERR1:0x1000000 (crc,vc: 0)
[   38.503945] mipi-csi2-hw ERR1:0x100 (f_seq,vc: 0)
[   38.570015] rkcif-mipi-lvds: ERROR: csi size err, intstat:0x1000000, size:0x7c50a20,0x0,0x0,0x0, cnt 1

17樓 巨大八爪鱼 2025-8-29 17:32

udhcpc: broadcasting discover

udhcpc: broadcasting select for 192.168.4.57, server 192.168.1.1

udhcpc: lease of 192.168.4.57 obtained from 192.168.1.1, lease time 3600

Setting IP address 192.168.4.57 on wlan0

Deleting routers

route: SIOCDELRT: No such process

Adding router 192.168.1.1

Recreating /etc/resolv.conf

 Adding DNS server 223.5.5.5

 Adding DNS server 114.114.114.114


Please press Enter to activate this console.


Processing /etc/profile... Done


[root@luckfox-rv1106 /]# 29 Aug 09:25:50 ntpdate[117]: step time server 139.199.215.251 offset +146955211.658819 sec

insmod /root/test/ov5640/drivers/video_rkcif.ko

[   20.123480] rkcifhw ffa10000.rkcif: no iommu attached, using non-iommu buffers

[root@luckfox-rv1106 /]# [   20.123509] rkcifhw ffa10000.rkcif: No reserved memory region assign to CIF

[   20.123880] rkcif rkcif-mipi-lvds: rkcif driver version: v00.02.00

[   20.123982] rkcif rkcif-mipi-lvds: attach to cif hw node

[   20.123995] rkcif rkcif-mipi-lvds: failed to get dphy hw node

[   20.124005] rkcif rkcif-mipi-lvds: rkcif wait line 0

[   20.124015] rkcif rkcif-mipi-lvds: rkcif fastboot reserve bufs num 3

[   20.124027] : terminal subdev does not exist

[   20.124039] : terminal subdev does not exist

[   20.124046] : terminal subdev does not exist

[   20.124054] : terminal subdev does not exist

[   20.124063] : get_remote_sensor: video pad[0] is null

[   20.124074] : rkcif_update_sensor_info: stream[0] get remote sensor_sd failed!

[   20.124086] : rkcif_scale_set_fmt: req(80, 60) src out(0, 0)

[   20.124094] : get_remote_sensor: video pad[0] is null

[   20.124101] : rkcif_update_sensor_info: stream[0] get remote sensor_sd failed!

[   20.124109] : rkcif_scale_set_fmt: req(80, 60) src out(0, 0)

[   20.124117] : get_remote_sensor: video pad[0] is null

[   20.124124] : rkcif_update_sensor_info: stream[0] get remote sensor_sd failed!

[   20.124132] : rkcif_scale_set_fmt: req(80, 60) src out(0, 0)

[   20.124139] : get_remote_sensor: video pad[0] is null

[   20.124147] : rkcif_update_sensor_info: stream[0] get remote sensor_sd failed!

[   20.124155] : rkcif_scale_set_fmt: req(80, 60) src out(0, 0)

[   20.125711] rkcif rkcif-mipi-lvds: No memory-region-thunderboot specified

[   20.126707] rockchip-mipi-csi2-hw ffa20000.mipi-csi2-hw: enter mipi csi2 hw probe!

[   20.126870] rockchip-mipi-csi2-hw ffa20000.mipi-csi2-hw: probe success, v4l2_dev:mipi-csi2-hw!

[   20.126978] rockchip-mipi-csi2-hw ffa30000.mipi-csi2-hw: enter mipi csi2 hw probe!

[   20.127100] rockchip-mipi-csi2-hw ffa30000.mipi-csi2-hw: probe success, v4l2_dev:mipi-csi2-hw!

[   20.127445] rockchip-mipi-csi2 mipi0-csi2: attach to csi2 hw node

[   20.127504] rkcif rkcif-mipi-lvds: Entity type for entity rockchip-mipi-csi2 was not initialized!

[   20.127521] rockchip-mipi-csi2: Async registered subdev

[   20.127533] rockchip-mipi-csi2: probe success, v4l2_dev:rkcif-mipi-lvds!


[root@luckfox-rv1106 /]# insmod /root/test/ov5640/drivers/phy-rockchip-csi2-dphy

-hw.ko

[   23.284804] rockchip-csi2-dphy-hw ff3e8000.csi2-dphy-hw: csi2 dphy hw probe successfully!

[root@luckfox-rv1106 /]# insmod /root/test/ov5640/drivers/phy-rockchip-csi2-dphy

.ko

[   25.523068] rockchip-csi2-dphy csi2-dphy0: dphy0 matches ov5640 4-003c:bus type 5

[root@luckfox-rv1106 /]# [   25.523097] rockchip-csi2-dphy csi2-dphy0: csi2 dphy0 probe successfully!


[root@luckfox-rv1106 /]# echo 1 > /sys/module/video_rkcif/parameters/clr_unready

_dev

[   29.449807] rkcif rkcif-mipi-lvds: clear unready subdev num: 1

[root@luckfox-rv1106 /]# [   29.450402] rkcif-mipi-lvds: Async subdev notifier completed


[root@luckfox-rv1106 /]# cd /root/test

[root@luckfox-rv1106 ~/test]# ls

ngroups_max  ov5640

[root@luckfox-rv1106 ~/test]# cd ov5640/

[root@luckfox-rv1106 ~/test/ov5640]# ls

Makefile  bmp.h     drivers   ov5640    ov5640.c  photos2

[root@luckfox-rv1106 ~/test/ov5640]# ./ov5640

interval=1/15

code=0x2006, field=1

[   38.490087] stream_cif_mipi_id0: open video, entity use_countt 1

Driver: rkcif

[   38.490794] cma: cma_alloc: rk-dma-heap-cma: alloc failed, req-size: 2471 pages, ret: -12

Card: rkcif

[   38.490813] vb2_cma_sg_alloc_contiguous: cma_en:1 alloc pages fail

Bus info: platform:rkcif-mipi-lvds

Version: 330400

VIDIOC_ENUM_FMT start

[   38.516456] rkcif-mipi-lvds: stream[0] start streaming

        1.Y/CbCr 4:2:2

[   38.516600] rockchip-mipi-csi2 mipi0-csi2: stream on, src_sd: 822e2933, sd_name:rockchip-csi2-dphy0

        2.Y/CrCb 4:2:2

[   38.516614] rockchip-mipi-csi2 mipi0-csi2: stream ON

        3.Y/CbCr 4:2:0

[   38.516665] rockchip-csi2-dphy0: dphy0, data_rate_mbps 506

        4.Y/CrCb 4:2:0

[   38.516700] rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:1, dphy0, ret 0

        5.YUYV 4:2:2

        6.YVYU 4:2:2

        7.UYVY 4:2:2

        8.VYUY 4:2:2

VIDIOC_ENUM_FMT end

Size: 2592x1944

Size: 2592x1944

i=0, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=0

i=1, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=10121216

i=2, buf.length=1, buf.m.planes[0]=10119168, buf.m.planes[0].m.mem_offset=20242432

i=0, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=1, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=2, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=3, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=4, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

[   38.553498] mipi-csi2-hw ERR1:0x1010 (fs/fe mis,vc: 0) (err_data,vc: 0)

i=5, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

[   39.022789] rkcif-mipi-lvds: ERROR: csi size err, intstat:0x1000000, size:0x8010a20,0x0,0x0,0x0, cnt 1

** 12288 console messages dropped **

i=6, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=7, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=8, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=9, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=10, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=11, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=12, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=13, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=14, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=15, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=16, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=17, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=18, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=19, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=20, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=21, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=22, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=23, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=24, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=25, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=26, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=27, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=28, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=29, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=30, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=31, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=32, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=33, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=34, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=35, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=36, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=37, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=38, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=39, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=40, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=41, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=42, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=43, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=44, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=45, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=46, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

i=47, buf.index=2, buf.length=1, buf.m.planes[0].length=10119168

i=48, buf.index=0, buf.length=1, buf.m.planes[0].length=10119168

i=49, buf.index=1, buf.length=1, buf.m.planes[0].length=10119168

[  114.478528] rkcif-mipi-lvds: stream[0] start stopping, total mode 0x1, cur 0x1

[  114.478564] rkcif-mipi-lvds: get vblank fail, vblank_def 0, vblank_curr 0

[  114.582227] rockchip-mipi-csi2 mipi0-csi2: stream off, src_sd: 822e2933, sd_name:rockchip-csi2-dphy0

[  114.582245] rockchip-mipi-csi2 mipi0-csi2: stream OFF

[root@luckfox-rv1106 ~/test/ov5640]# [  114.582288] rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream_stop stream stop, dphy0

[  114.582305] rockchip-csi2-dphy csi2-dphy0: csi2_dphy_s_stream stream on:0, dphy0, ret 0

[  114.583549] rkcif-mipi-lvds: stream[0] stopping finished, dma_en 0x0

[  114.592130] stream_cif_mipi_id0: close video, entity use_count 0


[root@luckfox-rv1106 ~/test/ov5640]#

18樓 巨大八爪鱼 2025-8-29 17:34

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。