MT9M021 unable to capture image using yavta

I am trying to port a camera driver which was working well on TX1 to TX2. I have made all the necessary modifications in the dtsi regarding clocks, gpios etc. However, while attempting to capture an image using yavta, I am getting the following error.

nvidia@tegra-ubuntu:~/git/yavta$ ls
COPYING.GPL  image.raw  include  Makefile  yavta  yavta.c  yavta.o
nvidia@tegra-ubuntu:~/git/yavta$ ./yavta /dev/video0 -c1 -n1 -s1280x720 -fSRGGB12 -Fimage.raw
Device /dev/video0 opened.
Device `vi-output, mt9m021 2-0010' on `platform:15700000.vi:0' (driver 'tegra-video') supports video, capture, without mplanes.
Video format set: SRGGB12 (32314752) 1280x720 (stride 2560) field none buffer size 1843200
Video format: SRGGB12 (32314752) 1280x720 (stride 2560) field none buffer size 1843200
3 buffers requested.
length: 1843200 offset: 0 timestamp type/source: mono/EoF
Buffer 0/0 mapped at address 0x7f88af8000.
length: 1843200 offset: 1843200 timestamp type/source: mono/EoF
Buffer 1/0 mapped at address 0x7f88936000.
length: 1843200 offset: 3686400 timestamp type/source: mono/EoF
Buffer 2/0 mapped at address 0x7f88774000.
0 (0) [-] none 0 1843200 B -266723336168.-274870094 94.970577 -0.000 fps ts mono/EoF
Captured 1 frames in 5.555889 seconds (0.179989 fps, 331756.055994 B/s).
3 buffers released.

Relevant portion of dmesg logs:

[   91.960411] mt9m021 2-0010: mt9m021_write: 0x10dc to 0x301a
[   92.965797] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
[   93.969796] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
[   94.973795] tegra-vi4 15700000.vi: PXL_SOF syncpt timeout! err = -11
[   95.993807] tegra-vi4 15700000.vi: ATOMP_FE syncpt timeout!
[   95.999933] mt9m021 2-0010: mt9m021_s_stream
[   96.004455] mt9m021 2-0010: Ending stream

What could be the reason for this issue?

Follow below link to enable the trace to get more information.
Also use the v4l2-ctl instead of yavta first.

v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --stream-to=t.raw

https://elinux.org/Jetson_TX2/28.1_Camera_BringUp

Here are the logs after enabling the error logs:

echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
echo 2 > /sys/kernel/debug/camrtc/log-level
echo > /sys/kernel/debug/tracing/trace
v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --stream-to=t.raw
cat /sys/kernel/debug/tracing/trace

Logs:

