Jump to content
  • 0

OV5640 camera with Orange Pi


mattday
 Share

Question

I have the gc2035 camera working on my Orange Pi One running Armbian, but I need a better image sensor. I've had a quick attempt to get an ov5640 working without any luck. It is a popular 5Mpixel module similar to the RPi camera. I know that 'Sitheek' on the Orange Pi forums had it working. However, that place is a ghost town now and Sitheek has not visited since January. 

 

So, I wonder if anyone here has got an OV5640 camera working, or failing that, could just offer some pointers on how to go about this? Thanks.

Link to comment
Share on other sites

Recommended Posts

Help Armbian team helping you!

  • 0

@Max, your camera module is not being recognized at hardware level.

[    2.984892] [OV5640]error at sensor_detect
[    2.984899] [OV5640]chip found is not an target chip.
To help you, please provide me with the following information:
 
- datasheet of your board containing the camera interface pinout;
- a high resolution photo from the camera conector showing the pins and electrical contacts;
- your /boot/script.bin file or converted to fex already.
Link to comment
Share on other sites

  • 0

The photo is here: https://dl.dropboxusercontent.com/u/18065445/Tmp/nanopi-m1-cam500a.jpg

The pin layout of the board DVP is here: http://www.friendlyarm.com/index.php?route=product/product&product_id=109

The pin of the camera is here: http://www.friendlyarm.com/index.php?route=product/product&product_id=70

There is no /boot/script.bin and no /boot/script.rex 

Link to comment
Share on other sites

  • 0

The photo is here: https://dl.dropboxusercontent.com/u/18065445/Tmp/nanopi-m1-cam500a.jpg

The pin layout of the board DVP is here: http://www.friendlyarm.com/index.php?route=product/product&product_id=109

The pin of the camera is here: http://www.friendlyarm.com/index.php?route=product/product&product_id=70

There is no /boot/script.bin and no /boot/script.rex 

 

Please, refer to this post http://forum.armbian.com/index.php/topic/1213-ov5640-camera-with-orange-pi/?p=12908 if you have some soldering skills and some hardware knowledge , unfortunately not my case so i cannot confirm it worked.

1.move R6 to R5 on cam500 pcb (so making VDDIO 3v, not 1.8V)

 

I would skip the other steps and go with this:

For the script.bin (fex) refer to http://forum.armbian.com/index.php/topic/1213-ov5640-camera-with-orange-pi/?p=9610 and try first with the AF disabled:

vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 

@lvmc has fixed something in vfe for stability that must pass some test before consider it stable.

Link to comment
Share on other sites

  • 0

Thank you for the help. I do not think I can solder that myself.

 

Then it might be better to wait for FriendlyARM's new CAM500B camera module (that should also fit on their next SBC this time based on Allwinner's A64)

 

Enhanced driver for OV5640 and vfe fix are now available on Armbian, thanks to lex and jules!

 

 

A big thank you to all of you that make the use of these camera modules now possible with SBCs and Linux!

Link to comment
Share on other sites

  • 0

Hi,

I have problems with ov5640(CAM500B) and nanopi neo air, there is no video0 under /dev. `modprobe vfe_v4l2` gave no output but when I checked dmesg, I got the following errors

[  180.531978] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[  216.550806] sunxi-pinctrl sunxi-pinctrl: pin already requested
[  216.557336] sunxi-pinctrl sunxi-pinctrl: pin-140 (csi0) status -22
[  216.564310] sunxi-pinctrl sunxi-pinctrl: could not get request pin 140 on device sunxi-pinctrl
[  216.573957] [VFE_ERR]vip0 request pinctrl handle for device [csi0] failed!
[  216.581741] [ISP] isp platform_id = 5!
[  216.602304] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[  216.670045] [OV5640@lex]sensor_init 0x0
[  216.670865] [OV5640@lex]sensor read retry=2
[  216.670876] [OV5640@lex]error at sensor_detect
[  216.670885] [OV5640@lex]chip found is not an target chip.
[  216.670897] [OV5640@lex]CSI_SUBDEV_PWR_OFF!

