香橙派5b 移植 imx415

本文详细描述了如何在香橙派5b上移植IMX415传感器,并对设备树进行配置,包括关闭OV13855并添加IMX415。文章还涉及了摄像头测试、I2C通信问题的排查以及CRC/ECC错误的可能原因分析。
摘要由CSDN通过智能技术生成

香橙派5b 移植 imx415

镜头配置

Sensor选用如下型号:香橙派OrangePi_5 RK3588S IMX415

我使用的时候更换了镜头,将该sensor装在了我的变焦780模组上,经过后续测试因为CAM1相对稳定,所以安装在CAM1。安装位置如下:

微信图片_20240106144725

配置设备树

配置 rk3588s-orangepi-5-camera*.dtsi

修改设备树,以 kernel/orange-pi-5.10-rk35xx/arch/arm64/boot/dts/rockchip/rk3588s-orangepi-5-camera3.dtsi 为例,关闭 ov13855 ,添加 imx415

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 *
 */


&csi2_dcphy1 {
	status = "disabled";

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

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_in_dcphy0: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&ov13850_out1>;
				data-lanes = <1 2>;
			};

			// mipi_in_dcphy1: endpoint@1 {
			// 	reg = <1>;
			// 	remote-endpoint = <&ov13855_out1>;
			// 	data-lanes = <1 2>;
			// };
			
			mipidcphy1_in_ucam2: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&imx415_out2>;
				data-lanes = <1 2 3 4>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			csidcphy1_out: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&mipi1_csi2_input>;
			};
		};
	};
};

&i2c2 {
	status = "okay";

	vm149cp1: vm149c@c {
		compatible = "silicon touch,vm149c";
		status = "disabled";
		reg = <0x0c>;
		rockchip,camera-module-index = <1>;
		rockchip,camera-module-facing = "front";
	};

	ov13850_3: ov13850@10 {
		compatible = "ovti,ov13850";
		status = "disabled";
		reg = <0x10>;
		clocks = <&cru CLK_MIPI_CAMARAOUT_M4>;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = <&mipim0_camera4_clk>;
		rockchip,grf = <&sys_grf>;
		reset-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
		pwdn-gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
		rockchip,camera-module-index = <1>;
		rockchip,camera-module-facing = "front";
		rockchip,camera-module-name = "CMK-CT0116";
		rockchip,camera-module-lens-name = "default";
		lens-focus = <&vm149cp1>;
		port {
			ov13850_out1: endpoint {
				remote-endpoint = <&mipi_in_dcphy0>;
				data-lanes = <1 2>;
			};
		};
	};

	// dw9714: dw9714@c {
	// 	compatible = "dongwoon,dw9714";
	// 	status = "disabled";
	// 	reg = <0x0c>;
	// 	rockchip,camera-module-index = <0>;
	// 	rockchip,vcm-start-current = <10>;
	// 	rockchip,vcm-rated-current = <85>;
	// 	rockchip,vcm-step-mode = <5>;
	// 	rockchip,camera-module-facing = "front";
	// };

	// ov13855_3: ov13855@36 {
	// 	compatible = "ovti,ov13855";
	// 	status = "disabled";
	// 	reg = <0x36>;
	// 	clocks = <&cru CLK_MIPI_CAMARAOUT_M4>;
	// 	clock-names = "xvclk";
	// 	pinctrl-names = "default";
	// 	pinctrl-0 = <&mipim0_camera4_clk>;
	// 	rockchip,grf = <&sys_grf>;
	// 	reset-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
	// 	pwdn-gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
	// 	rockchip,camera-module-index = <1>;
	// 	rockchip,camera-module-facing = "front";
	// 	rockchip,camera-module-name = "CMK-OT2016-FV1";
	// 	rockchip,camera-module-lens-name = "default";
	// 	lens-focus = <&dw9714>;
	// 	port {
	// 		ov13855_out1: endpoint {
	// 			remote-endpoint = <&mipi_in_dcphy1>;
	// 			data-lanes = <1 2>;
	// 		};
	// 	};
	// };
	
	imx415_3: imx415-3@37 {
		compatible = "sony,imx415";
		status = "disabled";
		reg = <0x37>;

		clocks = <&cru CLK_MIPI_CAMARAOUT_M4>;
		clock-names = "xvclk";
		pinctrl-names = "default";
		pinctrl-0 = <&mipim0_camera4_clk>;
		power-domains = <&power RK3588_PD_VI>;

		rockchip,grf = <&sys_grf>;
		reset-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>;
		power-gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
		// pwdn-gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
        
		orangepi,clkout-enabled-index = <0>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "CMK-OT2022-PX1";
		rockchip,camera-module-lens-name = "IR0147-50IRC-8M-F20";
		// rockchip,camera-module-name = "RADXA-CAMERA-4K";
		// rockchip,camera-module-lens-name = "DEFAULT";
		port {
			imx415_out2: endpoint {
				remote-endpoint = <&mipidcphy1_in_ucam2>;
				data-lanes = <1 2 3 4>;
			};
		};
	};
};

