Jetson Nano tc358748

Hey.
I am trying to write a driver for toshiba tc358748. I took imx219 as a basis.
Working with devkit jetson nano A02.
I have configured the tc358748 to output 1920 * 1080, 2 data lines, color bars.
Came across a problem. loading the driver.
dmesg

[ 54.648747] tc: loading out-of-tree module taints kernel.
[ 54.655958] tc_probe
[ 54.658328] tc_parse_dt
[ 54.660866] tc_power_get
[ 54.663630] tc358746 6-000e: tegracam sensor driver:tc_v2.0.6
[ 54.663633] tc_board_setup
[ 54.666476] tc_power_on
[ 54.692096] i2c_read
[ 54.695352] tc_power_off
[ 54.698056] vi 54080000.vi: subdev tc358746 6-000e bound
[ 54.707967] tc_open
[ 54.708985] tc_power_on
[ 54.732131] tc_set_mode
[ 54.734625] tc_bridge_setup count 1076
[ 55.040142] tc_start_streaming
[ 55.043544] tc_stop_streaming
[ 55.097718] tc_power_off
[ 55.100653] tc_power_on
[ 55.127866] tc_power_off

yavta -c -f YUYV -s 1920x1080 -F /dev/video0

Device /dev/video0 opened.
Device vi-output, tc358746 6-000e' on platform:54080000.vi:0’ (driver ‘tegra-video’) supports video, capture, without mplanes.
Video format set: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200
Video format: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200
8 buffers requested.
length: 4147200 offset: 0 timestamp type/source: mono/EoF
Buffer 0/0 mapped at address 0x7fb61b4000.
length: 4147200 offset: 4149248 timestamp type/source: mono/EoF
Buffer 1/0 mapped at address 0x7fb5dbf000.
length: 4147200 offset: 8298496 timestamp type/source: mono/EoF
Buffer 2/0 mapped at address 0x7fb59ca000.
length: 4147200 offset: 12447744 timestamp type/source: mono/EoF
Buffer 3/0 mapped at address 0x7fb55d5000.
length: 4147200 offset: 16596992 timestamp type/source: mono/EoF
Buffer 4/0 mapped at address 0x7fb51e0000.
length: 4147200 offset: 20746240 timestamp type/source: mono/EoF
Buffer 5/0 mapped at address 0x7fb4deb000.
length: 4147200 offset: 24895488 timestamp type/source: mono/EoF
Buffer 6/0 mapped at address 0x7fb49f6000.
length: 4147200 offset: 29044736 timestamp type/source: mono/EoF
Buffer 7/0 mapped at address 0x7fb4601000.

dmesg

[ 183.660349] tc_power_on
[ 183.686406] tc_set_mode
[ 183.688894] tc_bridge_setup count 1076
[ 184.082361] tc_start_streaming
[ 184.085715] tc_stop_streaming
[ 184.140171] tc_power_off
[ 184.143326] tc_power_on
[ 184.212337] tc_set_mode
[ 184.214818] tc_bridge_setup count 1076
[ 184.472399] tc_start_streaming
[ 184.677744] video4linux video0: frame start syncpt timeout!0
[ 184.885734] video4linux video0: frame start syncpt timeout!0
[ 185.093739] video4linux video0: frame start syncpt timeout!0

v4l2-compliance

v4l2-compliance SHA : not available

Driver Info:
Driver name : tegra-video
Card type : vi-output, tc358746 6-000e
Bus info : platform:54080000.vi:0
Driver version: 4.9.140
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 1 Private Controls: 17

Format ioctls:
fail: v4l2-test-formats.cpp(273): duplicate format 56595559 (YUYV)
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
fail: v4l2-test-formats.cpp(1184): ret && node->has_frmintervals
test VIDIOC_G/S_PARM: FAIL
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK

Test input 0:

Total: 43, Succeeded: 41, Failed: 2, Warnings: 0

cat / sys / kernel / debug / tracing / trace
Outputs nothing

