khadas / fenix

One-stop script set to build Ubuntu/Debian images
GNU General Public License v2.0
211 stars 135 forks source link

Corrupt video stream for MIPI CSI2 (IMX415) when docker or podman is installed (Edge2) #303

Closed flschmid89 closed 1 month ago

flschmid89 commented 1 month ago

The image was built with fenix with the current master branch. On the first camera port of a Edge2 board, the original Khadas IMX415 camera is mounted. After a fresh installation, the camera is recording images. But when docker or podman is installed and the device is rebooted, the v4l2 device is not delivering any frames and a "select timeout" error is displayed. After deinstallation of docker/podman and a restart, the camera is delivering frames again.


`Welcome to Fenix 1.6.9.1 Debian GNU/Linux 12 (bookworm) Linux 5.10.198
 _  ___               _             _____    _            ____
| |/ / |__   __ _  __| | __ _ ___  | ____|__| | __ _  ___|___ \
| ' /| '_ \ / _` |/ _` |/ _` / __| |  _| / _` |/ _` |/ _ \ __) |
| . \| | | | (_| | (_| | (_| \__ \ | |__| (_| | (_| |  __// __/
|_|\_\_| |_|\__,_|\__,_|\__,_|___/ |_____\__,_|\__, |\___|_____|
                                               |___/

 * Website:        https://www.khadas.com
 * Documentation:  https://docs.khadas.com
 * Forum:          https://forum.khadas.com

Last login: Sun Jul 14 22:52:45 2024 from 192.168.178.83
root@Khadas:~# v4l2-ctl -d /dev/video42 --set-fmt-video=width=3840,height=2160,pixelformat=NV12 --stream-mmap=3 --stream-skip=3 --stream-to=/tmp/data42.yuv --stream-count=1 --stream-poll` 

Logs from dmesg with enabled tracing during v4l2 capture command:

[ 1963.659417] video42: VIDIOC_QUERYCAP: driver=rkisp_v6, card=rkisp_mainpath, bus=platform:rkisp0-vir1, version=0x00020400, capabilities=0x84201000, device_caps=0x04201000
[ 1963.659444] video42: VIDIOC_QUERY_EXT_CTRL: id=0x9f0001, type=6, name=Image Processing Controls, min/max=0/0, step=0, default=0, flags=0x00000044, elem_size=4, elems=1, nr_of_dims=0, dims=0,0,0,0
[ 1963.659461] video42: VIDIOC_TRY_EXT_CTRLS: which=0x0, count=0, error_idx=0, request_fd=0
[ 1963.659476] video42: VIDIOC_QUERYCTRL: id=0x9f0001, type=6, name=Image Processing Controls, min/max=0/0, step=0, default=0, flags=0x00000044
[ 1963.659490] video42: VIDIOC_G_SELECTION: type=vid-cap, target=0, flags=0x0, wxh=3840x2160, x,y=0,0
[ 1963.659505] video42: VIDIOC_QUERYCAP: driver=rkisp_v6, card=rkisp_mainpath, bus=platform:rkisp0-vir1, version=0x00020400, capabilities=0x84201000, device_caps=0x04201000
[ 1963.659605] video42: VIDIOC_QUERY_EXT_CTRL: id=0x9f0001, type=6, name=Image Processing Controls, min/max=0/0, step=0, default=0, flags=0x00000044, elem_size=4, elems=1, nr_of_dims=0, dims=0,0,0,0
[ 1963.659623] video42: VIDIOC_QUERY_EXT_CTRL: id=0x9f0001, type=6, name=Image Processing Controls, min/max=0/0, step=0, default=0, flags=0x00000044, elem_size=4, elems=1, nr_of_dims=0, dims=0,0,0,0
[ 1963.659639] video42: VIDIOC_QUERY_EXT_CTRL: id=0x9f0902, type=5, name=Pixel Rate, min/max=0/1000000000, step=1, default=1000000000, flags=0x00000084, elem_size=8, elems=1, nr_of_dims=0, dims=0,0,0,0
[ 1963.659662] video42: VIDIOC_QUERY_EXT_CTRL: error -22: id=0xc09f0902, type=0, name=, min/max=0/0, step=0, default=0, flags=0x00000000, elem_size=0, elems=0, nr_of_dims=0, dims=0,0,0,0
[ 1963.659683] video42: VIDIOC_G_FMT: type=vid-cap-mplane, width=3840, height=2160, format=NV12, field=none, colorspace=0, num_planes=1, flags=0x0, ycbcr_enc=0, quantization=1, xfer_func=0
[ 1963.659699] plane 0: bytesperline=3840 sizeimage=12441600
[ 1963.659707] video42: VIDIOC_ENUM_FMT: index=0, type=vid-cap-mplane, flags=0x0, pixelformat=UYVY, mbus_code=0x0000, description='UYVY 4:2:2'
[ 1963.659720] video42: VIDIOC_ENUM_FMT: index=1, type=vid-cap-mplane, flags=0x0, pixelformat=NV16, mbus_code=0x0000, description='Y/CbCr 4:2:2'
[ 1963.659733] video42: VIDIOC_ENUM_FMT: index=2, type=vid-cap-mplane, flags=0x0, pixelformat=NV61, mbus_code=0x0000, description='Y/CrCb 4:2:2'
[ 1963.659746] video42: VIDIOC_ENUM_FMT: index=3, type=vid-cap-mplane, flags=0x0, pixelformat=NV21, mbus_code=0x0000, description='Y/CrCb 4:2:0'
[ 1963.659759] video42: VIDIOC_ENUM_FMT: index=4, type=vid-cap-mplane, flags=0x0, pixelformat=NV12, mbus_code=0x0000, description='Y/CbCr 4:2:0'
[ 1963.659775] video42: VIDIOC_S_FMT: type=vid-cap-mplane, width=3840, height=2160, format=NV12, field=none, colorspace=0, num_planes=1, flags=0x0, ycbcr_enc=0, quantization=1, xfer_func=0
[ 1963.659790] plane 0: bytesperline=3840 sizeimage=12441600
[ 1963.659805] video42: VIDIOC_G_SELECTION: error -22: type=vid-cap-mplane, target=256, flags=0x0, wxh=0x0, x,y=0,0
[ 1963.659821] video42: VIDIOC_G_SELECTION: type=vid-out-mplane, target=0, flags=0x0, wxh=3840x2160, x,y=0,0
[ 1963.659861] video42: VIDIOC_SUBSCRIBE_EVENT: error -25: type=0x2, id=0x0, flags=0x0
[ 1963.659876] video42: VIDIOC_SUBSCRIBE_EVENT: error -25: type=0x5, id=0x0, flags=0x0
[ 1963.659889] video42: VIDIOC_G_INPUT: error -25: value=0
[ 1963.661737] videobuf2_common: [cap-00000000185d23ed] __setup_offsets: buffer 0, plane 0 offset 0x00000000
[ 1963.663964] videobuf2_common: [cap-00000000185d23ed] __setup_offsets: buffer 1, plane 0 offset 0x00bde000
[ 1963.665708] videobuf2_common: [cap-00000000185d23ed] __setup_offsets: buffer 2, plane 0 offset 0x017bc000
[ 1963.665740] videobuf2_common: [cap-00000000185d23ed] __vb2_queue_alloc: allocated 3 buffers, 1 plane(s) each
[ 1963.665750] video42: VIDIOC_REQBUFS: count=3, type=vid-cap-mplane, memory=mmap
[ 1963.665783] video42: VIDIOC_QUERYBUF: 00:00:00.000000000 index=0, type=vid-cap-mplane, request_fd=0, flags=0x00002000, field=any, sequence=0, memory=mmap
[ 1963.665801] plane 0: bytesused=0, data_offset=0x00000000, offset/userptr=0x0, length=12441600
[ 1963.665805] timecode=00:00:00 type=0, flags=0x00000000, frames=0, userbits=0x00000000
[ 1963.665812] video42: VIDIOC_QUERYBUF: 00:00:00.000000000 index=1, type=vid-cap-mplane, request_fd=0, flags=0x00002000, field=any, sequence=0, memory=mmap
[ 1963.665827] plane 0: bytesused=0, data_offset=0x00000000, offset/userptr=0xbde000, length=12441600
[ 1963.665832] timecode=00:00:00 type=0, flags=0x00000000, frames=0, userbits=0x00000000
[ 1963.665837] video42: VIDIOC_QUERYBUF: 00:00:00.000000000 index=2, type=vid-cap-mplane, request_fd=0, flags=0x00002000, field=any, sequence=0, memory=mmap
[ 1963.665856] plane 0: bytesused=0, data_offset=0x00000000, offset/userptr=0x17bc000, length=12441600
[ 1963.665860] timecode=00:00:00 type=0, flags=0x00000000, frames=0, userbits=0x00000000
[ 1963.667249] videobuf2_common: [cap-00000000185d23ed] vb2_mmap: buffer 0, plane 0 successfully mapped
[ 1963.668649] videobuf2_common: [cap-00000000185d23ed] vb2_mmap: buffer 1, plane 0 successfully mapped
[ 1963.669975] videobuf2_common: [cap-00000000185d23ed] vb2_mmap: buffer 2, plane 0 successfully mapped
[ 1963.670518] videobuf2_common: [cap-00000000185d23ed] vb2_core_qbuf: qbuf of buffer 0 succeeded
[ 1963.671036] videobuf2_common: [cap-00000000185d23ed] vb2_core_qbuf: qbuf of buffer 1 succeeded
[ 1963.671600] videobuf2_common: [cap-00000000185d23ed] vb2_core_qbuf: qbuf of buffer 2 succeeded
[ 1963.671619] video42: VIDIOC_G_FMT: type=vid-cap-mplane, width=3840, height=2160, format=NV12, field=none, colorspace=0, num_planes=1, flags=0x0, ycbcr_enc=0, quantization=1, xfer_func=0
[ 1963.671636] plane 0: bytesperline=3840 sizeimage=12441600
[ 1963.678630] rkisp_hw fdcb0000.rkisp: set isp clk = 300000000Hz
[ 1963.679067] rkcif-mipi-lvds1: stream[0] start streaming
[ 1963.682625] rkcif-mipi-lvds1: Allocate dummy buffer, size: 0x01028000
[ 1963.682667] rockchip-mipi-csi2 mipi1-csi2: stream on, src_sd: 0000000046d63494, sd_name:rockchip-csi2-dphy0
[ 1963.682672] rockchip-mipi-csi2 mipi1-csi2: stream ON
[ 1963.682692] rockchip-csi2-dphy0: dphy0, data_rate_mbps 892
[ 1963.682957] rockchip-csi2-dphy csi2-dcphy1: csi2_dphy_s_stream stream on:1, dphy0, ret 0
[ 1963.682972] imx415 3-001a: s_stream: 1. 3864x2192, hdr: 0, bpp: 12
[ 1963.682980] imx415 3-001a: write reg array error
[ 1963.770216] imx415 3-001a: write reg array, sleep 30ms
[ 1963.771606] imx415 3-001a: set vblank 0x3a vts 2250
[ 1963.773071] imx415 3-001a: set exposure(shr0) 2149 = cur_vts(2250) - val(101)
[ 1963.773927] imx415 3-001a: set analog gain 0x0
[ 1963.776495] videobuf2_common: [cap-00000000496d7796] vb2_core_streamon: successful
[ 1963.776500] videobuf2_common: [cap-00000000185d23ed] vb2_core_streamon: successful
[ 1963.776517] video42: VIDIOC_STREAMON: type=vid-cap-mplane
[ 1963.776526] video42: VIDIOC_G_FMT: type=vid-cap-mplane, width=3840, height=2160, format=NV12, field=none, colorspace=0, num_planes=1, flags=0x0, ycbcr_enc=0, quantization=1, xfer_func=0
[ 1963.776532] plane 0: bytesperline=3840 sizeimage=12441600
[ 1963.776740] videobuf2_common: [out-00000000c228c859] vb2_core_streamon: successful
[ 1963.924543] videobuf2_common: [out-00000000ff4b814a] vb2_core_qbuf: qbuf of buffer 1 succeeded
[ 1963.991073] videobuf2_common: [out-00000000ff4b814a] vb2_core_qbuf: qbuf of buffer 2 succeeded
[ 1963.991107] videobuf2_common: [out-00000000ff4b814a] vb2_core_dqbuf: returning done buffer
[ 1963.991117] videobuf2_common: [out-00000000ff4b814a] vb2_core_dqbuf: dqbuf of buffer 0, state: dequeued
[ 1964.057762] videobuf2_common: [out-00000000ff4b814a] vb2_core_qbuf: qbuf of buffer 0 succeeded
[ 1965.789944] videobuf2_common: [out-00000000ff4b814a] vb2_core_streamoff: successful
[ 1965.790070] videobuf2_common: [cap-00000000ad7ff890] vb2_core_streamoff: successful
[ 1965.790106] videobuf2_common: [out-00000000ff4b814a] __vb2_buf_mem_free: freed plane 0 of buffer 0
[ 1965.790118] videobuf2_common: [out-00000000ff4b814a] __vb2_buf_mem_free: freed plane 0 of buffer 1
[ 1965.790129] videobuf2_common: [out-00000000ff4b814a] __vb2_buf_mem_free: freed plane 0 of buffer 2
[ 1965.790139] videobuf2_common: [out-00000000ff4b814a] __vb2_buf_mem_free: freed plane 0 of buffer 3
[ 1965.790195] videobuf2_common: [out-00000000c228c859] vb2_core_streamoff: successful
[ 1965.790198] videobuf2_common: [cap-00000000ad7ff890] __vb2_buf_mem_free: freed plane 0 of buffer 0
[ 1965.790206] videobuf2_common: [cap-00000000ad7ff890] __vb2_buf_mem_free: freed plane 0 of buffer 1
[ 1965.790213] videobuf2_common: [cap-00000000ad7ff890] __vb2_buf_mem_free: freed plane 0 of buffer 2
[ 1965.790225] videobuf2_common: [cap-00000000ad7ff890] __vb2_buf_mem_free: freed plane 0 of buffer 3
[ 1965.790254] rkcif-mipi-lvds1: stream[0] start stopping, total mode 0x1, cur 0x1
[ 1965.795450] videobuf2_common: [cap-00000000185d23ed] __vb2_buf_mem_free: freed plane 0 of buffer 0
[ 1965.797802] videobuf2_common: [cap-00000000185d23ed] __vb2_buf_mem_free: freed plane 0 of buffer 1
[ 1965.800220] videobuf2_common: [cap-00000000185d23ed] __vb2_buf_mem_free: freed plane 0 of buffer 2
[ 1965.856573] rockchip-mipi-csi2 mipi1-csi2: stream off, src_sd: 0000000046d63494, sd_name:rockchip-csi2-dphy0
[ 1965.856597] rockchip-mipi-csi2 mipi1-csi2: stream OFF
[ 1965.857658] rockchip-csi2-dphy csi2-dcphy1: csi2_dphy_s_stream_stop stream stop, dphy0
[ 1965.857674] rockchip-csi2-dphy csi2-dcphy1: csi2_dphy_s_stream stream on:0, dphy0, ret 0
[ 1965.857700] imx415 3-001a: s_stream: 0. 3864x2192, hdr: 0, bpp: 12
[ 1965.858190] rkcif-mipi-lvds1: stream[0] stopping finished, dma_en 0x0
[ 1965.858246] videobuf2_common: [cap-00000000496d7796] vb2_core_streamoff: successful
[ 1965.869714] videobuf2_common: [cap-00000000496d7796] __vb2_buf_mem_free: freed plane 0 of buffer 0
[ 1965.872797] videobuf2_common: [cap-00000000496d7796] __vb2_buf_mem_free: freed plane 0 of buffer 1
[ 1965.875895] videobuf2_common: [cap-00000000496d7796] __vb2_buf_mem_free: freed plane 0 of buffer 2
[ 1965.878950] videobuf2_common: [cap-00000000496d7796] __vb2_buf_mem_free: freed plane 0 of buffer 3
[ 1965.879293] videobuf2_common: [out-00000000ff4b814a] __setup_offsets: buffer 0, plane 0 offset 0x00000000
[ 1965.879309] videobuf2_common: [out-00000000ff4b814a] __setup_offsets: buffer 1, plane 0 offset 0x00003000
[ 1965.879324] videobuf2_common: [out-00000000ff4b814a] __setup_offsets: buffer 2, plane 0 offset 0x00006000
[ 1965.879337] videobuf2_common: [out-00000000ff4b814a] __setup_offsets: buffer 3, plane 0 offset 0x00009000
[ 1965.879345] videobuf2_common: [out-00000000ff4b814a] __vb2_queue_alloc: allocated 4 buffers, 1 plane(s) each
[ 1965.879379] videobuf2_common: [out-00000000ff4b814a] vb2_mmap: buffer 0, plane 0 successfully mapped
[ 1965.879454] videobuf2_common: [out-00000000ff4b814a] vb2_core_expbuf: buffer 0, plane 0 exported as 20 descriptor
[ 1965.879478] videobuf2_common: [out-00000000ff4b814a] vb2_mmap: buffer 1, plane 0 successfully mapped
[ 1965.879527] videobuf2_common: [out-00000000ff4b814a] vb2_core_expbuf: buffer 1, plane 0 exported as 21 descriptor
[ 1965.879549] videobuf2_common: [out-00000000ff4b814a] vb2_mmap: buffer 2, plane 0 successfully mapped
[ 1965.879596] videobuf2_common: [out-00000000ff4b814a] vb2_core_expbuf: buffer 2, plane 0 exported as 22 descriptor
[ 1965.879617] videobuf2_common: [out-00000000ff4b814a] vb2_mmap: buffer 3, plane 0 successfully mapped
[ 1965.879662] videobuf2_common: [out-00000000ff4b814a] vb2_core_expbuf: buffer 3, plane 0 exported as 23 descriptor
[ 1965.879678] videobuf2_common: [out-00000000ff4b814a] vb2_core_streamon: successful
[ 1965.881883] videobuf2_common: [cap-00000000496d7796] __setup_offsets: buffer 0, plane 0 offset 0x00000000
[ 1965.883775] videobuf2_common: [cap-00000000496d7796] __setup_offsets: buffer 1, plane 0 offset 0x00c21000
[ 1965.886018] videobuf2_common: [cap-00000000496d7796] __setup_offsets: buffer 2, plane 0 offset 0x01842000
[ 1965.887763] videobuf2_common: [cap-00000000496d7796] __setup_offsets: buffer 3, plane 0 offset 0x02463000
[ 1965.887778] videobuf2_common: [cap-00000000496d7796] __vb2_queue_alloc: allocated 4 buffers, 1 plane(s) each
[ 1965.889251] videobuf2_common: [cap-00000000496d7796] vb2_mmap: buffer 0, plane 0 successfully mapped
[ 1965.889342] videobuf2_common: [cap-00000000496d7796] vb2_core_expbuf: buffer 0, plane 0 exported as 24 descriptor
[ 1965.890705] videobuf2_common: [cap-00000000496d7796] vb2_mmap: buffer 1, plane 0 successfully mapped
[ 1965.890757] videobuf2_common: [cap-00000000496d7796] vb2_core_expbuf: buffer 1, plane 0 exported as 25 descriptor
[ 1965.892163] videobuf2_common: [cap-00000000496d7796] vb2_mmap: buffer 2, plane 0 successfully mapped
[ 1965.892338] videobuf2_common: [cap-00000000496d7796] vb2_core_expbuf: buffer 2, plane 0 exported as 26 descriptor
[ 1965.893694] videobuf2_common: [cap-00000000496d7796] vb2_mmap: buffer 3, plane 0 successfully mapped
[ 1965.893746] videobuf2_common: [cap-00000000496d7796] vb2_core_expbuf: buffer 3, plane 0 exported as 27 descriptor
[ 1965.893766] videobuf2_common: [cap-00000000496d7796] vb2_core_qbuf: qbuf of buffer 0 succeeded
[ 1965.893777] videobuf2_common: [cap-00000000496d7796] vb2_core_qbuf: qbuf of buffer 1 succeeded
[ 1965.893788] videobuf2_common: [cap-00000000496d7796] vb2_core_qbuf: qbuf of buffer 2 succeeded
[ 1965.893798] videobuf2_common: [cap-00000000496d7796] vb2_core_qbuf: qbuf of buffer 3 succeeded
[ 1965.893819] videobuf2_common: [out-00000000c228c859] __vb2_queue_alloc: allocated 4 buffers, 1 plane(s) each
[ 1965.901323] rkisp rkisp0-vir1: first params buf queue
[ 1965.901343] videobuf2_common: [out-00000000ff4b814a] vb2_core_qbuf: qbuf of buffer 0 succeeded
[ 1965.901960] videobuf2_common: [cap-00000000ad7ff890] __setup_offsets: buffer 0, plane 0 offset 0x00000000
[ 1965.901978] videobuf2_common: [cap-00000000ad7ff890] __setup_offsets: buffer 1, plane 0 offset 0x00004000
[ 1965.901993] videobuf2_common: [cap-00000000ad7ff890] __setup_offsets: buffer 2, plane 0 offset 0x00008000
[ 1965.902010] videobuf2_common: [cap-00000000ad7ff890] __setup_offsets: buffer 3, plane 0 offset 0x0000c000
[ 1965.902017] videobuf2_common: [cap-00000000ad7ff890] __vb2_queue_alloc: allocated 4 buffers, 1 plane(s) each
[ 1965.902053] videobuf2_common: [cap-00000000ad7ff890] vb2_mmap: buffer 0, plane 0 successfully mapped
[ 1965.902129] videobuf2_common: [cap-00000000ad7ff890] vb2_core_expbuf: buffer 0, plane 0 exported as 33 descriptor
[ 1965.902156] videobuf2_common: [cap-00000000ad7ff890] vb2_mmap: buffer 1, plane 0 successfully mapped
[ 1965.902202] videobuf2_common: [cap-00000000ad7ff890] vb2_core_expbuf: buffer 1, plane 0 exported as 34 descriptor
[ 1965.902226] videobuf2_common: [cap-00000000ad7ff890] vb2_mmap: buffer 2, plane 0 successfully mapped
[ 1965.902272] videobuf2_common: [cap-00000000ad7ff890] vb2_core_expbuf: buffer 2, plane 0 exported as 35 descriptor
[ 1965.902296] videobuf2_common: [cap-00000000ad7ff890] vb2_mmap: buffer 3, plane 0 successfully mapped
[ 1965.902340] videobuf2_common: [cap-00000000ad7ff890] vb2_core_expbuf: buffer 3, plane 0 exported as 36 descriptor
[ 1965.902359] videobuf2_common: [cap-00000000ad7ff890] vb2_core_qbuf: qbuf of buffer 0 succeeded
[ 1965.902370] videobuf2_common: [cap-00000000ad7ff890] vb2_core_qbuf: qbuf of buffer 1 succeeded
[ 1965.902379] videobuf2_common: [cap-00000000ad7ff890] vb2_core_qbuf: qbuf of buffer 2 succeeded
[ 1965.902388] videobuf2_common: [cap-00000000ad7ff890] vb2_core_qbuf: qbuf of buffer 3 succeeded
[ 1965.902406] videobuf2_common: [cap-00000000a
d7ff890] vb2_core_streamon: successful

Full logs: logs.txt

numbqq commented 1 month ago

But when docker or podman is installed and the device is rebooted, the v4l2 device is not delivering any frames and a "select timeout" error is displayed.

Thanks for your feedback.

Can you try to upgrade the kernel and install docker or podman to check whether it can work now ?

wget https://dl.khadas.com/.test/linux-image-rockchip-5.10_1.6.9.1_arm64.deb
sudo dpkg -i linux-image-rockchip-5.10_1.6.9.1_arm64.deb
sync
sudo reboot

After reboot, please install docker or podman and check camera again.

flschmid89 commented 1 month ago

Thanks, your patch solved the issue. I tested with podman and docker installation. Kind regards