5 5
mattday

OV5640 camera with Orange Pi

Recommended Posts

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.

Share this post


Link to post
Share on other sites

I'm able to use both OV5640 and GC2035 on Orange Pi PC Plus v1.1 with ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i

 

I can't seem to get either GC2035 or OV5640 to work on Orange Pi Zero Plus v1.0 H3 with ARMBIAN 5.38 stable Ubuntu 16.04.3 LTS 3.4.113-sun8i 

 

I noticed there's a change in the circuit schematics:

In Orange Pi PC Plus v1.1, CSI-PWR-EN is on PA17

In Orange Pi Zero Plus v1.0, CSI-PWR-EN is on PA8

 

image.thumb.png.47ecb7c13aa96a72e2153cd3a005bffd.png

Share this post


Link to post
Share on other sites
On 6/16/2018 at 2:42 AM, Chen Wang said:

I'm able to use both OV5640 and GC2035 on Orange Pi PC Plus v1.1 with ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i

 

I can't seem to get either GC2035 or OV5640 to work on Orange Pi Zero Plus v1.0 H3 with ARMBIAN 5.38 stable Ubuntu 16.04.3 LTS 3.4.113-sun8i 

 

I noticed there's a change in the circuit schematics:

In Orange Pi PC Plus v1.1, CSI-PWR-EN is on PA17

In Orange Pi Zero Plus v1.0, CSI-PWR-EN is on PA8

 

 

Hi Chen,

 

Can you post your tutorial to use both OV5640 and GC2035 on Orange Pi PC Plus?

Share this post


Link to post
Share on other sites
On 6/12/2018 at 12:51 AM, mostly said:

Faced exactly the same issue. The solution is here: 

 

On my on my Opi Zero plus2 H3 I built v4l2loopback with kernel sources, and now after modprobe I have /dev/video0 Hurraaay.

 

But modprobe --remove vfe_v4l2 is still Segmentation fault, and because of that, it can't even shut down properly :(

 

I tried motion and cheese, neither could read video from /dev/video0 , so I'm stuck again. In motion's log I have this:

[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_get_capability: - READWRITE
[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_get_capability: - STREAMING
[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_select_input: name = "loopback", type 0x00000002, status 00000000
[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_select_input: - CAMERA
[1] [WRN] [VID] [Jun 21 14:45:25] v4l2_select_input: Device doesn't support VIDIOC_G_STD
[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_set_pix_format: Config palette index 17 (YU12) doesn't work.
[1] [NTC] [VID] [Jun 21 14:45:25] v4l2_set_pix_format: Supported palettes:
[1] [ERR] [VID] [Jun 21 14:45:25] v4l2_set_pix_format: Unable to find a compatible palette format.
[1] [NTC] [VID] [Jun 21 14:45:25] vid_v4lx_start: Using V4L1
[1] [NTC] [ALL] [Jun 21 14:45:25] image_ring_resize: Resizing pre_capture buffer to 1 items

The code I'm using for enable:

sudo sunxi-pio -m "PA8<1><0><1><1>"
sudo sunxi-pio -m "PE15<1><0><1><0>"
sudo sunxi-pio -m "PE14<1><0><1><1>"
sudo modprobe gc2035
sudo modprobe vfe_v4l2
sleep 5
sudo modprobe -f v4l2loopback devices=2

@Chen WangHow do you tell if the board is a v1.0 or a v1.1 ? Do you use this code for enabling too, or is it with PA17?

Share this post


Link to post
Share on other sites

Quite after a lot of reading and trying, I checked back my camera module, and found out, that somewhere in the process, I forgot that I have an ov5640, NOT a gc2035.

So I changed fex to

vip_dev1_mname = "ov5640"

reboot

and run

sudo sunxi-pio -m "PA8<1><0><1><1>"
sudo sunxi-pio -m "PE15<1><0><1><0>"
sudo sunxi-pio -m "PE14<1><0><1><1>"
sudo modprobe ov5640 frame_rate=2
sudo modprobe vfe_v4l2
sleep 5
sudo modprobe -f v4l2loopback

And voila, camera is working on my Orange Pi Zero Plus 2 H3. Thank you Armbian, thank you all :)

Share this post


Link to post
Share on other sites

I tried to install ov5640 on orange pi one, 

 

after running 

 

sudo modprobe ov5640 frame_rate=2

sudo modprobe vfe_v4l2

 

then install the https://github.com/avafinger/cap-v4l2

 

i throw this error

 

Quote

./cap 1280 720 4 1 -999 -1 -1
---- cap parameters -----
width: 1280
height: 720
v4l2 buffers: 4
exposure: -999
hflip: -1
vflip: -1
Mode: V4L2_MODE_VIDEO
v4l2: failed to open the camera.

 

Share this post


Link to post
Share on other sites

Ok. This is annoying.  Can someone post working fex file for opi one with ov5640 from official oraneg pi seller on alli. I've changed flat cable to mach pins on opi zero and camera module and nothing still. No /dev/video0 and dmesg gives me an no maching chip found. I've tried and twi reg setups from all the posted fex files and still nothing removed and added AF regs but no /dev/video0. I'm afraid that I've burned camera module because the original flat cable was twisted so it was inverted pins. Pics are attached.

IMG_20180714_113005.jpg

IMG_20180714_113434.jpg

IMG_20180714_113015.jpg

IMG_20180714_113214.jpg

Share this post


Link to post
Share on other sites
2 minutes ago, Vladimir Petrovic said:

Ok. This is annoying.  Can someone post working fex file for opi one with ov5640 from official oraneg pi seller on alli. I've changed flat cable to mach pins on opi zero and camera module and nothing still. No /dev/video0 and dmesg gives me an no maching chip found. I've tried and twi reg setups from all the posted fex files and still nothing removed and added AF regs but no /dev/video0. I'm afraid that I've burned camera module because the original flat cable was twisted so it was inverted pins. Pics are attached.

IMG_20180714_113005.jpgmodule bought from opi alli shop

IMG_20180714_113434.jpginverted cable that maches pins

IMG_20180714_113015.jpgoriginal and twisted cable

IMG_20180714_113214.jpgoriginal cabele not maches the pins on module and opi one

 

Share this post


Link to post
Share on other sites

can you suggest any android image for testing if camera module is not fried? Also i figured out that twi addres does not want to change in bin file made from edited fex. When I write 0x78 in fex it compile to 120 (done bin2fex again on bin file I've created from modified fex)

Share this post


Link to post
Share on other sites

To get OV5640 working for your Allwinner H3 based board:

 

Step 1. Update the fex file

The file is usually located in /boot directory, name could be script.bin or *.bin depends on the os. 

Use bin2fex to convert the bin file to fex file. (If you don't have fex2bin, do "apt install sunxi-tools")

 

the fex file is just a text file, search for "[csi0]", it stands for Camera Serial Interface 0.

if you are using Orange Pi Zero Plus2 H3 board with OV5640 camera, you can use the following setting, if you are using a different board, you need to check the board schematic to make sure the pins(port:Pxnn<n><default><default><default>) defined in the fex file are in line with what's in the schematic(you can refer to my previous post in this thread on where in the schematic to check) and update them accordingly.

twi address(vip_dev0_twi_addr), voltage settings(vip_dev1_iovdd_vol,vip_dev1_avdd_vol,vip_dev1_dvdd_vol,vip_dev1_afvdd_vol) are described in OV5640 datasheet(8.3 DC characteristics https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf). 

 

Once done, use fex2bin to convert the fex file to bin file. Reboot the board to load the updated bin file.

[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 = 120
vip_dev0_isp_used = 0
vip_dev0_fmt = 0
vip_dev0_stby_mode = 0
vip_dev0_vflip = 1
vip_dev0_hflip = 1
vip_dev0_iovdd = ""
vip_dev0_iovdd_vol = 1800000
vip_dev0_avdd = ""
vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = ""
vip_dev0_dvdd_vol = 1500000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 0
vip_dev0_power_en = port:PA08<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
vip_dev1_mname = ""
vip_dev1_pos = "front"
vip_dev1_lane = 1
vip_dev1_twi_id = 0
vip_dev1_twi_addr =
vip_dev1_isp_used = 0
vip_dev1_fmt = 1
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = ""
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = ""
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = ""
vip_dev1_dvdd_vol = 1500000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset =
vip_dev1_pwdn =
vip_dev1_flash_en =
vip_dev1_flash_mode =
vip_dev1_af_pwdn =

 

Step 2. Load the drivers

 

modprobe ov5640
modprobe vfe_v4l2

 

check dmesg, the normal log should look like this:

[   24.397287] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[   35.772109] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[   35.849649] [OV5640@lex]sensor_init 0x0
[   35.897182] [OV5640@lex]CSI_SUBDEV_STBY_ON!
[   35.906344] [OV5640@lex]sensor_s_release_af
[   35.927791] [OV5640@lex]disalbe oe!

At this point you should have a working /dev/video0

 

 

 

Share this post


Link to post
Share on other sites
On 7/18/2018 at 1:14 AM, Chen Wang said:

To get OV5640 working for your Allwinner H3 based board:

 

Step 1. Update the fex file

The file is usually located in /boot directory, name could be script.bin or *.bin depends on the os. 

Use bin2fex to convert the bin file to fex file. (If you don't have fex2bin, do "apt install sunxi-tools")

 

the fex file is just a text file, search for "[csi0]", it stands for Camera Serial Interface 0.

if you are using Orange Pi Zero Plus2 H3 board with OV5640 camera, you can use the following setting, if you are using a different board, you need to check the board schematic to make sure the pins(port:Pxnn<n><default><default><default>) defined in the fex file are in line with what's in the schematic(you can refer to my previous post in this thread on where in the schematic to check) and update them accordingly.

twi address(vip_dev0_twi_addr), voltage settings(vip_dev1_iovdd_vol,vip_dev1_avdd_vol,vip_dev1_dvdd_vol,vip_dev1_afvdd_vol) are described in OV5640 datasheet(8.3 DC characteristics https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf). 

 

Once done, use fex2bin to convert the fex file to bin file. Reboot the board to load the updated bin file.


[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 = 120
vip_dev0_isp_used = 0
vip_dev0_fmt = 0
vip_dev0_stby_mode = 0
vip_dev0_vflip = 1
vip_dev0_hflip = 1
vip_dev0_iovdd = ""
vip_dev0_iovdd_vol = 1800000
vip_dev0_avdd = ""
vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = ""
vip_dev0_dvdd_vol = 1500000
vip_dev0_afvdd = ""
vip_dev0_afvdd_vol = 0
vip_dev0_power_en = port:PA08<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
vip_dev1_mname = ""
vip_dev1_pos = "front"
vip_dev1_lane = 1
vip_dev1_twi_id = 0
vip_dev1_twi_addr =
vip_dev1_isp_used = 0
vip_dev1_fmt = 1
vip_dev1_stby_mode = 0
vip_dev1_vflip = 0
vip_dev1_hflip = 0
vip_dev1_iovdd = ""
vip_dev1_iovdd_vol = 2800000
vip_dev1_avdd = ""
vip_dev1_avdd_vol = 2800000
vip_dev1_dvdd = ""
vip_dev1_dvdd_vol = 1500000
vip_dev1_afvdd = ""
vip_dev1_afvdd_vol = 2800000
vip_dev1_power_en =
vip_dev1_reset =
vip_dev1_pwdn =
vip_dev1_flash_en =
vip_dev1_flash_mode =
vip_dev1_af_pwdn =

 

Step 2. Load the drivers

 

modprobe ov5640
modprobe vfe_v4l2

 

check dmesg, the normal log should look like this:

[   24.397287] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[   35.772109] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[   35.849649] [OV5640@lex]sensor_init 0x0
[   35.897182] [OV5640@lex]CSI_SUBDEV_STBY_ON!
[   35.906344] [OV5640@lex]sensor_s_release_af
[   35.927791] [OV5640@lex]disalbe oe!

At this point you should have a working /dev/video0

 

 

 

 

I am stucked in the dmesg output


[    9.887800] [OV5640@lex]init_sensor - frame_rate: 0, max_win_size: 11
[    9.902103] [OV5640@lex]CSI_SUBDEV_PWR_ON!
[    9.970081] [OV5640@lex]sensor_init 0x0
[    9.970886] [OV5640@lex]sensor read retry=2
[    9.970896] [OV5640@lex]error at sensor_detect
[    9.970904] [OV5640@lex]chip found is not an target chip.
[    9.970914] [OV5640@lex]CSI_SUBDEV_PWR_OFF!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
5 5