root@jetson-desktop:/home/jetson# echo 1 > /sys/kernel/debug/tracing/tracing_on
root@jetson-desktop:/home/jetson# echo 30720 > /sys/kernel/debug/tracing/buffer_size_kb
root@jetson-desktop:/home/jetson# echo 1 > /sys/kernel/debug/tracing/events/tegra_rtcpu/enable
root@jetson-desktop:/home/jetson# echo 1 > /sys/kernel/debug/tracing/events/freertos/enable
root@jetson-desktop:/home/jetson# echo 2 > /sys/kernel/debug/camrtc/log-level
bash: /sys/kernel/debug/camrtc/log-level: No such file or directory
root@jetson-desktop:/home/jetson# echo > /sys/kernel/debug/tracing/trace
root@jetson-desktop:/home/jetson# cat /sys/kernel/debug/tracing/trace
tracer: nop

entries-in-buffer/entries-written: 0/0 #P:4

                          _-----=> irqs-off
                         / _----=> need-resched
                        | / _---=> hardirq/softirq
                        || / _--=> preempt-depth
                        ||| /     delay
       TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
          | |       |   ||||       |         |

root@jetson-desktop:/home/jetson#

Maybe you find here useful info. I got a tc358743xbg I hope some day somebody make a driver for Nano or NX should be great, but I guess it is a hard job

hello djager471,

there’s nothing according to your tracing logs, it means VI engine did not receive any active MIPI signaling.
you may review your power-on sequence in kernel driver, regulator settings, port bindings, and Debugging Tips.
thanks

I did from Imx219. I think that there should be no mistake.

tegra210-porg-p3448-common.dtsi
removed
#include “porg-platforms/tegra210-porg-camera-rbpcv2-imx219.dtsi”
#include “porg-platforms/tegra210-porg-camera-rbpcv2-dual-imx219.dtsi”
#include “porg-plugin-manager/tegra210-porg-plugin-manager.dtsi”
insert
#include “tegra210-tc358746.dtsi”

tegra210-tc358746.dtsi

#include <dt-bindings/media/camera.h>
#include <dt-bindings/platform/t210/t210.h>
#include <dt-bindings/gpio/gpio.h>

#define CAM1_PWDN TEGRA_GPIO(S, 7)

/ {
host1x {
vi_base: vi {
num-channels = <1>; // Change 4->2
ports {
#address-cells = <1>;
#size-cells = <0>;
vi_port0: port@0 {
reg = <0>;
status = “okay”;
tc358746_vi_in0: endpoint {
status = “okay”;
port-index = <0>;
bus-width = <2>;
remote-endpoint = <&tc358746_csi_out0>;
};
};
};
};

csi_base: nvcsi {
    num-channels = <1>;
    #address-cells = <1>;
    #size-cells = <0>;
    
    channel@0 {
        reg = <0>;
        ports {
            #address-cells = <1>;
            #size-cells = <0>;
            port@0 {
                reg = <0>;
                tc358746_csi_in0: endpoint@0 {
                    port-index = <0>;
                    bus-width = <2>;
                    remote-endpoint = <&tc358746_out0>;
                };
            };
            port@1 {
                reg = <1>;
                tc358746_csi_out0: endpoint@1 {
                    remote-endpoint = <&tc358746_vi_in0>;
                };
            };
        };
    };
};

i2c@546c0000 {  /* I2C_PM, "adapter" 6 */
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
    tc358746@0e {

        compatible = "tc358746";
        /* I2C device address */
        reg = <0x0e>; /* shifted by 2 */

        /* V4L2 device node location */
  devnode = "video0";

        /* Physical dimensions of sensor */
  physical_w = "3.680";
  physical_h = "2.760";

  sensor_model = "TC358746";

  use_sensor_mode_id = "true";

        //clocks = <&tegra_car TEGRA210_CLK_ID_CLK_OUT_3>;
        //clock-names = "mclk";
        //clock-frequency = <24000000>;

        //mclk = "cam_mclk1";
        //refclk_hz = <27000000>;  // refclk_hz -> regclk

        reset-gpios = <&gpio CAM1_PWDN GPIO_ACTIVE_HIGH>;

        mode0 { /* IMX219_MODE_1920x1080_25FPS */
  			mclk_khz = "24000";
  			num_lanes = "2";
  			tegra_sinterface = "serial_a";
  			phy_mode = "DPHY";
  			discontinuous_clk = "no";
  			dpcm_enable = "false";
  			cil_settletime = "0";
  			
  			dynamic_pixel_bit_depth = "16";
  			csi_pixel_bit_depth = "16";
  			mode_type = "yuv";
  			pixel_phase = "yuyv";

  			active_w = "1920";
  			active_h = "1080";
  			readout_orientation = "0";
  			line_length = "2640";
  			inherent_gain = "1";
  			pix_clk_hz = "74250000";

  			gain_factor = "16";
  			framerate_factor = "1000000";
  			exposure_factor = "1000000";
  			step_gain_val = "1";
  			default_gain = "16"; /* 1.00x */
  			step_framerate = "1";
  			step_exp_time = "1";
  			default_exp_time = "2495"; /* us */
  			
  			
  			min_gain_val = "16"; /* 1.00x */
  			max_gain_val = "170"; /* 10.66x */
  			min_hdr_ratio = "1";
  			max_hdr_ratio = "1";
  			min_framerate = "2000000"; /* 2.0 fps */
  			max_framerate = "25000000"; /* 25.0 fps */
  			default_framerate = "25000000"; /* 25.0 fps */
  			min_exp_time = "13"; /* us */
  			max_exp_time = "683709"; /* us */
  			embedded_metadata_height = "0";
  		};

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

            port@0 {
                reg = <0>;
                tc358746_out0: endpoint {
                    port-index = <0>; /* CSI A */
                    bus-width = <2>; 
                    remote-endpoint = <&tc358746_csi_in0>;
                };
            };
        };
    };
};

};

