Not so successful test of the parallel CSI


Hey there,

since many guys in this forum were curious about getting the parallel CSI working, I got it working! :sunglasses:

However I was unable to take a single frame (jpg picture), I could only shoot a video.
But however most of the video contains green artifacts. I don’t know if this is an issue with the CSI driver or with ffmpeg. Could somebody help me?
Command for video with ffmpeg:

ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv

If anyone is interested in the .dts files, just message me.



Would like to have the dts, i am also working on CSI parallel DVP on OV5640.
Your share will really help me, a lot.

Thank you. -


Do you use mainline Linux kernel ?
Which version of CSI patch do you use ?
Which camera model/driver ?
All this affect result.


Yes I used 4.17 mainline linux kernel, I used this patch:
And I used the OV7670 camera.
After starting ffmpeg I get some kind of ioctl warning.
I think I made a mistake in the devicetree, the OV7670.txt doesn’t mention PCLK-sample<>; in the example devicetree. Fuhrtermore I messed up the h-sync and v-sync setttings. I will test the CSI with the new devicetree soon.


Found some more issues:
[ 54.113025] cma: cma_alloc: alloc failed, req-size: 113 pages, ret: -12
[ 54.122194] sun6i-csi 1cb4000.csi: dma_alloc_coherent of size 462848 failed
[ 65.151183] random: crng init done
[ 195.090072] Adding 131048k swap on /swap. Priority:-2 extents:5 across:147448k SS
[ 282.100162] cma: cma_alloc: alloc failed, req-size: 113 pages, ret: -12
[ 282.109070] sun6i-csi 1cb4000.csi: dma_alloc_coherent of size 462848 failed
Error 12 = Out of memory
As you can see after that I enabled swap but it didn’t change anything.

Full Log of ffmpeg( I used the same command as I mentioned earlier):

ffmpeg version 3.4.2 Copyright © 2000-2018 the FFmpeg developers
built with gcc 6.4.0 (Buildroot 2018.02.1)
configuration: --enable-cross-compile --cross-prefix=/home/marcel/workspace/allwinnerV3s/buildroot/output/host/bin/arm-buildroot-linux-uclibcgnueabihf- --sysroot=/home/marcel/workspace/allwinnerV3s/buildroot/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot --host-cc=’/home/marcel/workspace/allwinnerV3s/buildroot/output/host/bin/ccache /usr/bin/gcc’ --arch=arm --target-os=linux --disable-stripping --pkg-config=/home/marcel/workspace/allwinnerV3s/buildroot/output/host/bin/pkg-config --disable-static --enable-shared --prefix=/usr --enable-avfilter --disable-version3 --enable-logging --enable-optimizations --disable-extra-warnings --enable-avdevice --enable-avcodec --enable-avformat --enable-network --disable-gray --enable-swscale-alpha --disable-small --enable-dct --enable-fft --enable-mdct --enable-rdft --disable-crystalhd --disable-dxva2 --enable-runtime-cpudetect --disable-hardcoded-tables --disable-mipsdsp --disable-mipsdspr2 --disable-msa --enable-hwaccels --disable-cuda --disable-cuvid --disable-nvenc --disable-avisynth --disable-frei0r --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libcdio --disable-libdc1394 --disable-libgsm --disable-libilbc --disable-libvo-amrwbenc --disable-symver --disable-doc --enable-gpl --enable-nonfree --enable-ffmpeg --disable-ffplay --disable-ffserver --disable-avresample --disable-ffprobe --disable-postproc --disable-swscale --enable-indevs --enable-alsa --enable-outdevs --enable-pthreads --enable-zlib --disable-bzlib --disable-libfdk-aac --disable-gnutls --disable-openssl --disable-libopenh264 --disable-vaapi --disable-vdpau --disable-mmal --disable-omx --disable-omx-rpi --disable-libopencv --disable-libopus --disable-libvpx --disable-libass --disable-libbluray --disable-librtmp --disable-libmp3lame --disable-libmodplug --disable-libspeex --disable-libtheora --disable-libwavpack --disable-iconv --disable-libfreetype --disable-fontconfig --disable-libopenjpeg --disable-libx264 --disable-libx265 --disable-x86asm --disable-mmx --disable-sse --disable-sse2 --disable-sse3 --disable-ssse3 --disable-sse4 --disable-sse42 --disable-avx --disable-avx2 --enable-armv6 --enable-vfp --enable-neon --disable-altivec --extra-libs=-latomic --enable-pic --cpu=cortex-a7
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswresample 2. 9.100 / 2. 9.100
[video4linux2,v4l2 @ 0x4e220] ioctl(VIDIOC_G_PARM): Inappropriate ioctl for device
[video4linux2,v4l2 @ 0x4e220] Time per frame unknown
Input #0, video4linux2,v4l2, from ‘/dev/video0’:
Duration: N/A, start: 450.843605, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 30 tbr, 1000k tbn, 1000k tbc
File ‘output.mkv’ already exists. Overwrite ? [y/N] Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg4 (native))
Press [q] to stop, [?] for help
Output #0, matroska, to ‘output.mkv’:
encoder : Lavf57.83.100
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 640x480, q=2-31, 200 kb/s, 30 fps, 1k tbn, 30 tbc
encoder : Lavc57.107.100 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1
frame= 23 fps=0.0 q=2.0 size= 6kB time=00:00:00.73 bitrate= 64.1kbits/s speed=1.41x

All of the captured frames are nearly green and you can barely see anything.
Can anyone help me?


I checked some signals with my old analog 40Mhz Oscilloscope, the MCLK is always present. The MCLK starts roughly at kernel boot time. The PCLK is also present. But most interesting after boot the Ov7670 outputs data on the parallel bus without requesting data. Is this normal?
Since I only have a 40Mhz Oscilloscope many of the signals look distorted.
I fixed the issue with dma_alloc_coherent with trying a lower resolution.


petit_miner, could you please share your dts file? I think you can upload stuff on this forum as well


Here are the two dts files. I couldn’t upload them into the forum, because you can only upload images.
I don’t know if the dts files are correct.


Great job! Is this reproducible with the camera provided with the original kickstarter kit? (Camera Suit)?

This looks like raw video saving, any idea if ffmpeg could support the V3S h.264 encoder?


One of the main problems is that after some time of working, there is no memory for video frames.
So for better results use it after boot/reboot.


How can we update the zero with this patch and use a camera? Any instructions for getting the camera (whichever works) to work now?


I think the parallel CSI driver works correctly, however my selfmade V3s development board has some hardware issues. Thats the reason I can’t confirm that the driver works 100%.

I tested the OV7670 (8bit) and got only a complete green image, but however I tried the OV2640 (10bit) aswell and got a slight greenish image. I also attached the image.

If you want to test the parallel camera interface you have to rebuild the linux kernel.

If you have some experience in building the linux kernel, just apply this patch and you are good to go:

If you don’t have much experience you can use my tutorial on Github or download the prebuilt image:

If you want to use the camera with the prebuilt image you will need to replace the compiled devicetree file.


Hey guys,
I finally got it working :sunglasses:
I successfully connected the OV7670 to the V3s and was able to capture images and videos!
You can find the devicetree files on my github page.

Keep in mind that you have to connect the Camera this way:


Just to let you know: The CSI driver is now in the mainline linux kernel. So no patch is needed anymore!