Loading...
首页专栏正文

nvidia xavier平台nvp6324模块调试

free-jdx 发布于 2021-02-05 18:34:08 浏览 2822 点赞 0 收藏 0

1. 前言

nvp6324模块支持四合一 模拟高清相机输入; 由于输出也是CSI接口,所以可以对接到nvidia xavier平台上

2. 驱动移植

原厂给的初始化列表; 驱动移植参照xavier平台的标准驱动框架修改即可; 例如: kernel/nvidia/drivers/media/i2c/ov5693.c

硬件连接:

video 0 -> csi2 lane0
video 1 -> csi2 lane1
video 2 -> csi3 lane0
video 3 -> csi3 lane1

目前调试只开了一路video0

3. 设备树dts修改

(1)VI& CSI端 修改
host1x {
vi@15c10000 {
num-channels = <1>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
nvp6324_vi_in0: endpoint {
port-index = <2>;
bus-width = <2>;
remote-endpoint = <&nvp6324_csi_out0>;
};
};
};
};
    nvcsi@15a00000 {
        num-channels = <1>;
        #address-cells = <1>;
        #size-cells = <0>;
        channel@0 {
            reg = <0>;
            ports {
                #address-cells = <1>;
                #size-cells = <0>;
                port@0 {
                    reg = <0>;
                    nvp6324_csi_in0: endpoint@0 {
                        port-index = <2>;
                        bus-width = <2>;
                        remote-endpoint = <&linvp6324_nvp6324_out0>;
                    };
                };
                port@1 {
                    reg = <1>;
                    nvp6324_csi_out0: endpoint@1 {
                        remote-endpoint = <&nvp6324_vi_in0>;
                    };
                };
            };
        };
    };
};
(2)I2C节点信息修改
i2c@3180000 {
    ov5693_c@31 {
        compatible = "nextchip,nvp6324_mipi";
        /* I2C device address */
        reg = <0x31>;

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

        /* ie. clocks, io pins, power sources */
        /* mclk-index indicates the index of the */
        /* mclk-name with in the clock-names array */

        clocks = <&bpmp_clks TEGRA194_CLK_EXTPERIPH1>,
                 <&bpmp_clks TEGRA194_CLK_PLLP_OUT0>;
        clock-names = "extperiph1", "pllp_grtba";
        mclk = "extperiph1";
        clock-frequency = <27000000>;
        //reset-gpios = <&tegra_main_gpio CAM0_RST_L GPIO_ACTIVE_HIGH>;
        //pwdn-gpios = <&tegra_main_gpio CAM0_PWDN GPIO_ACTIVE_HIGH>;
        //vana-supply = <&p2822_avdd_cam_2v8>;
        //vif-supply = <&p2822_vdd_1v8_cvb>;

        /* Sensor output flip settings */
        //vertical-flip = "true";
        mode0 { // nvp6324_MODE_1280*720
            mclk_khz = "27000";
            num_lanes = "2";
            tegra_sinterface = "serial_c";
            phy_mode = "DPHY";
            discontinuous_clk = "no";
            dpcm_enable = "false";
            cil_settletime = "0";

            active_w = "1280";
            active_h = "720";
            mode_type = "yuv";
            pixel_phase = "uyvy";
            csi_pixel_bit_depth = "16";
            readout_orientation = "0";
            line_length = "1800";
            inherent_gain = "1";
            mclk_multiplier = "28";
            pix_clk_hz = "756000000";

            gain_factor = "10";
            min_gain_val = "10";/* 1DB*/
            max_gain_val = "160";/* 16DB*/
            step_gain_val = "1";
            default_gain = "10";
            min_hdr_ratio = "1";
            max_hdr_ratio = "1";
            framerate_factor = "1000000";
            min_framerate = "1816577";/*1.816577 */
            max_framerate = "30000000";/*30*/
            step_framerate = "1";
            default_framerate = "30000000";
            exposure_factor = "1000000";
            min_exp_time = "34";/* us */
            max_exp_time = "550385";/* us */
            step_exp_time = "1";
            default_exp_time = "33334";/* us */
            embedded_metadata_height = "0";
        };

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

            port@0 {
                reg = <0>;
                linvp6324_nvp6324_out0: endpoint {
                    port-index = <2>;
                    bus-width = <2>;
                    remote-endpoint = <&nvp6324_csi_in0>;
                };
            };
        };
    };
};
(3)tegra-camera-platform修改
    compatible = "nvidia, tegra-camera-platform";
    num_csi_lanes = <2>;
    max_lane_speed = <1500000>;
    min_bits_per_pixel = <8>;
    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 {
            badge = "nvp6324_bottom_mipi31";
            position = "front";
            orientation = "0";
            drivernode0 {
                /* Declare PCL support driver (classically known as guid)  */
                pcl_id = "v4l2_sensor";
                /* Driver v4l2 device name */
                devname = "nvp6324_v1 2-0031";
                /* Declare the device-tree hierarchy to driver instance */
                proc-device-tree = "/proc/device-tree/i2c@3180000/nvp6324@31";
            };
        };
    };
};

