Getting Started Guide - phyCAM with phyBOARD-Polis iMX 8M Mini (L-1024e.A0)

Table of Contents

Getting Started Guide - phyCAM with phyBOARD-Polis iMX 8M Mini (L-1024e.A0)
Document TitlephyCAM with phyBOARD-Polis iMX 8M Mini Getting Started Guide (L-1024e.A0)
Document TypeHardware/Software Guide
Article NumberL-1024e.A0
Release Date06.05.2021
Is Branch ofGetting Started Guide - phyCAM with phyBOARD-Polis iMX 8M Mini (L-1024e.Ax) Head

Copyrighted products are not explicitly indicated in this manual. The absence of the trademark (TM or ®) and copyright (©) symbols does not imply that a product is not protected. Additionally, registered patents and trademarks are similarly not expressly indicated in this manual.

The information in this document has been carefully checked and is considered to be entirely reliable. However, PHYTEC Messtechnik GmbH assumes no responsibility for any inaccuracies. PHYTEC Messtechnik GmbH neither gives any guarantee nor accepts any liability whatsoever for consequential damages resulting from the use of this manual or its associated product. PHYTEC Messtechnik GmbH reserves the right to alter the information contained herein without prior notification and accepts no responsibility for any damages that might result.

Additionally, PHYTEC Messtechnik GmbH offers no guarantee nor accepts any liability for damages arising from the improper usage or improper installation of the hardware or software. PHYTEC Messtechnik GmbH further reserves the right to alter the layout and/or design of the hardware without prior notification and accepts no liability for doing so.

@ Copyright 2021 PHYTEC Messtechnik GmbH, D-55129 Mainz.

Rights - including those of translation, reprint, broadcast, photomechanical or similar reproduction and storage or processing in computer systems, in whole or in part - are reserved. No reproduction may occur without the express written consent from PHYTEC Messtechnik GmbH.

 

EUROPE

NORTH AMERICA

FRANCE

INDIACHINA

Address:

PHYTEC Messtechnik GmbH
Robert-Koch-Str. 39
D-55129 Mainz
GERMANY

PHYTEC America LLC
203 Parfitt Way SW
Bainbridge Island, WA 98110
USA

PHYTEC France
17, place Saint-Etienne
F-72140 Sillé-le-Guillaume
FRANCE

PHYTEC Embedded Pvt. Ltd
No. 1688, 25th A Cross
27th Main, 2nd Sector, Opp. PEP School
V2, HRS Layout
Bangalore 560102
INDIA

PHYTEC Information Technology (Shenzhen) Co. Ltd.
2106A, Block A, Tianxia Jinniu Square
Taoyuan Road, Nanshan District
518052 Shenzhen
CHINA

Ordering Information:

+49 6131 9221-32
sales@phytec.de

+1 800 278-9913
sales@phytec.com

+33 2 43 29 22 33
info@phytec.fr

+91-80-4086 7046/48
sales@phytec.in
+86-755-3395-5875
sales@phytec.cn

Technical Support:

+49 6131 9221-31
support@phytec.de

+1 206 780-9047
support@phytec.com


support@phytec.fr

+91-80-4086 7047
support@phytec.in

support@phytec.cn

Fax:

+49 6131 9221-33

+1 206 780-9135

+33 2 43 29 22 34


+86-755-3395-5999

Web Site:

http://www.phytec.de
http://www.phytec.eu

http://www.phytec.com

http://www.phytec.fr

http://phytec.inhttp://www.phytec.cn

Introduction

The SBC (Single Board Computer) kits from PHYTEC represent an ideal basis for testing and the first design steps with phyCAM camera modules. The kit forms the starting point for your development project. The kit can be used to develop and test application software before your own adapted hardware is available. It is also an optimal platform for testing special hardware extensions before you create a complex application board.

This optional step secures your design while at the same time provides software developers with an opportunity to adapt newly added hardware components. Extensions can be easily connected via the extension interfaces of the baseboards included in the kit. In the simplest case, a freely wired hole grid structure is sufficient.

For certain combinations of controller modules, camera modules, and lenses, we offer ready-made kits. If the combination you require is not available, we recommend that you first put a similarly-equipped kit into operation and then connect the camera you require to the kit.

We will be happy to advise you on the best way to carry out your project.

SBC Kit Start-Up

