T113/D1-H (MQ-Pro)驱动 OV5640 摄像头(内含驱动源码)
-
内核配置
运行
m kernel_menuconfig
勾选下列驱动Device Drivers ---> <*> Multimedia support ---> [*] V4L platform devices ---> <*> Video Multiplexer [*] SUNXI platform devices ---> <*> sunxi video input (camera csi/mipi isp vipp)driver <M> v4l2 new driver for SUNXI <*> use cci function select cci or cci to twi (chenge cci to twi) ---> [*] use IOMMU for memery alloc [*] ISP WDR module [*] sensor same i2c addr sensor driver select ---> <M> use ov5640 driver [*] Memory-to-memory multimedia devices ---> <*> Deinterlace support <*> SuperH VEU mem2mem video processing driver
设备树配置
路径:
lichee/linux-5.4/arch/riscv/boot/dts/sunxi/sun20iw1p1.dtsi
vind0: vind@5800800 { compatible = "allwinner,sunxi-vin-media", "simple-bus"; #address-cells = <2>; #size-cells = <2>; ranges; device_id = <0>; csi_top = <336000000>; csi_isp = <327000000>; reg = <0x0 0x05800800 0x0 0x200>, <0x0 0x05800000 0x0 0x800>; clocks = <&ccu CLK_CSI_TOP>, <&ccu CLK_PLL_VIDEO1_2X>, <&ccu CLK_CSI0_MCLK>, <&dcxo24M>, <&ccu CLK_PLL_VIDEO1>, <&ccu CLK_BUS_CSI>, <&ccu CLK_MBUS_CSI>; clock-names = "csi_top", "csi_top_src", "csi_mclk0", "csi_mclk0_24m", "csi_mclk0_pll", "csi_bus", "csi_mbus"; resets = <&ccu RST_BUS_CSI>; reset-names = "csi_ret"; pinctrl-names = "mclk0-default", "mclk0-sleep"; pinctrl-0 = <&csi_mclk0_pins_a>; pinctrl-1 = <&csi_mclk0_pins_b>; status = "okay"; csi0: csi@5801000{ compatible = "allwinner,sunxi-csi"; reg = <0x0 0x05801000 0x0 0x1000>; interrupts-extended = <&plic0 116 IRQ_TYPE_LEVEL_HIGH>; pinctrl-names = "default","sleep"; pinctrl-0 = <&csi0_pins_a>; pinctrl-1 = <&csi0_pins_b>; device_id = <0>; iommus = <&mmu_aw 1 1>; status = "okay"; }; isp0: isp@5809410 { compatible = "allwinner,sunxi-isp"; reg = <0x0 0x05809410 0x0 0x10>; device_id = <0xfe>; status = "okay"; }; isp1: isp@5809420 { compatible = "allwinner,sunxi-isp"; reg = <0x0 0x05809420 0x0 0x10>; device_id = <0xff>; status = "okay"; }; scaler0: scaler@5809430 { compatible = "allwinner,sunxi-scaler"; reg = <0x0 0x05809430 0x0 0x10>; device_id = <0xfe>; status = "okay"; }; scaler1: scaler@5809440 { compatible = "allwinner,sunxi-scaler"; reg = <0x0 0x05809440 0x0 0x10>; device_id = <0xff>; status = "okay"; }; actuator0: actuator@5809450 { compatible = "allwinner,sunxi-actuator"; device_type = "actuator0"; reg = <0x0 0x05809450 0x0 0x10>; actuator0_name = "ad5820_act"; actuator0_slave = <0x18>; actuator0_af_pwdn = <>; actuator0_afvdd = "afvcc-csi"; actuator0_afvdd_vol = <2800000>; status = "okay"; }; flash0: flash@5809460 { device_type = "flash0"; compatible = "allwinner,sunxi-flash"; reg = <0x0 0x05809460 0x0 0x10>; flash0_type = <2>; flash0_en = <>; flash0_mode = <>; flash0_flvdd = ""; flash0_flvdd_vol = <>; device_id = <0>; status = "okay"; }; sensor0: sensor@5809470 { reg = <0x0 0x05809470 0x0 0x10>; device_type = "sensor0"; compatible = "allwinner,sunxi-sensor"; sensor0_mname = "ov5640"; sensor0_twi_cci_id = <2>; sensor0_twi_addr = <0x78>; sensor0_mclk_id = <0>; sensor0_pos = "rear"; sensor0_isp_used = <0>; sensor0_fmt = <0>; sensor0_stby_mode = <0>; sensor0_vflip = <0>; sensor0_hflip = <0>; sensor0_iovdd-supply = <>; sensor0_iovdd_vol = <>; sensor0_avdd-supply = <>; sensor0_avdd_vol = <>; sensor0_dvdd-supply = <>; sensor0_dvdd_vol = <>; sensor0_power_en = <>; sensor0_reset = <&pio PE 14 GPIO_ACTIVE_LOW>; sensor0_pwdn = <&pio PE 15 GPIO_ACTIVE_LOW>; sensor0_sm_vs = <>; flash_handle = <&flash0>; act_handle = <&actuator0>; device_id = <0>; status = "okay"; }; sensor1: sensor@5809480 { reg = <0x0 0x05809480 0x0 0x10>; device_type = "sensor1"; compatible = "allwinner,sunxi-sensor"; sensor1_mname = "ov5647"; sensor1_twi_cci_id = <3>; sensor1_twi_addr = <0x6c>; sensor1_mclk_id = <1>; sensor1_pos = "front"; sensor1_isp_used = <0>; sensor1_fmt = <0>; sensor1_stby_mode = <0>; sensor1_vflip = <0>; sensor1_hflip = <0>; sensor1_iovdd-supply = <>; sensor1_iovdd_vol = <>; sensor1_avdd-supply = <>; sensor1_avdd_vol = <>; sensor1_dvdd-supply = <>; sensor1_dvdd_vol = <>; sensor1_power_en = <>; sensor1_reset = <&pio PE 7 GPIO_ACTIVE_LOW>; sensor1_pwdn = <&pio PE 6 GPIO_ACTIVE_LOW>; sensor1_sm_vs = <>; flash_handle = <>; act_handle = <>; device_id = <1>; status = "disabled"; }; vinc0: vinc@5809000 { compatible = "allwinner,sunxi-vin-core"; device_type = "vinc0"; reg = <0x0 0x05809000 0x0 0x200>; interrupts-extended = <&plic0 111 IRQ_TYPE_LEVEL_HIGH>; vinc0_csi_sel = <0>; vinc0_mipi_sel = <0xff>; vinc0_isp_sel = <0>; vinc0_tdm_rx_sel = <0xff>; vinc0_rear_sensor_sel = <0>; vinc0_front_sensor_sel = <0>; vinc0_sensor_list = <0>; device_id = <0>; iommus = <&mmu_aw 1 1>; status = "okay"; }; vinc1: vinc@5809200 { device_type = "vinc1"; compatible = "allwinner,sunxi-vin-core"; reg = <0x0 0x05809200 0x0 0x200>; interrupts-extended = <&plic0 112 IRQ_TYPE_LEVEL_HIGH>; vinc1_csi_sel = <0>; vinc1_mipi_sel = <0xff>; vinc1_isp_sel = <1>; vinc1_tdm_rx_sel = <0xff>; vinc1_rear_sensor_sel = <0>; vinc1_front_sensor_sel = <0>; vinc1_sensor_list = <0>; device_id = <1>; iommus = <&mmu_aw 1 1>; status = "disabled"; }; };
ROOTFS 配置
运行
m menuconfig
,勾选<*> kmod-sunxi-vin......................................... sunxi-vin support
常见错误
[VIN_ERR]media_entity_find_link null
驱动版本不匹配所致,目前SDK分支过多驱动版本过多,用下列驱动替换即可:
sunxi-vin.tar.gz解压,覆盖到
tina-d1-h/lichee/linux-5.4/drivers/media/platform/sunxi-vin
文件夹测试固件
-
-
-
-
-
-
-
@yuzukitsuru 是不是可同样适用于T113-S3
-
@yuzukitsuru 加载之后报段错误,这个版本能不能解决这个问题
root@TinaLinux:/lib/modules/5.4.61# insmod videobuf2-memops.ko root@TinaLinux:/lib/modules/5.4.61# insmod videobuf2-dma-contig.ko root@TinaLinux:/lib/modules/5.4.61# insmod videobuf2-vmalloc.ko root@TinaLinux:/lib/modules/5.4.61# insmod vin_io.ko [ 72.641600] [VIN_WARN]sensor_helper_probe: cannot get sensor0_cameravdd supply, setting it to NULL! [ 72.651954] [VIN_WARN]sensor_helper_probe: cannot get sensor0_iovdd supply, setting it to NULL! [ 72.661786] [VIN_WARN]sensor_helper_probe: cannot get sensor0_avdd supply, setting it to NULL! [ 72.671670] [VIN_WARN]sensor_helper_probe: cannot get sensor0_dvdd supply, setting it to NULL! [ 72.682016] [VIN_WARN]sensor_helper_probe: cannot get sensor1_cameravdd supply, setting it to NULL! [ 72.692318] [VIN_WARN]sensor_helper_probe: cannot get sensor1_iovdd supply, setting it to NULL! [ 72.702155] [VIN_WARN]sensor_helper_probe: cannot get sensor1_avdd supply, setting it to NULL! [ 72.711922] [VIN_WARN]sensor_helper_probe: cannot get sensor1_dvdd supply, setting it to NULL! root@TinaLinux:/lib/modules/5.4.61# insmod ov5640.ko root@TinaLinux:/lib/modules/5.4.61# insmod vin_v4l2.ko [ 94.266161] vin_csi 5801000.csi: Adding to iommu group 0 [ 94.275576] sunxi-vin-core 5809000.vinc: Adding to iommu group 0 [ 94.282873] sunxi-vin-core 5809200.vinc: Adding to iommu group 0 [ 94.291191] [VIN_WARN]get csi isp clk fail [ 94.295852] [VIN_WARN]get csi isp src clk fail [ 94.300967] [VIN_WARN]get csi mipi clk fail [ 94.305682] [VIN_WARN]get csi mipi src clk fail [ 94.310798] [VIN_WARN]get csi isp clk fail [ 94.315499] [VIN_WARN]Get isp reset control fail [ 94.321390] 8<--- cut here --- [ 94.324819] Unable to handle kernel paging request at virtual address e1d220c8 [ 94.332920] pgd = 8fd21213 [ 94.335950] [e1d220c8] *pgd=00000000 [ 94.339961] Internal error: Oops: 5 [#1] PREEMPT SMP ARM [ 94.345915] Modules linked in: vin_v4l2(+) ov5640 vin_io videobuf2_vmalloc videobuf2_dma_contig videobuf2_memops r8188eu(C) sunxi_gpadc [ 94.359591] CPU: 0 PID: 228 Comm: insmod Tainted: G C 5.4.61 #92 [ 94.367786] Hardware name: Generic DT based system [ 94.373167] PC is at __device_attach_driver+0x14/0x98 [ 94.378833] LR is at bus_for_each_drv+0xa8/0xb8 [ 94.383911] pc : [<c03d4abc>] lr : [<c03d2b9c>] psr: 20000013 [ 94.390937] sp : c3c3fb28 ip : 00000000 fp : 00000000 [ 94.396794] r10: c0b36518 r9 : 00000000 r8 : c3c34088 [ 94.402652] r7 : c03d4aa8 r6 : c3c34020 r5 : c3c3fb64 r4 : bf015158 [ 94.409972] r3 : e1d220b0 r2 : 00000000 r1 : c3c3fb64 r0 : bf015158 [ 94.417292] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 94.425295] Control: 10c5387d Table: 43cfc06a DAC: 00000051 [ 94.431738] Process insmod (pid: 228, stack limit = 0x52e7d2dc) [ 94.438375] Stack: (0xc3c3fb28 to 0xc3c40000) [ 94.443262] fb20: c3c3e000 00000000 c3c3fb64 c03d2b9c 00000000 c7491ebc [ 94.452439] fb40: c41715dc 6b4b7779 c3c34020 c3c34020 c0b36548 c3c3e000 00000001 c03d480c [ 94.461615] fb60: c3c34020 c3c34020 00000001 6b4b7779 c3c34020 c0b36548 c3c34020 c6df3080 [ 94.470792] fb80: c3c3e000 c03d37a0 c3c34020 00000000 c0b2b278 c03d1348 00000000 c6df3040 [ 94.479968] fba0: c3c34020 c3c34004 c3c4f2ec 6b4b7779 c3c34000 c3c3fc1c 00000000 c6df3040 [ 94.489144] fbc0: c3c34020 c3c34004 c3c4f2ec c04a2adc c6df3040 c3c3fc1c 6b4b7779 c3c4f8a0 [ 94.498321] fbe0: c3c3fc1c c6df3040 00000000 0000003c c3c4f2b8 c04a2b1c c3c4f8a0 c04bfea8 [ 94.507498] fc00: c3c3e000 c3c4f8a0 c6df3040 00000000 0000003c c04bff18 c3c4f8a0 3635766f [ 94.516673] fc20: 00003034 00000000 00000000 00000000 003c0000 00000000 00000000 00000000 [ 94.525849] fc40: 00000000 00000000 00000000 00000000 00000000 6b4b7779 c3ce8600 0000003c [ 94.535024] fc60: c3c4f2b8 00000000 c6df3040 c3c4f8a0 00000000 bf089be0 00000000 c3c4f2b8 [ 94.544200] fc80: 0000003c c3c4f040 c3c4f040 c3c4f8a0 c3c4f040 c3c4f0fc 00000000 bf08a4dc [ 94.553377] fca0: 00000002 00000001 c7563410 c3c4f040 c3c4f5f0 c04f6ff0 ffffffff c3c4f6f0 [ 94.562554] fcc0: 00000000 1406f400 5f697363 6b6c636d 6c705f30 0000006c 00000000 6b4b7779 [ 94.571730] fce0: 00000000 c7563410 00000000 bf0923b0 bf0923b0 c0c68b80 00000017 c0c68b84 [ 94.580907] fd00: c3c3ff28 c03d60f4 c7563410 00000000 00000000 c03d45b4 c7563410 bf0923b0 [ 94.590084] fd20: bf0923b0 c03d4ba4 00000000 00000021 c8e9d8e4 c03d49e0 bf0923b0 c7563410 [ 94.599261] fd40: 6b4b7779 00000000 c7563410 bf0923b0 c03d4ba4 00000000 00000021 c03d4b8c [ 94.608437] fd60: 00000000 c7563410 bf0923b0 c03d4c50 c7563410 c3c3e000 bf0923b0 c03d2aa8 [ 94.617614] fd80: c8e9d8e4 c74902a8 c7552eb4 6b4b7779 c74902bc bf0923b0 c3c74900 00000000 [ 94.626791] fda0: c0b2ba50 c03d3a24 bf08fd2f bf08fd3a 00000000 bf0923b0 c3c3e000 bf09b000 [ 94.635967] fdc0: 00000028 c03d5428 00000000 c3c3e000 bf09b000 bf09b07c c0b4f000 c0102efc [ 94.645144] fde0: c7401c00 8040003f 00000000 c3c3e000 00000001 c7b706e0 c7b706e0 c3c3e000 [ 94.654320] fe00: c7401e00 c3cb71c0 0000804c c3c3e000 00000001 c01c2858 00000001 c3cb71c0 [ 94.663497] fe20: bf092440 c01c33f0 bf092440 6b4b7779 bf092440 00000021 c3c75940 00000028 [ 94.672672] fe40: 00000000 c0181a34 bf092440 07081000 bf092440 00000021 bf092488 c01804c8 [ 94.681849] fe60: bf09244c 00007fff bf092440 c017dcf8 00000000 c8e9d3e4 c8e9d8e4 c08023ec [ 94.691025] fe80: bf0925dc b6e6af90 c8e79000 000003d6 00000001 00000080 c3cbcec0 c8e79000 [ 94.700201] fea0: c3c14c00 00000025 00000000 00000000 00000000 00000000 00000000 00000000 [ 94.709377] fec0: 6e72656b 00006c65 00000000 00000000 00000000 00000000 00000000 00000000 [ 94.718552] fee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6b4b7779 [ 94.727729] ff00: 00000000 0000490c b6e5091c 00000000 c8e9d90c c3c3e000 b6e6af90 c3c3e000 [ 94.736906] ff20: 00000051 c0180c18 c8e8db91 c8e8f0c0 c8e79000 0002490c c8e9d3e4 c8e9d2a4 [ 94.746082] ff40: c8e9509c 00018000 0001bd70 00008de0 0001e5dd 00000000 00000000 00000000 [ 94.755258] ff60: 00008dd0 0000001f 00000020 00000017 00000000 00000010 00000000 6b4b7779 [ 94.764434] ff80: 00000000 00000000 00000000 00000003 00000080 c0101228 c3c3e000 00000080 [ 94.773610] ffa0: 00000000 c0101000 00000000 00000000 b6e2c010 0002490c b6e6af90 00000011 [ 94.782786] ffc0: 00000000 00000000 00000003 00000080 0002490c 00000000 004c0f14 00000000 [ 94.791963] ffe0: be90fa84 be90fa68 004afe88 b6eb37ac 60000010 b6e2c010 00000000 00000000 [ 94.801151] [<c03d4abc>] (__device_attach_driver) from [<c03d2b9c>] (bus_for_each_drv+0xa8/0xb8) [ 94.811014] [<c03d2b9c>] (bus_for_each_drv) from [<c03d480c>] (__device_attach+0xc8/0x13c) [ 94.820290] [<c03d480c>] (__device_attach) from [<c03d37a0>] (bus_probe_device+0x28/0x80) [ 94.829469] [<c03d37a0>] (bus_probe_device) from [<c03d1348>] (device_add+0x5bc/0x6a4) [ 94.838356] [<c03d1348>] (device_add) from [<c04a2adc>] (i2c_new_client_device+0x1a4/0x1dc) [ 94.847729] [<c04a2adc>] (i2c_new_client_device) from [<c04a2b1c>] (i2c_new_device+0x8/0x14) [ 94.857201] [<c04a2b1c>] (i2c_new_device) from [<c04bfea8>] (v4l2_i2c_new_subdev_board+0xd0/0xd8) [ 94.867159] [<c04bfea8>] (v4l2_i2c_new_subdev_board) from [<c04bff18>] (v4l2_i2c_new_subdev+0x68/0x84) [ 94.877691] [<c04bff18>] (v4l2_i2c_new_subdev) from [<bf089be0>] (vin_remove+0x1a8/0x288 [vin_v4l2]) [ 94.888047] [<bf089be0>] (vin_remove [vin_v4l2]) from [<bf08a4dc>] (vin_probe+0x728/0xe2c [vin_v4l2]) [ 94.898447] [<bf08a4dc>] (vin_probe [vin_v4l2]) from [<c03d60f4>] (platform_drv_probe+0x48/0x94) [ 94.908308] [<c03d60f4>] (platform_drv_probe) from [<c03d45b4>] (really_probe+0x1f8/0x388) [ 94.917585] [<c03d45b4>] (really_probe) from [<c03d49e0>] (driver_probe_device+0x13c/0x154) [ 94.926959] [<c03d49e0>] (driver_probe_device) from [<c03d4b8c>] (device_driver_attach+0x44/0x5c) [ 94.936917] [<c03d4b8c>] (device_driver_attach) from [<c03d4c50>] (__driver_attach+0xac/0xb4) [ 94.946486] [<c03d4c50>] (__driver_attach) from [<c03d2aa8>] (bus_for_each_dev+0x6c/0xa4) [ 94.955664] [<c03d2aa8>] (bus_for_each_dev) from [<c03d3a24>] (bus_add_driver+0x150/0x1b0) [ 94.964940] [<c03d3a24>] (bus_add_driver) from [<c03d5428>] (driver_register+0xb4/0xf8) [ 94.973975] [<c03d5428>] (driver_register) from [<bf09b07c>] (init_module+0x7c/0x1000 [vin_v4l2]) [ 94.983985] [<bf09b07c>] (init_module [vin_v4l2]) from [<c0102efc>] (do_one_initcall+0x70/0x18c) [ 94.993849] [<c0102efc>] (do_one_initcall) from [<c0181a34>] (do_init_module+0x54/0x1dc) [ 95.002932] [<c0181a34>] (do_init_module) from [<c01804c8>] (load_module+0x1834/0x1e44) [ 95.011915] [<c01804c8>] (load_module) from [<c0180c18>] (sys_init_module+0x140/0x150) [ 95.020800] [<c0180c18>] (sys_init_module) from [<c0101000>] (ret_fast_syscall+0x0/0x54) [ 95.029874] Exception stack(0xc3c3ffa8 to 0xc3c3fff0) [ 95.035540] ffa0: 00000000 00000000 b6e2c010 0002490c b6e6af90 00000011 [ 95.044716] ffc0: 00000000 00000000 00000003 00000080 0002490c 00000000 004c0f14 00000000 [ 95.053890] ffe0: be90fa84 be90fa68 004afe88 b6eb37ac [ 95.059558] Code: e1a04000 e5903004 e1a05001 e5916000 (e5933018) [ 95.066392] ---[ end trace 4ef5ab75bbabd3a8 ]--- Segmentation fault
-
@lansecd 段错误位于_device_attach_driver,iic调用,查看配置文件是否配置iic as cci,查看iic是否扫卡,iic配置是否正常,这个报错与vin无关。另外SDK请问使用的是哪一个,mangopi开源的那个版本测试vin驱动不能用,所以我才单独打了一个包,考虑iic驱动也有类似的问题
-
@yuzukitsuru 用的芒果派Tina-Linux_20220818这个固件,我也怀疑就是II2这的问题,如果我不配置IIC AS CCI就不会段错误,这个一配上就会段错误,我再捋一下
-
@lansecd Tina-Linux-20220815
-
-
你们sdk是这么来的
-
我的MQ-D1S吃灰1年多了,准备找出来玩玩
-
学习中,看看资料
-
This post is deleted! -
这货支持isp吗?
-
正在学习摄像头这块内容,前来打卡做个记录
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号