4. 采集图像

报错如下:

misc tegra_camera_ctrl: tegra_camera_update_isobw: Warning, Requested ISO BW 1476562 has been capped to VI’s max BW 1000000
[ 213.877749] [RCE] vi5_hwinit: firmware CL2018101701 protocol version 2.2
[ 214.089721] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65517, flags: 0, err_data 512
[ 214.114091] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.175388] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 112, err_data 10486370
[ 214.189587] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65326, flags: 0, err_data 512
[ 214.189817] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65456, flags: 0, err_data 512
[ 214.342068] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 112, err_data 10486370
[ 214.380806] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.389569] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65429, flags: 0, err_data 512
[ 214.389777] tegra194-vi5 15c10000.vi: corr_err: discarding frame 57270, flags: 0, err_data 512
[ 214.441917] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 112, err_data 10486370
[ 214.513957] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.522937] tegra194-vi5 15c10000.vi: corr_err: discarding frame 57273, flags: 0, err_data 512
[ 214.523148] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65434, flags: 0, err_data 512
[ 214.575257] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 112, err_data 10486370
[ 214.680464] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.689778] tegra194-vi5 15c10000.vi: corr_err: discarding frame 180, flags: 0, err_data 512
[ 214.689985] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65471, flags: 0, err_data 512
[ 214.741897] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 112, err_data 10486370
[ 214.780521] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.789758] tegra194-vi5 15c10000.vi: corr_err: discarding frame 57281, flags: 0, err_data 512
[ 214.789935] tegra194-vi5 15c10000.vi: corr_err: discarding frame 65506, flags: 0, err_data 512
[ 214.838117] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 214.842009] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 546
[ 214.842237] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 0, err_data 131072
[ 214.980719] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 215.104683] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.142007] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 215.180412] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.241886] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 215.408582] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 546
[ 215.447404] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.508580] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 215.580467] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.641857] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 215.841232] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.841896] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 546
[ 215.875176] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 215.878608] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 215.941901] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 215.980512] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.080416] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.113799] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.175193] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 216.207838] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.213778] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 32, err_data 162
[ 216.241878] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.275226] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 216.347165] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.380622] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.441866] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 216.580344] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 216.641854] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 240, err_data 10486370
[ 216.780614] tegra194-vi5 15c10000.vi: corr_err: discarding frame 0, flags: 160, err_data 162
[ 219.373730] tegra194-vi5 15c10000.vi: no reply from camera processor
[ 219.373907] tegra194-vi5 15c10000.vi: uncorr_err: request timed out after 2500 ms
[ 219.374048] tegra194-vi5 15c10000.vi: err_rec: attempting to reset the capture channel
[ 219.377436] tegra194-vi5 15c10000.vi: unexpected response from camera processor
[ 219.377619] tegra194-vi5 15c10000.vi: vi capture setup failed
[ 219.377815] tegra194-vi5 15c10000.vi: fatal: error recovery failed

从上面的log信息可以大致分析出: 到VI端的图像数据有问题,有可能是clk不匹配问题,或者图像残缺问题

5. debug 工具

sudo su
echo 1 > /sys/kernel/debug/bpmp/debug/clk/vi/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/isp/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked
cat /sys/kernel/debug/bpmp/debug/clk/vi/max_rate |tee /sys/kernel/debug/bpmp/debug/clk/vi/rate
cat /sys/kernel/debug/bpmp/debug/clk/isp/max_rate | tee  /sys/kernel/debug/bpmp/debug/clk/isp/rate
cat /sys/kernel/debug/bpmp/debug/clk/nvcsi/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/nvcsi/rate

增大VI/ISP/CSI的最大时钟

调试信息如下:

To enable trace for more information
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 1 > /sys/kernel/debug/tracing/events/camera_common/enable
echo > /sys/kernel/debug/tracing/trace
cat /sys/kernel/debug/tracing/trace