Before you try out the camera and image processing functions, we recommend that you first familiarize yourself with the basic functions of the kit and the associated development environment. Each kit contains a Quick Start Guide that guides you through installing the software on your development PC and configuring the hardware.

Before You Start

The following components are required for the camera setup:

  • PHYTEC SBC-Kit with power supply and serial connection (RS232 or USB)
  • Camera module with camera cable, lens holder, and lens

If you have ordered the corresponding kit as an Embedded Imaging Kit, all hardware components required for installation are already included.

As a rule, both the extension of an existing kit by one camera and the extension of an existing video kit by additional cameras is possible without problems with an existing phyCAM interface.

Before connecting and starting up the camera, carry out the first steps of the "Quick Start Instructions" of the respective kit. To start the scripts on the module, follow the steps to establish a serial connection with the module. You can use the terminal program suggested in the manual or your own terminal program.

To transfer saved image files to a PC (host) via Ethernet, follow the steps to establish an FTP connection. You can use the FTP server suggested in the manual or your own FTP server.

Connecting and Starting the Camera

Note

Depending on the kernel version, the software installation may differ in some details from the described procedure.

When you purchase an SBC kit, you will receive the PHYTEC guarantee. If you encounter any difficulties during installation, PHYTEC support will help you!

Overview

The i.MX 8M Mini Microcontroller supports one MIPI CSI-2 camera interface:

 

Camera Interfaces of i.MX 8M Mini Controller (Quad) Block Diagram

On the phyCORE-i.MX 8M Mini, the CSI1/CAM1 camera path goes out as CSI-2 MIPI signal:

CAM_1 (CSI1) Present on Connector X3

On PHYTEC or customer carrier boards, the interfaces are led out as phyCAM-M. For more information on phyCAM-M, see the phyCAM-Manuals on our website.

On the phyBOARD-Polis baseboard, the camera interfaces are led out as phyCAM-M (MIPI CSI-2) interfaces. Here you can connect different phyCAM-M camera modules:

phyCAM-M Camera Interfaces of phyCORE-i.MX 8M Mini (Quad) and the output on the phyBOARD-Polis-i.MX 8M Mini

The BSP shipped with the Kit includes the software drivers for the supported phyCAM-M camera modules. The drivers are compatible with v4l2. GStreamer scripts are also included for the evaluation of the camera modules. If you need the camera interface to connect to your own camera module, an adapter to phyCAM-M is necessary.

Camera Connectors on the Polis - Carrier Boards

The development kits for the i.MX 8M Mini phyBOARD-Polis contains:

  • one carrier board (phyBOARD-Polis)
  • one phyCORE-i.MX 8M module SOM (phyCORE-i.MX 8M Mini)

The phyCORE-i.MX 8M Mini is directly soldered on the carrier board.

On the phyBOARD-Polis baseboard (PB-02820), we convert the MIPI CSI-2 interfaces into phyCAM-M standard.

  • phyCAM-M camera interface 1 (support on connector X10)

Camera Interface on phyBOARD-Polis up PCB Version PL1532.1

Note

If you use the phyCAM-M interface, use an FFC cable that is especially suitable for FH41 connectors (e.g. Phytec WF271). Standard FFC cables can cause a short circuit.

Connecting the phyCAM-M Camera

A type-A FFC cable (stripped and reinforced on the same side) is supplied with the kit. This ensures the correct signal assignment between the camera and the baseboard in the kit.

The position of the camera socket on the baseboard can be found in the hardware manual of the kit. Parallel to the connector designation (e.g. X100), some basic boards also have "CAM" printed on the board. The phyCAM-M interface is a 30-pin FFC socket, which can be installed standing or lying on the board.

The FFC cable is plugged in exactly the same way as the cable is plugged into the camera FFC socket.

Note

In the vertical version of the FFC socket, the contacts are also on the side opposite the bracket.

Open the lock of the 30-pin FFC connector on the camera by lifting the lock upwards.

phyCAM-M Flip Lock – FCC Socket Camera Connection

  1. Plug the 30-pin FFC cable into the FFC socket with the contact surfaces facing downwards until you feel the stop. The reinforcement of the FFC cable (usually highlighted in color) points to the bracket of the socket.
  2. Lock the FFC socket by carefully pressing down on the bracket.

