Install video sensor OV5647 module on SP7021 demo board V3

The goal of this document is to illustrate how to install video sensor OV5647 module to Plus 1 demo board V3.

Video sensor OV5647 module is a Raspberry Pi compatible camera module. It equips with 15-pin FFC connector. Refer to picture below:

Please follow the following steps:

1. Install hardware

Please connect FFC cable of OV5647 module to connector J48 of Plus 1 demo board V3 directly. Connector J48 is for MIPI/CSI-RX and is compatible to Raspberry Pi camera connector. Note that the 15-pin FFC cable is opposite-sided contacts FFC cable. Please pay attention to contact side of FFC cable when you insert an FFC cable into a connector. Refer to screenshot below:

2. Modify device-tree source

Modify device-tree node mipicsi0 in device-tree source include file, linux/kernel/arch/arm/boot/dts/sp7021-demov3.dts, as shown below:

&mipicsi0 { i2c-id = <1>; pinctrl-names = "default"; pinctrl-0 = <&mipicsi0_pins>; cam_gpio0-gpios = <&pctl 92 GPIO_ACTIVE_HIGH>; cam_gpio1-gpios = <&pctl 93 GPIO_ACTIVE_HIGH>; };

As shown in node property i2c-id, channel 1 of I2C interface is used to communicate with video sensor. MIPI/CSI-RX driver does not use GPIO pins mipicsi-gpio0 and mipicsi-gpio1 currently. The two pins is set to HIGH by default.

Please also add node pinmux_mipicsi0-pins as subnode of node pctl in the same device-tree source include file as shown below:

mipicsi0_pins: pinmux_mipicsi0-pins { sunplus,pins = < SPPCTL_IOPAD(64, SPPCTL_PCTL_G_PMUX, MUXF_I2CM1_DAT, 0) SPPCTL_IOPAD(61, SPPCTL_PCTL_G_PMUX, MUXF_I2CM1_CLK, 0) SPPCTL_IOPAD(92, SPPCTL_PCTL_G_GPIO, 0, SPPCTL_PCTL_L_OU1) SPPCTL_IOPAD(93, SPPCTL_PCTL_G_GPIO, 0, SPPCTL_PCTL_L_OU1) >; };

G_MX64 and G_MX61 are set as DAT and CK signal of channel 1 of I2C interface, respectively. G_MX92 and G_MX93 are set as GPIO pins.

Please note that to comply with Linux rules, after version 5.10.59, 4 property-names of pin node of SP7021 are changed as shown in table below:

5.4.35

5.10.59

5.4.35

5.10.59

sppctl,function

function

sppctl,groups

groups

sppctl,pins

sunplus,pins

sppctl,zero_func

sunplus,zerofunc

3. Enable Sunplus I2C driver

Run make kconfig in project top directory. When “Linux/arm Kernel Configuration” menu pops up, move cursor to go to “Device Drivers” --> “I2C support” → “I2C Hardware Bus support”. Enable “SP I2C support”. Refer to screenshot below:

4. Enable Sunplus MIPI/CSI-RX driver

Move cursor to go to “Device Drivers” --> “Multimedia support” → “V4L platform devices”. Enable “Sunplus Video Sensor Support“ and “Sunplus SP7021 MIPI/CSI-RX driver”. Refer to screenshot below:

5. Enable Sunplus driver

Enter menu “Sunplus Video Sensor Support”. Enable “Video Sensor (OV5647) Driver”. Select image-size if this is not you want (select 1280x720 in this example). Refer to screenshot below:

Save configuration finally.

6. Build Linux image

Go to top folder. Run make all to build Linux image.

7. Boot Linux

Boot Linux with the built image. During booting, you will see MIPI/CSI related log messages:

MIPI/CSI-RX and video sensor OV5647 probed successfully. Video device /dev/video0 was also registered successfully. Refer to screenshot below:

Major device number is 81. Minor device number is 3.

8. Run ffmpeg on Raspbian

A. List v4l2 video devices

To list v4l2 video devices, run v4l2-ctl with command-line option --list-devices as shown below:

pi@raspberrypi:~$ v4l2-ctl --list-devices SP DISPLAY Card (SP DISP Device BUS OSD0): /dev/video10 SP DISPLAY Card (SP DISP Device BUS OSD1): /dev/video11 SP DISPLAY Card (SP DISP Device BUS VPP0): /dev/video12 SP MIPI Camera Card (SP MIPI Camera BUS): /dev/video0 pi@raspberrypi:~$

B. Show supported format

To show supported format of video device, run ffmpeg with command-line option -list_formats all as shown below:

where command-line option -hide_banner suppresses the output of configuration information, -f v4l2 selects v4l2 format, and -i /dev/video0 selects input video device.

C. Take a picture

To take a picture from video device, run ffmpeg with .jpeg output file-name as shown below:

where command-line option -s 640x480 set size of a picture, -vframes 1 sets number of video frames and test.jpeg is output file-name.

D. Record video using MPEG format

To record a MPEG video from video device, run ffmpeg with .mpg output file-name as shown below:

where command-line option -framerate 25 sets frame-rate and test.mpg is output file-name.

E. Record video using MPEG-4 format

To record a MPEG-4 video from video device, run ffmpeg with .mkv output file-name as shown below:

where test.mkv is output file-name.