Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

V4l2 device not initializing #6

Open
OlegErmolaev opened this issue Dec 1, 2022 · 9 comments
Open

V4l2 device not initializing #6

OlegErmolaev opened this issue Dec 1, 2022 · 9 comments
Labels
good first issue Good for newcomers

Comments

@OlegErmolaev
Copy link

First of all I initialized media device to be as v4l2 device with the following command:

sudo media-ctl --device /dev/media1 --set-v4l2 '"ov5640 2-003c":0[fmt:YUYV8_2X8/640x480]'

Command succeed, media-ctl has the following output

pi@banana:~$ media-ctl -p -d /dev/media1
Media controller API version 5.10.43

Media device information
------------------------
driver          sun6i-csi
model           Allwinner Video Capture Device
serial          
bus info        platform:1cb0000.camera
hw revision     0x0
driver version  5.10.43

Device topology
- entity 1: sun6i-csi (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
	pad0: Sink
		<- "ov5640 2-003c":0 [ENABLED]

- entity 5: ov5640 2-003c (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev0
	pad0: Source
		[fmt:YUYV8_2X8/640x480@1/30 colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range]
		-> "sun6i-csi":0 [ENABLED]

/dev/video1 also is been created, but unfortunately I can't see device with v4l2-ctl

Due to dmesg I have the register error:

pi@banana:~$ dmesg | grep ov5640
[    7.473763] sun6i-csi 1cb0000.camera: creating ov5640 2-003c:0 -> sun6i-csi:0 link
[    8.069158] ov5640 2-003c: ov5640_read_reg: error: reg=300a
[    8.069175] ov5640 2-003c: ov5640_set_power_on: failed to read chip identifier

Camera seems to be strangely initialized on the bus, without 100% correct address 0x3c

pi@banana:~$ sudo i2cdetect -y 2
     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: -- -- -- -- -- -- -- --       

Finally:

  • what should I try to get image from camera?
  • if I make aptitude update with upgrade the csi device gets out from the bus
@Uiopio
Copy link

Uiopio commented Dec 1, 2022

Ooooh, this is exactly what I was looking for, damn it. Just an incredible problem. Would like to get an answer as soon as possible!!!

@Qengineering
Copy link
Owner

Unfortunately, there are two versions of the OV5640 connector. Since they have 24 pins, they both fit in the camera slot.
However, the pin numbers are reversed. You will get issues like above if you use the wrong connector.
The i2c communication with the sensor fails hence the errors in dmesg.
image

@codingCoffee
Copy link

I'm facing the exact same error, and logs as posted @OlegErmolaev
However, I can confirm that my camera's connector is the 1st type, i.e. 1 --- 24
Also, this seems to be an intermittent error, unable to perfectly reproduce it. Sometimes it works, and most times it throws the errors as mentioned.

@codingCoffee
Copy link

When the camera is working properly these are the results

pi@banana:~$ media-ctl -p -d /dev/media1
Media controller API version 5.10.43

Media device information
------------------------
driver          sun6i-csi
model           Allwinner Video Capture Device
serial
bus info        platform:1cb0000.camera
hw revision     0x0
driver version  5.10.43

Device topology
- entity 1: sun6i-csi (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
        pad0: Sink
                <- "ov5640 2-003c":0 [ENABLED]

- entity 5: ov5640 2-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]

pi@banana:~$ dmesg | grep ov5640
[    7.753658] sun6i-csi 1cb0000.camera: creating ov5640 2-003c:0 -> sun6i-csi:0 link
pi@banana:~$ sudo i2cdetect -y 2
     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: -- -- -- -- -- -- -- --
pi@banana:~$ v4l2-ctl --list-devices
sun6i-csi (platform:camera):
        /dev/video1

cedrus (platform:cedrus):
        /dev/video0

The only difference I've seen in testing is potentially the temprature of the pi (cool when it's working) and the HDMI connection (connected when working). Probably unrelated events, but mentinoing them just the same

@OlegErmolaev
Copy link
Author

Unfortunately, there are two versions of the OV5640 connector. Since they have 24 pins, they both fit in the camera slot. However, the pin numbers are reversed. You will get issues like above if you use the wrong connector. The i2c communication with the sensor fails hence the errors in dmesg. image

Unfortunately it seems to be true and I've wrong type of connector. Will try to get correct camera and type the results

@Qengineering Qengineering added the good first issue Good for newcomers label Apr 3, 2023
@NekoCWD
Copy link

NekoCWD commented Jul 18, 2023

As i know CSI connector is double-sided. Can flip camera connector??

@Qengineering
Copy link
Owner

@NekoCWD,

Be careful!
The connector is not double sided!
On one side you get gold plated copper fingers. On the other side you have a transparent folio carrying the wires (and fingers)

@NekoCWD
Copy link

NekoCWD commented Jul 20, 2023

@Qengineering,
I mean connector on board. It's double sided

@Qengineering
Copy link
Owner

@NekoCWD,

The connector on the PCB is not double sided (just as the cable).
image
The side mounted on the PCB holds the pins. The opposite side has no electrical connections.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants