avafinger / ov5640

Improved OV5640 for Orange Pi (H3) / Nano Pi (H3) / Banana Pi M64 / Pine64+ / Nano Pi M2/M3 (Experimental)
28 stars 15 forks source link

ov5640_read_reg: error: reg=300a #6

Open chdwjzd opened 3 years ago

chdwjzd commented 3 years ago

I try to Enable OV5640 on Banana Pi M64 too;used armbian with kernel 5.10; but when kernel start OV5640 has an error

[ 6.771712] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Mar 30 2016 11:30:56 version 7.45.77.h8.4 FWID 01-ee8a6268 [ 7.185164] ov5640 1-003c: ov5640_read_reg: error: reg=300a [ 7.185180] ov5640 1-003c: ov5640_set_power_on: failed to read chip identifier [ 7.904788] Adding 985724k swap on /dev/zram0. Priority:5 extents:1 across:985724k SSFS [ 9.133355] zram1: detected capacity change from 0 to 52428800

I added this to sun50i-a64-bananapi-m64.dts:

`i2c-csi { compatible = "i2c-gpio"; sda-gpios = <&pio 4 13 GPIO_ACTIVE_HIGH>; / PE13 / scl-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; / PE12 / i2c-gpio,delay-us = <5>;

address-cells = <1>;

    #size-cells = <0>;
    ov5640: camera@3c {
        compatible = "ovti,ov5640";
        reg = <0x3c>;
        pinctrl-names = "default";
        pinctrl-0 = <&csi_mclk_pin>;
        clocks = <&ccu CLK_CSI_MCLK>;
        clock-names = "xclk";
        AVDD-supply = <&reg_dldo3>;
        DOVDD-supply = <&reg_aldo1>;
        DVDD-supply = <&reg_eldo3>;
        reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* PE16 */
        powerdown-gpios = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* PE17 */
        port {
            ov5640_ep: endpoint {
                remote-endpoint = <&csi_ep>;
                bus-width = <8>;
                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 */
    };
};

};`

and according to your answer in armbian I try to change I2C to:

sda-gpios = <&pio 4 13 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP)>; /* CSI0-SDA: PE13 */ [scl-gpios = <&pio 4 12 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP)>; /* CSI0-SCK: PE12 */

but the result is the same

I just check my I2C setting,it seems right root@bananapim64:~# lsmod|grep ov ov5640 28672 1 v4l2_fwnode 24576 2 ov5640,sun6i_csi videodev 233472 9 sunxi_cedrus,sun8i_rotate,v4l2_fwnode,ov5640,videobuf2_v4l2,sun8i_di,sun6i_csi,videobuf2_common,v4l2_mem2mem mc 49152 7 sunxi_cedrus,videodev,ov5640,videobuf2_v4l2,sun6i_csi,videobuf2_common,v4l2_mem2mem

root@bananapim64:~# dmesg | grep sun6i-csi [ 5.985118] sun6i-csi 1cb0000.csi: creating ov5640 1-003c:0 -> sun6i-csi:0 link root@bananapim64:~#

I don't know how to solve this problem, can you help me, thank you

avafinger commented 3 years ago

You need to enable:

CONFIG_I2C_GPIO=m

The message:

[ 7.185164] ov5640 1-003c: ov5640_read_reg: error: reg=300a is an indication you can't talk to the sensor, which could be: a) I2C_GPIO not enabled in your running kernel (get the config from the running kernel) b) Your ov5640 sensor must be the BPI sensor only, any other sensor will certainly fail with this message

chdwjzd commented 3 years ago

I check my I2C setting, it seems right

root@feiji:~# cat /boot/config- 'uname -r' | grep I2C | grep GPIO CONFIG_I2C_ARB_GPIO_CHALLENGE=m CONFIG_I2C_MUX_GPIO=m CONFIG_I2C_CBUS_GPIO=m CONFIG_I2C_GPIO=m

My OV5640 is not BPI sensor, I just bought an BPI official one last night and will test it later.

Can you please tell me what difference between Normal OV5640 and BPI OV5640?

Thanks a lot

avafinger commented 3 years ago

t difference between Normal OV5640 and BPI OV5640?

The pinouts are reversed 180º. Pin 1 is pin 16, Pin 2 is pin 15, and so on. (in a 16 pin example)

chdwjzd commented 3 years ago

Thank you very much. Since use BPI OV5640 I can open the cap but still can't take a picture with openCV, but I need to used openCV on my project. I will try your project: https://github.com/avafinger/cap-v4l2 Can it work in kernel 5.10?

avafinger commented 3 years ago

Unfortunately no, this will not work. Only for BSP now. I will try to update for mainline kernel this weekend.

avafinger commented 3 years ago

@chdwjzd In order to work with a v4l2 compliant app, you need to configure the sensor first, just like here: https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal#working-with-cameras

chdwjzd commented 3 years ago

I just do some change on your code form https://github.com/avafinger/cap-v4l2 And success get a picture in kernel 5.10 It's basically no problem, but some code written in C language will have problems when compiled with C + +, so I modified it briefly. In build_script_A64.sh : 4,I changed gcc to g++ In cap.c I add return 0; to v4l2_display_pix_format and v4l2_close_camera , changed fd = open("/dev/video0", O_RDWR | O_NONBLOCK); to fd = open("/dev/video2", O_RDWR | O_NONBLOCK); because in my system

root@feiji:/usr/cap_test/cap-v4l2# v4l2-ctl --list-devices cedrus (platform:cedrus): /dev/video1

sun6i-csi (platform:csi): /dev/video2

sun8i-di (platform:sun8i-di): /dev/video3

sun8i-rotate (platform:sun8i-rotate): /dev/video0

Thank you again , your work help me a lot And I will try to use camera on H6 ,because A64 performance may not be enough on my project