Vim3 A311D with gc2145 camera

hello:
we test gc2145 with vim3 board
use this connector


we modify dts for gc2145

	aml_cams {
		compatible = "amlogic, cams_prober";
		status = "okay";
		pinctrl-names="default";
		pinctrl-0=<&gen_clk_ee_ao>;
		clocks = <&clkc CLKID_GEN_CLK>;
		clock-names = "g12a_24m";
		cam_0{
			cam_name = "gc2145_mipi";
			front_back = <0>;
			camera-i2c-bus = <&i2c_AO>;
			gpio_pwdn-gpios = <&gpio_expander 3 GPIO_ACTIVE_HIGH>;
			gpio_rst-gpios = <&gpio_expander 2 GPIO_ACTIVE_HIGH>;
			mirror_flip = <1>;
			vertical_flip = <1>;
			spread_spectrum = <0>;
			bt_path = "csi";
			interface = "mipi";
			clk_channel = "a";
			bt_path_count = <1>;
			status = "okay";
		};
	};
 and config kernel "gc2145-mipi "module enable

now kernel log show as follow

[    5.200395] gc2145_mipi: failed to map gpio_cam_vdd !
[    5.205610] camera dev gc2145_mipi found
[    5.209666] camera i2c addr: 0x3c
[    5.213129] bt_path :0
[    5.215642] camer pwdn_act: 0x1
[    5.218935] camer addr: 0x3c
[    5.221978] camer i2c bus: 0
[    5.371901] aml_cams: gc2145_mipi init OK
[    5.376332] gc2145_mipi_v4l2_probe, ret = 1
[    5.380456] aml_cams: gc2145_mipi uninit.
[    5.439906] Success disable mclk
[    5.444035] failed to read max_cap_size
[    5.448176] vcm mode is 0
[    5.452285] camera interface:mipi
[    5.456439] clock channel:clk a
[    5.460481] failed to read camera bayer fmt
[    5.462429] failed to read config_file path
[    5.466785] =======cam gc2145_mipi info=======
               i2c_bus_num: 0
               pwdn_act: 1
               front_back: 0
               m_flip: 1
               v_flip: 1
               i2c_addr: 0x3c
               config path:(null)
               bt_path:1
[    5.502314] new i2c device
[    5.505214] camera probe cost time = 308ms
[    5.509402] aml probe finish
[    5.512508] gc2145_mipi 4-003c: chip found @ 0x78 (Meson I2C adapter)
[    5.519027] gc2145_probe, front_back = 0
[    5.523094] t->vdev = ffffffc02680d000, video_nr = 0
[    5.528297] gc2145_probe successful

it seems successful

but the kernel reported an error at the last stage

[   12.836251] amlvideo2.0 cma memory release succeed
[   13.242924] BT_RADIO going: on
[   13.242929] AML_BT: going ON
[   13.319820] ionvid: dbg: ionvideo open
[   13.320115] ionvid: dbg: vidioc_close!!!!
[   13.320133] ionvid: dbg: vidioc_close
[   13.329366] Unable to handle kernel NULL pointer dereference at virtual address 00000018
[   13.335323] pgd = ffffffc025ace000
[   13.341342] [0000000000000018] *pgd=0000000000000000, *pud=0000000000000000
[   13.347368] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   13.350773] Modules linked in:
[   13.353814] CPU: 2 PID: 2732 Comm: v4l_id Not tainted 4.9.241 #8
[   13.353815] Hardware name: Khadas VIM3 (DT)
[   13.353817] task: ffffffc0252caa00 task.stack: ffffff80202b4000
[   13.353826] PC is at vm_init_resource+0x3c/0x108
[   13.353830] LR is at gc2145_open+0x4c/0x308
[   13.353831] pc : [<ffffff8009b1f3bc>] lr : [<ffffff8009b2821c>] pstate: 20000145
[   13.353831] sp : ffffff80202b7a90
[   13.353832] x29: ffffff80202b7a90
[   13.353833] x28: 0000000000000000
[   13.353834] x27: 0000000000000000
[   13.353835] x26: ffffff80202b7d48
[   13.353836] x25: 0000000000000000
[   13.353836] x24: ffffffc02680cec8
[   13.353837] x23: ffffffc024250300
[   13.353838] x22: ffffffc02680d010
[   13.353838] x21: 0000000000000000
[   13.353839] x20: 0000000001800000
[   13.353840] x19: ffffffc02680cec8
[   13.353841] x18: 0000000073516240
[   13.353841] x17: 0000007fab844478
[   13.353842] x16: ffffff800923dd58
[   13.353843] x15: 000000006fffff47
[   13.353843] x14: 0000000000000000

the kernel version which i used is khadas-vims-4.9.y branch

and filesystem is VIM3_Ubuntu-gnome-focal_Linux-4.9_arm64_SD-USB_V0.9-20200530(Latest release)

What should I change next?

thanks a lot

this error resulted in
when i use v4l2 operation /dev/video0 device
can’t open this device

    v4l2_fd = open("/dev/video0", O_RDWR);
    if (v4l2_fd < 0)
    {
        fprintf(stderr, "open = %d, errno = %d \r\n", v4l2_fd, errno);
        return -1;
    }

    struct v4l2_capability cap;
    if (xioctl(v4l2_fd, VIDIOC_QUERYCAP, &cap) == -1)
    {
        printf("Error opening device : unable to query device.\r\n");
        return -1;
    }