# tracer: nop
#
# entries-in-buffer/entries-written: 50/50   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
     kworker/3:1-51    [003] ...1    71.158251: rtos_queue_peek_from_isr_failed: tstamp:2524281930 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    71.158258: rtcpu_start: tstamp:2524283424
     kworker/3:1-51    [003] ...1    71.314283: rtos_queue_peek_from_isr_failed: tstamp:2529282835 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    71.470277: rtos_queue_peek_from_isr_failed: tstamp:2534283340 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    71.626274: rtos_queue_peek_from_isr_failed: tstamp:2539283845 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    71.782228: rtos_queue_peek_from_isr_failed: tstamp:2544284335 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    71.938228: rtos_queue_peek_from_isr_failed: tstamp:2549284841 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.098222: rtos_queue_peek_from_isr_failed: tstamp:2554285350 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.253138: rtos_queue_peek_from_isr_failed: tstamp:2559285854 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.459557: rtos_queue_peek_from_isr_failed: tstamp:2564286362 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.614232: rtos_queue_peek_from_isr_failed: tstamp:2569286866 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.770227: rtos_queue_peek_from_isr_failed: tstamp:2574287379 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    72.926233: rtos_queue_peek_from_isr_failed: tstamp:2579287883 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.082278: rtos_queue_peek_from_isr_failed: tstamp:2584288406 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.238270: rtos_queue_peek_from_isr_failed: tstamp:2589288914 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.394282: rtos_queue_peek_from_isr_failed: tstamp:2594289419 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.550512: rtos_queue_peek_from_isr_failed: tstamp:2599289915 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.710241: rtos_queue_peek_from_isr_failed: tstamp:2604290415 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    73.866238: rtos_queue_peek_from_isr_failed: tstamp:2609290923 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.022250: rtos_queue_peek_from_isr_failed: tstamp:2614291418 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.178246: rtos_queue_peek_from_isr_failed: tstamp:2619291924 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.334249: rtos_queue_peek_from_isr_failed: tstamp:2624292431 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.542245: rtos_queue_peek_from_isr_failed: tstamp:2629292939 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.698248: rtos_queue_peek_from_isr_failed: tstamp:2634293445 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    74.854247: rtos_queue_peek_from_isr_failed: tstamp:2639293952 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.010244: rtos_queue_peek_from_isr_failed: tstamp:2644294458 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.166245: rtos_queue_peek_from_isr_failed: tstamp:2649294965 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.322252: rtos_queue_peek_from_isr_failed: tstamp:2654295473 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.478259: rtos_queue_peek_from_isr_failed: tstamp:2659295982 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.634255: rtos_queue_peek_from_isr_failed: tstamp:2664296486 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.790247: rtos_queue_peek_from_isr_failed: tstamp:2669297005 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    75.946249: rtos_queue_peek_from_isr_failed: tstamp:2674297500 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.102253: rtos_queue_peek_from_isr_failed: tstamp:2679298006 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.258248: rtos_queue_peek_from_isr_failed: tstamp:2684298515 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.414276: rtos_queue_peek_from_isr_failed: tstamp:2689299049 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.622234: rtos_queue_peek_from_isr_failed: tstamp:2694299540 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.778231: rtos_queue_peek_from_isr_failed: tstamp:2699300032 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    76.934241: rtos_queue_peek_from_isr_failed: tstamp:2704300554 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.090236: rtos_queue_peek_from_isr_failed: tstamp:2709301047 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.246241: rtos_queue_peek_from_isr_failed: tstamp:2714301554 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.402256: rtos_queue_peek_from_isr_failed: tstamp:2719302060 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.558282: rtos_queue_peek_from_isr_failed: tstamp:2724302597 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.714290: rtos_queue_peek_from_isr_failed: tstamp:2729303106 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    77.870279: rtos_queue_peek_from_isr_failed: tstamp:2734303610 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.026308: rtos_queue_peek_from_isr_failed: tstamp:2739304106 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.182271: rtos_queue_peek_from_isr_failed: tstamp:2744304624 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.338262: rtos_queue_peek_from_isr_failed: tstamp:2749305132 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.494279: rtos_queue_peek_from_isr_failed: tstamp:2754305627 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.702239: rtos_queue_peek_from_isr_failed: tstamp:2759306127 queue:0x0b4a3c58
     kworker/3:1-51    [003] ...1    78.758235: rtos_queue_peek_from_isr_failed: tstamp:2760879267 queue:0x0b4a3c58

@EV
From the trace log the VI logic didn’t receive any validate data from the MIPI bus. You may need to probe the MIPI signal to make sure the sensor is output validate data.

Hi ShaneCCC,
We were able to obtain an image although the following error persists. However, gstreamer fails to start. I hope the attached image would be helpful in understanding what the issue is.
When we did camera bring up for TX1, we had to tune some settling time parameters in the driver code(in addition to cil settle time in dtsi). If you think it could be such an issue, let me know what variable in the driver source I should tune for testing.
Can you please help us understand what this log means:

nvidia@tegra-ubuntu:~$ sudo -s
root@tegra-ubuntu:~# echo 1 > /sys/kernel/debug/tracing/tracing_on
root@tegra-ubuntu:~# echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
root@tegra-ubuntu:~# echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
root@tegra-ubuntu:~# echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
root@tegra-ubuntu:~# echo 2 > /sys/kernel/debug/camrtc/log-level
root@tegra-ubuntu:~# echo > /sys/kernel/debug/tracing/trace
root@tegra-ubuntu:~# v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=1 --stream-to=t.raw
VIDIOC_DQBUF: failed: Input/output error
root@tegra-ubuntu:~# cat /sys/kernel/debug/tracing/trace
# tracer: nop
#
# entries-in-buffer/entries-written: 36/36   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
     kworker/3:1-105   [003] ...1   245.813936: rtos_queue_peek_from_isr_failed: tstamp:7982265892 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   245.813943: rtcpu_start: tstamp:7982266908
     kworker/3:1-105   [003] ...1   245.965912: rtos_queue_peek_from_isr_failed: tstamp:7987266746 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.125907: rtos_queue_peek_from_isr_failed: tstamp:7992267255 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.281903: rtos_queue_peek_from_isr_failed: tstamp:7997267761 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.489902: rtos_queue_peek_from_isr_failed: tstamp:8002268286 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.641900: rtos_queue_peek_from_isr_failed: tstamp:8007268773 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.797909: rtos_queue_peek_from_isr_failed: tstamp:8012269277 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   246.957954: rtos_queue_peek_from_isr_failed: tstamp:8017269803 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.113940: rtos_queue_peek_from_isr_failed: tstamp:8022270311 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.165949: rtcpu_vinotify_handle_msg: tstamp:8023593938 tag:CSIMUX_STREAM channel:0xff frame:0 vi_tstamp:3728626213 data:0x00000001
     kworker/3:1-105   [003] ...1   247.269933: rtos_queue_peek_from_isr_failed: tstamp:8027270817 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.425976: rtos_queue_peek_from_isr_failed: tstamp:8032271325 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.585893: rtos_queue_peek_from_isr_failed: tstamp:8037271830 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.737922: rtcpu_vinotify_handle_msg: tstamp:8041284533 tag:CHANSEL_PXL_SOF channel:0x00 frame:0 vi_tstamp:3746316687 data:0x00000001
     kworker/3:1-105   [003] ...1   247.737929: rtcpu_vinotify_handle_msg: tstamp:8041284681 tag:ATOMP_FS channel:0x00 frame:0 vi_tstamp:3746316700 data:0x00000000
     kworker/3:1-105   [003] ...1   247.737931: rtcpu_vinotify_handle_msg: tstamp:8041286946 tag:CHANSEL_LOAD_FRAMED channel:0x01 frame:0 vi_tstamp:3746319240 data:0x08000000
     kworker/3:1-105   [003] ...1   247.737933: rtcpu_vinotify_handle_msg: tstamp:8041784479 tag:CHANSEL_PXL_EOF channel:0x00 frame:0 vi_tstamp:3746816594 data:0x02cf0002
     kworker/3:1-105   [003] ...1   247.737934: rtcpu_vinotify_handle_msg: tstamp:8041784582 tag:ATOMP_FE channel:0x00 frame:0 vi_tstamp:3746816654 data:0x00000000
     kworker/3:1-105   [003] ...1   247.737936: rtcpu_vinotify_handle_msg: tstamp:8041972038 tag:CHANSEL_PXL_SOF channel:0x00 frame:0 vi_tstamp:3747004195 data:0x00000001
     kworker/3:1-105   [003] ...1   247.737938: rtcpu_vinotify_handle_msg: tstamp:8041972184 tag:ATOMP_FS channel:0x00 frame:0 vi_tstamp:3747004207 data:0x00000000
     kworker/3:1-105   [003] ...1   247.737940: rtcpu_vinotify_handle_msg: tstamp:8041974168 tag:CHANSEL_LOAD_FRAMED channel:0x01 frame:0 vi_tstamp:3747006460 data:0x08000000
     kworker/3:1-105   [003] ...1   247.737944: rtos_queue_peek_from_isr_failed: tstamp:8042272326 queue:0x0b4a3c58
     kworker/3:1-105   [003] ...1   247.737945: rtcpu_vinotify_handle_msg: tstamp:8042472000 tag:CHANSEL_PXL_EOF channel:0x00 frame:0 vi_tstamp:3747504100 data:0x02cf0002
     kworker/3:1-105   [003] ...1   247.737947: rtcpu_vinotify_handle_msg: tstamp:8042472144 tag:ATOMP_FE channel:0x00 frame:0 vi_tstamp:3747504161 data:0x00000000
     kworker/3:1-105   [003] ...1   247.737949: rtcpu_vinotify_handle_msg: tstamp:8042659553 tag:CHANSEL_PXL_SOF channel:0x00 frame:0 vi_tstamp:3747691701 data:0x00000001
     kworker/3:1-105   [003] ...1   247.737951: rtcpu_vinotify_handle_msg: tstamp:8042659752 tag:ATOMP_FS channel:0x00 frame:0 vi_tstamp:3747691714 data:0x00000000
     kworker/3:1-105   [003] ...1   247.737953: rtcpu_vinotify_handle_msg: tstamp:8042662541 tag:CHANSEL_LOAD_FRAMED channel:0x01 frame:0 vi_tstamp:3747694818 data:0x08000000
     kworker/3:1-105   [003] ...1   247.789931: rtcpu_vinotify_handle_msg: tstamp:8043159509 tag:CHANSEL_PXL_EOF channel:0x00 frame:0 vi_tstamp:3748191607 data:0x02cf0002
     kworker/3:1-105   [003] ...1   247.789939: rtcpu_vinotify_handle_msg: tstamp:8043159645 tag:ATOMP_FE channel:0x00 frame:0 vi_tstamp:3748191668 data:0x00000000
     kworker/3:1-105   [003] ...1   247.789942: rtcpu_vinotify_handle_msg: tstamp:8043347057 tag:CHANSEL_PXL_SOF channel:0x00 frame:0 vi_tstamp:3748379209 data:0x00000001
     kworker/3:1-105   [003] ...1   247.789945: rtcpu_vinotify_handle_msg: tstamp:8043347241 tag:ATOMP_FS channel:0x00 frame:0 vi_tstamp:3748379221 data:0x00000000
     kworker/3:1-105   [003] ...1   247.789947: rtcpu_vinotify_handle_msg: tstamp:8043352987 tag:CHANSEL_LOAD_FRAMED channel:0x01 frame:0 vi_tstamp:3748385264 data:0x08000000
     kworker/3:1-105   [003] ...1   247.789950: rtcpu_vinotify_handle_msg: tstamp:8043847004 tag:CHANSEL_PXL_EOF channel:0x00 frame:0 vi_tstamp:3748879114 data:0x02cf0002
     kworker/3:1-105   [003] ...1   247.789953: rtcpu_vinotify_handle_msg: tstamp:8043847140 tag:ATOMP_FE channel:0x00 frame:0 vi_tstamp:3748879175 data:0x00000000
     kworker/3:1-105   [003] ...1   247.789959: rtos_queue_peek_from_isr_failed: tstamp:8043860999 queue:0x0b4a3c58

