iMX6 OpenRex Camera

From Voipac Wiki
Revision as of 16:17, 1 April 2021 by Voipac (talk | contribs)
Jump to navigation Jump to search

This example uses Raspberry Pi Camera Rev 1.3 (build on OV5647 MIPI sensor) as a test device for CSI Interface. On this page OV5647 sensor integration, settings and usage on i.MX6 processors are shown.

Note: There is an issue concerning Raspberry Pi 1.3 cameras and its I2C detected. There might be some camera models that does not get identified.

Device detection

Kernel 4.1

...
camera ov5647_mipi is found
...

Kernel 3.14

...
camera ov5647_mipi is found
mxc_v4l2_master_attach: ipu(0:0)/csi(1:0)/mipi(1:0) doesn't match
mxc_v4l2_master_attach: ipu0:/csi1 mipi attached ov5647_mipi:mxc_v4l2_cap1
ERROR: v4l2 capture: slave not found!
...

I2C detect

CSI connector uses I2C2 to communicate with cameras. OV5647 sensor is located at 0x36 address:

root@imx6-openrex:~# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- UU -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- 
40: UU -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
50: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

GPIO control

GPIO pins are controlled by the camera driver and access to these pins is blocked. Power on signal is recognised as GPIO 74, LED GPIO has number 54.

LED located on camera module can be tested by temporarily disabling mipi kernel module and toggling corresponding GPIO pin:

root@imx6s-openrex:~# modprobe -r ov5647_camera_mipi
root@imx6s-openrex:~# echo 54 > /sys/class/gpio/export
root@imx6s-openrex:~# echo out > /sys/class/gpio/gpio54/direction
root@imx6s-openrex:~# echo 1 > /sys/class/gpio/gpio54/value
root@imx6s-openrex:~# echo 0 > /sys/class/gpio/gpio54/value
root@imx6s-openrex:~# echo 54 > /sys/class/gpio/unexport
root@imx6s-openrex:~# modprobe ov5647_camera_mipi

Modules listing

Kernel 4.1

root@imx6-openrex:~# lsmod
Module                  Size  Used by
mxc_v4l2_capture       27624  2
ipu_bg_overlay_sdc      5385  1 mxc_v4l2_capture
ipu_still               2331  1 mxc_v4l2_capture
ipu_prp_enc             5903  1 mxc_v4l2_capture
ipu_csi_enc             3904  1 mxc_v4l2_capture
ipu_fg_overlay_sdc      6130  1 mxc_v4l2_capture
ov5647_camera_mipi_int    30566  0
adv7610_video           6373  0
v4l2_int_device         2872  4 ov5647_camera_mipi_int,adv7610_video,ipu_csi_enc,mxc_v4l2_capture
mxc_dcic                6528  0

Kernel 3.14

root@imx6s-openrex:~# lsmod
Module                  Size  Used by
mxc_v4l2_capture       28532  1 
ipu_bg_overlay_sdc      5401  1 mxc_v4l2_capture
ipu_still               2528  1 mxc_v4l2_capture
ipu_prp_enc             5943  1 mxc_v4l2_capture
ipu_csi_enc             3863  1 mxc_v4l2_capture
ipu_fg_overlay_sdc      6217  1 mxc_v4l2_capture
ov5647_camera_mipi     30906  0 
v4l2_int_device         2930  2 ov5647_camera_mipi,mxc_v4l2_capture
mxc_dcic                6569  0 
evbug                   1875  0

Resolution setting

1280x960

echo 0 > /sys/bus/i2c/devices/1-0036/ov5647_mode

1280x720

echo 1 > /sys/bus/i2c/devices/1-0036/ov5647_mode

1920x1080

echo 2 > /sys/bus/i2c/devices/1-0036/ov5647_mode

640x480

echo 3 > /sys/bus/i2c/devices/1-0036/ov5647_mode

1024x768 (default)

echo 4 > /sys/bus/i2c/devices/1-0036/ov5647_mode

960x720

echo 5 > /sys/bus/i2c/devices/1-0036/ov5647_mode

640x480 (narrow angle of view)

echo 6 > /sys/bus/i2c/devices/1-0036/ov5647_mode

Gstreamer

Capture single JPEG picture

echo 2 > /sys/bus/i2c/devices/1-0036/ov5647_mode
gst-launch-1.0 v4l2src device="/dev/video1" num-buffers=1 ! video/x-bayer,width=1920,height=1080,framerate=30/1 ! bayer2rgb ! videoconvert ! jpegenc ! filesink location=sample_1920_1080.jpeg

Video preview

echo 2 > /sys/bus/i2c/devices/1-0036/ov5647_mode
gst-launch-1.0 v4l2src device="/dev/video1" ! video/x-bayer,width=1920,height=1080,framerate=30/1 ! queue ! bayer2rgb ! videoconvert ! fbdevsin
echo 3 > /sys/bus/i2c/devices/1-0036/ov5647_mode
gst-launch-1.0 v4l2src device="/dev/video1" ! video/x-bayer,width=640,height=480,framerate=15/1 ! bayer2rgb ! videoconvert ! fbdevsink