thanh_tan Posted July 2, 2022 Share Posted July 2, 2022 On 3/15/2021 at 6:41 PM, rreignier said: Hi @rdeyes On an Orange Pi One (which might be close to your Orange Pi PC), I have managed to get the OV5640 thanks to the amazing work of the contributors of this thread. Last time I have tried was on Armbian 20.08.17 with Linux 5.8.16. The device tree overlay I use is this one (you may have to change some pins) : /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; }; &ccu { assigned-clocks = <&ccu 107>; assigned-clock-parents = <&osc24M>; assigned-clock-rates = <24000000>; }; &pio { csi_mclk_pin: csi-mclk-pin { pins = "PE1"; function = "csi"; }; }; &i2c2_pins { bias-pull-up; }; &i2c2 { status = "okay"; ov5640: camera@3c { compatible = "ovti,ov5640"; reg = <0x3c>; pinctrl-names = "default"; pinctrl-0 = <&csi_mclk_pin>; clocks = <&ccu 107>; clock-names = "xclk"; AVDD-supply = <®_vcc_af_csi>; DOVDD-supply = <®_vdd_1v5_csi>; DVDD-supply = <®_vcc_csi>; reset-gpios = <&pio 4 14 1>; /* CSI-RST-R: PE14 */ powerdown-gpios = <&pio 4 15 0>; /* CSI-STBY-R: PE15 */ port { ov5640_ep: endpoint { remote-endpoint = <&csi_ep>; bus-width = <8>; data-shift = <2>; /* lines 9:2 are used */ hsync-active = <1>; /* Active high */ vsync-active = <0>; /* Active low */ data-active = <1>; /* Active high */ pclk-sample = <1>; /* Rising */ }; }; }; }; &csi { status = "okay"; port { #address-cells = <1>; #size-cells = <0>; csi_ep: endpoint { remote-endpoint = <&ov5640_ep>; bus-width = <8>; hsync-active = <1>; /* Active high */ vsync-active = <0>; /* Active low */ data-active = <1>; /* Active high */ pclk-sample = <1>; /* Rising */ }; }; }; To enable it, I use this command: sudo armbian-add-overlay csi-ov5640.dts And then, to take a picture: media-ctl --device /dev/media1 --set-v4l2 '"ov5640 1-003c":0[fmt:JPEG_1X8/1920x1080]' fswebcam -d /dev/video0 -r 1920x1080 -D 0 --jpeg 100 /tmp/test.jpg I hope this can help you and others. Today, i have tried your dts on Orange Pi PC Plus with the camera ov5640. But after reboot there are only the video0 and it is not ov5640, the output of command v4l2-ctl -d /dev/video0 --all show Quote Driver Info: Driver name : cedrus Card type : cedrus Bus info : platform:cedrus Driver version : 5.4.45 Capabilities : 0x84208000 Video Memory-to-Memory Streaming Extended Pix Format Device Capabilities Device Caps : 0x04208000 Video Memory-to-Memory Streaming Extended Pix Format any wrong? 0 Quote Link to comment Share on other sites More sharing options...
Splynncryth Posted October 29, 2022 Share Posted October 29, 2022 First off, thanks to everyone who has figured this all out. Much of this is over my head I think I've nearly got my camera working with Armbian 22.08.6 Jammy on Linux 5.15.69-sunxi which is running on an Orange Pi PC. I've gotten /dev/media1 and /dev/video1 nodes after using the following device tree overlay. It is just a combination of @rreignier's overlay with @gsumner's regulator nodes but I haven't seen anyone post a combined overlay yet so I hope this makes it clear for anyone trying to get this to work on the same platform. /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; }; &ccu { assigned-clocks = <&ccu 107>; assigned-clock-parents = <&osc24M>; assigned-clock-rates = <24000000>; }; &pio { csi_mclk_pin: csi-mclk-pin { pins = "PE1"; function = "csi"; }; }; &i2c2_pins { bias-pull-up; }; &i2c2 { status = "okay"; ov5640: camera@3c { compatible = "ovti,ov5640"; reg = <0x3c>; pinctrl-names = "default"; pinctrl-0 = <&csi_mclk_pin>; clocks = <&ccu 107>; clock-names = "xclk"; AVDD-supply = <®_vcc_af_csi>; DOVDD-supply = <®_vdd_1v5_csi>; DVDD-supply = <®_vcc_csi>; reset-gpios = <&pio 4 14 1>; /* CSI-RST-R: PE14 */ powerdown-gpios = <&pio 4 15 0>; /* CSI-STBY-R: PE15 */ port { ov5640_ep: endpoint { remote-endpoint = <&csi_ep>; bus-width = <8>; data-shift = <2>; /* lines 9:2 are used */ hsync-active = <1>; /* Active high */ vsync-active = <0>; /* Active low */ data-active = <1>; /* Active high */ pclk-sample = <1>; /* Rising */ }; }; }; }; &csi { status = "okay"; port { #address-cells = <1>; #size-cells = <0>; csi_ep: endpoint { remote-endpoint = <&ov5640_ep>; bus-width = <8>; hsync-active = <1>; /* Active high */ vsync-active = <0>; /* Active low */ data-active = <1>; /* Active high */ pclk-sample = <1>; /* Rising */ }; }; }; &{/} { reg_vdd_1v5_csi: vdd-1v5-csi { compatible = "regulator-fixed"; regulator-name = "vdd1v5-csi"; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <1500000>; gpio = <&pio 6 13 0>; /* PG13 */ enable-active-high; regulator-boot-on; regulator-always-on; }; reg_vcc_csi: vcc-csi { compatible = "regulator-fixed"; regulator-name = "vcc-csi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; gpio = <&pio 6 11 0>; /* PG11 */ enable-active-high; regulator-boot-on; regulator-always-on; }; reg_vcc_af_csi: vcc-af-csi { compatible = "regulator-fixed"; regulator-name = "vcc-af-csi"; regulator-min-microvolt = <2800000>; regulator-max-microvolt = <2800000>; gpio = <&pio 0 17 0>; /* PA17 */ enable-active-high; regulator-boot-on; regulator-always-on; }; }; After applying the overlay and rebooting, I can use lsmod to see the camera driver: lsmod | grep "ov5640" ov5640 28672 1 v4l2_fwnode 24576 2 ov5640,sun6i_csi v4l2_async 20480 3 ov5640,v4l2_fwnode,sun6i_csi And I can use the media-ctl command to check the topology: media-ctl --device /dev/media1 --print-topology Media controller API version 5.15.69 Media device information ------------------------ driver sun6i-csi model Allwinner Video Capture Device serial bus info platform:1cb0000.camera hw revision 0x0 driver version 5.15.69 Device topology - entity 1: sun6i-csi (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video1 pad0: Sink <- "ov5640 0-003c":0 [ENABLED] - entity 5: ov5640 0-003c (1 pad, 1 link) type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev0 pad0: Source [fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range] -> "sun6i-csi":0 [ENABLED] However, when I try to use the command to set 1920x1080, it fails: media-ctl --device /dev/media1 --set-v4l2 '"ov5640 1-003c":0[fmt:UYVY8/1920x1080]' Unable to setup formats: Invalid argument (22) I've been staring at the help output for media-ctl but I'm in over my head with this one. I also tried poking around with v4l2-ctl but nothing there seems to be working. Here is the result of a v4l2-ctl --info command: Driver Info: Driver name : cedrus Card type : cedrus Bus info : platform:cedrus Driver version : 5.15.74 Capabilities : 0x84208000 Video Memory-to-Memory Streaming Extended Pix Format Device Capabilities Device Caps : 0x04208000 Video Memory-to-Memory Streaming Extended Pix Format Media Driver Info: Driver name : cedrus Model : cedrus Serial : Bus info : platform:cedrus Media version : 5.15.74 Hardware revision: 0x00000000 (0) Driver version : 5.15.74 Interface Info: ID : 0x0300000c Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : cedrus-source Function : V4L2 I/O Pad 0x01000002 : 0: Source Link 0x02000008: to remote pad 0x1000004 of entity 'cedrus-proc' (Video Decoder): Data, Enabled, Immutable What am I still missing? 0 Quote Link to comment Share on other sites More sharing options...
schunckt Posted August 7, 2023 Share Posted August 7, 2023 Did you ever solve this? Maybe try this: media-ctl --device /dev/media1 --set-v4l2 '"ov5640 1-003c":0[fmt:UYVY8_2X8/1920x1080]' note the _2X8 (I found this while searching for latest DT overlay) T. 0 Quote Link to comment Share on other sites More sharing options...
bschwand Posted January 27 Share Posted January 27 (edited) trying to get the ov5640 camera working on an OrangePiOne. armbianmonitor logs : https://paste.armbian.com/gucenokapa Using this overlay : I get some things working and mostly not at all. What works: the kernel modules load bruno@orangepione2:~$ lsmod | grep ov ov5640 36864 1 v4l2_fwnode 24576 2 ov5640,sun6i_csi v4l2_async 20480 3 ov5640,v4l2_fwnode,sun6i_csi videodev 167936 7 ov5640,sunxi_cedrus,videobuf2_common,sun6i_csi,v4l2_mem2mem,videobuf2_v4l2,v4l2_async mc 40960 8 ov5640,sunxi_cedrus,videobuf2_common,videodev,sun6i_csi,v4l2_mem2mem,videobuf2_v4l2,v4l2_async and the device appears on /dev/video1 I assume this means the camera is accessed through the i2c and detected. I see it on the i2c bus: bruno@orangepione2:~/ustreamer$ cat /sys/class/i2c-dev/i2c-1/device/1-003c/of_node/name camera bruno@orangepione2:~/ustreamer$ ls -l /sys/class/i2c-adapter/ total 0 lrwxrwxrwx 1 root root 0 Jan 1 1970 i2c-0 -> ../../devices/platform/soc/1ee0000.hdmi/i2c-0 lrwxrwxrwx 1 root root 0 Jan 1 1970 i2c-1 -> ../../devices/platform/soc/1c2b400.i2c/i2c-1 bruno@orangepione2:~/ustreamer$ sudo i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- media-ctl sees it bruno@orangepione2:~$ media-ctl -d 1 --print-topology Media controller API version 6.1.63 Media device information ------------------------ driver sun6i-csi model Allwinner A31 CSI Device serial bus info platform:1cb0000.camera hw revision 0x0 driver version 6.1.63 Device topology - entity 1: sun6i-csi (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video1 pad0: Sink <- "ov5640 1-003c":0 [ENABLED] - entity 5: ov5640 1-003c (1 pad, 1 link) type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev0 pad0: Source [fmt:JPEG_1X8/640x480@1/30 colorspace:jpeg xfer:srgb ycbcr:601 quantization:full-range crop.bounds:(0,0)/2624x1964 crop:(0,4)/2624x1944] -> "sun6i-csi":0 [ENABLED] I read https://linux-sunxi.org/CSI so I know the format and size must be selected before grabbing frames this for example works correctly media-ctl --device /dev/media1 --set-v4l2 '"ov5640 1-003c":0[fmt:UYVY8_2X8/640x480@1/30]' (no error after executing that command. and I can then verify it has been selected by running media-ctl and see the pad0 Source has the format changed. Tried many other formats and sizes, they are taken correctly. What does not work: everything else. I can not grab frames with anything. For both ustreamer and ffmpeg I tried many sizes and format, always fails the same way. ffmpeg: bruno@orangepione2:~/ustreamer$ ffmpeg -input_format mjpeg -s 640x480 -i /dev/video1 output.mjpg fmpeg version 5.1.4-0+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --arch=arm --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 [video4linux2,v4l2 @ 0xa36470] ioctl(VIDIOC_G_PARM): Inappropriate ioctl for device [video4linux2,v4l2 @ 0xa36470] Time per frame unknown [video4linux2,v4l2 @ 0xa36470] ioctl(VIDIOC_STREAMON): Broken pipe /dev/video1: Broken pipe ustreamer bruno@orangepione2:~/ustreamer$ ustreamer -d /dev/video1 -r 640x480 -m JPEG -- INFO [14503.025 main] -- Using internal blank placeholder -- INFO [14503.027 main] -- Listening HTTP on [127.0.0.1]:8080 -- INFO [14503.027 stream] -- Using V4L2 device: /dev/video1 -- INFO [14503.028 stream] -- Using desired FPS: 0 -- INFO [14503.028 http] -- Starting HTTP eventloop ... ================================================================================ -- INFO [14503.030 stream] -- Device fd=8 opened -- INFO [14503.030 stream] -- Using input channel: 0 -- INFO [14503.030 stream] -- Using resolution: 640x480 -- INFO [14503.030 stream] -- Using pixelformat: JPEG -- INFO [14503.030 stream] -- Querying HW FPS changing is not supported -- ERROR [14503.030 stream] -- Device does not support setting of HW encoding quality parameters -- INFO [14503.030 stream] -- Using IO method: MMAP -- INFO [14503.035 stream] -- Requested 5 device buffers, got 5 -- ERROR [14503.036 stream] -- Unable to start capturing: Broken pipe -- INFO [14503.038 stream] -- Device fd=8 closed -- INFO [14503.038 stream] -- Sleeping 1 seconds before new stream init ... I built ustreamer from source with debug symbols and stepped with gdb, it fails on device.c:328 if (_D_XIOCTL((enable ? VIDIOC_STREAMON : VIDIOC_STREAMOFF), &type) < 0) { which is, afaik, when the video device is opened for grabbing frames. Something else that is very strange, trying to list camera controls returns empty bruno@orangepione2:~$ v4l2-ctl -d 1 --list-ctrls bruno@orangepione2:~$ however using yavta on the video subdevice retrieves controls bruno@orangepione2:~$ yavta --no-query -l /dev/v4l-subdev0 Device /dev/v4l-subdev0 opened. --- User Controls (class 0x00980001) --- control 0x00980901 `Contrast' min 0 max 255 step 1 default 0 current 0 control 0x00980902 `Saturation' min 0 max 255 step 1 default 64 current 64 control 0x00980903 `Hue' min 0 max 359 step 1 default 0 current 0 control 0x0098090c `White Balance, Automatic' min 0 max 1 step 1 default 1 current 1 control 0x0098090e `Red Balance' min 0 max 4095 step 1 default 0 current 0 control 0x0098090f `Blue Balance' min 0 max 4095 step 1 default 0 current 0 control 0x00980911 `Exposure' min 0 max 65535 step 1 default 0 current 0 control 0x00980912 `Gain, Automatic' min 0 max 1 step 1 default 1 current 1 control 0x00980914 `Horizontal Flip' min 0 max 1 step 1 default 0 current 0 control 0x00980915 `Vertical Flip' min 0 max 1 step 1 default 0 current 0 control 0x00980918 `Power Line Frequency' min 0 max 3 step 1 default 1 current 1 0: Disabled 1: 50 Hz (*) 2: 60 Hz 3: Auto --- Camera Controls (class 0x009a0001) --- control 0x009a0901 `Auto Exposure' min 0 max 1 step 1 default 0 current 0 0: Auto Mode (*) 1: Manual Mode control 0x009a090c `Focus, Automatic Continuous' min 0 max 1 step 1 default 0 current 0 control 0x009a091c `Auto Focus, Start' min 0 max 0 step 0 default 0 control 0x009a091d `Auto Focus, Stop' min 0 max 0 step 0 default 0 control 0x009a091e `Auto Focus, Status' min 0 max 7 step 0 default 0 current 0x00000000 --- Image Source Controls (class 0x009e0001) --- control 0x009e0901 `Vertical Blanking' min 24 max 2895 step 1 default 600 current 600 control 0x009e0902 `Horizontal Blanking' min 1256 max 1256 step 1 default 1256 current 1256 control 0x009e0903 `Analogue Gain' min 0 max 1023 step 1 default 0 current 0 --- Image Processing Controls (class 0x009f0001) --- control 0x009f0901 `Link Frequency' min 0 max 22 step 1 default 13 current 13 0: 992000000 1: 888000000 2: 768000000 3: 744000000 4: 672000000 5: 672000000 6: 592000000 7: 592000000 8: 576000000 9: 576000000 10: 496000000 11: 496000000 12: 384000000 13: 384000000 (*) 14: 384000000 15: 336000000 16: 296000000 17: 288000000 18: 248000000 19: 192000000 20: 192000000 21: 192000000 22: 96000000 control 0x009f0902 `Pixel Rate' min 48000000 max 168000000 step 1 default 48000000 current 48000000 control 0x009f0903 `Test Pattern' min 0 max 4 step 1 default 0 current 0 0: Disabled (*) 1: Color bars 2: Color bars w/ rolling bar 3: Color squares 4: Color squares w/ rolling bar 22 controls found. something else that is bothersome: the adapter board for the ov5640 has one component that reaches 90 degrees (c) constantly... not sure it should be that hot all the time ! this is starting to irritate me as it seems everything is configured correctly... grr. Any suggestions ? Edited January 27 by bschwand add more information 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.