VEYE CS Camera on MYIR i.MX8 board

From wiki_veye
Jump to navigation Jump to search

查看中文

1 Overview

MYD-JX8MX development board from MYIR Technology uses i.MX8M processor, MYD-C8MMX uses i.MX8M Mini processor.

On the basis of MYIR's official SDK(L4.19.35 version), our camera module driver is added, and some application layer routines are provided.

In general, you only need to use the Image and dtb that we have compiled. Of course, you can also modify or recompile the driver according to our open source code.

1.1 Camera module list

Camera module dirver status list
Series Model Status Adaptor board
VEYE series VEYE-MIPI-IMX327S Done ADP-MYiR
VEYE series VEYE-MIPI-IMX385 Done ADP-MYiR
VEYE series VEYE-MIPI-IMX462 Done ADP-MYiR
CS series CS-MIPI-IMX307 Done ADP-MYiR
CS series CS-MIPI-SC132 Done ADP-MYiR

VEYE and CS series camera modules are camera module with ISP functions build in. It output UYVY/YUYV data using MIPI-CSI2. We provide V4L2 interface for video streaming apps , and Video Control Toolkits (which is Shell Script) to control the camera module directly, which is called DRA(Directly Register Access).

Specifically, on this i.MX platform, the default driver configures the camera to YUYV format.

2 Hardware Setup

We use ADP-MYiR to connnect MYD-J8XMX board.

MYiR-MYD-J8XMX connection overview
MYiR-MYD-J8XMX connection overview
MYiR MYD-JX8MX connection details
MYiR MYD-JX8MX connection details


3 Upgrade MYD-JX8MX system

3.1 Overview

This section describes how to update the MYD-JX8MX system to support our camera module. To support our camera module, we need to update two parts of the system, Image and DTB.

In the Image, we added the camera driver, while the DTB indicates the camera model used. In general, you only need to use the Image and DTB, that we have prebuilt, and you don't need to build from source when it is not necessary.

3.2 BSP package introduction

3.2.1 i.MX platform bsp

https://github.com/veyeimaging/nxp_i.mx_veye_bsp

includes:

  • driver source code
  • i2c toolkits
  • application demo
3.2.2 MYiR i.MX platform bsp

https://github.com/veyeimaging/myir_nxp_i.mx

includes:

  • prebuild linux kernel:Image
  • prebuild dtb for different boards
  • dts source code

3.3 Burn the MYIR standard system

Refer to : MYD-JX8MX-Software-Manual-zh-V1.3.pdf

Burn the standard system provided by MYIR to the board.

3.4 Using prebuilt Image and dtb file

The Image and dtb files of the MYD-JX8MX board are saved in the FAT partition of emmc. After the system is started, it is automatically mounted to the /run/media/mmcblk0p1/ directory.

On HOST PC:

git clone https://github.com/veyeimaging/myir_nxp_i.mx.git

Extract the kernel Image, and copy the Image and dtb files to the MYD-JX8MX board.

cp <your path>/Image /run/media/mmcblk0p1/

cp <your path>/myb-fsl-imx8mq-evk-veye327.dtb /run/media/mmcblk0p1/myb-fsl-imx8mq-evk.dtb

Reboot MYD-JX8MX board.

4 Applications and Test

4.1 Check system status

Run the following command to confirm whether the camera is probed.

  • VEYE-MIPI-IMX327S

dmesg | grep veye327  

The output message appears as shown below:

camera veye327_mipi is found

Registered sensor subdevice: veye327_mipi <0/1>-003b

  • CS-MIPI-IMX307

dmesg | grep csimx307  

The output message appears as shown below:

camera csimx307_mipi is found

Registered sensor subdevice: csimx307_mipi <0/1>-003b

  • CS-MIPI-SC132

dmesg | grep cssc132  

The output message appears as shown below:

camera cssc132_mipi is found

Registered sensor subdevice: cssc132_mipi <0/1>-003b

  • Run the following command to check the presence of video node.

ls /dev/video*

The output message appears as shown below.

video0 or video1 

The cameras of the two MIPI-CSI2 interfaces are identified and mounted to i2-0 and i2c-1 respectively.

4.2 List the modes supported by the camera

v4l2-ctl --list-formats-ext -d /dev/video<0/1>

4.3 Video Stream test

