Difference between revisions of "DIGILENT MIPI-CSI Camera Set"

From Voipac Wiki
Jump to navigation Jump to search
(Created page with "Category:iMX8M Industrial Development Kit Category:iMX8M Industrial Peripherals <!-- --> <div style="float:right">__TOC__</div> This example uses Raspberry Pi Camera...")
 
Line 8: Line 8:
 
'''''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.
 
'''''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 ==
+
MINISASTOCSI is a MIPI-CSI interface camera kit, based on OmniVision chipset OV5640 Detection, performance and essential commands are described here.
=== Kernel 4.1 ===
+
<br /><br />
 +
[[image:hot-plug.png|400px]]
 +
<br /><br />
 +
[[image:MINISASTOCSI-Voipac-BB.png|800px]]<br />
 +
MINISASTOCSI is a MIPI-CSI interface camera connected to iMX8M Development Baseboard
 +
<br />
 +
 +
== Kernel detection ==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
...
+
root@imx8mq-voipac:~# dmesg | grep ov56
camera ov5647_mipi is found
+
[    2.398433] ov5640_mipi 1-003c: No pin available
...
+
[    2.403090] ov5640_mipi 1-003c: No sensor pwdn pin available
 +
[    2.408777] ov5640_mipi 1-003c: No sensor reset pin available
 +
[    2.414571] ov5640_regulator_enable: cannot get io voltage error - err:-517
 +
[    2.539603] ov5640_mipi 2-003c: No pin available
 +
[    2.549079] ov5640_mipi 2-003c: No sensor reset pin available
 +
[    2.554887] ov5640_regulator_enable: cannot get io voltage error - err:-517
 +
[    2.999855] ov5640_mipi 1-003c: No pin available
 +
[    3.005558] ov5640_mipi 1-003c: No sensor reset pin available
 +
[    3.012003] ov5640_mipi 1-003c: 1-003c supply DVDD not found, using dummy regulator
 +
[    3.019785] ov5640_mipi 1-003c: 1-003c supply AVDD not found, using dummy regulator
 +
[    3.039290] ov5640_mipi 1-003c: Read reg error: reg=300a
 +
[    3.044691] ov5640_mipi 1-003c: Camera is not found
 +
[    3.051918] ov5640_mipi 2-003c: No pin available
 +
[    3.062814] ov5640_mipi 2-003c: No sensor reset pin available
 +
[    3.069209] ov5640_mipi 2-003c: 2-003c supply DVDD not found, using dummy regulator
 +
[    3.076945] ov5640_mipi 2-003c: 2-003c supply AVDD not found, using dummy regulator
 +
[    4.291092] mxc-mipi-csi2_yav 30a70000.mipi_csi: Registered sensor subdevice: ov5640_mipi 2-003c
 +
[    4.304334] ov5640_mipi 2-003c: Camera is found
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Kernel 3.14 ===
+
== I2C detection ==
 +
MINISASTOCSI  camera chip is connected via I2C3. The most important address for correct detection is 0x3c.
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
...
+
root@imx8mq-voipac:~# i2cdetect -y 2
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!
 
...
 
</syntaxhighlight>
 
 
 
== I2C detect ==
 
CSI connector uses I2C2 to communicate with cameras. OV5647 sensor is located at 0x36 address:
 
<syntaxhighlight lang="bash">
 
root@imx6s-tinyrex:~# i2cdetect -y 1
 
 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --  
+
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
+
10: UU UU UU UU -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
+
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- UU -- -- -- 3a -- -- -- -- --  
+
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
+
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
+
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
+
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --  
+
70: -- -- -- -- -- -- -- --
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== GPIO control ==
+
MINISASTOCSI  camera can be also connected to I2C2 interface by moving 0R resistors. However second camera connected on CSI-2 interface have same address 0x3c as MINISASTOCSI  camera connected on CSI-1 interface.
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.<br /><br />
+
[[image:CSI1-I2C2 and I2C3.png|800px]]
 
 
LED located on camera module can be tested by temporarily disabling mipi kernel module and toggling corresponding GPIO pin:
 
<syntaxhighlight lang="bash">
 
root@imx6s-tinyrex:~# modprobe -r ov5647_camera_mipi
 
root@imx6s-tinyrex:~# echo 54 > /sys/class/gpio/export
 
root@imx6s-tinyrex:~# echo out > /sys/class/gpio/gpio54/direction
 
root@imx6s-tinyrex:~# echo 1 > /sys/class/gpio/gpio54/value
 
root@imx6s-tinyrex:~# echo 0 > /sys/class/gpio/gpio54/value
 
