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 ?