Supported Camera Boards (YOCTO Linux PD21.1.0 and higher)

The cameras and the camera interface supported as sub-devices. To configure the v4l2 framework is the handler "media-ctl" used, see Configure Camera and Controller Camera Interface with "media-ctl"

Tip

The device tree of the camera VM-016 (sensor AR0144) is preselected in PD21.1.0. To use other cameras (e.g. VM-017/117) the device tree must be changed. See Change the Camera Types in Standard Vision Image

Supported Camera Types in Standard Vision Image (phytec-vision-image-phyboard-polis-imx8mm-3)

Per default are following Kameratyps are supported in the image:

  • VM-016-BW-M series (VM-016-BW-M, VM-016-BW-M-M12, VM-016-BW-M-H, …) based on camera sensor “AR0144”
  • VM-016-COL-M series (VM-016-COL-M, VM-016-COL-M-M12, VM-016-COL-M-H, …) based on camera sensor “AR0144”

After login, you can start working with the Demo Scripts.

Hardware Configuration

Possible Parameters


Default I²C-address
(default jumper on camera and boards)

phyCAM Camera Model (part number)

Connected to

csi_port

cam_bus_type

cam_type

cam_i2c_address

VM-016-BW-M (-M12 / -H)

X10 on Polaris board

1

phyCAM-M

VM-016

0x10, 0x18

0x10

VM-016-COL-M (-M12 / -H)

X10 on Polaris board

1

phyCAM-M

VM-016

0x10, 0x18

0x10


Note

