CPHY does not work using gst-launch (but works with v4l2)

On our custom board, DPHY mode works well.
sensor ==> max96717 ==>max96712 ==>DPHY==> orin
both v4l2-ctl and gst-launch are ok

Using CPHY mode, i edited csi5_fops.c
lane_polarity for lane 1 was changed to NVCSI_CPHY_POLARITY_CAB

To receive image

  1. using v4l2-ctl command is ok and image(raw12) can be saved and checked with 7yuv

root@orin1-desktop:/home/orin1/debugc# v4l2-ctl --set-fmt-video=width=3840,height=2160,pixelformat=BA12 --set-ctrl bypass_mode=0 --stream-mmap -d /dev/video0

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.98 fps
<<<<<<<^C

trace_ok.log (307.7 KB)

  1. using gst-launch, we are not able to receive image

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! ‘video/x-raw(memory:NVMM), width=3840, height=2160, format=(string)NV12, framerate=(fraction)29/1’ ! nv3dsink -e

trace_no_ok.log (2.1 MB)

it seems that, using v4l2, intr_cphy_edge_delay_cal_done_trio0_a bit was set after calibration
but using gst-launch(argus), no calibration was done in trace

device tree for camera below
camera.dtsi (25.4 KB)

i found that, T_HS settle can be set by setting cil_settletime in device tree

using v4l2-ctl, if cil_settletime is not set, auto calibration will be done
and T_HS settle and T_CLK settle will be auto calculated in RCE

but for gst-launch, these two values seem not to be calculated in trace

hello chenghao.shen,

do you also apply kernel patch to configure CPHY mode by device tree instead of hardcode values.
for example, Orin receives the MIPI C-PHY signal output by serdes

you may also review device tree property, cil_settletime. it’s the parameter related to PREAMBLE.
please tune the value for testing.

hi Jerry,

i have noticed the problem in csi5_fops.c. And have patched the kernel myself. See below

    bool is_cphy = (csi_lanes == 3);

/* Brick config */
memset(&brick_config, 0, sizeof(brick_config));
if (is_cphy) {
	brick_config.phy_mode = NVCSI_PHY_TYPE_CPHY;
	brick_config.lane_polarity[1] = NVCSI_CPHY_POLARITY_CAB;
	brick_config.lane_polarity[3] = NVCSI_CPHY_POLARITY_CAB;
} else {
	brick_config.phy_mode = NVCSI_PHY_TYPE_DPHY;
}

Thus, using v4l2-ctl is ok.
Now problem is using gst-launch(argus) does not work

Hi Jerry,
is there any other suggestions?

As i said

using v4l2-ctl, if cil_settletime is not set, auto calibration will be done. T_HS settle and T_CLK settle will be auto calculated in RCE and canbe seen in trace. So v4l2 is ok.
using gst-launch(with argus) T_HS settle and T_CLK settle may not be automatically set by RCE. Especially for T_CLK settle, there is even no way to edit it.

hello chenghao.shen,

I’m not certain the root cause at the monent.
however, please try applying this scf pre-built for a quick testing.
i.e. r3521_deskew_libnvscf.7z (1.6 MB)

Hi Jerry,
as far as i know, deskew is only for DPHY to calirabtion skew between lanes.
is it also valid for CPHY?

hello chenghao.shen,

that’s correct deskew is only for DPHY to calibration skew between lanes.
but… could you please have a quick test? since there’s also fixes to revise the init sequence.

should i also use L4T 35.2.1 first?
The L4T version i use now is 35.1.
Replacing the shared lib /usr/lib/aarch64-linux-gnu/tegra/libnvscf.so with the attachment you gave will cause “undefined symbol” problem

Hi,
Please upgrade to Jetpack 5.1(r35.2.1) and try. There are fixes between the two releases and we would suggest use the latest release.

Hi Danel,

After upgrading to 35.2.1 and replacing libnvscf.so with the attachment, the problem remains the same. For cphy mode,
V4l2-ctl is OK.
gst-launch still does not work. Trace below

kworker/10:2-157     [010] ....   178.331496: rtcpu_nvcsi_intr: tstamp:8895283191 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:1 st:0 vc:0 status:0x00000080
kworker/10:2-157     [010] ....   178.331496: rtcpu_nvcsi_intr: tstamp:8895283999 class:GLOBAL type:PHY_INTR0 phy:0 cil:0 st:0 vc:0 status:0x00000080
kworker/10:2-157     [010] ....   178.331496: rtcpu_nvcsi_intr: tstamp:8895283999 class:GLOBAL type:PHY_INTR0 phy:0 cil:1 st:0 vc:0 status:0x00000080
kworker/10:2-157     [010] ....   178.331497: rtcpu_nvcsi_intr: tstamp:8895283999 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:0 st:0 vc:0 status:0x00000080
kworker/10:2-157     [010] ....   178.331497: rtcpu_nvcsi_intr: tstamp:8895283999 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:1 st:0 vc:0 status:0x00000080
kworker/10:2-157     [010] ....   178.331499: rtcpu_string: tstamp:8895285047 id:0x04010000 str:"BUG: core/watchdog/heartbeat-task.c:162 [heartbe"
kworker/10:2-157     [010] ....   178.331501: rtcpu_string: tstamp:8895285149 id:0x04010000 str:"at_halt_execution] ""
kworker/10:2-157     [010] ....   178.331502: rtcpu_string: tstamp:8895289435 id:0x04010000 str:"*** RCE WATCHDOG FAILURE: HALTING ***"