export DISPLAY=:0

  • Preview (VEYE-MIPI-IMX327S,CS-MIPI-IMX307 @1080p mode)

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=1920,height=1080,framerate=(fraction)30/1' ! waylandsink

  • Preview (CS-MIPI-IMX307 @1080p mode 10fps)

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=1920,height=1080,framerate=(fraction)10/1' ! waylandsink

  • Preview (CS-MIPI-IMX307 @720p mode 60fps)

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=1280,height=720,framerate=(fraction)60/1' ! waylandsink

  • Preview (CS-MIPI-SC132 @1280*1080 mode 45fps)

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=1280,height=1080,framerate=(fraction)45/1' ! waylandsink

  • Preview (CS-MIPI-SC132 @1080*1280 mode 45fps)

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,width=1080,height=1280,framerate=(fraction)45/1' ! waylandsink

  • Snap a picture (VEYE-MIPI-327S,CS-MIPI-IMX307 @1080p mode)

gst-launch-1.0 v4l2src num-buffers=1 device=/dev/video0 ! 'video/x-raw, width=1920,height=1080' ! jpegenc ! filesink location=test_image.jpg

  • Snap a picture (CS-MIPI-IMX307 @720p mode)

gst-launch-1.0 v4l2src num-buffers=1 device=/dev/video0 ! 'video/x-raw, width=1280,height=720' ! jpegenc ! filesink location=720p.jpg

  • Snap a picture (CS-MIPI-SC132 @1280*1080 mode)

gst-launch-1.0 v4l2src num-buffers=1 device=/dev/video0 ! 'video/x-raw, width=1280,height=1080' ! jpegenc ! filesink location=test_image.jpg

  • v4l2grab snap a picture(VEYE-MIPI-327S,CS-MIPI-IMX307 @1080p mode)

./v4l2grab -d /dev/video0 -W 1920 -H 1080 -I 30 -o picture.jpg

4.4 I2C Control Toolkits Manual

Because of the high degree of freedom of our camera parameters, we do not use V4L2 parameters to control, but use scripts to configure parameters.

https://github.com/veyeimaging/nxp_i.mx_veye_bsp/tree/main/i2c_cmd

using -b option to identify which bus you want to use.

  • VEYE series

Video Control Toolkits Manual :VEYE-MIPI-327 I2C

  • CS series

Video Control Toolkits Manual :CS-MIPI-X I2C

5 Build the drivers from source

The following operations are done on Ubuntu Host PC.

5.1 Set up the Host PC environment

Refer to the official document MYD-JX8MX-Software-Manual-zh-V1.3.pdf to deploy the development environment.

Note that you don't have to use yocto if you only want to compile kernel, Of course, there is no problem with using yocto.

5.1.1 Cross-compiling Toolchain

There is a compiler tool chain installation script in the 03-Tools directory, which can be executed directly.

./fsl-imx-xwayland-glibc-x86_64-meta-toolchain-aarch64-toolchain-4.19-warrior.sh

After installing the compilation tool chain, execute the following command to configure the compilation environment:

source /opt/fsl-imx-xwayland/4.19-warrior/environment-setup-aarch64-poky-linux

5.2 Build MYIR version kernel

Copy the officially provided fsl-release-yocto.tar.gz to the development host and extract it.

The source code for linux is already available in the fsl-release-yocto/linux-imx directory.

cd fsl-release-yocto/linux-imx

make ARCH=arm64 CROSS_COMPILE=aarch64-poky-linux- defconfig

make ARCH=arm64 CROSS_COMPILE=aarch64-poky-linux- -j4

5.3 Patch code

  • Driver source code

git clone https://github.com/veyeimaging/nxp_i.mx_veye_bsp.git

The source code path of the camera driver is: linux/drivers/media/platform/mxc/capture, places the source code of the camera driver in the corresponding directory.

Merge the Config and Makefile in the same path. Add the corresponding camera driver.

  • dts file

git clone https://github.com/veyeimaging/myir_nxp_i.mx.git

The path to the dts file is: linux/arch/arm64/boot/dts/freescale, places the dts file in this path.

Modify the Config and Makefile in the same path. Add the corresponding dts option.

5.4 Add compilation options

make menuconfig

Add the compilation options for the corresponding camera module driver, and the path is Device Drivers > Multimedia support > V4L platform devices > MXC Camera/V4L2 PRP Features support.

5.5 Build

make Image dtbs -j4

6 References

MYIR official site:http://www.myir-tech.com/

MYD-JX8MX : http://down.myir-tech.com/MYD-JX8MX/