I²C addresses of the camera are set by hardware configuration (jumper setting on the camera and/or on the baseboard. Please refer to the L-1018e.A0 phyCAM-M VM-016 1/4“ 1,0 MPixel Global Shutter Camera Module Guide and the L-862e.A1 phyCORE-i.MX 8M Mini / phyBOARD-Polis (1518.1a / 1532.1) Hardware Manual.

Change the Camera Types in Standard Vision Image (phytec-vision-image-phyboard-polis-imx8mm-3)

The following camera types are interchangeable in the image:

  • VM-017-BW-M series (VM-017-BW-M, VM-017-BW-M-M12, VM-017-BW-M-H, …) based on camera sensor “AR052x”
  • VM-017-COL-M series (VM-017-COL-M, VM-017-COL-M-M12, VM-017-COL-M-H, …) based on camera sensor “AR052x”
  • VM-117-BW-M series (VM-117-BW-M, VM-117-BW-M-M12, …) based on camera sensor “AR052x”
  • VM-117-COL-M series (VM-117-COL-M, VM-117-COL-M-M12, …) based on camera sensor “AR052x”
  • VM-017-BW-L series (VM-017-BW-L, VM-017-BW-L-M12, VM-017-BW-L-H, …) based on camera sensor “AR052x” (note: in progress)
  • VM-017-COL-L series (VM-017-COL-L, VM-017-COL-L-M12, VM-017-COL-L-H, …) based on camera sensor “AR052x” (note: in progress)

Hardware Configuration

Possible Parameters


Default I²C-address
(default jumper on camera and boards)

phyCAM Camera Model
 (part number)

Connected to

csi_port

cam_bus_type

cam_type

cam_i2c_address

VM-017-BW-M (-M12 / -H)

VM-117-BW-M (-M12)

X10 on Polaris board

1

phyCAM-M

VM-017

0x36, 0x37

0x36

VM-017-COL-M (-M12 / -H)

VM-117-COL-M (-M12)

X10 on Polaris board

1

phyCAM-M

VM-017

0x36, 0x37

0x36

VM-017-BW-L (-M12 / -H)

X10 on Polaris board

via VZ-018

1

phyCAM-M

VM-017

0x36, 0x37

0x36

VM-017-COL-L (-M12 / -H)

X10 on Polaris board

via VZ-018

1

phyCAM-M

VM-017

0x36, 0x37

0x36

How to Change the Device Tree for VM-017/VM-117

Please follow the instructions of “README.md” from PHYTEC FTP Server:  https://download.phytec.de/ImageProcessing/phyBOARD-Polis-i.MX8MM_linux_PD21.1.0/VM-017/

After reboot and login, load ar052x.ko camera driver: > insmod ar052x.ko

VM-017/117 driver AR052x Output (after loading)

Now the VM-0x17 driver (AR052x) is ready for use and you can start working with the Demo Scripts

Demo Scripts

If you want to see the live images, we recommend using a display on the Polis Board (for example 10” 1280x800 Display KPEB-AV-10-100.A0)

There are 3 subdirectories with demo scripts for the cameras:

  • GStreamer-examples
  • v4l2_c-examples
  • opencv-examples

Note

Remove the qt-demo at first startup with the \gstreamer-examples\remove_qt_demo.sh script. Otherwise, the qt-demo is always present on the display.

GStreamer scripts

After login, change into the directory:  \gstreamer-examples\..
cd gstreamer_examples <ENTER>.

Now you can start working with the GStreamer demo scripts.

Start the scripts with den word phrase "col" or "bw" depending on the connected camera color type.

  • _cam-fbdev_1280x720.sh: scripts show a live stream on display
  • _cam-save_jpg_full_res.sh: scripts save a JPG File in this directory
  • _cam-save_raw_full_res.sh: scripts save a RAW File in this directory
  • sh: scripts detect the camera type and define the parameter for the scripts
  • sh: scripts remove the qt-demo from autostart
  • sh: scripts turn on/off if Wayland necessary or not

Subdirectories:

  • more_ar0144_scripts: contain more scripts for the VM-016 camera series (v4l-ctrl_ar0144.txt list the v4l2-controls for this camera)
  • more_ar052x_scripts: contain more scripts for the VM-017/117 camera series (v4l-ctrl_ar052x.txt list the v4l2-controls for this camera)
  • vpu_enc_dec_scripts: contain scripts how use the vpu-encoder (e.g network streaming or save H.264 streams)
  • tools: contain scripts to get and set the camera register direct via i2c access
  • phytec_usb_cam: scripts for use the PHYTEC USB-cameras

Call of “colcam-fbdev_1280x720.sh” for VM-016-COL (AR0144) series (A live image should show on the display)

All camera/video components get a separate "/dev/video[x]" or "dev/v4l-subdev[x]" device.

The v4l2 capabilities are shown if you type: "v4l2-ctl -d [device] -L" e.g. "v4l2-ctl -d /dev/video0 -L".

For the first use, the camera and controller-camera interface must be configured with the tool v4l2-ctl. See chapter 5.

Scripts to Call C/C++ files Based on v4l2 Interface

After login, change into the directory:  \v4l2_c-examples\..
cd v4l2_c-examples <ENTER>.

Now you can start working with the demo scripts.

Start the scripts with den word phrase "col" or "bw" depending on the connected camera color type.

  • ar0144_col/bw_full_save-raw: scripts save a raw image from VM-016 in full resolution (8/10 and 12-Bit Formats are possible)
  • ar052x_col/bw_full_save-raw: scripts save a raw image from VM-017/117 in full resolution (8/10 and 12-Bit Formats are possible)

To save the image, we use the program Yavta. Yavta stands for "Yet Another V4L2 Test Application". This is a test application based on V4L2 Linux interface.

Another way to use in your C-program is the direct access call to the v4l2 interface. For example:

v4l2-ctl -d0 --stream-mmap --stream-count 1 --stream-to=raw_image1.raw

For the first use, the camera and controller camera interface must be configured with the tool v4l2-ctl. See chapter 5.

OpenCV Scripts

PHYTEC i.MX 8M Mini BSP PD21.1.0 includes OpenCV4.4.  To use OpenCV with image output, we use window manager Wayland. PHYTEC tested OpenCV with PYTHON programming language.  Examples of scripts can be found in the path “opencv-examples”:

  • /opencv-examples/python/python3 phycam_video_v4l2.py: show the live image from the camera
  • /opencv-examples/python/python3 face_detection.py: small application to detect faces

Tip

For the first use, the camera and controller-camera interface must be configured with the tool v4l2-ctl. See Scripts to Call C/C++ files Based on v4l2 Interface

Configure Camera and Controller Camera Interface with “media-ctl”

Modern System-on-Chip (SoC) devices support a wide range of functionality in the way of internal hardware blocks which has resulted in a variety of ways to interconnect functions within the SoC that alter the V4L device content.

The Media Controller kernel API has been designed to expose detailed information about media devices and capture devices to userspace in a way that allows them to be interconnected in dynamic and complex ways at runtime.

Media controller devices expose entities to the media controller framework. Each entity has one or more source pads and one or more sink pads. You use the media controller kernel API (ie via media-ctl) to query entities, link source pads to sink pads, and set formats of pads.

We use media-ctl to set:

  • the desired resolution and color format of the camera sensor
  • the fitting resolution and color format in the CSI interface (controller-camera-interface)
  • the way (and/or preprocessing) through the different hardware blocks in the controller
  • the resulting camera stream is made available as “/dev/videox” device

These settings are necessary:

  • once after restarting the system and using the camera for the first time
  • set a new resolution, color format, or bit-depth
  • set a new path through the hardware blocks

Following entities are present at the i.MX 8M Mini Image (check with “media-ctl –p”):

  • entity 1: csi (2 pads, 2 links)

                        pad0: Sink

                        pad1: Source

  • entity 4: csi capture (1 pad, 1 link)

                        pad0: Sink

  • entity 10: imx7-mipi-csis.0 (2 pads, 2 links)

                        pad0: Sink

                        pad1: Source

  • entity 13: ar0144 3-0010 (1 pad, 1 link)                         #(depend on selected camera)

                        pad0: Source

To set the media-ctl, we use in our demo script following points:

  • media-ctl –r: reset all links to inactive
  • media-ctl –l: setup the links between the hardware blocks
  • media-ctl –V: formats the hardware blocks

For example, we will set the VM-016-COL (AR0144) with full Resolution from CSI Port to a /dev/videox device.

First we set the links:

media-ctl -r

media-ctl -l "'ar0144 3-0010':0->'imx7-mipi-csis.0':0[1]"

media-ctl -l "'imx7-mipi-csis.0':1->'csi':0[1]"

media-ctl -l "'csi':1->'csi capture':0[1]"

#           Camera -> imx7_mipi_csis.0 -> CSI -> CSI capture (/dev/videoX)

Video path VM-016 (AR0144)                   Video path VM-017 (AR052x)

Then we format the hardware blocks:

media-ctl -V "'ar0144 3-0010':0 [fmt:SGRBG8_1X8/1280x800 (0,4)/1280x800]"

media-ctl -V "'imx7-mipi-csis.0':1 [fmt:SGRBG8_1X8/1280x800]"

media-ctl -V "'csi':1 [fmt:SGRBG8_1X8/1280x800 field:none]"

Check the settings with “media-ctl –p”:

 “media-ctl –p” Output

Now the camera is present at “dev/video0” device. The camera is ready for access.

Camera Features Configuration

v4l2-ctl Configuration

To set the various camera functions (e.g. exposure, gain, ...) use please the v4l2-ctl functions. You can get an overview of the existing functions by entering the commands:

  • for example: v4l2-ctl -d /dev/video0 –all (list all)
  • for example: v4l2-ctl -d /dev/video0 -L (list all detail)

With this control are many features usable. For example exposure. Set one exposure value (if the automatic disable):

  • v4l2-ctl -d /dev/video0 --set-ctrl=auto_exposure=1 (set AR0144 AEC off)
  • v4l2-ctl -d /dev/video0 --set-ctrl=exposure=800 (set the exposure time for a time, that the sensor need to generate 800 rows)

Camera Register Direct Configuration

To set or get a camera register directly, use the i2c functions in the path …/gstreamer-examples/tools/...

Use this function only, if you know the register reaction. Read the register reference manual of the camera sensor manufacturer.

De-Bayering (demosaicking) with NEON CoProcessor

Most CMOS color chips provide the image in the Bayer mosaicing (Bayer raw) format. To get a color image in RGB format, it is necessary to convert the Bayer raw image.

These links detail how this can be done:

There also exist different algorithms for converting:

If the microprocessor does not include debayering hardware, you will have to do the converting via software. For this, you need additional processing power and the framerate will go down. It is better to use the NEON coprocessor of the i.MX 8M Mini. It is available as a GStreamer plugin "bayer2rgbneon" and in sources for use in an own C-program. PHYTEC supports a simple bilinear algorithm.

To use in GStreamer, take the "bayer2rgbneon" plugin. For more information on "bayer2rgbneon" parameters type:

gst-inspect-1.0 bayer2rgbneon

The source are located at:

Revision History

Date

Version Numbers

Changes in this Manual

06.05.2021

Manual L-1024e.A0

Preliminary Edition