Is the debug rce-fw for 35.1 still valid for 35.2.1? Without debug fw, no info about the cil clk/hs settel time was printed.

Hi,
Please try to enable nvargus-daemon log and check what error is reported:
Jetson/l4t/Camera BringUp - eLinux.org

Ideally we would like to fit firmware version with the release.

Hi,

nvargus-daemon log is as follows. this kill & restart ops was always done.

=== gst-launch-1.0[2473]: Connection established (FFFF827A5900)OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module1
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module2
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: Found override file [/var/nvidia/nvcam/settings/ar0820_bottom_0070.isp]. ----
CAM: serial no file already exists, skips storing again---- imager: Found override file [/var/nvidia/nvcam/settings/ar0820_top_0030.isp]. ----
CAM: serial no file already exists, skips storing again---- imager: No override file found. ----
(NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
(NvCamV4l2) Error ModuleNotPresent: (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
(NvOdmDevice) Error ModuleNotPresent: (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclDriver_V4L2_Focuser_Stub_Close: Invalid NULL input pPclDriver
NvPclStateControllerOpen: Failed ImagerGUID 2. (error 0xA000E)
NvPclOpen: PCL Open Failed. Error: 0xf
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 677)
SCF: Error BadParameter: (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 453)
SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 333)
SCF: Error BadParameter: (propagating from src/api/CameraDriver.cpp, function getSource(), line 505)
=== gst-launch-1.0[2473]: CameraProvider initialized (0xffff7c6950f0)SCF: Error BadValue: NvPHSSendThroughputHints (in src/common/CameraPowerHint.cpp, function sendCameraPowerHint(), line 56)
root@tnt:/home/tnt/debugc# SCF: Error Timeout: (propagating from src/services/capture/FusaCaptureViCsiHw.cpp, function waitCsiFrameEnd(), line 617)
SCF: Error Timeout: (propagating from src/common/Utils.cpp, function workerThread(), line 114)
SCF: Error Timeout: Worker thread ViCsiHw frameComplete failed (in src/common/Utils.cpp, function workerThread(), line 133)
SCF: Error InvalidState: Timeout waiting on frame start sensor guid 0, capture sequence ID = 0 (in src/services/capture/FusaCaptureViCsiHw.cpp, function waitCsiFrameStart(), line 531)
SCF: Error InvalidState: (propagating from src/common/Utils.cpp, function workerThread(), line 114)
SCF: Error InvalidState: Worker thread ViCsiHw frameStart failed (in src/common/Utils.cpp, function workerThread(), line 133)

could you please also share the debug rce-fw for r3521?

Hi,
The issue may be in end of frame:

root@tnt:/home/tnt/debugc# SCF: Error Timeout: (propagating from src/services/capture/FusaCaptureViCsiHw.cpp, function waitCsiFrameEnd(), line 617)

Please check and inspect the signals. Probably it does not meet the requirement.

For the request, we would need to check with our teams.

Hi,

but if using v4l2-ctl, it’s already ok to receive the raw12 image.
And i can verify with 7yuv, that the received raw12 image is correct.

According to trace for gst-launch(with argus plugin)
kworker/10:2-157 [010] … 178.331497: rtcpu_nvcsi_intr: tstamp:8895283999 class:CORRECTABLE_ERR type:PHY_INTR phy:0 cil:1 st:0 vc:0 status:0x00000080

Bit 7 is set, which means intr_cil_data_lane_ctrl_err1_a
It’s a LP / HS transition issue, right?
So maybe the init sequence for argus or v4l2 is not the same? but v4l2 is more robust?

Hi Danel,

is there any other suggestions?

Hi,
So you need this setting in VI driver:

	brick_config.phy_mode = NVCSI_PHY_TYPE_CPHY;
	brick_config.lane_polarity[1] = NVCSI_CPHY_POLARITY_CAB;
	brick_config.lane_polarity[3] = NVCSI_CPHY_POLARITY_CAB;

Do you use Orin or Orin NX? Seems like the pins are swapped so you would need the patch for the camera.

I use the cvm from jetson agx orin developer kit, and put it on our custom board.
Our custom board use the lane mapping compatible for BOTH DPHY and CPHY.
In DPHY mode, use default lane polarity. Everything works, both v4l2-ctl and gst-launch.
In CPHY mode, now only v4l2-ctl works

The mipi-csi TX side is the Deserializer max96712.
For CPHY mode, I have also tried both 3 trios and 4 trios.
The error trace is the same. (with v4l2-ctl works)

Hi,
Please confirm if you have to apply this patch to make v4l2-ctl command work for the sensor:

 	brick_config.phy_mode = NVCSI_PHY_TYPE_CPHY;
	brick_config.lane_polarity[1] = NVCSI_CPHY_POLARITY_CAB;
	brick_config.lane_polarity[3] = NVCSI_CPHY_POLARITY_CAB;

In general we would expect the camera sensor works with default driver code.