[rapa3기][3조][운행정보를 활용한 운전 습관 개선 시스템 개발] AI-G 보드와 imx219 모듈을 활용한 이미지 취득 관련 질문 드립니다

안녕하세요, 최근 qna 및 docs, sdk git 업데이트를 살펴보며 AI-G에 imx219 모듈을 활용하여 이미지 캡쳐를 시도하고 있습니다.
다만 카메라 인식 및 신호취득은 잘 되지만 이미지 저장 시 0바이트로 저장되는 이슈가 있습니다.

진행 순서

  • topst sdk를 원격저장소 상태로 최신회
    • meta-topst-bsp 브랜치 1.3.0-r01
    • kernel-source 브랜치 release/ai/1.1.0*
  • isp 포함 각종 sstate 캐시 삭제
  • local.conf 수정 후 빌드 (기존 ov5647 주석 후 imx219 활성화)

문의 사항

  • qna 참고사항 및 매뉴얼을 그대로 따라해보아도 이미지 저장이 올바르게 되지 않습니다. AI-G 보드에 imx219 모듈을 활용하여 취득 시 어떤 과정을 추가로 거쳐야 하는지 확인해주시면 너무 감사하겠습니다.

  • docs의 내용이 d3-g를 기준으로 되어있는 것 같습니다. 최신 커밋에서 만들어주신 ai-g 의 imx219 dtsi 파일은 d3g가 video0을 사용하는 것과 달리, videoinput2를 사용하는 것으로 확인했습니다. 해당 사항이 이미지 취득 관련 이슈와 연관이 있는지 궁금합니다. 확인을 위해 제가 빌드하고 있는 dtsi는 바로 아래에 첨부드리겠습니다.

  • 현재 보드 내 이미지 취득 환경을 점검하려면 어떠한 사항들을 주로 확인해야하는지 궁금합니다.

  • ai-g imx219 dtsi 파일
    kernel-source/arch/arm64/boot/dts/telechips/tcc750x/override/tcc750x-videoinput-imx219.dtsi

/ {
        imx219_vana: fixedregulator@0 {
                compatible = "regulator-fixed";
                regulator-name = "imx219_vana";
                regulator-min-microvolt = <2800000>;
                regulator-max-microvolt = <2800000>;
                enable-active-high;
                regulator-always-on;
        };

        imx219_vdig: fixedregulator@1 {
                compatible = "regulator-fixed";
                regulator-name = "imx219_vdig";
                regulator-min-microvolt = <1800000>;
                regulator-max-microvolt = <1800000>;
                enable-active-high;
                regulator-always-on;
        };

        imx219_vddl: fixedregulator@2 {
                compatible = "regulator-fixed";
                regulator-name = "imx219_vddl";
                regulator-min-microvolt = <1200000>;
                regulator-max-microvolt = <1200000>;
                enable-active-high;
                regulator-always-on;
        };

        imx219_clk: imx219_clk {
                compatible = "fixed-clock";
                #clock-cells = <1>;
                clock-frequency = <24000000>;
        };
};

&i2c3 {
        status = "okay";
        imx219@10 {
                compatible = "sony,imx219";
                status = "okay";
                reg = <0x10>;

                clocks = <&imx219_clk 200>;
                clock-names = "xclk";
                clock-frequency = <24000000>;

                VANA-supply = <&imx219_vana>;   // 2.8v
                VDIG-supply = <&imx219_vdig>;   // 1.8v
                VDDL-supply = <&imx219_vddl>;   // 1.2v

                reset-gpios = <&gpg 3 GPIO_ACTIVE_HIGH>;

                ports {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        port@0 {
                                reg = <0>;
                                imx219_out0: endpoint@0 {
                                        remote-endpoint = <&mipi_csi2_0_in>;
                                        io-direction = "output";
                                        channel = <0>;

                                        clock-lanes = <0>;
                                        data-lanes = <1 2>;
                                        clock-noncontinuous;
                                        link-frequencies =
                                                /bits/ 64 <456000000>;
                                };
                        };
                };
        };
};