gpio@6000d000 {
    camera-control-output-low {
        gpio-hog;
        output-low;
        gpios = < CAM1_PWDN 0 >;
        label = "cam1-pwdn";
    };
};

tegra-camera-platform {
    compatible = "nvidia, tegra-camera-platform";

    num_csi_lanes = <2>;
    max_lane_speed = <1500000>;
    min_bits_per_pixel = <16>; 
    vi_peak_byte_per_pixel = <2>;
    vi_bw_margin_pct = <25>;
    max_pixel_rate = <750000>;
    isp_peak_byte_per_pixel = <5>; 
    isp_bw_margin_pct = <25>; 

    modules {
        module0 {
            badge = "tc358746_top_i2c6_b";
            position = "front";
            orientation = "0";
            status = "okay";
            drivernode0 {   
                pcl_id ="v4l2_sensor";//Declare PCL support driver(classically known as guid)
                devname = "tc358746 6-000e";// Driver's v4l2 device name
                /* Declare the device-tree hierarchy to driver instance */
                proc-device-tree = "/proc/device-tree/host1x/i2c@546c0000/tc358746@0e";
                status = "okay";
            };
        };
    };
};

};

Hey.
I connected imx219 and saw an image.
But my log ‘cat / sys / kernel / debug / tracing / trace’ remains empty.
What ideas?

hello djager471,

because Nano did not have such log level settings,

please have alternative way to enable dynamic debug flag,
you may check dmesg for the enable logs.
for example,

$ cd /sys/kernel/debug/dynamic_debug/
$ echo file imx219.c +p > control

Нow to get debug information when writing your driver?

hello djager471,

you may also check imx219 sources,
for example,
$L4T_Sources/r32.4.3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/imx219.c

dynamic_debug flag will enable dev_dbg() functions, to enable that print into kernel messages, i.e.$ dmesg
please also refer to Building the NVIDIA Kernel for the steps to build the NVIDIA kernel.
thanks

No matter what I do, I always get the same error. Tell me where to look?
Physically I see the signals on the oscilloscope.
Tried setting tc358748 to different resolutions.