&mipi1_csi2 {
	status = "disabled";

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

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi1_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&csidcphy1_out>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi1_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in1>;
			};
		};
	};
};

&rkcif_mipi_lvds1 {
	status = "disabled";

	port {
		cif_mipi_in1: endpoint {
			remote-endpoint = <&mipi1_csi2_output>;
		};
	};
};

&rkcif_mipi_lvds1_sditf {
	status = "disabled";

        port {
                mipi1_lvds_sditf: endpoint {
                        remote-endpoint = <&isp1_in0>;
                };
        };
};

&rkisp1_vir0 {
	status = "disabled";

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

		isp1_in0: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi1_lvds_sditf>;
		};
	};
};

以此类推,修改三个 dtsi 文件:

image-20240104211758917

配置 rk3588-imx415-c*.dts

再增加三个激活的设备树文件,分别对应香橙派上的三个相机接口:

image-20240104211908213

添加的路径为: kernel/orange-pi-5.10-rk35xx/arch/arm64/boot/dts/rockchip/overlay/rk3588-imx415-c1.dts

添加的内容如下:

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&csi2_dphy0_hw>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@1 {
		target = <&csi2_dphy0>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@2 {
		target = <&mipi2_csi2>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@3 {
		target = <&rkcif_mipi_lvds2>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@4 {
		target = <&rkcif_mipi_lvds2_sditf>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@5 {
		target = <&rkisp0_vir1>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@6 {
		target = <&i2c7>;

		__overlay__ {
			status = "okay";

			imx415-1@37 {
				status = "okay";
			};
		};
	};

	fragment@7 {
		target = <&rkcif>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@8 {
		target = <&rkcif_mmu>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@9 {
		target = <&rkisp0>;

		__overlay__ {
			status = "okay";
		};
	};

	fragment@10 {
		target = <&isp0_mmu>;

		__overlay__ {
			status = "okay";
		};
	};
};

然后在 kernel/orange-pi-5.10-rk35xx/arch/arm64/boot/dts/rockchip/overlay/Makefile 目录下面添加编译:

image-20240104211528984

编译下载dtb文件

然后使用命令重编kernel,会自动将 dts 文件编译,在对应目录下载这四个文件即可:

image-20240104212134398

rk3588s-orangepi-5b.dts 和三个 dtsi 文件在同一目录下。

之所以更新 rk3588s-orangepi-5b.dts ,是因为三个 dtsi 文件是被其调用的,不会单独生成 dtb

image-20240104212334048

rk3588s-orangepi-5b.dts 更新到 /boot/dtb/rockchip

image-20240104212609464

三个 .dtbo 更新到 /boot/dtb/rockchip/overlay

image-20240104212757240

配置板端加载imx415

最后在香橙派上直接输入 sudo orangepi-config ,在 System->Hardware 里空格选择对应在对应camera接口位置加载,回车save然后reboot。

image-20240104212949414

测试camera

测试命令:

gst-launch-1.0 v4l2src device=/dev/video11 ! video/x-raw,format=NV12,width=1920,height=1080, framerate=60/1 ! xvimagesink

iq文件有些问题,颜色有点失真,不过可以正常出图:

Screenshot from 2024-01-06 13-10-27

问题解决

1. 上电读取不到sensor id

香橙派上读取imx415寄存器报错:

Screenshot from 2024-01-04 19-05-59

找到报错源头,I2C 通信出错:

image-20240104190233766

最终排查,相机电源引脚及I2C未正常配置,配置完成后,即可正常启动。

使用的imx415芯片两个 SLAMODE 引脚均拉高,因此I2C从机地址为 0x37 ,参照下图:

image-20240105215525175

同时,本电路中复位脚需配置 reset-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; ,应该注意。

最终成功dmesg信息如下:

Screenshot from 2024-01-05 21-53-20

2. 出图一段时间出现crc/ecc错误

image-20240105211857735

搜索的可能原因如下 1

  • 驱动配置的MIPI时钟与sensor输出的MIPI时钟对应不上
  • MIPI时序错误,例如SOT的时序不符合MIPI的SPEC
  • MIPI信号质量不佳导致的报错

后来发现,在camera1接口可以稳定出图,而2、3接口存在相关问题。考虑cam2、cam3使用的是时钟4:

image-20240106131535673

而CAM1使用的是时钟3:

image-20240106131558386

可能是相关时钟源导致的,等待进一步验证相关问题。



部分图片来源网络,如有侵权请联系我删除。
如有疑问或错误,欢迎和我私信交流指正。
版权所有,未经授权,请勿转载!
Copyright © 2024.01 by Mr.Idleman. All rights reserved.


参考文献


  1. camera调试:RK3588 apk打开不出图如何排查? ↩︎

  • 19
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr.Idleman

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值