root@imx6s-tinyrex:~# echo 54 > /sys/class/gpio/unexport
 
root@imx6s-tinyrex:~# modprobe ov5647_camera_mipi
 
</syntaxhighlight>
 
  
 
== Modules listing ==
 
== Modules listing ==
 
=== Kernel 4.1 ===
 
=== Kernel 4.1 ===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
root@imx6-tinyrexmax:~# lsmod
+
root@imx6-openrex:~# lsmod
 
Module                  Size  Used by
 
Module                  Size  Used by
 
mxc_v4l2_capture      27624  2
 
mxc_v4l2_capture      27624  2
Line 70: Line 73:
 
v4l2_int_device        2872  4 ov5647_camera_mipi_int,adv7610_video,ipu_csi_enc,mxc_v4l2_capture
 
v4l2_int_device        2872  4 ov5647_camera_mipi_int,adv7610_video,ipu_csi_enc,mxc_v4l2_capture
 
mxc_dcic                6528  0
 
mxc_dcic                6528  0
</syntaxhighlight>
 
  
=== Kernel 3.14 ===
+
 
<syntaxhighlight lang="bash">
+
 
root@imx6s-tinyrex:~# lsmod
+
root@imx8mq-voipac:~# lsmod
 
Module                  Size  Used by
 
Module                  Size  Used by
mxc_v4l2_capture      28532 1  
+
crct10dif_ce          16384 1
ipu_bg_overlay_sdc      5401 1 mxc_v4l2_capture
+
mwifiex_pcie          45056 0
ipu_still               2528 1 mxc_v4l2_capture
+
mwifiex               294912 1 mwifiex_pcie
ipu_prp_enc            5943  1 mxc_v4l2_capture
+
galcore              610304 2
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
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 127: Line 124:
 
=== Capture single JPEG picture ===
 
=== Capture single JPEG picture ===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
echo 2 > /sys/bus/i2c/devices/1-0036/ov5647_mode
+
root@imx8mq-voipac:~# gst-launch-1.0 v4l2src num-buffers=1 ! jpegenc ! filesink location=sample_image.jp
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
+
eg
 +
Setting pipeline to PAUSED ...
 +
Pipeline is live and does not need PREROLL ...
 +
Setting pipeline to PLAYING ...
 +
New clock: GstSystemClock
 +
[ 1301.273334] ov5640_mipi 2-003c: s_stream: 1
 +
Got EOS from element "pipeline0".[ 1303.353181] ov5640_mipi 2-003c: s_stream: 0
 +
 
 +
Execution ended after 0:00:02.649996154
 +
Setting pipeline to PAUSED ...
 +
Setting pipeline to READY ...
 +
Setting pipeline to NULL ...
 +
Freeing pipeline ...
 +
root@imx8mq-voipac:~# ls
 +
sample_image.jpeg
 +
root@imx8mq-voipac:~#
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
The image stored in local media with name sample_image.jpeg
  
 
=== Video preview ===
 
=== Video preview ===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
echo 2 > /sys/bus/i2c/devices/1-0036/ov5647_mode
+
root@imx8mq-voipac:~# GST_DEBUG=GST_BUFFER:5 gst-launch-1.0 v4l2src ! 'video/x-raw,framerate=30/1' ! aut
gst-launch-1.0 v4l2src device="/dev/video1" ! video/x-bayer,width=1920,height=1080,framerate=30/1 ! queue ! bayer2rgb ! videoconvert ! fbdevsin
+
ovideosink
</syntaxhighlight>
+
Setting pipeline to PAUSED ...
 
+
Pipeline is live and does not need PREROLL ...
<syntaxhighlight lang="bash">
+
Setting pipeline to PLAYING ...
echo 3 > /sys/bus/i2c/devices/1-0036/ov5647_mode
+
New clock: GstSystemClock
gst-launch-1.0 v4l2src device="/dev/video1" ! video/x-bayer,width=640,height=480,framerate=15/1 ! bayer2rgb ! videoconvert ! fbdevsink
+
0:00:00.842776580  469 0xaaaadc001c00 DEBUG            GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc0623c0 (GstVideoMeta) of size 112
 +
0:00:00.842935198  469 0xaaaadc001c00 DEBUG            GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc062440 (GstVideoMeta) of size 112
 +
0:00:00.843278592  469 0xaaaadc001c00 DEB[ 1415.898001] ov5640_mipi 2-003c: s_stream: 1
 +
UG            GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc0624c0 (GstVideoMeta) of size 112
 +
