This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: Enable CSI2 for IMX219 (Raspberry PI 2.1 camera)

Part Number: AM625

Hello,

We are trying to enable an IMX219 on CSI2 with an AM625 design.  I am attaching the device tree overlay we have made for it (below).

IMX219 driver loads and we are able to run the example pipeline, but we don't get any frames out of the CSI2 engine.  I have checked that the camera is outputting data using an oscilloscope.  Both data lanes and clock lanes appear to be active (I can only really see the blanking periods, my scope isn't fast enough to see more than noise for the data portions, but it looks like something is there).  I am suspicious that I don't have something correct in the device tree setup, because the cdns_dphy module is not used during the operation of the camera while the gstreamer pipeline is active.  I am wondering if the DHPY part of the CSI2 bridge may not be running (so nothing is getting through).  I am not seeing any errors in dmesg regarding the imx219 (it probes fine and reports in on i2cdetect when not identified to the kernel, no I2C errors communicating with the device).

Any suggestions how to debug this?



root@am62xx-evm:~# gst-launch-1.0 v4l2src device="/dev/video0" ! video/x-raw , width=640, height=480 ! waylandsink &
[1] 1248
root@am62xx-evm:~# [ 36.804536] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[ 36.825108] Bridge firewalling registered
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[ 38.447239] process 'docker/tmp/qemu-check654253808/check' started with executable stack
root@am62xx-evm:~# !gst
gst-launch-1.0 v4l2src device="/dev/video0" ! video/x-raw , width=640, height=480 ! waylandsink &
[1] 1248
root@am62xx-evm:~# [ 36.804536] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[ 36.825108] Bridge firewalling registered
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

root@am62xx-evm:~# lsmod | grep 'csi\|cdns\|dhpy'
cdns_csi2rx 24576 1
j721e_csi2rx 24576 1
videobuf2_dma_contig 24576 8 j721e_csi2rx
videobuf2_v4l2 32768 1 j721e_csi2rx
cdns_dphy 16384 0
v4l2_fwnode 24576 2 imx219,cdns_csi2rx
videobuf2_common 57344 2 j721e_csi2rx,videobuf2_v4l2

// SPDX-License-Identifier: GPL-2.0
/*
 * ALINX AN5641 & Digilent PCam 5C - OV5640 camera module
 * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>

/ {
	fragment@101 {
		target-path = "/";
		__overlay__ {
			clk_imx219_fixed: imx219-xclk {
				compatible = "fixed-clock";
				#clock-cells = <0>;
				clock-frequency = <24000000>;
			};

			cam_supplies: cam_pwr_enables {
				compatible = "regulator-fixed";
				regulator-name = "cam_supplies";
				gpio = <&mcu_gpio0 8 GPIO_ACTIVE_HIGH>;
				enable-active-high;
				startup-delay-us = <100000>;
			};
		};
	};
};

&main_i2c1 {
	#address-cells = <1>;
	#size-cells = <0>;

	/* MIPI Raspberry Pi Camera V2 0x10 */
	imx219_1: imx219_1@10 {
		compatible = "sony,imx219";
		reg = <0x10>;

		clocks = <&clk_imx219_fixed>;
		clock-names = "xclk";

		pinctrl-names = "default";
		pinctrl-0 = <&cam0_pin2_default
					 &cam0_pin1_default>;
		// reset-gpios = <&mcu_gpio0 8 GPIO_ACTIVE_HIGH>;
		// the enable line on the camera enables all the local power supplies.
		VDIG-supply = <&cam_supplies>;
		port {
			csi2_cam0: endpoint {
				remote-endpoint = <&csi2rx0_in_sensor>;
				link-frequencies = /bits/ 64 <456000000>;
				clock-lanes = <0>;
				data-lanes = <1 2>;
			};
		};
	};
};

&ti_csi2rx0 {
	status = "okay";
};

&csi0_port0 {
	status = "okay";

	csi2rx0_in_sensor: endpoint {
		remote-endpoint = <&csi2_cam0>;
		bus-type = <4>; /* CSI2 DPHY. */
		clock-lanes = <0>;
		data-lanes = <1 2>;
	};
};