image.png

@EV
Looks there’s no any problem from the log. How about change the stream-count=10 to capture more frame. And what the gstreamer command to launch the camera?

v4l2-ctl -d /dev/video0 --set-ctrl bypass_mode=0 --stream-mmap --stream-count=10

@ShaneCCC

I tried with stream-count=10 and it ran without any errors. I verified the image and it contains 10 images appended together.

Following is the gstreamer command we use(this command works on TX1 for us):

gst-launch-1.0 -e nvcamerasrc sensor-id=1 ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)60/1' ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! omxh264enc bitrate=8000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! filesink location=test.h264

Following is the terminal log:

nvidia@tegra-ubuntu:~$ gst-launch-1.0 -e nvcamerasrc sensor-id=1 ! 'video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)60/1' ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! omxh264enc bitrate=8000000 ! 'video/x-h264, stream-format=(string)byte-stream' ! filesink location=test.h264
Setting pipeline to PAUSED ...
Socket read error. Camera Daemon stopped functioning.....
gst_nvcamera_open() failed ret=0
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstNvCameraSrc:nvcamerasrc0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
gstbasesrc.c(3354): gst_base_src_start (): /GstPipeline:pipeline0/GstNvCameraSrc:nvcamerasrc0:
Failed to start
Setting pipeline to NULL ...
Freeing pipeline ...

Did you have two sensor? Why sensor-id=1 ?

@ShaneCCC,

Yes. We have two cameras. We have tried setting sensor-id to 0 as well. But however, we get similar errors.
Is there any way to get meaningful debug logs for this error?

You can enable logs from user-space for more details to check if any clue.

https://elinux.org/Jetson_TX2/28.1_Camera_BringUp

@ShaneCCC

I ran gstreamer with debug logs enabled, but was not able to figure out what exactly is causing the issue. Can you please help us identify the issue in the device tree.
Device tree:

#include "dt-bindings/clock/tegra186-clock.h"
#define CAM0_RST        TEGRA_MAIN_GPIO(R, 5)
#define CAM1_RST        TEGRA_MAIN_GPIO(R, 1)
#define CAM0_PWDN       TEGRA_MAIN_GPIO(R, 0)
#define CAM1_PWDN       TEGRA_MAIN_GPIO(N, 2)


/*
I2C Busses:

i2c0 = "/i2c@3160000";
i2c1 = "/i2c@c240000";
i2c2 = "/i2c@3180000";
i2c3 = "/i2c@3190000";
i2c4 = "/i2c@31a0000";
i2c5 = "/i2c@31b0000";
i2c6 = "/i2c@31c0000";
i2c7 = "/i2c@c250000";
i2c8 = "/i2c@31e0000";
*/