root@Khadas:/home/khadas/camera_test# ./oritest 
[ 5657.249827@4] Unable to handle kernel NULL pointer dereference at virtual address 00000018
[ 5657.252453@4] pgd = ffffffc024d7d000
[ 5657.256044@4] [0000000000000018] *pgd=0000000000000000, *pud=0000000000000000
[ 5657.263101@4] Internal error: Oops: 96000005 [#3] PREEMPT SMP
[ 5657.268819@4] Modules linked in:
[ 5657.272026@4] CPU: 4 PID: 66409 Comm: oritest Tainted: G      D         4.9.241 #8
[ 5657.279564@4] Hardware name: Khadas VIM3 (DT)
[ 5657.283898@4] task: ffffffc01673d400 task.stack: ffffff8020058000
[ 5657.289969@4] PC is at vm_init_resource+0x3c/0x108
[ 5657.294733@4] LR is at gc2145_open+0x4c/0x308
[ 5657.299064@4] pc : [<ffffff8009b1f3bc>] lr : [<ffffff8009b2821c>] pstate: 20000145
[ 5657.306604@4] sp : ffffff802005ba90
[ 5657.310071@4] x29: ffffff802005ba90 x28: 0000000000000000 
[ 5657.315530@4] x27: 0000000000000000 x26: ffffff802005bd48 
[ 5657.320990@4] x25: 0000000000000000 x24: ffffffc02680cec8 
[ 5657.326450@4] x23: ffffffc02412e100 x22: ffffffc02680d010 
[ 5657.331910@4] x21: 0000000000000000 x20: 0000000001800000 
[ 5657.337371@4] x19: ffffffc02680cec8 x18: 0000000073516240 
[ 5657.342830@4] x17: 0000007f8e4fa478 x16: ffffff800923dd58 
[ 5657.348290@4] x15: 000000006fffff47 x14: 0000000000000000 
[ 5657.353750@4] x13: 0000000000000000 x12: 000000000000f940 
[ 5657.359210@4] x11: 0000000000000004 x10: d0d0e0bfb5b4b9a6 
[ 5657.364670@4] x9 : 0000000000000000 x8 : ffffffc027408480 
[ 5657.370130@4] x7 : 0000000000003ff0 x6 : 0000000000000000 
[ 5657.375590@4] x5 : 0000000000000003 x4 : 0000000000000003 
[ 5657.381050@4] x3 : ffffffc0272ed638 x2 : 0000000000000000 
[ 5657.386510@4] x1 : 0000000000000000 x0 : ffffff800ad82d10 
  • The problem occurs between the point 2 and point 3…
static int gc2145_open(struct file *file)
{
	struct gc2145_device *dev = video_drvdata(file);
	struct gc2145_fh *fh = NULL;
	int retval = 0;

	pr_info("gc2145_open. point 1\n");
	dev->vminfo.vdin_id = dev->cam_info.vdin_path;
	dev->vminfo.bt_path_count = dev->cam_info.bt_path_count;

	pr_info("gc2145_open. dev->vminfo.vdin_id %d\n",dev->vminfo.vdin_id);
	pr_info("gc2145_open. dev->vminfo.bt_path_count %d\n",dev->vminfo.bt_path_count);
#ifdef CONFIG_CMA
	pr_info("gc2145_open. point 2\n");
	retval = vm_init_resource(16 * SZ_1M, &dev->vminfo);
	if (retval < 0) {
		pr_err("error: no cma memory\n");
		return -1;
	}
	pr_info("gc2145_open. point 3\n");
#endif

emmmm
i see the code for sensor OV08a10 in
/linux-khadas-vims-4.9.y/drivers/amlogic/isp_module/subdev/sensor/src/driver/sensor/OV08a10_drv.c
Maybe I’ll rewrite the GC2145 code with this architecture in mind??

any one can help me ?

thanks a lot

I think you use the wrong dts node. As you said, you can check our OS08A10 dts configuration.

emm
i see the vim3l board use this dts

so i use it for vim3

aml_cams {
		compatible = "amlogic, cams_prober";
		status = "okay";
		pinctrl-names="default";
		pinctrl-0=<&gen_clk_ee_ao>;
		clocks = <&clkc CLKID_GEN_CLK>;
		clock-names = "g12a_24m";
		cam_0{
			cam_name = "gc2145_mipi";
			front_back = <0>;
			camera-i2c-bus = <&i2c_AO>;
			gpio_pwdn-gpios = <&gpio_expander 3 GPIO_ACTIVE_HIGH>;
			gpio_rst-gpios = <&gpio_expander 2 GPIO_ACTIVE_HIGH>;
			mirror_flip = <1>;
			vertical_flip = <1>;
			spread_spectrum = <0>;
			bt_path = "csi";
			interface = "mipi";
			clk_channel = "a";
			bt_path_count = <1>;
			status = "okay";
		};
	};

and gc2145 is big differences with OV08A10…
I can only use this OV08A10 architecture, not gc2145-mipi.c in
/linux-khadas-vims-4.9.y/drivers/amlogic/media/camera/gc2145_mipi.c
right?

VIM3 is different from VIM3L. VIM3 contains ISP but VIM3L not.

1 Like

@numbqq @zhaowei
I am also trying to bring up ov5640 on VIM3L(without ISP).
I am able to probe the driver but i am seeing error as same as above.
I am suspecting vm_init_resource due to cma malfunction.
From initial level of debugging, i found that this error comes due to NULL value of devp devp = vm_device[info->vdin_id]; in function vm_init_resource.

were you able to solve this?
Any help or pointer will be appreciated.