Today I had a chance to test OV5640 on mainline kernel 4.17.2 and see the status of OV5640 and CSI drivers, thanks to FE work and the author of the driver (help name here...). I tested on NanoPi K1 Plus (H5) to verify the images in very low light conditions, so don't expect good quality.
I could take some images using fswebcam and you should expect basic v4l2 functionality already works if not all. I think motion (did not test / had time to test it) can work with current OV5640 on mainline kernel.
Grabbing Image is very fast, currently, Image size I can get are 320x240 and 640x480 pixels, above this i get a dark image. I have not looked at the driver source code to see if it is implemented or not.
Basically, you need to add the sun6i_csi and ov5640 drivers to the kernel and adjust DT to have the endpoint. FE has already done it and left H5 for homework, but is the same as H3.
To check the functionality, install v4l2-utils and when the driver sun6i_cs loads, it creates the device node /dev/video0 and you can check that:
sudo v4l2-ctl -d /dev/video0 -D
Driver Info (not using libv4l2):
Driver name : sun6i-video
Card type : sun6i-csi
Bus info : platform:camera
Driver version: 4.17.2
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
You should see the modules loaded like this:
lsmod
Module Size Used by
sun6i_csi 24576 0
videobuf2_dma_contig 20480 1 sun6i_csi
videobuf2_memops 16384 1 videobuf2_dma_contig
ov5640 36864 1
videobuf2_v4l2 24576 1 sun6i_csi
videobuf2_common 40960 2 videobuf2_v4l2,sun6i_csi
v4l2_fwnode 20480 2 ov5640,sun6i_csi
v4l2_common 16384 1 ov5640
videodev 196608 6 v4l2_fwnode,v4l2_common,ov5640,videobuf2_v4l2,sun6i_csi,videobuf2_common
sunxi_cir 16384 0
media 36864 3 videodev,ov5640,sun6i_csi
rc_core 40960 2 sunxi_cir
sch_fq_codel 20480 6
8189es 1118208 0
So time to revisit the camera drivers on mainline.
Here are some images (remember, low light condition!):
*update: All possible window sizes are working for streaming!
I'm not sure about the specs for the battery, I just used a 4400mAh lipo I found on ebay or aliexpress a while back. I didn't configure anything on the m2m for this specific battery, so it might blow up eventually...
I bought some 6 pin 1.25mm JST connectors that were mentioned here: http://forum.banana-pi.org/t/battery-cable-circuit/3737 (even though this is for a different board).
This is from the m2magic schematic located here: https://bananapi.gitbooks.io/banana-pi-bpi-m2-magic-iot-development-board/content/chapter1/bpi-m2-magic-schematic-diagram.html
Here are the pins on the board:
The battery I'm using at the moment only has two wires (no temp sensor). I put pins 1-3 to bat +, pins 4 and 5 to bat - and a 10k resistor between pin 6 and gnd. It looks like that was wrong though, and pin 6 should go straight to gnd with no resistor?