[ 871.813132] video4linux video0: frame start syncpt timeout!0
[ 871.819167] video4linux video0: TEGRA_VI_CSI_ERROR_STATUS 0x00000000
[ 871.825852] vi 54080000.vi: TEGRA_CSI_PIXEL_PARSER_STATUS 0x00000000
[ 871.832530] vi 54080000.vi: TEGRA_CSI_CIL_STATUS 0x00000010
[ 871.839055] vi 54080000.vi: TEGRA_CSI_CILX_STATUS 0x00040040 (sometimes 0x00040041)
[ 871.845047] vi 54080000.vi: cil_settingtime was autocalculated
[ 871.851036] vi 54080000.vi: csi clock settle time: 13, cil settle time: 10

yavta -f YUYV -s 1920x1080 -n 4 --capture=5 -F /dev/video0
Device /dev/video0 opened: vi-output, tc358746 6-000e (platform:54080000.vi:0).
Video format set: width: 1920 height: 1080 buffer size: 4147200
Video format: YUYV (56595559) 1920x1080
4 buffers requested.
length: 4147200 offset: 0
Buffer 0 mapped at address 0x7f8a6fd000.
length: 4147200 offset: 4149248
Buffer 1 mapped at address 0x7f8a308000.
length: 4147200 offset: 8298496
Buffer 2 mapped at address 0x7f89f13000.
length: 4147200 offset: 12447744
Buffer 3 mapped at address 0x7f89b1e000.

hello djager471,

please access TX1 TRM from download center, you should check the Chapter-29.16 for MIPI-CSI registers reporting.
for example,
CSI_CSI_CILA_STATUS_0 = 0x40040, bit-6 & bit-18 indicate there’s lane control errors.

are you able to enable test-pattern-generator on the tc358748 chips, this should help to narrow down the issue.
thanks

1 Like

Hey. I figured out the capture problem. There was poor contact in the board. I grab a picture:


Most of the frames are broken.
What could be the problem?

hello djager471,

this looks like you’re not assign correct stride alignments, you should note that VI requires atom (64-Byte) aligned.
could you please enable preferred_stride controls via v4l2 standard controls for verification,
for example,
$ v4l2-ctl -d /dev/video0 ... --set-ctrl preferred_stride=256 ...

you may also check kernel drivers for reference.
for example,
$L4T_Sources/r32.4.3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/platform/tegra/camera/vi/channel.c

        case TEGRA_CAMERA_CID_VI_PREFERRED_STRIDE:
                chan->preferred_stride = ctrl->val;
                tegra_channel_update_format(chan, chan->format.width,
                                chan->format.height,
                                chan->format.pixelformat,
                                &chan->fmtinfo->bpp,
                                chan->preferred_stride);

Recorded video. Until I understand what the problem is. It seems to me that this is a tc358748 configuration problem

https://youtu.be/en6htMFVgHI

hello djager471,

do you have any chance to enable bridge driver’s test-pattern-generator? this may helps to narrow down the issue.
thanks

Hey.
I tried to run a test picture for HD (1280x720) resolution, the picture was normal.
Broken frames appeared at FullHd (1920x1080). Both for the test picture and for the video camera.

https://youtu.be/vAKNKH3LXKw

hello djager471,

could you please share a raw file for me checking,
for example,

$ v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=YUYV --stream-mmap --stream-count=1 --stream-to=test.raw

please also let me know your capture commands, I would like to use 3rdparty tools to analysis your raw files.
thanks

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=test.raw
raw.zip (1.5 MB)

v4l2-ctl -d /dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=UYVY --stream-mmap --stream-count=1 --stream-to=test.raw
HD.zip (2.2 MB)

hello djager471,

according to your 1080p colorbar.raw; it looks you only had 640*720 valid data. please double confirm your TPG register settings.
you may also access TX1 TRM, check Chapter-31 Video Input.
please also check [Figure 139: VI3 Pipeline Formatting for U1.13 Raw Pixel Data], and we usually using T_R16_I pixel format in memory.
thanks

1 Like

What application did you use to open the raw file?

hello djager471,

I’m using 7yuv to open Raw file as a viewer.
thanks