/ {
    gpio@2200000 {
        camera-control-output-low {
            gpio-hog;
            output-high;
            gpios = <CAM0_RST 0 CAM0_PWDN 0 CAM1_RST 0 CAM1_PWDN 0>;
            label = "cam0-rst", "cam0-pwdn, cam1-rst, cam1-pwdn";
            status = "okay";
        };
    };
	i2c@c240000 {
		status = "okay";
		#address-cells = <1>;
		#size-cells = <0>;

		mt9m021_b@10 {
			compatible = "nvidia,mt9m021";

			/* I2C device address */
			reg = <0x10>;

			/* Physical dimensions of sensor */
			physical_w = "10";
			physical_h = "10";

			/* Sensor Model */
			sensor_model ="mt9m021";

			/* Defines number of frames to be dropped by driver internally after applying */
			/* sensor crop settings. Some sensors send corrupt frames after applying */
			/* crop co-ordinates */
			post_crop_frame_drop = "0";

			/* when set true analog gain value expressed in decibels." */
			use_decibel_gain = "false";

			/* if true, delay gain setting by one frame to be in sync with exposure */
			delayed_gain = "false";

			/* enable CID_SENSOR_MODE_ID for sensor modes selection */
			use_sensor_mode_id = "true";

			/* slave or master mode */
			trigger_mode = "master";

			/* Device */
			devnode = "video1";

			/* input clock for the device in MHz*/
			clocks = <&tegra_car TEGRA186_CLK_EXTPERIPH2>,
          <&tegra_car TEGRA186_CLK_PLLP_OUT0>;
			clock-names = "extperiph2", "pllp_grtba";
			clock-frequency = <24000000>;
			mclk = "extperiph2";
			reset-gpios = <&tegra_main_gpio CAM1_RST GPIO_ACTIVE_HIGH>;
			/* Define any required hw resources needed by driver */
			/* ie. clocks, io pins, power sources */
			vana-supply = <&battery_reg>;     // analog 2.8v
			vif-supply = <&battery_reg>;             // interface 1.8v
			vdig-supply = <&battery_reg>;    // digital 1.2v

			avdd-reg = "vana";
			iovdd-reg = "vana";
			dvdd-reg = "vana";
			has-eeprom = <0>;


			mode0 {
				mclk_khz = "24000";
				num_lanes = "1";
				tegra_sinterface = "serial_b";
				discontinuous_clk = "yes";
				dpcm_enable = "false";
				cil_settletime = "0x6";

				active_w = "1280";
				active_h = "720";
				dynamic_pixel_bit_depth = "12";
				csi_pixel_bit_depth = "12";
				mode_type="bayer";
				pixel_phase="rggb";
				pixel_t = "bayer_rggb12";
				readout_orientation = "0";
				line_length = "1650";
				inherent_gain = "1";
				mclk_multiplier = "3.094";
				pix_clk_hz = "74250000";

				min_gain_val = "1";
				max_gain_val = "22.2";
				min_hdr_ratio = "1";
				max_hdr_ratio = "64";
				min_framerate = "1.462526";
				max_framerate = "60";
				min_exp_time = "16.165";
				max_exp_time = "165770";
				embedded_metadata_height = "0";
			};
			ports {
				#address-cells = <0x1>;
				#size-cells = <0x0>;
				status = "okay";

				port@0 {
					reg = <0x0>;
					status = "okay";
					mt9m021_slave: endpoint {
						status = "okay";
						csi-port = <0x1>;
						bus-width = <0x1>;
						remote-endpoint = <&mt9m021_slave_nvcsi_port0>;
					};
				};
			};
		};
	};

	i2c@3180000 {
		status = "okay";
					#address-cells = <1>;
					#size-cells = <0>;

		mt9m021_a@10 {
			compatible = "nvidia,mt9m021";

			/* I2C device address */
			reg = <0x10>;

			/* Physical dimensions of sensor */
			physical_w = "10";
			physical_h = "10";

			/* Sensor Model */
			// sensor_model ="mt9m021";

			/* Defines number of frames to be dropped by driver internally after applying */
			/* sensor crop settings. Some sensors send corrupt frames after applying */
			/* crop co-ordinates */
			// post_crop_frame_drop = "0";

			/* when set true analog gain value expressed in decibels." */
			// use_decibel_gain = "false";

			/* if trae, delay gain setting by one frame to be in sync with exposure */
			delayed_gain = "true";

			/* enable CID_SENSOR_MODE_ID for sensor modes selection */
			// use_sensor_mode_id = "true";

			/* slave or master mode */
			trigger_mode = "master";

			/* Device */
			 devnode = "video0";

			/* input clock for the device in MHz*/
			clocks = <&tegra_car TEGRA186_CLK_EXTPERIPH1>,
          <&tegra_car TEGRA186_CLK_PLLP_OUT0>;
			clock-names = "extperiph1", "pllp_grtba";
			clock-frequency = <24000000>;
			mclk = "extperiph1";
			reset-gpios = <&tegra_main_gpio CAM0_RST GPIO_ACTIVE_HIGH>;
			/* Define any required hw resources needed by driver */
			/* ie. clocks, io pins, power sources */
			vana-supply = <&battery_reg>;     // analog 2.8v
			vif-supply = <&battery_reg>;             // interface 1.8v
			vdig-supply = <&battery_reg>;    // digital 1.2v

			avdd-reg = "vana";
			iovdd-reg = "vana";
			dvdd-reg = "vana";
			has-eeprom = <0>;
			status = "okay";

			mode0 {
				mclk_khz = "24000";
				num_lanes = "1";
				tegra_sinterface = "serial_a";
				discontinuous_clk = "yes";
				dpcm_enable = "false";
				cil_settletime = "0x6";

				active_w = "1280";
				active_h = "720";
				pixel_t = "bayer_rggb12";
				readout_orientation = "0";
				line_length = "1650";
				inherent_gain = "1";
				mclk_multiplier = "3.094";
				pix_clk_hz = "74250000";

				min_gain_val = "1.0";
				max_gain_val = "22.2";
				min_hdr_ratio = "1";
				max_hdr_ratio = "64";
				min_framerate = "1.462526";
				max_framerate = "60";
				min_exp_time = "16.165";
				max_exp_time = "165770";
				embedded_metadata_height = "0";
			};
			ports {
				#address-cells = <0x1>;
				#size-cells = <0x0>;
				status = "okay";

				port@0 {
					reg = <0x0>;
					status = "okay";
					mt9m021_master: endpoint {
						status = "okay";
						csi-port = <0x0>;
						bus-width = <0x1>;
						remote-endpoint = <&mt9m021_master_nvcsi_port0>;
					};
				};
			};
		};
	};

	host1x {
		vi@15700000 {
			num-channels = <0x2>;
			status = "okay";
			ports {
				#address-cells = <0x1>;
				#size-cells = <0x0>;
				port@0 {
					reg = <0x0>;
					status = "okay";
					mt9m021_master_vi: endpoint {
						status = "okay";
						csi-port = <0x0>;
						bus-width = <0x1>;
						remote-endpoint = <&mt9m021_master_nvcsi_port1>;
					};
				};
				port@1 {
					reg = <0x1>;
					status = "okay";
					mt9m021_slave_vi: endpoint {
						status = "okay";
						csi-port = <0x1>;
						bus-width = <0x1>;
						remote-endpoint = <&mt9m021_slave_nvcsi_port1>;
					};
				};
			};
		};

		nvcsi@150c0000 {
			status = "okay";
			num-channels = <0x2>;
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			channel@0 {
				status = "okay";
				reg = <0x0>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						status = "okay";
						reg = <0x0>;
						mt9m021_master_nvcsi_port0: endpoint@0 {
							status = "okay";
							csi-port = <0x0>;
							bus-width = <0x1>;
							remote-endpoint = <&mt9m021_master>;
						};
					};
					port@1 {
						status = "okay";
						reg = <0x1>;
						mt9m021_master_nvcsi_port1: endpoint@1 {
							status = "okay";
							remote-endpoint = <&mt9m021_master_vi>;
						};
					};
				};
			};
			channel@1 {
				status = "okay";
				reg = <0x1>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						status = "okay";
						reg = <0x0>;
						mt9m021_slave_nvcsi_port0: endpoint@2 {
							status = "okay";
							csi-port = <0x1>;
							bus-width = <0x1>;
							remote-endpoint = <&mt9m021_slave>;
						};
					};
					port@1 {
						status = "okay";
						reg = <0x1>;
						mt9m021_slave_nvcsi_port1: endpoint@3 {
							status = "okay";
							remote-endpoint = <&mt9m021_slave_vi>;
						};
					};
				};
			};
		};
	};

	tegra-camera-platform {
		compatible = "nvidia, tegra-camera-platform";
    	status = "okay";
		num_csi_lanes = <4>;
		max_lane_speed = <1500000>;
		min_bits_per_pixel = <10>;
		vi_peak_byte_per_pixel = <2>;
		vi_bw_margin_pct = <25>;
		max_pixel_rate = <160000>;
		isp_peak_byte_per_pixel = <5>;
		isp_bw_margin_pct = <25>;
		modules {
			module0 {
				status = "okay";
				badge = "mt9m021_master";
				position = "front";
				orientation = "1";
				drivernode0 {
					status = "okay";
					pcl_id = "v4l2_sensor";
					devname = "mt9m021 2-0010";
					proc-device-tree = "/proc/device-tree/i2c@3180000/mt9m021_a@10";
				};
			};
			module1 {
				status = "okay";
				badge = "mt9m021_slave";
				position = "rear";
				orientation = "1";
				drivernode0 {
					status = "okay";
					pcl_id = "v4l2_sensor";
					devname = "mt9m021 1-0010";
					proc-device-tree = "/proc/device-tree/i2c@c240000/mt9m021_b@10";
				};
			};
		};
	};
};