root@nvidia-xavier:/home/hitron/hitron/firmware# cat /sys/kernel/debug/tracing/trace
tracer: nop
entries-in-buffer/entries-written: 35/35 #P:8
_-----=> irqs-off
/ _----=> need-resched
| / _—=> hardirq/softirq
|| / _–=> preempt-depth
||| / delay
TASK-PID CPU# |||| TIMESTAMP FUNCTION
| | | |||| | |
 kworker/0:2-1296  [000] ....   259.974862: rtos_queue_peek_from_isr_failed: tstamp:8322429346 queue:0x0bcbcf78
 kworker/0:2-1296  [000] ....   260.142869: rtos_queue_peek_from_isr_failed: tstamp:8327429353 queue:0x0bcbcf78
 kworker/0:2-1296  [000] ....   260.310838: rtos_queue_peek_from_isr_failed: tstamp:8332429344 queue:0x0bcbcf78
 kworker/0:2-1296  [000] ....   260.422925: rtos_queue_peek_from_isr_failed: tstamp:8337429344 queue:0x0bcbcf78
 kworker/0:2-1296  [000] ....   260.590895: rtos_queue_peek_from_isr_failed: tstamp:8342429342 queue:0x0bcbcf78
 kworker/0:2-1296  [000] ....   260.758834: rtos_queue_peek_from_isr_failed: tstamp:8347429342 queue:0x0bcbcf78

6. 继续采集

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=UYVY --stream-mmap --stream-count=100 -d /dev/video0

