Skip to content

Camera

Testing MIPI-CSI2 Cameras

Connect the OV5640 camera before running the commands below. This guide applies to DART-MX8M-MINI on Sonata-Board and VAR-SOM-MX8M-MINI on Symphony-Board using the Media Controller drivers. Run the commands on the board as root, one block at a time.

Camera Probe

List the video devices and inspect the media graph:

v4l2-ctl --list-devices
media-ctl -d /dev/media0 -p

The examples use the following devices observed on both boards:

Component Device or Entity
Media device /dev/media0
Capture device /dev/video2
OV5640 sensor ov5640 1-003c
MIPI CSI-2 receiver csis-32e30000.mipi-csi

The graph should contain the path OV5640 -> CSIS -> CSI -> csi capture. Device numbering may change between boots. Check the device list and graph, and adjust the paths and entity names in all commands if necessary.

The Media Controller pipeline requires the sensor, receiver and CSI pads to use matching formats and resolutions. Each example configures the link and all required pads before starting capture. The && operators stop the sequence if a configuration command fails.

The examples request 30 fps, or 15 fps for QSXGA. Check the accepted sensor interval with media-ctl -d /dev/media0 -p and the actual capture rate; the requested interval does not guarantee the resulting frame rate.

Testing Capture without a Display

Start with VGA. Each block captures 100 frames and discards them, with a 30-second timeout. Run echo $? immediately after the block: 0 indicates success and 124 indicates a timeout.

VGA — 640x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/640x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=640,height=480,pixelformat=UYVY &&
timeout 30 v4l2-ctl -d /dev/video2 --stream-mmap=4 --stream-count=100 --stream-to=/dev/null

NTSC — 720x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/720x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=720,height=480,pixelformat=UYVY &&
timeout 30 v4l2-ctl -d /dev/video2 --stream-mmap=4 --stream-count=100 --stream-to=/dev/null

HD — 1280x720, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1280x720 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1280,height=720,pixelformat=UYVY &&
timeout 30 v4l2-ctl -d /dev/video2 --stream-mmap=4 --stream-count=100 --stream-to=/dev/null

Full HD — 1920x1080, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1920x1080 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY &&
timeout 30 v4l2-ctl -d /dev/video2 --stream-mmap=4 --stream-count=100 --stream-to=/dev/null

QSXGA — 2592x1944, 15 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/2592x1944 field:none @1/15]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=2592,height=1944,pixelformat=UYVY &&
timeout 30 v4l2-ctl -d /dev/video2 --stream-mmap=4 --stream-count=100 --stream-to=/dev/null

Testing Camera Preview on Display

The examples use the Wayland session at /run/wayland-0, with XDG_RUNTIME_DIR=/run/user/0. Adjust these values to match the active session on your board. Stop the preview with Ctrl+C before running another example.

VGA — 640x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/640x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=640,height=480,pixelformat=UYVY &&
XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=/run/wayland-0 \
gst-launch-1.0 -v v4l2src device=/dev/video2 \
! 'video/x-raw,format=UYVY,width=640,height=480' \
! waylandsink sync=false

NTSC — 720x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/720x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=720,height=480,pixelformat=UYVY &&
XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=/run/wayland-0 \
gst-launch-1.0 -v v4l2src device=/dev/video2 \
! 'video/x-raw,format=UYVY,width=720,height=480' \
! waylandsink sync=false

HD — 1280x720, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1280x720 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1280,height=720,pixelformat=UYVY &&
XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=/run/wayland-0 \
gst-launch-1.0 -v v4l2src device=/dev/video2 \
! 'video/x-raw,format=UYVY,width=1280,height=720' \
! waylandsink sync=false

Full HD — 1920x1080, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1920x1080 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY &&
XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=/run/wayland-0 \
gst-launch-1.0 -v v4l2src device=/dev/video2 \
! 'video/x-raw,format=UYVY,width=1920,height=1080' \
! waylandsink sync=false

