BPI-M2+ OV5640 camera linux driver is work fine

[twi2]
twi_used = 0
twi_scl = port:PE12<3><default><default><default>
twi_sda = port:PE13<3><default><default><default

Hi @avaf,

I realize this is a pretty old thread, but I’m also struggling to get OV5640 working on the BPI M2 Zero (running the latest released Raspbian image), and I’ve been having the same error messagea in dmesg as @Flex when I connect the camera to it.

I’m using this particular camera, which should have the right pinout to the CSI connector on the BPI M2 Zero:

Inside of /boot/bananapi/bpi-m2z/linux/sys_config.fex, I see that twi2 is selected for csi0 (vip_dev0_twi_id = 2), and that twi2 is unused:

[twi0] 
twi_used = 1
twi_scl = port:PA11<2><default><default><default>
twi_sda = port:PA12<2><default><default><default>

[twi1]
twi_used = 1
twi_scl = port:PA18<3><default><default><default>
twi_sda = port:PA19<3><default><default><default>

[twi2]
twi_used = 0
twi_scl = port:PE12<3><default><default><default>
twi_sda = port:PE13<3><default><default><default>

Any help with this would be appreciated!

A quick glance at specification and I see two possible problems here, your sensor is MIPI and the pin layout is not reversed. You can search Armbian forum for OV5640, there you find a lengthy thread and lot of information about OV5640.

twi2 is not enabled because CSI interface will be used. MIPI is serial and CSI is parallel.

Купил родную камеру для banana pi zero. Подскажите как заставить ее работать. Именно, не получается установить драйвер. Система Armbian Ubuntu 18.04

Hello friends) I load ov5640 and sun6i_csi modules to /etc/modules of armbian hirsute_edge, restart, but my dmesg no speak about ov5640 or CSI.

root@bananapim2zero:~# dmesg |grep -i csi
 [    1.181583] SCSI subsystem initialized
 [    1.479792] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
root@bananapim2zero:~# dmesg |grep -i 5640
root@bananapim2zero:~# lsmod |grep 5640
 ov5640                 28672  0
 v4l2_fwnode            24576  2 ov5640,sun6i_csi
root@bananapim2zero:~#

How I can see whats happened or may be I can download image with ov5640 supported?

Hello, I’m also struggling with getting a camera module work on banana pi m2 zero.

So I have this module, which I think has reversed pins.

photo1670166224

So I’ve got a reversed flat cable to make pin1 on the camera match pin1 on the board.

photo1670166224%20(1) photo1670166224%20(2)

I’ve added a couple of modules on my /etc/modules

corrado@bananapim2zero:~$ cat /etc/modules
g_serial
sun6i-csi
ov5640

My lsmod

corrado@bananapim2zero:~$ lsmod
Module                  Size  Used by
lz4hc                  16384  0
lz4                    16384  0
snd_soc_hdmi_codec     20480  1
hci_uart               61440  0
brcmfmac              184320  0
btrtl                  24576  1 hci_uart
btbcm                  16384  1 hci_uart
brcmutil               16384  1 brcmfmac
bluetooth             430080  4 btrtl,hci_uart,btbcm
cfg80211              516096  1 brcmfmac
dw_hdmi_i2s_audio      16384  0
ecdh_generic           16384  1 bluetooth
lima                   45056  0
sun9i_hdmi_audio       16384  0
dw_hdmi_cec            16384  0
sun4i_gpadc_iio        16384  0
ecc                    32768  1 ecdh_generic
gpu_sched              28672  1 lima
industrialio           57344  1 sun4i_gpadc_iio
sun8i_thermal          16384  0
rfkill                 20480  5 bluetooth,cfg80211
sunxi_cedrus           40960  0
v4l2_mem2mem           20480  1 sunxi_cedrus
evdev                  20480  0
display_connector      20480  0
uio_pdrv_genirq        20480  0
uio                    16384  1 uio_pdrv_genirq
cpufreq_dt             20480  0
zram                   24576  3
sch_fq_codel           20480  2
ov5640                 28672  0
sun6i_csi              32768  0
videobuf2_dma_contig    20480  2 sunxi_cedrus,sun6i_csi
v4l2_fwnode            24576  2 ov5640,sun6i_csi
v4l2_async             20480  3 ov5640,v4l2_fwnode,sun6i_csi
videobuf2_memops       20480  1 videobuf2_dma_contig
videobuf2_v4l2         20480  3 sunxi_cedrus,sun6i_csi,v4l2_mem2mem
videobuf2_common       45056  6 sunxi_cedrus,videobuf2_dma_contig,sun6i_csi,videobuf2_memops,v4l2_mem2mem,videobuf2_v4l2
usb_f_acm              20480  1
u_serial               24576  3 usb_f_acm
g_serial               16384  0
libcomposite           45056  2 g_serial,usb_f_acm
ramoops                24576  0
sunrpc                327680  1
reed_solomon           16384  1 ramoops
pstore_blk             16384  0
pstore_zone            24576  1 pstore_blk
ip_tables              24576  0
x_tables               28672  1 ip_tables
autofs4                36864  2
pwrseq_simple          16384  1
sunxi                  16384  0
phy_generic            20480  2 sunxi
gpio_keys              20480  0

