Skip to main content
Version: 6

First Steps with CSI Camera Set 5MP AR0521 Color (Torizon)

Introduction

This article provides information on how to start working with the CSI Camera Set 5MP AR0521 Color, which includes how to set up the hardware (wiring), install, and configure the necessary drivers for a touch demo.

e-con Camera and adapter

Getting Started

What I need to order

The CSI Camera Set 5MP AR0521 Color can be ordered with many Toradex computers on modules and carrier boards. See the compatible products.

CSI Camera Set 5MP AR0521 Front View Connected to Toradex Board

Where do I order

All the products can be ordered online in the Toradex Webshop.

Cable Connection

This topic provides pin connection details regarding connecting the CSI Camera Set 5MP AR0521 Color to the carrier boards.

CSI Camera Set 5MP AR0521 module, cables, adapter, and carrier board

info

The flat ribbon cable, used to connect the carrier board and the camera adaptor is very fragile. If your camera does not work, make sure to test the cable connections on the flat cable.

Please refer to the below instructions for connecting the display to your specific carrier board.

Connections on Ixora

See the picture below for the direct connection from the camera to the Ixora board. Make sure to connect the pin 1 side of the CSI camera to the respective pin 1 of the carrier board (MIPI-CSI Connector X28).

CSI Camera Set 5MP AR0521 Connection to Ixora

Connections on Verdin Development Board

Connect the camera to the Verdin Development Board as indicated in the figure below. The MIPI-CSI Camera Interface is on connector X47. Make sure to connect the pin 1 side of the CSI camera to the respective pin 1 of the carrier board.

Camera Connection to Verdin Development Board

Verdin Development Board Connection upside view

Connections on Dahlia Carrier Board

Connect the camera to the Dahlia Board, as indicated in the figure below. The MIPI-CSI Camera Interface is on connector X16.

caution

Picture still to be provided.

First Steps on Torizon

The CSI Camera AR0521 is fully supported to be used with Apalis iMX8. It means that, in this case, the camera device driver and device tree are integrated into the Toradex BSP Layers and the binaries are deployed to the reference images, so being able to work both with the Toradex BSP Layers and Reference Images for Yocto Project and Torizon.

When it comes to Verdin SoMs, full support is still a work in progress. However, if you want to develop your applications with Verdin iMX8M Plus, Toradex provides a tested device tree overlay: verdin-imx8mp_ar0521_overlay.dts.

The next sections explain how to use the camera with the refered modules.

info

e-con Systems and Toradex are working on a Partner Demo Container for a great out-of-the-box experience. Subscribe to our developer website updates or contact our sales team to stay up-to-date.

Using Toradex Easy Installer, install pre-build TorizonCore image (Toradex Download Links (Torizon, Linux BSP, WinCE and Partner Demos)) on the board.

Device tree Overlay - TorizonCore Builder

Apalis iMX8

  1. Follow one of the approaches on Device Tree Overlays on Torizon to enable the device tree overlay for the camera (apalis-imx8_ar0521_overlay.dtbo).

  2. Reboot the board and check if the driver is properly installed.

# dmesg | grep ar0521
[ 3.077064] ar0521 5-0042: Current Firmware Version - (1150CU96RKV1901110d381894XXXXXXX)
[ 8.047832] mx8-img-md: Registered sensor subdevice: ar0521 5-0042 (1)
[ 8.047864] mx8-img-md: created link [ar0521 5-0042] => [mxc-mipi-csi2.1]

Verdin iMX8M Plus

  1. Download the device tree overlay for Verdin iMX8M Plus: verdin-imx8mp_ar0521_overlay.dts

  2. Follow one of the approaches on Device Tree Overlays on Torizon to enable the verdin-Imx8mp_ar0521_overlay.dts.

  1. Reboot the board and check if the driver is properly installed.
# dmesg | grep ar0521
[ 3.077064] ar0521 5-0042: Current Firmware Version - (1150CU96RKV1901110d381894XXXXXXX)
[ 8.047832] mx8-img-md: Registered sensor subdevice: ar0521 5-0042 (1)
[ 8.047864] mx8-img-md: created link [ar0521 5-0042] => [mxc-mipi-csi2.1]

Camera Usage

To start the camera usage, you first need to build a container with GStreamer and V4L2-utils. So, it's recommended to follow the steps:

  • Develop a Dockerfile running the installation of GStreamer and its plugins and V4L2-utils. The article How to use Gstreamer on TorizonCore is going to be very helpful and you can develop your Dockerfile based on the Sample Dockerfile.
  • Build the Dockerfile using Docker build command.
  • Push the image to your Dockerhub account.