the error log:[/b]
[ 343.898810] misc tegra_camera_ctrl: tegra_camera_update_isobw: Warning, Requested ISO BW 1476562 has been capped to VI’s max BW 1000000
[ 343.977610] [RCE] Configuring VI GoS.
[ 343.977944] [RCE] VM GOS[#0] addr=0xe4900000
[ 343.978473] [RCE] VM GOS[#1] addr=0xe4901000
[ 343.978484] [RCE] VM GOS[#2] addr=0xe4902000
[ 343.978494] [RCE] VM GOS[#3] addr=0xe4903000
[ 343.978503] [RCE] VM GOS[#4] addr=0xe4904000
[ 343.978513] [RCE] VM GOS[#5] addr=0xe4905000
[ 344.091916] [RCE] vi5_hwinit: firmware CL2018101701 protocol version 2.2
[ 344.148467] [RCE] VI GOS[#0] set to VM GOS[4] base 0xe4904000
[ 344.428930] [RCE] ERROR: heartbeat-task.c:97 [heartbeat_wdt_fiq_callback] “WDT irq died. RCE in bad state.”
[ 344.580151] tegra186-cam-rtcpu bc00000.rtcpu: Alert: Camera RTCPU gone bad! restoring it immediately!!
[ 346.651741] tegra194-vi5 15c10000.vi: no reply from camera processor
[ 346.651943] tegra194-vi5 15c10000.vi: uncorr_err: request timed out after 2500 ms
[ 346.652120] tegra194-vi5 15c10000.vi: err_rec: attempting to reset the capture channel
[ 346.652404] tegra194-vi5 15c10000.vi: vi_capture_release: control failed, errno 1
[ 346.654113] tegra194-vi5 15c10000.vi: unexpected response from camera processor
[ 346.654297] tegra194-vi5 15c10000.vi: vi capture setup failed
[ 346.654440] tegra194-vi5 15c10000.vi: fatal: error recovery failed
[ 346.667657] [RCE] vi5_hwinit: firmware CL2018101701 protocol version 2.2

同时查看trace信息

cat /sys/kernel/debug/tracing/trace

kworker/0:4-2262 [000] … 119.278722: rtcpu_nvcsi_intr: tstamp:3925845007 class:CORRECTABLE_ERR type:STREAM_VC phy:0 cil:0 st:2 vc:8 status:0x0000000a
kworker/0:4-2262 [000] … 119.278722: rtcpu_nvcsi_intr: tstamp:3925845007 class:CORRECTABLE_ERR type:STREAM_VC phy:0 cil:0 st:2 vc:15 status:0x0000000a
kworker/0:4-2262 [000] … 119.278722: rtcpu_nvcsi_intr: tstamp:3925846232 class:GLOBAL type:STREAM_NOVC phy:0 cil:0 st:2 vc:0 status:0x00000001
kworker/0:4-2262 [000] … 119.278723: rtcpu_nvcsi_intr: tstamp:3925846232 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:1 status:0x0000000a
kworker/0:4-2262 [000] … 119.278723: rtcpu_nvcsi_intr: tstamp:3925846232 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:8 status:0x0000000a
kworker/0:4-2262 [000] … 119.278724: rtcpu_nvcsi_intr: tstamp:3925846232 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:15 status:0x0000000a
kworker/0:4-2262 [000] … 119.278725: rtcpu_nvcsi_intr: tstamp:3925846232 class:CORRECTABLE_ERR type:STREAM_NOVC phy:0 cil:0 st:2 vc:0 status:0x00000001
kworker/0:4-2262 [000] … 119.278725: rtcpu_nvcsi_intr: tstamp:3925846232 class:CORRECTABLE_ERR type:STREAM_VC phy:0 cil:0 st:2 vc:1 status:0x0000000a
kworker/0:4-2262 [000] … 119.278726: rtcpu_nvcsi_intr: tstamp:3925846232 class:CORRECTABLE_ERR type:STREAM_VC phy:0 cil:0 st:2 vc:8 status:0x0000000a
kworker/0:4-2262 [000] … 119.278726: rtcpu_nvcsi_intr: tstamp:3925846232 class:CORRECTABLE_ERR type:STREAM_VC phy:0 cil:0 st:2 vc:15 status:0x0000000a
kworker/0:4-2262 [000] … 119.278726: rtcpu_nvcsi_intr: tstamp:3925847774 class:GLOBAL type:STREAM_NOVC phy:0 cil:0 st:2 vc:0 status:0x00000001
kworker/0:4-2262 [000] … 119.278727: rtcpu_nvcsi_intr: tstamp:3925847774 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:1 status:0x0000000a
kworker/0:4-2262 [000] … 119.278727: rtcpu_nvcsi_intr: tstamp:3925847774 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:8 status:0x0000000a
kworker/0:4-2262 [000] … 119.278727: rtcpu_nvcsi_intr: tstamp:3925847774 class:GLOBAL type:STREAM_VC phy:0 cil:0 st:2 vc:15 status:0x0000000a
kworker/0:4-2262 [000] … 119.278728: rtcpu_nvcsi_intr: tstamp:3925847774 class:CORRECTABLE_ERR type:STREAM_NOVC phy:0 cil:0 st:2 vc:0 status:0x00000001

7. 关闭ECC check

修改如下

diff --git a/drivers/media/platform/tegra/camera/csi/csi4_fops.c b/drivers/media/platform/tegra/camera/csi/csi4_fops.c
index 0377d7b..b3d01d3 100644
--- a/drivers/media/platform/tegra/camera/csi/csi4_fops.c
+++ b/drivers/media/platform/tegra/camera/csi/csi4_fops.c
@@ -76,8 +76,18 @@ static void csi4_stream_init(struct tegra_csi_channel *chan, int port_num)
        csi4_stream_write(chan, port_num, INTR_STATUS, 0x3ffff);
        csi4_stream_write(chan, port_num, ERR_INTR_STATUS, 0x7ffff);
        csi4_stream_write(chan, port_num, ERROR_STATUS2VI_MASK, 0x0);
-       csi4_stream_write(chan, port_num, INTR_MASK, 0x0);
-       csi4_stream_write(chan, port_num, ERR_INTR_MASK, 0x0);
+
+       csi4_stream_write(chan, port_num, INTR_MASK, PH_ECC_MULTI_BIT_ERR |
+                       PD_CRC_ERR_VC0 | PH_ECC_SINGLE_BIT_ERR_VC0);
+       csi4_stream_write(chan, port_num, ERR_INTR_MASK, PH_ECC_MULTI_BIT_ERR |
+                       PD_CRC_ERR_VC0 | PH_ECC_SINGLE_BIT_ERR_VC0);
+       csi4_stream_write(chan, port_num, ERROR_STATUS2VI_MASK,
+                       CFG_ERR_STATUS2VI_MASK_VC0 |
+                       CFG_ERR_STATUS2VI_MASK_VC1 |
+                       CFG_ERR_STATUS2VI_MASK_VC2 |
+                       CFG_ERR_STATUS2VI_MASK_VC3);
 }

修改完后,效果仍然是一样的

8. 分析原因

后来分析发现使用nvp6324多路复合输入; 需要使用CSI的虚拟通道; dts需要按照CSI的vc-id来匹配接入数据

9. 参考dts修改

common/kernel-dts/t19x-common-modules/tegra194-camera-imx390-a00.dtsi

*本文仅代表作者观点,不代表易百纳技术社区立场。系作者授权易百纳技术社区发表,未经许可不得转载。

精彩评论

内容存在敏感词
打赏
打赏作者
free-jdx
您的支持将鼓励我继续创作!
金额:
¥1 ¥5 ¥10 ¥50 ¥100
支付方式:
微信支付
支付宝支付
微信支付
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

易百纳技术社区
确定要删除此文章、专栏、评论吗?
确定
取消
易百纳技术社区