Logs:

root@tegra-ubuntu:/home/nvidia# ps aux | grep nvcamera
root       823  0.0  0.1  35416  9432 ?        Ss   11:46   0:00 /usr/sbin/nvcamera-daemon
root      3008  0.0  0.0   5548   540 pts/2    S+   11:52   0:00 grep --color=auto nvcamera
root@tegra-ubuntu:/home/nvidia# kill 823
root@tegra-ubuntu:/home/nvidia# ps aux | grep nvcamera
root      3079  0.0  0.0   5548   548 pts/2    S+   11:52   0:00 grep --color=auto nvcamera
root@tegra-ubuntu:/home/nvidia# export enableCamPclLogs=1
root@tegra-ubuntu:/home/nvidia# export enableCamScfLogs=1
root@tegra-ubuntu:/home/nvidia# /usr/sbin/nvcamera-daemon
Thread 1 getting next capture
Thread 1 is waiting
Thread 2 getting next capture
Thread 2 is waiting
Thread 3 getting next capture
Thread 3 is waiting
Thread 4 getting next capture
Thread 4 is waiting
Thread 5 getting next capture
Thread 5 is waiting
Thread 6 getting next capture
Thread 6 is waiting
Thread 7 getting next capture
Thread 7 is waiting
Thread 8 getting next capture
Thread 8 is waiting
Thread 9 getting next capture
Thread 9 is waiting
Thread 10 getting next capture
Thread 10 is waiting
Thread 11 getting next capture
Thread 11 is waiting
Thread 12 getting next capture
Thread 12 is waiting
Starting services...
Worker thread IspHw statsComplete start
Worker thread IspHw frameComplete start
Worker thread CaptureScheduler checkFramePending start
Worker thread CaptureScheduler frameStart start
Worker thread V4L2CaptureScheduler checkCaptureComplete start
Worker thread V4L2CaptureScheduler issueCaptures start
Worker thread PS handleRequests start
getInstance: s_instance(0x7f9cb92570)
getInstance: s_instance(0x7f9cb92570)
subscribe: create SensorType(gyroscope) sensor(0x7f9cb946f0)
subscribe: create SensorType(accelerometer) sensor(0x7f9cb99b50)
AC plugin not present: dlopen "acplugin.so", acplugin.so: cannot open shared object file: No such file or directory
Services are started
NvPclSetHotplugCallback: ++++++++++++++++++++++
---- Imager: Calibration blob file handling supported in this build ----
NvPclHwGetModuleList: OFParserListModules Succeeded
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: mt9m021_slave
NvPclHwPrintModuleDefinition -- Position: 0
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: mt9m021 0-0010
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwPrintModuleDefinition -- Name: mt9m021_master
NvPclHwPrintModuleDefinition -- Position: 1
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: mt9m021 2-0010
NvPclHwGetModuleList: OFParserListModules Succeeded
NvPclModuleListInitialize: NvPclModule list[0]: mt9m021_slave position0
NvPclModuleListInitialize: NvPclModule list[1]: mt9m021_master position1
NvPclModuleListInitialize: No plugable modules on platform
getHotplugMonitor: Getting hotplug monitor instance
 initializeHotplug++
 hotPlugfunc ++ 
 addWatch: Watch added wd='1'