The following Dockefile is an example of a one that can be used to fulfill the requirements:

Click here to see the Dockerfile
ARG BASE_NAME=wayland-base
# Use BASE_NAME=wayland-base-vivante for i.MX 8 SoMs
ARG IMAGE_ARCH=linux/arm
ARG IMAGE_TAG=2
ARG DOCKER_REGISTRY=torizon

FROM --platform=$IMAGE_ARCH $DOCKER_REGISTRY/$BASE_NAME:$IMAGE_TAG
ARG IMAGE_ARCH

RUN apt-get -y update && apt-get install -y --no-install-recommends \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-pulseaudio \
v4l-utils \
&& if [ "${IMAGE_ARCH}" = "linux/arm64/v8" ]; then \
apt-get install -y --no-install-recommends \
gstreamer1.0-qt5; fi \
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*

Then, build it and push:

$ docker build -f Dockerfile -t <your-dockerhub-username>/<Dockerfile-name> .
$ docker push <your-dockerhub-username>/<Dockerfile-name>

After these steps, you can start properly working on your device. So, make sure that there is no container running on Torizon by stopping them all.

# docker stop $(docker ps -a -q)
d942c0b4c5f1
3bff2f66a8d8
61dab378a9eb
f8eca0e69f26
1455a33e6d78
cd529e7f036d

Because the camera application container also needs a Weston container running at the same time, launch the Weston container.

# docker run -e ACCEPT_FSL_EULA=1 -d --rm --name=weston --net=host --cap-add CAP_SYS_TTY_CONFIG \
-v /dev:/dev -v /tmp:/tmp -v /run/udev/:/run/udev/ \
--device-cgroup-rule='c 4:* rmw' --device-cgroup-rule='c 13:* rmw' \
--device-cgroup-rule='c 199:* rmw' --device-cgroup-rule='c 226:* rmw' \
torizon/weston-vivante:$CT_TAG_WESTON_VIVANTE --developer weston-launch \
--tty=/dev/tty7 --user=torizon

# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
473d395c761d torizon/weston-vivante:2 "/usr/bin/entry.sh -…" 7 seconds ago Up 5 seconds weston

Now pull the container from your Dockerhub account and then, finally, launch the container where you going to run the pipeline.

# docker pull <your-dockerhub-username>/<Dockerfile-name>

# docker run --rm -it \
-v /tmp:/tmp \
-v /var/run/dbus:/var/run/dbus \
-v /dev/galcore:/dev/galcore \
--device /dev/video0 \
--device-cgroup-rule='c 199:* rmw' \
<your-dockerhub-username>/<Dockerfile-name>

Here are some considerations:

  • Make sure to pass the right camera device. In this case, was /dev/video0. If you are not sure which device is a camera capture device, pass under the argument --device all the devices available to be used.
  • Don't forget to replace <your-dockerhub-username>/<Dockerfile-name> with your container.

Then, once you are inside the container, enable the streaming by running a Gstreamer pipeline on the terminal:

## gst-launch-1.0 v4l2src device='/dev/video0'  ! "video/x-raw, format=RGB16, framerate=30/1, width=1920, height=1080" ! fpsdisplaysink video-sink=waylandsink text-overlay=false sync=false -v
Click here to see the Gstreamer command output
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstWaylandSink:waylandsink0: sync = false
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, format=(string)R[G Bh1960,6 .f5r3a2m5e5r4a]t es=t(rferaamcdtbi[o0n])=300,/ 1m,o dew=id3t
=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
Setting pipeline to PLAYING ...
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
New clock: GstSystemClock
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstWaylandSink:waylandsink0.GstPad:sink: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0.GstGhostPad:sink: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, colorimetry=(string)sRGB, interlace-mode=(string)progressive
[ 906.532557] streamdb[1]=1, mode=3
[ 906.658370] streamdb[2]=2, mode=3
[ 906.661706] streamdb[3]=3, mode=3
[ 906.708655] input fmt YUV4
[ 906.714672] output fmt RGBP
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstWaylandSink:waylandsink0: sync = false
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 32, dropped: 0, current: 62.91, average: 62.91
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 56, dropped: 0, current: 47.37, average: 55.16
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 87, dropped: 0, current: 59.26, average: 56.55
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0: last-message = rendered: 118, dropped: 0, current: 61.07, average: 57.67
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:02.720832534
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Total showed frames (125), playing for (0:00:02.721266280), fps (45.934).
Freeing pipeline ...


Send Feedback!