This can be reproduced on both latest Debian/Ubuntu releases. I've went through this thread and done the followings trying to make it work:

  1. Modify the fex file to enable i2c2 and csi.
  2. Change logic level of the camera module to 3V.
  3. I tried to compile the kernel with latest codes, but no luck :(
  4. I tried to power the board with MP2303 based DCDC converter which is capable of 5V/3A output. And again, I got the same output.

I also checked I2C comms with i2c-tools, it seemed to work(I can read ID register of ov5640).

root@nanopiair:~# i2cset -y 2 0x3c 0x30 0x0a
root@nanopiair:~# i2cget -y 2 0x3c 
0x56
root@nanopiair:~# i2cset -y 2 0x3c 0x30 0x0b
root@nanopiair:~# i2cget -y 2 0x3c 
0x40

I'm out of ideas, any help are appreciated.

Link to comment
Share on other sites

  • 0
  1.  
  2. Change logic level of the camera module to 3V

 

CAM500B should have no need to change logic level according to FA doc.

Can you explain what you have changed? 

 

We known from your iec-tools that  I2C is working and talking to ov5640 but during the sensor init it was not able to use I2C so i think you should not enable I2C session in the fex that will be used by the sensor.

 

Excerpt from fex taken from Banana Pi M2+ that is known to be working (and this should work on NanoPi Air):

[twi_para]
twi_port = 0
twi_scl = port:PA11<2><default><default><default>
twi_sda = port:PA12<2><default><default><default>
[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>

* Note

[csi0]
vip_used = 1
vip_mode = 0
vip_dev_qty = 1
vip_define_sensor_list = 0
vip_csi_pck = port:PE00<2><default><default><default>
vip_csi_mck = port:PE01<2><default><default><default>
vip_csi_hsync = port:PE02<2><default><default><default>
vip_csi_vsync = port:PE03<2><default><default><default>
vip_csi_d0 = port:PE04<2><default><default><default>
vip_csi_d1 = port:PE05<2><default><default><default>
vip_csi_d2 = port:PE06<2><default><default><default>
vip_csi_d3 = port:PE07<2><default><default><default>
vip_csi_d4 = port:PE08<2><default><default><default>
vip_csi_d5 = port:PE09<2><default><default><default>
vip_csi_d6 = port:PE10<2><default><default><default>
vip_csi_d7 = port:PE11<2><default><default><default>
vip_csi_sck = port:PE12<2><default><default><default>
vip_csi_sda = port:PE13<2><default><default><default>


vip_dev0_mname           = "ov5640"
vip_dev0_pos             = "rear"
vip_dev0_lane            = 4
vip_dev0_twi_id          = 2
vip_dev0_twi_addr        = 0x78
vip_dev0_isp_used        = 1
vip_dev0_fmt             = 0
vip_dev0_stby_mode       = 1
vip_dev0_vflip           = 1
vip_dev0_hflip           = 1
vip_dev0_iovdd           = ""
vip_dev0_iovdd_vol       = 2800000
vip_dev0_avdd            = ""
vip_dev0_avdd_vol        = 2800000
vip_dev0_dvdd            = ""
vip_dev0_dvdd_vol        = 1500000
vip_dev0_afvdd           = ""
vip_dev0_afvdd_vol       = 2800000
==>>>> M2+ ====> vip_dev0_power_en        = port:PD14<1><default><default><default>
; ??? *** NanoPi Air *** ??? vip_dev0_power_en        = port:PD14<1><default><default><default>
vip_dev0_reset           = port:PE14<1><default><default><default>
vip_dev0_pwdn            = port:PE15<1><default><default><default>
vip_dev0_flash_en        =
vip_dev0_flash_mode      =
vip_dev0_af_pwdn         =
vip_dev0_act_used = 0
vip_dev0_act_name = "ad5820_act"
vip_dev0_act_slave = 24
Link to comment
Share on other sites

  • 0

 

CAM500B should have no need to change logic level according to FA doc.

Can you explain what you have changed?

I removed the 0 ohm resistor at R6 and solder it to R5, so that the VDDIO of ov5640 is 3V. I've verified this with a multi-meter.

 

 

 

We known from your iec-tools that  I2C is working and talking to ov5640 but during the sensor init it was not able to use I2C so i think you should not enable I2C session in the fex that will be used by the sensor.

Thanks for pointing this out. I think I've blindly enabled I2C2 to make it "work" with CSI... After disabling twi2 in fex, the camera worked! :D

 

Really thanks for your help!!

Link to comment
Share on other sites

  • 0

so I have read this whole thread and also the one at the orangepi forums - Never been so confused...

 

Is it correct that if I want to connect an OV5640 Camera to an Orangepi PC without soldering and massacrating cables,

then I have to get this Extension set from Xunlong with the low-res camera;

https://www.aliexpress.com/item/Orange-Pi-Open-source-IP-Camera-with-wide-angle-lens-Smart-Home-Control-Device-for-PC/32652476606.html

 

remove the 2MP camera, then get a reversing 24 pin flat cable like this:
https://www.aliexpress.com/item/6pcs-24-PIN-200MM-Length-0-5mm-Pitch-FFC-TTL-Ribbon-Flat-Cable-Reverse-Direction-For/32619251538.html
 

and hook this into

Cam500B from FriendlyArm https://www.aliexpress.com/item/CAM500B-High-Definition-Camera-5M-Pixel-2592x1944-image-sizes-support-AFC-AWB-AEC-etc-720P-30fps/32766487392.html

 

Ok so far? Then it is almost like Lego.

Thanks, gnasch
 

Link to comment
Share on other sites

  • 0

Ok so far? Then it is almost like Lego.

 

ROFL... Really, i can't stop laughing.

 

 

Ok, serious now, i will try to answer.

 

* CAM500B works only on FriendlyArm M1/Neo Air boards AFAIK, no need to change anything. CAM500A needs to change logic level to work on M1/Neo Air.

 

* Orange Pi PC/One needs the extention, and you need the pins reversed (OV5640), you can either get a Banana Pi sensor (no need to reverse the pins with this sensor) or use this FPC cable (this might work).

 

* If your board is Banana Pi M2+,M64 you just need their sensor (OV5640).

 

This thread ended with general information about how to use OV5640 on OPI, FA and Banana Pi boards .

 

Thanks for the FPC/FFC cable tip.

 

* Update: Not sure the FFC reversed cable will work since you have to reverse the pins on the output connector!

Link to comment
Share on other sites

  • 0

I have  a nanopiM1 and the CAM500B

I have to make modification in script.bin , my nanopim1.fex part :

#
[csi0]
vip_used = 1
vip_mode = 0
vip_dev_qty = 1
vip_define_sensor_list = 0
vip_csi_pck = port:PE00<2><default><default><default>
vip_csi_mck = port:PE01<2><default><default><default>
vip_csi_hsync = port:PE02<2><default><default><default>
vip_csi_vsync = port:PE03<2><default><default><default>
vip_csi_d0 = port:PE04<2><default><default><default>
vip_csi_d1 = port:PE05<2><default><default><default>
vip_csi_d2 = port:PE06<2><default><default><default>
vip_csi_d3 = port:PE07<2><default><default><default>
vip_csi_d4 = port:PE08<2><default><default><default>
vip_csi_d5 = port:PE09<2><default><default><default>
vip_csi_d6 = port:PE10<2><default><default><default>
vip_csi_d7 = port:PE11<2><default><default><default>
vip_csi_sck = port:PE12<2><default><default><default>
vip_csi_sda = port:PE13<2><default><default><default>

vip_dev0_mname           = "ov5640"
vip_dev0_pos             = "rear"
vip_dev0_lane            = 2
vip_dev0_twi_id          = 2
vip_dev0_twi_addr        = 0x78
vip_dev0_isp_used        = 0
vip_dev0_fmt             = 0
vip_dev0_stby_mode       = 0
vip_dev0_vflip           = 0
vip_dev0_hflip           = 0
vip_dev0_iovdd           = ""
vip_dev0_iovdd_vol       = 2800000
vip_dev0_avdd            = ""
vip_dev0_avdd_vol        = 2800000
vip_dev0_dvdd            = ""
vip_dev0_dvdd_vol        = 1500000
vip_dev0_afvdd           = ""
vip_dev0_afvdd_vol       =
vip_dev0_power_en        =
vip_dev0_reset           = port:PE14<1><default><default><default>
vip_dev0_pwdn            = port:PE15<1><default><default><default>
vip_dev0_flash_en        =
vip_dev0_flash_mode      =
vip_dev0_af_pwdn         =

vip_dev0_act_used        = 0
vip_dev0_act_name        = "ad5820_act"
vip_dev0_act_slave       = 0x18
#FIN camera

then after fex2bin nanopim1.fex script.bin and a reboot, I have a /dev/video0 device

so i take https://github.com/avafinger/guvcview code

and after compilation i have a good image with guvcview :-)

I noticed that xawtv doesn't work

Link to comment
Share on other sites

  • 0

@lex, perfect!

 

Also if someone need custom camera modules with wider lense, send me a PM.

 

Hello @lvmc i think as a new user i can't send you a PM...

 

Can you please give me some information about modules with wider lense for NEO Air? Could be interesting for my project.

 

Thanks

Link to comment
Share on other sites

  • 0

Hello.

 

Is there any way to change focus settings on CAM500B? I can't get clear images fswebcam.

 

Using nanopi neo air with CAM500B and Ubuntu core.

 

:~# v4l2-ctl --list-ctrls

error 25 getting ctrl White Balance, Automatic
error 25 getting ctrl Exposure
error 25 getting ctrl Horizontal Flip
error 25 getting ctrl Vertical Flip
error 25 getting ctrl Color Effects
 
Thanks
Link to comment
Share on other sites

  • 0

@lex, perfect!

 

Also if someone need custom camera modules with wider lense, send me a PM.

 

Can you explain a bit more : I have got a cam for a raspberry pi some years ago and was really disappointed. The fixed focus wide angle lens makes it quiet useless. With the tiny aperture, it is even not granted than the diffraction allow to reach sensor definition on those devices. So is there cam with "real lens" available for direct connection on these boards ?

Link to comment
Share on other sites

  • 0

Blurred and distorted image. Looks like you are handling the module with your hand, this should be a fixed module.

 

CAM500B has Auto Focus support, did you try to check AF with FA image?

Link to comment
Share on other sites

  • 0

AF or not AF?

 

I've tried to take some images with CAM500B to see the AF in action with mid/low light condition.

 

"enhanced" driver (FF)

post-957-0-37270000-1481824455_thumb.jpg

 

BSP driver (AF)

post-957-0-14421400-1481824422_thumb.jpg

 

 

Let's wait for the @pyl 's answer about the blurred image.

Link to comment
Share on other sites

  • 0

That is exactly the problem of AF. FA changed it a bit to trigger Auto Focus on a moving object and on first time you start shooting. You can hear a click when you shoot. (still image).

My understanding is that there is no time enough ( i maybe wrong ) to Focus on the object for still image.

 

You could try this:

* take images with lower res and see if you get better Focus results

* For movies,  try with other res. as well

 

Is there any way to change focus to fixed?

FA image has ov5640 and actuator built-in kernel Image, i don't know if there is a way to unload/disable it, you could try to disable AF changing script.bin section:

[csi0]
vip_used = 1
vip_mode = 0
.
.
.
vip_dev0_afvdd = ""
; vip_dev0_afvdd_vol = 2800000
vip_dev0_afvdd_vol =
.
.
Link to comment
Share on other sites

  • 0

@lex, I can generate the new patch as you need and submit to @Igor.

 

Let's remember that we kept DEBUG enable on the current OV5640 driver patch to facilitate collecting dmesg logs from Armbian users. As soon we collect more positive feedbacks I suggest turning it off again.

Link to comment
Share on other sites

  • 0

Hi, new to this (Have done a few arduino projects.) but trying to build a camera.

For a "Beginner" do you think this would be a passable option? I need good image quality (I have good quality optics, at a fixed focal length, object to be photographed will be at a fixed location each time it is photographed, with mostly fixed lighting conditions) the sample pictures people have been posting leads me to be much more confident in this than the RPi V2 camera (Because of it's funky lens situation) but I don't have a proper basis for comparison and haven't started buying junk to compare directly yet.

Thank you. 

Link to comment
Share on other sites

  • 0

Hi, 

 

 

Sorry for bringing this topic from dead but I have some problems with ov5640. I bought this camera module :  https://www.aliexpress.com/item/OPI-5MP-Camera-OV5640-Auto-zoom-with-wide-angle-lens-for-Orange-Pi-PC-Pi-One/32869355445.html?spm=a2g0s.9042311.0.0.2ac84c4d4jeaqv and I connected it to Orange Pi One. I've isntalled lts 16 image with kernel 3.4.113 and I've loaded ov5640 kernel and vfe_v4l2 modules. I dont get /dev/video0 device and have this otput from kernel.log:

 [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[ISP] isp platform_id = 5!
[OV5640@lex]CSI_SUBDEV_PWR_ON!
[OV5640@lex]sensor_init 0x0
[OV5640@lex]sensor read retry=2
[OV5640@lex]error at sensor_detect
[OV5640@lex]chip found is not an target chip.
[OV5640@lex]CSI_SUBDEV_PWR_OFF!

 

what could be wrong? Do I have to swap R6 and r5 on this board?

Link to comment
Share on other sites

  • 0

Hi,

 

I got a very similar result for the same camera as @Vladimir Petrovic, but with Orange Pi Zero Plus 2 H3 . 

 [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
sensor_remove ov5640 sd = d5126a80!
... similar later ...

 [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
sensor_remove ov5640 sd = d5be42c0!

And some other addresses like that a couple of other times. Maybe while modprobe or reboot.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...