CheckProcDTExists: INFO: accessing /proc/device-tree/tegra-virtual-camera-platform/modules; No such file or directory
PCLHW_DTParser
setHotplugCallback: Registered new callback client
NvPclSetHotplugCallback: ----------------------
NvPclOpen: ++++++++++++++++++++++
NvPclStateControllerOpen: Found GUID 0 match at index[0]
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbac840
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbac8d0
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbac960
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbac9f0
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbcc190
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f9cbcc220
LoadOverridesFile: looking for override file [/Calib/camera_override.isp] 1/16CheckOverridesPermissions: cannot stat file [/Calib/camera_override.isp]
LoadOverridesFile: looking for override file [/data/nvcam/settings/camera_overrides.isp] 2/16CheckOverridesPermissions: cannot stat file [/data/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/camera_overrides.isp] 3/16CheckOverridesPermissions: cannot stat file [/opt/nvidia/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/camera_overrides.isp] 4/16CheckOverridesPermissions: cannot stat file [/var/nvidia/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/data/nvcam/camera_overrides.isp] 5/16CheckOverridesPermissions: cannot stat file [/data/nvcam/camera_overrides.isp]
LoadOverridesFile: looking for override file [/data/nvcam/settings/mt9m021_slave.isp] 6/16CheckOverridesPermissions: cannot stat file [/data/nvcam/settings/mt9m021_slave.isp]
LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/mt9m021_slave.isp] 7/16CheckOverridesPermissions: cannot stat file [/opt/nvidia/nvcam/settings/mt9m021_slave.isp]
LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/mt9m021_slave.isp] 8/16CheckOverridesPermissions: cannot stat file [/var/nvidia/nvcam/settings/mt9m021_slave.isp]
---- imager: No override file found. ----
Imager: looking for override file [/mnt/factory/camera/factory.bin] 1/16
Imager: looking for override file [/Calib/factory.bin] 2/16
Imager: looking for override file [/Calib/calibration.bin] 3/16
Imager: looking for override file [(null)] 4/16
Imager: looking for override file [(null)] 5/16
Imager: looking for override file [(null)] 6/16
Imager: looking for override file [(null)] 7/16
Imager: looking for override file [(null)] 8/16
Imager: looking for override file [(null)] 9/16
Imager: looking for override file [(null)] 10/16
Imager: looking for override file [(null)] 11/16
Imager: looking for override file [(null)] 12/16
Imager: looking for override file [(null)] 13/16
Imager: looking for override file [(null)] 14/16
Imager: looking for override file [(null)] 15/16
Imager: looking for override file [(null)] 16/16
Imager: looking for override file [/data/nvcam/settings/factory.bin] 1/16
Imager: looking for override file [/data/nvcam/settings/mt9m021_slave.bin] 2/16
Imager: looking for override file [/opt/nvidia/nvcam/settings/mt9m021_slave.bin] 3/16
Imager: looking for override file [/var/nvidia/nvcam/settings/mt9m021_slave.bin] 4/16
Imager: looking for override file [(null)] 5/16
Imager: looking for override file [(null)] 6/16
Imager: looking for override file [(null)] 7/16
Imager: looking for override file [(null)] 8/16
Imager: looking for override file [(null)] 9/16
Imager: looking for override file [(null)] 10/16
Imager: looking for override file [(null)] 11/16
Imager: looking for override file [(null)] 12/16
Imager: looking for override file [(null)] 13/16
Imager: looking for override file [(null)] 14/16
Imager: looking for override file [(null)] 15/16
Imager: looking for override file [(null)] 16/16
NvPclCreateDriver: Found NvPcl Driver Hal dev_name match (v4l2_sensor)
NvPclCreateDriver: Found a Driver name match (v4l2_sensor)
NvPclConnectDrivers: hImager was NULL, creating new imager
NvPclInitializeDrivers: v4l2_sensor ++++++++++++++++++
OFDPropertyGetString: could not read property [devnode-bus]
initialize: mt9m021 0-0010
(NvOdmDevice) Error ModuleNotPresent: V4L2Device not available (in dvs/git/dirty/git-master_linux/camera-partner/imager/src/V4L2Device.cpp, function findDevice(), line 231)
(NvOdmDevice) Error ModuleNotPresent:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/V4L2Device.cpp, function initialize(), line 54)
(NvOdmDevice) Error ModuleNotPresent:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 97)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbac9f0
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbcc190
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbcc220
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbac840
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbac8d0
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f9cbac960
NvPclStateControllerOpen: Failed ImagerGUID 0. (error 0xA000E)
NvPclStateControllerClose: Module mt9m021_slave closed
NvPclOpen: PCL Open Failed. Error: 0xf
NvPclClose: ++++++++++++++++++++++
NvPclClose: ----------------------
NvPclOpen: ----------------------
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 596)
SCF: Error BadParameter:  (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 781)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 276)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function getSource(), line 439)
Segmentation fault (core dumped)

Looks like the devname didn’t match.

devname = “mt9m021 1-0010”;
NvPclHwPrintCameraSubModule – HwCamSubModule[0].DevName: mt9m021 0-0010

@ShaneCCC,

In my dtsi, I use devname = “mt9m021 1-0010”; based on our understanding that it should be connected to “i2c1 = i2c@c240000”.

NvPclHwPrintCameraSubModule – HwCamSubModule[0].DevName: mt9m021 0-0010
In my dtsi, I haven’t mentioned anywhere to use “mt9m021 0-0010”. I am wondering where the second debug print got the information from.
Does this mean that I should be using “i2c0 = i2c@3160000” instead(and change the devname to mt9m021 0-0010)?

@EV
Could you check the devname in /proc/device-tree/tegra-camera-platform/modules/moduleX/drivernode0/devname