dmesg | grep -i 5640 is empty.

I have /dev/media0 and /dev/video0 but they seem associated with cedrus.

corrado@bananapim2zero:~$ v4l2-ctl --all
Driver Info:
        Driver name      : cedrus
        Card type        : cedrus
        Bus info         : platform:cedrus
        Driver version   : 5.15.80
        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.80
        Hardware revision: 0x00000000 (0)
        Driver version   : 5.15.80
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': Data, Enabled, Immutable
Priority: 2
Format Video Capture:
        Width/Height      : 16/32
        Pixel Format      : 'ST12' (Sunxi Tiled NV12 Format)
        Field             : None
        Bytes per Line    : 32
        Size Image        : 2048
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
Format Video Output:
        Width/Height      : 16/32
        Pixel Format      : 'MG2S' (MPEG-2 Parsed Slice Data)
        Field             : None
        Bytes per Line    : 0
        Size Image        : 1024
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :

Codec Controls

                   h264_profile 0x00990a6b (menu)   : min=0 max=4 default=2 value=2
                                0: Baseline
                                1: Constrained Baseline
                                2: Main
                                4: High
    hevc_sequence_parameter_set 0x00990cf0 (unknown): type=120 flags=has-payload
     hevc_picture_parameter_set 0x00990cf1 (unknown): type=121 flags=has-payload
          hevc_slice_parameters 0x00990cf2 (unknown): type=122 flags=has-payload
            hevc_scaling_matrix 0x00990cf3 (unknown): type=123 flags=has-payload
         hevc_decode_parameters 0x00990cf4 (unknown): type=124 flags=has-payload
               hevc_decode_mode 0x00990cf7 (menu)   : min=0 max=0 default=0 value=0
                                0: Slice-Based
                hevc_start_code 0x00990cf8 (menu)   : min=0 max=0 default=0 value=0
                                0: No Start Code

Stateless Codec Controls

               h264_decode_mode 0x00a40900 (menu)   : min=0 max=0 default=0 value=0
                                0: Slice-Based
                h264_start_code 0x00a40901 (menu)   : min=0 max=0 default=0 value=0
                                0: No Start Code
    h264_sequence_parameter_set 0x00a40902 (unknown): type=200 flags=has-payload
     h264_picture_parameter_set 0x00a40903 (unknown): type=201 flags=has-payload
            h264_scaling_matrix 0x00a40904 (unknown): type=202 flags=has-payload
   h264_prediction_weight_table 0x00a40905 (unknown): type=205 flags=has-payload
          h264_slice_parameters 0x00a40906 (unknown): type=203 flags=has-payload
         h264_decode_parameters 0x00a40907 (unknown): type=204 flags=has-payload
           vp8_frame_parameters 0x00a409c8 (unknown): type=240 flags=has-payload
         mpeg_2_sequence_header 0x00a409dc (unknown): type=251 flags=has-payload
          mpeg_2_picture_header 0x00a409dd (unknown): type=252 flags=has-payload
   mpeg_2_quantisation_matrices 0x00a409de (unknown): type=250 flags=has-payload

Any help on what I might try next?

I am using stock armbian for bpi-m2zero (unofficial but works)

 ____  ____  _   __  __ ____    _____
| __ )|  _ \(_) |  \/  |___ \  |__  /___ _ __ ___
|  _ \| |_) | | | |\/| | __) |   / // _ \ '__/ _ \
| |_) |  __/| | | |  | |/ __/   / /|  __/ | | (_) |
|____/|_|   |_| |_|  |_|_____| /____\___|_|  \___/

Welcome to Armbian 21.08.1 Focal with Linux 5.15.80-sunxi

No end-user support: community creations

System load:   2%               Up time:       1:25
Memory usage:  22% of 491M      IP:            192.168.0.183
CPU temp:      37°C             Usage of /:    9% of 29G

[ General system configuration (beta): armbian-config ]