IMX6UL CSI: Difference between revisions

From Variscite Wiki
(Add Debian category)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{PageHeader|DART-6UL - Camera}} {{DocImage|category1=DART-6UL|category2=Yocto}} __toc__
{{PageHeader|DART-6UL - Camera}} {{DocImage|category1=Yocto|category2=Debian}}[[category:DART-6UL]] __toc__
= Testing Parallel camera interface =
= Testing Parallel camera interface =
The i.MX6UL/L is capable of handling one parallel camera.<br>
The i.MX6UL/L is capable of handling one parallel camera.<br>
Line 5: Line 5:
— Support 24-bit, 16-bit, 10-bit, and 8-bit input<br>
— Support 24-bit, 16-bit, 10-bit, and 8-bit input<br>
— Support BT.656 interface<br>
— Support BT.656 interface<br>
For more details refer to  https://www.nxp.com/docs/en/reference-manual/IMX6ULRM.pdf Chapter 19. Section.<br>
For more details refer to  https://www.nxp.com/docs/en/reference-manual/IMX6ULRM.pdf Chapter 19, "CMOS Sensor Interface (CSI)".<br>


== Hardware Setup ==
== Hardware Setup ==
Camera VSYNC line is in use on the [https://www.variscite.com/products/single-board-computers/var-6ulcustomboard/ EVK].<br>
The Camera VSYNC line is in use on the [https://www.variscite.com/products/single-board-computers/var-6ulcustomboard/ EVK].<br>
It is used as WDOG Output to force POR and disconnect DEBUG_UART_RTS_B line on Watch Dog event. Allowing boot from external SD card.<br>
It is used as WDOG Output to force POR and disconnect DEBUG_UART_RTS_B line on Watch Dog event, allowing to boot from an external SD card.<br>
We strongly recommend using only RX, TX lines of Debug UART in designs.<br>
We strongly recommend using only the RX & TX lines of the Debug UART in your board design.<br>
* [https://www.variscite.com/products/single-board-computers/var-6ulcustomboard/ EVK] required with C127 capacitor removed (C127 is located near Coin Cell battery connector)
<br>
* [https://www.variscite.com/products/accessories/var-ext-cb6ul/ Camera Adapter Board] is required for the test<br>
Requirements for the Camera test:
* [https://www.variscite.com/products/single-board-computers/var-6ulcustomboard/ EVK] with the C127 capacitor removed (C127 is located near the Coin Cell battery connector)
* [https://www.variscite.com/products/accessories/var-ext-cb6ul/ Camera Adapter Board]


== Software Setup ==
== Software Setup ==
Rocko/Sumo version , requires following device tree changes.<br>
The following device tree patch adds camera support for the DART-6UL:<br>
<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
diff --git a/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi b/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
diff --git a/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi b/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
Line 117: Line 119:
</syntaxhighlight>
</syntaxhighlight>


* Copy above code, and paste to patch file<br>
Follow either the "Customizing the Linux kernel" or "Build the Linux kernel from source code" Wiki pages to build the updated device tree and to copy it to your board.
* Compile the device tree changes as per: {{Varlink|Yocto Customizing the Linux kernel|{{#var:RELEASE_LINK}}|Customizing the Linux kernel}}<br>
* Update your kernel device tree and filesystem as per: * {{Varlink|Yocto NAND Flash Burning|{{#var:RELEASE_LINK}}|Burning Yocto binaries to NAND flash/eMMC via SD card}}<br>


== Camera probe ==
== Camera probe ==
Line 125: Line 125:
If the camera is detected, you should see the below output during bootup:
If the camera is detected, you should see the below output during bootup:
<pre>
<pre>
[    4.346295] udevd[200]: starting udev-3.2.5
[    5.781666] 1-003c supply DOVDD not found, using dummy regulator
[    5.818277] 1-003c supply DVDD not found, using dummy regulator
[    5.873060] 1-003c supply AVDD not found, using dummy regulator
[    7.443605] CSI: Registered sensor subdevice: ov5640 1-003c
[    7.443605] CSI: Registered sensor subdevice: ov5640 1-003c
[    7.447903] camera ov5640, is found
[    7.447903] camera ov5640, is found
</pre>
</pre>
Run the below command to verify the camera was detected successfully:
You can also run the below command to verify the camera was detected successfully:
  # v4l2-ctl --list-devices
  # v4l2-ctl --list-devices


This should output below
The output should look like this:
<pre>
<pre>
i.MX6S_CSI (platform:30710000.csi):
i.MX6S_CSI (platform:30710000.csi):
Line 144: Line 140:


</pre>
</pre>
In the output seen above, "i.MX6S_CSI" is the camera, and "pxp" is the i.MX Pixel Processing Pipeline.
"i.MX6S_CSI" is the camera, and "pxp" is the i.MX Pixel Processing Pipeline.


== i.MX platform specific gstreamer plugins ==
== i.MX platform specific gstreamer plugins ==
Run below command to verify you have the DART-6UL/6ULL platform specific gstreamer plugins installed on your system:
Run the below command to verify you have the i.MX6UL/L platform specific gstreamer plugins installed on your system:
 
<pre>
<pre>
# gst-inspect-1.0  | grep "imx"
# gst-inspect-1.0  | grep "imx"
Line 177: Line 172:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 ! imxpxpvideosink
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 ! imxpxpvideosink


* For 1920x1080@7fps:
* For 1920x1080@7.5fps:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=5 fps-n=15 ! 'video/x-raw,format=UYVY,width=1920,height=1080,framerate=15/1' ! imxpxpvideosink
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=5 fps-n=15 ! imxpxpvideosink


* For 2592x1944
* For 2592x1944@7.5fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=6 fps-n=7 ! 'video/x-raw,format=UYVY,width=2592,height=1944,framerate=7/1' ! imxpxpvideosink
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=6 fps-n=7 ! imxpxpvideosink


== Gstreamer example 2: Taking a JPEG snapshot from the camera ==
== Gstreamer example 2: Taking a JPEG snapshot from the camera ==
To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:
To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:


* For 640x480@30fps:
* For 640x480:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=0 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=0 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
   
   
* For 320x240@30fps:
* For 320x240:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=1 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=1 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


* For 720x480@30fps:
* For 720x480:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=2 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=2 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


* For 720x576@30fps:
* For 720x576:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=3 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=3 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


* For 1280x720@30fps:
* For 1280x720:
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  # gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
* For 1920x1080:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=5 fps-n=15 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
* For 2592x1944:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=6 fps-n=7  num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg


= References =
= References =

Latest revision as of 19:41, 6 June 2023

DART-6UL - Camera

Testing Parallel camera interface

The i.MX6UL/L is capable of handling one parallel camera.
The SOC has one parallel camera port, up to 24 bit and upto 148.5 MHz pixel clock.
— Support 24-bit, 16-bit, 10-bit, and 8-bit input
— Support BT.656 interface
For more details refer to https://www.nxp.com/docs/en/reference-manual/IMX6ULRM.pdf Chapter 19, "CMOS Sensor Interface (CSI)".

Hardware Setup

The Camera VSYNC line is in use on the EVK.
It is used as WDOG Output to force POR and disconnect DEBUG_UART_RTS_B line on Watch Dog event, allowing to boot from an external SD card.
We strongly recommend using only the RX & TX lines of the Debug UART in your board design.

Requirements for the Camera test:

Software Setup

The following device tree patch adds camera support for the DART-6UL:

diff --git a/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi b/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
index f9170af..dbe7530 100644
--- a/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
+++ b/arch/arm/boot/dts/imx6ul-imx6ull-var-dart-common.dtsi
@@ -261,11 +261,7 @@
        xnur-gpio = <&gpio1 3 GPIO_ACTIVE_LOW>;
        measure_delay_time = <0xffff>;
        pre_charge_time = <0xfff>;
-#ifdef WIFI
        status = "disabled";
-#else
-       status = "okay";
-#endif
 };

 /* Console UART */
@@ -291,12 +287,6 @@
        status = "okay";
 };

-&wdog1 {
-       pinctrl-names = "default";
-       pinctrl-0 = <&pinctrl_wdog>;
-       fsl,ext-reset-output;
-};
-
 &usbotg1 {
        dr_mode = "host";
        disable-over-current;
@@ -436,6 +426,26 @@
                touchscreen-inverted-y;
        };

+       ov5640: ov5640@3c {
+               compatible = "ovti,ov5640";
+               reg = <0x3c>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_csi1>;
+               clocks = <&clks IMX6UL_CLK_CSI>;
+               clock-names = "csi_mclk";
+               pwn-gpios = <&gpio1 2 1>;
+               rst-gpios = <&gpio1 1 0>;
+               csi_id = <0>;
+               mclk = <24000000>;
+               mclk_source = <0>;
+               status = "okay";
+               port {
+                       ov5640_ep: endpoint {
+                               remote-endpoint = <&csi1_ep>;
+                       };
+               };
+       };
+
        /* DS1337 RTC module */
        rtc@0x68 {
                compatible = "dallas,ds1337";
@@ -447,6 +457,16 @@
        };
 };

+&csi {
+       status = "okay";
+
+       port {
+               csi1_ep: endpoint {
+                       remote-endpoint = <&ov5640_ep>;
+               };
+       };
+};
+
 &iomuxc {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_hog_1>;
@@ -711,9 +731,22 @@
                        >;
                };

-               pinctrl_wdog: wdoggrp {
+               pinctrl_csi1: csi1grp {
                        fsl,pins = <
-                               MX6UL_PAD_GPIO1_IO08__WDOG1_WDOG_B      0x78b0
+                               MX6UL_PAD_CSI_MCLK__CSI_MCLK            0x1b090
+                               MX6UL_PAD_CSI_PIXCLK__CSI_PIXCLK        0x1b088
+                               MX6UL_PAD_GPIO1_IO08__CSI_VSYNC         0x1b088
+                               MX6UL_PAD_GPIO1_IO09__CSI_HSYNC         0x1b088
+                               MX6UL_PAD_CSI_DATA00__CSI_DATA02        0x1b088
+                               MX6UL_PAD_CSI_DATA01__CSI_DATA03        0x1b088
+                               MX6UL_PAD_CSI_DATA02__CSI_DATA04        0x1b088
+                               MX6UL_PAD_CSI_DATA03__CSI_DATA05        0x1b088
+                               MX6UL_PAD_CSI_DATA04__CSI_DATA06        0x1b088
+                               MX6UL_PAD_CSI_DATA05__CSI_DATA07        0x1b088
+                               MX6UL_PAD_CSI_DATA06__CSI_DATA08        0x1b088
+                               MX6UL_PAD_CSI_DATA07__CSI_DATA09        0x1b088
+                               MX6UL_PAD_GPIO1_IO01__GPIO1_IO01        0x1b0b0
+                               MX6UL_PAD_GPIO1_IO02__GPIO1_IO02        0x1b0b0
                        >;
                };
        };

Follow either the "Customizing the Linux kernel" or "Build the Linux kernel from source code" Wiki pages to build the updated device tree and to copy it to your board.

Camera probe

Make sure the camera is connected, and boot the board.
If the camera is detected, you should see the below output during bootup:

[    7.443605] CSI: Registered sensor subdevice: ov5640 1-003c
[    7.447903] camera ov5640, is found

You can also run the below command to verify the camera was detected successfully:

# v4l2-ctl --list-devices

The output should look like this:

i.MX6S_CSI (platform:30710000.csi):
        /dev/video1

pxp (pxp_v4l2_out):
        /dev/video0

"i.MX6S_CSI" is the camera, and "pxp" is the i.MX Pixel Processing Pipeline.

i.MX platform specific gstreamer plugins

Run the below command to verify you have the i.MX6UL/L platform specific gstreamer plugins installed on your system:

# gst-inspect-1.0  | grep "imx"
imxpxp:  imxpxpvideotransform: Freescale PxP video transform
imxpxp:  imxpxpvideosink: Freescale PxP video sink
imxv4l2videosrc:  imxv4l2videosrc: V4L2 CSI Video Source
imxaudio:  imxmp3audioenc: Freescale i.MX MP3 encoder
imxaudio:  imxuniaudiodec: Freescale i.MX uniaudio decoder

Gstreamer example 1: Testing Camera Loopback / Camera preview on the display

The below pipelines are suitable for the fslc based Yocto releases for the (Yocto Rocko and newer).

  • For 640x480@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=0 ! imxpxpvideosink
  • For 320x240@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=1 ! imxpxpvideosink
  • For 720x480@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=2 ! imxpxpvideosink
  • For 720x576@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=3 ! imxpxpvideosink
  • For 1280x720@30fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 ! imxpxpvideosink
  • For 1920x1080@7.5fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=5 fps-n=15 ! imxpxpvideosink
  • For 2592x1944@7.5fps:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=6 fps-n=7 ! imxpxpvideosink

Gstreamer example 2: Taking a JPEG snapshot from the camera

To capture and encode a JPEG snapshot from the camera, run one of the below pipelines depending on the wanted resolution:

  • For 640x480:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=0 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg

  • For 320x240:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=1 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  • For 720x480:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=2 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  • For 720x576:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=3 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  • For 1280x720:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=4 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  • For 1920x1080:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=5 fps-n=15 num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg
  • For 2592x1944:
# gst-launch-1.0 imxv4l2videosrc device=/dev/video1  imx-capture-mode=6 fps-n=7  num-buffers=1 ! 'video/x-raw,format=UYVY' ! jpegenc ! filesink location=/tmp/test.jpg

References