&dphy0 {
	status = "okay";
};

  • Hello Michael,

    IMX219 is a raw sensor without in-built ISP, and the AM62x doesn't have ISP either, so streaming won't work on AM62x. 

    Regards,

    Jianzhong

  • Thanks Jianzhon,

    We will order a camera supporting processed color output (YUV) such as the OV5640 for testing.

    Do you know if it is possible to capture RAW data from such a sensor to memory (e.g., don't try to run video / route it to display) to support taking a picture and post processing it in the A53 complex?  Or is that use case not supported?

    With regards,

    Mike

  • Hi Mike,

    Yes, it is possible to capture RAW image and store to memory. Below is a test log using IMX219 for your reference:

    root@am62xx-evm:~# v4l2-ctl --list-formats
    ioctl: VIDIOC_ENUM_FMT
            Type: Video Capture
    
            [0]: 'YUYV' (YUYV 4:2:2)
            [1]: 'UYVY' (UYVY 4:2:2)
            [2]: 'YVYU' (YVYU 4:2:2)
            [3]: 'VYUY' (VYUY 4:2:2)
            [4]: 'BA81' (8-bit Bayer BGBG/GRGR)
            [5]: 'GBRG' (8-bit Bayer GBGB/RGRG)
            [6]: 'GRBG' (8-bit Bayer GRGR/BGBG)
            [7]: 'RGGB' (8-bit Bayer RGRG/GBGB)
            [8]: 'BG10' (10-bit Bayer BGBG/GRGR)
            [9]: 'GB10' (10-bit Bayer GBGB/RGRG)
            [10]: 'BA10' (10-bit Bayer GRGR/BGBG)
            [11]: 'RG10' (10-bit Bayer RGRG/GBGB)
            [12]: 'BG12' (12-bit Bayer BGBG/GRGR)
            [13]: 'GB12' (12-bit Bayer GBGB/RGRG)
            [14]: 'BA12' (12-bit Bayer GRGR/BGBG)
            [15]: 'RG12' (12-bit Bayer RGRG/GBGB)
    
    root@am62xx-evm:~# media-ctl -d /dev/media0 --set-v4l2 "'imx219 4-0010':0 [fmt:SRGGB8/3280x2464 field:none]"
    root@am62xx-evm:~# media-ctl -d /dev/media0 -p
    ...
    - entity 13: imx219 4-0010 (1 pad, 1 link, 0 route)
                 type V4L2 subdev subtype Sensor flags 0
                 device node name /dev/v4l-subdev2
            pad0: Source
                    [stream:0 fmt:SRGGB8_1X8/3280x2464 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range
                     crop.bounds:(8,8)/3280x2464
                     crop:(8,8)/3280x2464]
                    -> "cdns_csi2rx.30101000.csi-bridge":0 [ENABLED,IMMUTABLE]
    ...
    
    root@am62xx-evm:~# v4l2-ctl --device /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=RGGB --stream-mmap --stream-to=imx219_10frm.raw --stream-count=10

    Regards,

    Jianzhong

  • Hi Jianzhong,

    I tried the media-ctl command to force SRGGB8 per your line and got the following error:

    root@am62xx-evm:~# media-ctl -d /dev/media0 --set-v4l2 "'imx219 4-0010':0 [fmt:SRGGB8/3280x2464 field:none]"
    Unable to setup formats: Invalid argument (22)

    -Mike

  • Hello Mike,

    Sorry for the delayed response. I was on vacation last week. 

    Are you able to configure the IMX219 format now?

    Thanks,

    Jianzhong

  • Hi Jianzhong,

    Since my last post, we've purchased the Digilent Pvcam that uses the OV5640 (same as the EVK) and the example pipeline provided by TI works for 640x480 resolution.  It doesn't work for any other resolutions, but I don't think it does for the TI EVM board either.  There appears to be a fair amount of activity in the kernel for that media I2C controller.  Our focus is mostly to verify that the prototype hardware is stable.

    Sometime today or tomorrow I will check back on the IMX219 and post a follow up.  We have adjusted a couple of pullup resistors on the I2C bus that might have been the root cause for that problem. 

    Thanks for your help!

    Mike

  • Hi Mike,

    We've validated streaming with higher resolutions when using the OV5640 with TI's AM62x SK EVM. Please refer to the Linux Academy chapter on using camera

    Regards,

    Jianzhong

  • Hi Jianzhong,

    The IMX219 raw capture is working now (I needed to change the I2C bus from 4 to 1 in your example).  I can take pictures and post process them using the command you have provided to set the format as:

    media-ctl -d /dev/media0 --set-v4l2 "'imx219 1-0010':0 [fmt:SRGGB8/3280x2464 field:none]"

    I see your notes on the OV5640, but we are not using the same version of the SDK/kernel and the other resolutions do not work properly.  The results from some of the v4l2 queries don't match, for example, I see:

    root@mitysom-am62x:~# v4l2-ctl -d /dev/v4l-subdev2 --list-subdev-mbus-codes pad=0
    ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=0,stream=0)
    0x4001: MEDIA_BUS_FMT_JPEG_1X8
    0x200f: MEDIA_BUS_FMT_UYVY8_1X16
    0x2011: MEDIA_BUS_FMT_YUYV8_1X16
    0x1017: MEDIA_BUS_FMT_RGB565_1X16
    0x1013: MEDIA_BUS_FMT_BGR888_1X24
    0x3001: MEDIA_BUS_FMT_SBGGR8_1X8
    0x3013: MEDIA_BUS_FMT_SGBRG8_1X8
    0x3002: MEDIA_BUS_FMT_SGRBG8_1X8
    0x3014: MEDIA_BUS_FMT_SRGGB8_1X8

    but on your link, we should expect to see an option for:

    0x2006: MEDIA_BUS_FMT_UYVY8_2X8

    I suspect when we align the SDK's this will resolve.

    I think we can close this issue.

    Thanks for you help!
    Mike

  • Hello Mike,

    Thanks for the update. Glad that your IMX219 raw capture is working. I'll close this thread.

    Regards,

    Jianzhong