0:00:00.843338584  469 0xaaaadc001c00 DEBUG            GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc062540 (GstVideoMeta) of size 112
 +
[ 1416.119964] skip frame 1
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
The video stream from camera can be displayed on display/monitor

Revision as of 21:23, 22 July 2022

This example uses Raspberry Pi Camera Rev 1.3 (built on OV5647 MIPI sensor) as a test device for CSI Interface. On this page OV5647 sensor integration, settings and usage on i.MX8M 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.

MINISASTOCSI is a MIPI-CSI interface camera kit, based on OmniVision chipset OV5640 Detection, performance and essential commands are described here.

hot-plug.png

MINISASTOCSI-Voipac-BB.png
MINISASTOCSI is a MIPI-CSI interface camera connected to iMX8M Development Baseboard

Kernel detection

root@imx8mq-voipac:~# dmesg | grep ov56
[    2.398433] ov5640_mipi 1-003c: No pin available
[    2.403090] ov5640_mipi 1-003c: No sensor pwdn pin available
[    2.408777] ov5640_mipi 1-003c: No sensor reset pin available
[    2.414571] ov5640_regulator_enable: cannot get io voltage error - err:-517
[    2.539603] ov5640_mipi 2-003c: No pin available
[    2.549079] ov5640_mipi 2-003c: No sensor reset pin available
[    2.554887] ov5640_regulator_enable: cannot get io voltage error - err:-517
[    2.999855] ov5640_mipi 1-003c: No pin available
[    3.005558] ov5640_mipi 1-003c: No sensor reset pin available
[    3.012003] ov5640_mipi 1-003c: 1-003c supply DVDD not found, using dummy regulator
[    3.019785] ov5640_mipi 1-003c: 1-003c supply AVDD not found, using dummy regulator
[    3.039290] ov5640_mipi 1-003c: Read reg error: reg=300a
[    3.044691] ov5640_mipi 1-003c: Camera is not found
[    3.051918] ov5640_mipi 2-003c: No pin available
[    3.062814] ov5640_mipi 2-003c: No sensor reset pin available
[    3.069209] ov5640_mipi 2-003c: 2-003c supply DVDD not found, using dummy regulator
[    3.076945] ov5640_mipi 2-003c: 2-003c supply AVDD not found, using dummy regulator
[    4.291092] mxc-mipi-csi2_yav 30a70000.mipi_csi: Registered sensor subdevice: ov5640_mipi 2-003c
[    4.304334] ov5640_mipi 2-003c: Camera is found

I2C detection

MINISASTOCSI camera chip is connected via I2C3. The most important address for correct detection is 0x3c.

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

MINISASTOCSI camera can be also connected to I2C2 interface by moving 0R resistors. However second camera connected on CSI-2 interface have same address 0x3c as MINISASTOCSI camera connected on CSI-1 interface. CSI1-I2C2 and I2C3.png

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



root@imx8mq-voipac:~# lsmod
Module                  Size  Used by
crct10dif_ce           16384  1
mwifiex_pcie           45056  0
mwifiex               294912  1 mwifiex_pcie
galcore               610304  2

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

root@imx8mq-voipac:~# gst-launch-1.0 v4l2src num-buffers=1 ! jpegenc ! filesink location=sample_image.jp
eg
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[ 1301.273334] ov5640_mipi 2-003c: s_stream: 1
Got EOS from element "pipeline0".[ 1303.353181] ov5640_mipi 2-003c: s_stream: 0

Execution ended after 0:00:02.649996154
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
root@imx8mq-voipac:~# ls
sample_image.jpeg
root@imx8mq-voipac:~#

The image stored in local media with name sample_image.jpeg

Video preview

root@imx8mq-voipac:~# GST_DEBUG=GST_BUFFER:5 gst-launch-1.0 v4l2src ! 'video/x-raw,framerate=30/1' ! aut
ovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.842776580   469 0xaaaadc001c00 DEBUG             GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc0623c0 (GstVideoMeta) of size 112
0:00:00.842935198   469 0xaaaadc001c00 DEBUG             GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc062440 (GstVideoMeta) of size 112
0:00:00.843278592   469 0xaaaadc001c00 DEB[ 1415.898001] ov5640_mipi 2-003c: s_stream: 1
UG             GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc0624c0 (GstVideoMeta) of size 112
0:00:00.843338584   469 0xaaaadc001c00 DEBUG             GST_BUFFER gstbuffer.c:2279:gst_buffer_add_meta: alloc metadata 0xaaaadc062540 (GstVideoMeta) of size 112
[ 1416.119964] skip frame 1

The video stream from camera can be displayed on display/monitor