&mipi_csi2_0 {
        status = "okay";
        ports {
                #address-cells = <1>;
                #size-cells = <0>;
                /*
                 * 0
                 * input port.
                 *
                 * 1 ~ 4
                 * output ports. (1: VC0 ~ 4: VC3)
                 */
                port@0 {
                        reg = <0>;
                        mipi_csi2_0_in: endpoint {
                                remote-endpoint = <&imx219_out0>;
                                io-direction    = "input";
                                num-channel     = <4>;

                                /*
                                 * 0: CH0 only, no data interleave
                                 * 1: DT only
                                 * 2: VC only
                                 * 3: VC and DT
                                 */
                                interleave-mode = <0>;
                                hs-settle = <13>;
                                data-lanes = <1 2>;
                        };
                };
                port@1 {
                        reg = <1>;
                        mipi_csi2_0_out0: endpoint {
                                remote-endpoint = <&isp0_in>;
                                io-direction    = "output";
                                channel         = <0>;
                                /*
                                 * 0: Single pixel mode
                                 * 1: Dual pixel mode (RAW8/10/12, YUV422)
                                 * 2: Quad pixel mode (RAW8/10/12)
                                 * 3: Invalid
                                 */
                                pixel-mode = <0>;
                        };
                };
                port@2 {
                        reg = <2>;
                        mipi_csi2_0_out1: endpoint {
                                io-direction    = "output";
                                channel         = <1>;
                                pixel-mode = <0>;
                        };
                };
                port@3 {
                        reg = <3>;
                        mipi_csi2_0_out2: endpoint {
                                io-direction    = "output";
                                channel         = <2>;
                                pixel-mode = <0>;
                        };
                };
                port@4 {
                        reg = <4>;
                        mipi_csi2_0_out3: endpoint {
                                io-direction    = "output";
                                channel         = <3>;
                                pixel-mode = <0>;
                        };
                };
        };
};

&mipi_wrap {
        isp0-bypass = <0>;
};

&isp0 {
        status = "okay";
        mem_share = <1>;
        /*
         * 0: RGGB
         * 1: RCCB (ISP0 only)
         * 2: RCCC (ISP0 only)
         * 3: RGBIR (ISP0 only)
         */
        cfa = <0>;

        /* buffer for 3DNR */
        //memory-region = <&pmap_isp0_3dnr>;

        /*
         * Crop output image (X, Y)
         * X: The number of left pixel. It will also crop X pixels of right.
         * Y: The number of top pixel. It will also crop Y pixels of bottom.
         * The default value is (8, 8).
         */
        out_win_crop = <4 8>;

        ports {
                #address-cells = <1>;
                #size-cells = <0>;
                port@0 {
                        reg = <0>;
                        isp0_in: endpoint {
                                remote-endpoint = <&mipi_csi2_0_out0>;
                                io-direction    = "input";
                        };
                };
                port@1 {
                        reg = <1>;
                        isp0_out: endpoint {
                                remote-endpoint = <&videoinput2_in>;
                                io-direction    = "output";
                        };
                };
        };
};

&videoinput2 {
        status          = "okay";
        /* memory-region
         *  - [0]: parking guideline
         *  - [1]: deinterlacing by viqe
         *  - [2]: preview
         *  - [3]: last frame
         */
        cam-ch = <0>;
        memory-region   = <0
						   0
						   &pmap_rearcamera2
						   0>;
        port {
                videoinput2_in: endpoint {
                        remote-endpoint = <&isp0_out>;
                        io-direction    = "input";
                        stream-enable   = <1>;  // VIN_CTRL.SE
                        flush-vsync     = <1>;  // VIN_MISC.FVS
                };
        };
};

보드 내에 확인할 수 있는 사항

media-ctl -p

ai-g-topst:~$ media-ctl -p
Media controller API version 5.10.223

Media device information
------------------------
driver          tcc-cap-media-d
model           Telechips capture subsystem
serial
bus info        platform:camera sub-system
hw revision     0x0
driver version  5.10.223

