BPI-M2+ OV5640 camera linux driver is work fine

new driver:

Hi,

I use the latest armbian 5.20. I succeed to use an USB webcam on it but I didn’t find any information or help to use a 5640 camera module with it. Do you have some information or link to help me? Thank you

the steps:

  • Edit /etc/modules and add the two line: ov5640 vfe_v4l2

  • Edit script.bin and make sure you have the OV5640 enabled search Armbian for the tools and how to edit it

  • reboot with the sensor attached

  • check if the sensor was recognized: dmesg | grep ov5640 or dmesg | grep OK

  • Always check for updates and fix and latest drivers as Igor has announced: http://image.armbian.com/

Hope it helps.

Thank you for your help Avaf.

I add the module in /etc/modules and I checked that OV5640 was enabled in script.bin.

Unfortunately the sensor is not recognized: no ov5640 in the dmesg log.

I will check for update and fix.

I don’t know if somebody else has already test the camera with armbian on BPi M2+

Oups, my mistake, I miss these 2 messages in dmesg:

[ 5.242088] [OV5640@lex]CSI_SUBDEV_PWR_ON! [ 5.310824] [OV5640@lex]CSI_SUBDEV_PWR_OFF!

I will check why the device is powered off

Hi,

I switch back on this point.

I tried again to make my camera working. So, I load the 2 modules: ov5640 followed by vfe_v4l2

root@ice001:~# sudo modprobe ov5640 root@ice001:~# dmesg [ 76.635959] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11 root@ice001:~#

root@ice001:~# sudo modprobe vfe_v4l2 root@ice001:~# dmesg [ 76.635959] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11 [ 129.559950] [ISP] isp platform_id = 5! [ 129.572122] [OV5640@lex]CSI_SUBDEV_PWR_ON! [ 129.640038] [OV5640@lex]sensor_init 0x0 [ 129.640789] [OV5640@lex]sensor read retry=2 [ 129.640800] [OV5640@lex]error at sensor_detect [ 129.640808] [OV5640@lex]chip found is not an target chip. [ 129.640818] [OV5640@lex]CSI_SUBDEV_PWR_OFF! root@ice001:~#

I use the following ov5640 module:

Any help will be apreciated Thank you BR

You need Sinovoip OV5640 or you need to reverse the pins 180º to make this sensor work.

I tried to reverse the cable, but it seems not possible to simply reverse the cable of my camera. Do you have a simple solution to do it? any idea?

Thanks again for your help.

we ust test our OV5640 module on BPI-M2+

https://bananapi.gitbooks.io/bpi-m2-/content/en/bpim2+csicamerainterface.html

Hi @avaf / @sinovoip,

I am trying to get this camera working, I have both a BPI-M2M and BPI-M2Z and I am trying to get the OV5640 working on either one of them and I get the same error on both: [OV5640]error at sensor_detect

I am using the HDF5640 camera module but I cannot find a pinout of the CSI connector anywhere for these modules, the only pin outs I can find are for the 40-pin connector, not the 24pin found on the M2M and the M2Z.

BPI-M2M-HDF5640-qnt

Above is the board (with camera) and below is the boot log part where I get the error:

[   11.762415] systemd[1]: Started Journal Service.
[   17.350387] EXT4-fs error (device mmcblk0p2): ext4_mb_generate_buddy:741: group 15, 9216 clusters in bitmap, 9179 in gd
[   21.850386] [VFE_DEV_I2C_ERR]cci_read_a16_d8 error! slave = 0x3c, addr = 0x300a, value = 0xd5
[   21.850392]  
[   21.877717] [VFE_DEV_I2C_ERR]cci_read_a16_d8 error! slave = 0x3c, addr = 0x300a, value = 0xd5
[   21.877723]  
[   21.878003] [VFE_DEV_I2C_ERR]cci_read_a16_d8 error! slave = 0x3c, addr = 0x300a, value = 0xd5
[   21.878009]  [OV5640]error at sensor_detect
[   21.912067] ctp_fetch_sysconfig_para: ctp_power_io script_get_item err. 
[   21.912081] ctp_irq gpio number is 37
[   21.916845] [VFE_ERR]vfe sensor register check error at input_num = 0


Ubuntu 16.04.3 LTS bpi-iot-ros-ai ttyS2

bpi-iot-ros-ai login: 

If you have any ideas at all or if you know where I can find a pin diagram for the 24-pin CSI connector I would be incredibly grateful.

Thanks

Flex,

You need a camera sensor with the pins reversed 180 º, like this: pin 1 sensor => pin 24 board, pin 2 sensor => pin 23 board, and so on.

You have two choices:

  • Buy a BPI camera sensor
  • Reverse the pins

This has been extensively discussed here:

Edit: all schematics here: https://drive.google.com/drive/u/0/folders/0B4PAo2nW2KfnflVqbjJGTFlFTTd1b1o1OUxDNk5ackVDM0RNUjBpZ0FQU19SbDk1MngzZWM?tid=0B4PAo2nW2Kfndjh6SW9MS2xKSWs

Hi Avaf,

Thanks for this, the schematics are very useful :slight_smile:

I did read somewhere about reversing the pins and I have tried this but I don’t think its making a decent connection as I get the same error, I have bought some breakout boards and ribbon cable so I can try reversing the pins, once they arrive I will give it another go.

I did try to find some of the BPI camera sensors however unless I wait a month for delivery or pay €30 extra I can’t get them in my country, I was trying to use a sensor that was readily available. With the pins reversed I get the following error:

root@bpi-iot-ros-ai:/home/pi# dmesg | grep -P 'ov564|OV564|VFE'
[ 9.171912] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[ 9.310135] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[ 9.388408] [OV5640@lex]sensor_init 0x0
[ 9.398437] [OV5640@lex]sensor read retry=2
[ 9.407827] [OV5640@lex]error at sensor_detect
[ 9.417251] [OV5640@lex]chip found is not an target chip.
[ 9.427711] [OV5640@lex]CSI_SUBDEV_PWR_OFF!

I assume that means the pins are not making contact properly? (This is on the M2Z)

Thanks for your help.

BPI OV5640 Camera works with M2Z (Armbian by bpi) if i recall correctly, no changes were necessary. I can’t remember if attaching a sensor without the pins reversed could damage the sensor. You have to check if 3.3v was not applied to a pin that should get 2.8v, only you can check this by reading your sensor pinout.

sensor read retry=2 usually means that it could not talk to the sensor via i2c (SDA/CLK), one possibility is TWI2 (you can search if is TW1 or TW2) is in use on your fex. You must not enable it, or are not making contact.

As you could see on that thread, the author did the reversing successfully and i could not do that… :wink:

Ah maybe its TWI thats the problem then?

I’ve just looked in my fex file and it has this:

[twi0]
twi_used = 1
twi_scl = port:PH02<2><default><default><default>
twi_sda = port:PH03<2><default><default><default>

[twi1]
twi_used = 1
twi_scl = port:PH04<2><default><default><default>
twi_sda = port:PH05<2><default><default><default>

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

So should I disable TWI2 or all of them?

Thanks again, your help is much appreciated.

[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 ]