QSXGA — 2592x1944, 15 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/2592x1944 field:none @1/15]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=2592,height=1944,pixelformat=UYVY &&
XDG_RUNTIME_DIR=/run/user/0 WAYLAND_DISPLAY=/run/wayland-0 \
gst-launch-1.0 -v v4l2src device=/dev/video2 \
! 'video/x-raw,format=UYVY,width=2592,height=1944' \
! waylandsink sync=false

Testing Camera JPEG Snapshot

Each block captures one frame, converts it to I420 and saves a JPEG under /tmp. Check that GStreamer reaches EOS and exits successfully, then open the image to verify its content and dimensions. The first frame may still be adjusting exposure and white balance.

VGA — 640x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/640x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/640x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=640,height=480,pixelformat=UYVY &&
timeout 30 gst-launch-1.0 -e -v v4l2src device=/dev/video2 num-buffers=1 \
! 'video/x-raw,format=UYVY,width=640,height=480' \
! videoconvert ! 'video/x-raw,format=I420' \
! jpegenc ! filesink location=/tmp/test_640x480.jpg

NTSC — 720x480, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/720x480 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/720x480 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=720,height=480,pixelformat=UYVY &&
timeout 30 gst-launch-1.0 -e -v v4l2src device=/dev/video2 num-buffers=1 \
! 'video/x-raw,format=UYVY,width=720,height=480' \
! videoconvert ! 'video/x-raw,format=I420' \
! jpegenc ! filesink location=/tmp/test_720x480.jpg

HD — 1280x720, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1280x720 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1280x720 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1280,height=720,pixelformat=UYVY &&
timeout 30 gst-launch-1.0 -e -v v4l2src device=/dev/video2 num-buffers=1 \
! 'video/x-raw,format=UYVY,width=1280,height=720' \
! videoconvert ! 'video/x-raw,format=I420' \
! jpegenc ! filesink location=/tmp/test_1280x720.jpg

Full HD — 1920x1080, 30 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/1920x1080 field:none @1/30]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/1920x1080 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=1920,height=1080,pixelformat=UYVY &&
timeout 30 gst-launch-1.0 -e -v v4l2src device=/dev/video2 num-buffers=1 \
! 'video/x-raw,format=UYVY,width=1920,height=1080' \
! videoconvert ! 'video/x-raw,format=I420' \
! jpegenc ! filesink location=/tmp/test_1920x1080.jpg

QSXGA — 2592x1944, 15 FPS Requested

media-ctl -d /dev/media0 -l '"ov5640 1-003c":0 -> "csis-32e30000.mipi-csi":0 [1]' &&
media-ctl -d /dev/media0 -V '"ov5640 1-003c":0 [fmt:UYVY8_1X16/2592x1944 field:none @1/15]' &&
media-ctl -d /dev/media0 -V '"csis-32e30000.mipi-csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
media-ctl -d /dev/media0 -V '"csi":0 [fmt:UYVY8_1X16/2592x1944 field:none]' &&
v4l2-ctl -d /dev/video2 --set-fmt-video=width=2592,height=1944,pixelformat=UYVY &&
timeout 30 gst-launch-1.0 -e -v v4l2src device=/dev/video2 num-buffers=1 \
! 'video/x-raw,format=UYVY,width=2592,height=1944' \
! videoconvert ! 'video/x-raw,format=I420' \
! jpegenc ! filesink location=/tmp/test_2592x1944.jpg

Troubleshooting

Run capture, preview and JPEG examples separately. If an example fails, collect the device list, media graph, capture format and kernel messages:

uname -r
v4l2-ctl --list-devices
media-ctl -d /dev/media0 -p
v4l2-ctl -d /dev/video2 --get-fmt-video
dmesg | tail -100
  • Device or resource busy: stop the previous capture process.
  • Unable to parse link: verify that the sensor and receiver entities exist in the graph and that their names match the commands.
  • Capture format not valid / Buffer pool activation failed: check the format and resolution on every pad and the capture device.
  • Timeout: inspect the media graph and kernel log for capture errors.
  • Capture works but preview fails: check the Wayland session and sink.
  • JPEG fails: check that videoconvert and jpegenc are available with gst-inspect-1.0.