Device topology
- entity 1: videoinput2 (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video2
        pad0: Sink
                <- "tcc-isp-0":1 [ENABLED,IMMUTABLE]

- entity 5: tcc-isp-0 (2 pads, 2 links)
            type V4L2 subdev subtype Unknown flags 1
            device node name /dev/v4l-subdev0
        pad0: Sink
                [fmt:SBGGR10_1X10/1640x1232 field:none colorspace:raw xfer:none ycbcr:601 quantization:full-range]
                <- "mipi_csi2_0":1 [ENABLED,IMMUTABLE]
        pad1: Source
                [fmt:UYVY8_1X16/1632x1216 field:none]
                -> "videoinput2":0 [ENABLED,IMMUTABLE]

- entity 8: mipi_csi2_0 (5 pads, 2 links)
            type V4L2 subdev subtype Unknown flags 1
            device node name /dev/v4l-subdev1
        pad0: Sink
                [fmt:SBGGR10_1X10/1640x1232 field:none colorspace:raw xfer:none ycbcr:601 quantization:full-range]
                <- "imx219 3-0010":0 [ENABLED,IMMUTABLE]
        pad1: Source
                [fmt:SBGGR10_1X10/1640x1232 field:none colorspace:raw xfer:none ycbcr:601 quantization:full-range]
                -> "tcc-isp-0":0 [ENABLED,IMMUTABLE]
        pad2: Source
                [fmt:UYVY8_2X8/1x1 field:none]
        pad3: Source
                [fmt:UYVY8_2X8/1x1 field:none]
        pad4: Source
                [fmt:UYVY8_2X8/1x1 field:none]

- entity 14: imx219 3-0010 (1 pad, 1 link)
             type V4L2 subdev subtype Sensor flags 0
             device node name /dev/v4l-subdev2
        pad0: Source
                [fmt:SBGGR10_1X10/1640x1232 field:none colorspace:raw xfer:none ycbcr:601 quantization:full-range
                 crop.bounds:(8,8)/3280x2464
                 crop:(8,8)/3280x2464]
                -> "mipi_csi2_0":0 [ENABLED,IMMUTABLE]

이미지 캡쳐 시도 시 결과

ai-g-topst:~$  v4l2-ctl --device=/dev/video2 --stream-mmap=3 --stream-count=1 --stream-to=frame.raw --verbose
VIDIOC_QUERYCAP: ok
                VIDIOC_REQBUFS retu[ 1743.556389] tcc-isp 16080000.isp0: [ERROR][tcc-isp] tcc_isp_cmm_read_file(36) - request_firmware(tcc-isp-fw) returned error(-2)
rned 0 (Success)
                VIDIOC_QUERY[ 1743.570285] tcc-isp 16080000.isp0: [ERROR][tcc-isp] tcc_isp_load_fw(485) - FAIL - loading firmware(tcc-isp-fw)
BUF returned 0 (Success)
                VIDI[ 1743.583048] tcc-isp 16080000.isp0: [ERROR][tcc-isp] tcc_isp_init(465) - tcc_isp_load_fw returned -2
OC_QUERYBUF returned 0 (Success)[ 1743.594853] tcc-cap-media-drv tcc_cap_media: [ERROR][tcc-cap-media-drv] tcc_cap_media_call_sd_init(377) - init of tcc-isp-0 returned -2

                VIDIOC_QUERYBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_QBUF returned 0 (Success)
                VIDIOC_STREAMON returned 0 (Success)
cap dqbuf: 0 seq:    312 bytesused: 614400 ts: 1743.710153 (ts-monotonic, ts-src-soe)

ai-g-topst:~$ ls -l
total 0
-rw-r--r-- 1 topst topst 0 Apr 28 18:27 frame.raw
ai-g-topst:~$

안녕하세요, 검토 후 답변 드리겠습니다.
감사합니다.

안녕하세요. 관련하여 아래 링크에 답변 남겼습니다.

패치파일 보신 후 kernel 코드 수정하여 재빌드 후 동작 확인 부탁드립니다.

감사합니다!

넵 해당 사항 참고하여 실시간 스트리밍 환경도 잘 구현했습니다.
감사합니다!

1 Like