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

Hi there,
I have been trying for over three days now to add the yocto project layer for the camera drivers to work on my Verdin IMX8M+ using the AR0521 camera. I keep running into issues with the build after I have added the neccessary layer as per the instrcutions for BSP6. May I please have a compatible image so I can install using the Easy Installer, sent to me so I can at least get the camera running as my application is time critical?

Kind regards,

Ben

So this is one of the errors for example with my build:
Its been happening the whole time and I have followed all of the steps correctly in the developer pages for both Torizon and Linux installation instructions.

Hi @btj2 , there seems to be something wrong when cloning GitHub - docker/go-metrics: Package for metrics collection in Docker projects. Does another round of bitbake torizon-core-docker work? It could be a networking issue.

Hi Shanfeng,
Thank you for your reply, we hope you can help!
Our issue does not appear to be a networking issue as our entire build we have been monitoring it and it has been fine. The errors are random and are to do with the build process itself. Are you able to give us an image with the layer added and built so we can use it please? I assume that there would be an standard image that you can provide as you would have tested it on devices before selling the camera product. We would love one without any preset containers, so we can run our python torizon ide application and install it via the Easy Installer.

Hi Shangfeng,
Also whist following the BSP6 Linux AR0521 instructions, we got this error:
ERROR: linux-toradex-5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0 do_patch: Could not apply patches for verdin-imx8mp.
ERROR: linux-toradex-5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0 do_patch: Patch failures can be resolved in the linux source directory /home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/git)
ERROR: linux-toradex-5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0 do_patch: ExecutionError(‘/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/temp/run.do_patch.974402’, 1, None, None)
ERROR: Logfile of failure stored in: /home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/temp/log.do_patch.974402
Log data follows:

DEBUG: Executing python function extend_recipe_sysroot
NOTE: Direct dependencies are [‘/home/agriai/build-torizon/conf/…/…/layers/openembedded-core/meta/recipes-devtools/quilt/quilt-native_0.67.bb:do_populate_sysroot’, ‘/home/agriai/build-torizon/conf/…/…/layers/openembedded-core/meta/recipes-kernel/kern-tools/kern-tools-native_git.bb:do_populate_sysroot’, ‘virtual:native:/home/agriai/build-torizon/conf/…/…/layers/openembedded-core/meta/recipes-devtools/patch/patch_2.7.6.bb:do_populate_sysroot’]
NOTE: Installed into sysroot: [‘quilt-native’, ‘patch-native’, ‘libtool-native’, ‘attr-native’, ‘texinfo-dummy-native’, ‘gettext-minimal-native’]
NOTE: Skipping as already exists in sysroot: [‘kern-tools-native’]
DEBUG: sed -e ‘s:[1]*/:/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/recipe-sysroot-native/:g’ /home/agriai/build-torizon/tmp/sysroots-components/x86_64/quilt-native/fixmepath /home/agriai/build-torizon/tmp/sysroots-components/x86_64/libtool-native/fixmepath | xargs sed -i -e ‘s:FIXMESTAGINGDIRTARGET:/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/recipe-sysroot:g; s:FIXMESTAGINGDIRHOST:/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/recipe-sysroot-native:g’ -e ‘s:FIXME_PSEUDO_SYSROOT:/home/agriai/build-torizon/tmp/sysroots-components/x86_64/pseudo-native:g’ -e ‘s:FIXME_HOSTTOOLS_DIR:/home/agriai/build-torizon/tmp/hosttools:g’ -e ‘s:FIXME_PKGDATA_DIR:/home/agriai/build-torizon/tmp/pkgdata/verdin-imx8mp:g’ -e ‘s:FIXME_PSEUDO_LOCALSTATEDIR:/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/pseudo/:g’ -e ‘s:FIXME_LOGFIFO:/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/temp/fifo.974402:g’
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing shell function do_patch
(1/4) 0001-kernel-patches.patch
[INFO]: check of .kernel-meta//patches//./0001-kernel-patches.patch with “git am” did not pass, trying reduced context.
[INFO]: Context reduced git-am of .kernel-meta//patches//./0001-kernel-patches.patch with “git am” did not work, trying “apply”.
/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/git/.git/rebase-apply/patch:142: trailing whitespace.

/home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/git/.git/rebase-apply/patch:268: space before tab in indent.
.data_alignment = 16,
error: patch failed: drivers/staging/media/imx/imx8-mipi-csi2.c:1182
error: drivers/staging/media/imx/imx8-mipi-csi2.c: patch does not apply
[ERROR]: Application of .kernel-meta//patches//./0001-kernel-patches.patch failed.
Patch needs to be refreshed. Sample resolution script:
.git/rebase-apply/resolve_rejects
ERROR: Could not apply patches for verdin-imx8mp.
ERROR: Patch failures can be resolved in the linux source directory /home/agriai/build-torizon/tmp/work/verdin_imx8mp-tdx-linux/linux-toradex/5.15.129+gitAUTOINC+94602d0611_d6880bf83a-r0/git)
WARNING: exit code 1 from a shell command.
ERROR: Task (/home/agriai/build-torizon/conf/…/…/layers/meta-toradex-nxp/recipes-kernel/linux/linux-toradex_5.15-2.2.x.bb:do_patch) failed with exit code ‘1’


  1. ^/ ↩︎

Hi @btj2 , here is a Linux BSP v6.4 multimedia reference image with meta-toradex-econ layer added. But I don’t have AR0521 camera at hand now. Please try it on your side. Thanks.

Hi @btj2 , current AR0521 patch is not compatible with Torizon or Linux BSP v6.5.0. You have to go back to v6.4.0 with the following command. This is a Torizon v6.4.0 image with AR0521 driver for your quick test.

repo init -u https://git.toradex.com/toradex-manifest.git -b refs/tags/6.4.0 -m torizoncore/default.xml
repo sync

Hi there,

We tried the older image ou sent through but we cannot connect to the dveice once it is loaded via ssh or IP. The error it gives is ‘permission denied please try again’ for the default username ‘torizon’ and password ‘torizon’.

Also the latest Torizon-docker image you sent is corrupted and unable to zip, or run on the device using the Torizon Easy Installer.

Please help!

Kind regards,

Ben

Hi @btj2 , please download it from here. It is a Torizon V6.4.0 image. The previous one could be corrupted when uploading it to the server.

I also ran into this particular error when compiling the AR0521 layers last week and solved it by fixing the patch. PR is here: Update kernel patch to apply again by matthijskooijman · Pull Request #1 · toradex/meta-toradex-econ · GitHub

With that applied, I was able to a 6.5.0 TorizonCore/OS image with Yocto that I could boot succesfully (I have not managed to make the camera work with it yet, but there’s probably something in our other customizations that interferes).

Maybe not a direct answer to what you need, but maybe it can be one piece of the puzzle at least :slight_smile:

Thank you very much for that :slight_smile: I appreciate the knowledge

Hi Shanfeng,
So we have got the image built on our device. We are trying to access the camera via gstreamer and python3 opencv. The camera does appear in /dev/video2 but we keep getting an error when using the recommended gstreamer pipeline and using cv2.VideoCapture(). The cap.isopened() function appears to not access the camera and we cannot get any output. Do you have some fixes or python code to ensure the camera can output? Do you have a sample program to run the camera on my Verdin IMX8MP & Mallow carrier?

Kind regards,

Ben

Hi @btj2 , I assume you will need video hardware decoding on Verin iMX8M Plus. We are still working on VPU support for Torizon on Verdin iMX8M Plus. With this PoC container, /dev/video2 camera device can be found inside the container. apt install v4l-utils -y needs to be installed.

docker run -it --rm --name=ap --net=host --privileged  \
-v /tmp:/tmp -v /var/run/dbus:/var/run/dbus -v /dev/galcore:/dev/galcore -v /var/run/dbus:/var/run/dbus -v /dev:/dev -v /sys:/sys \
--device /dev/video0 --device /dev/video1 --device /dev/video2 \
--device-cgroup-rule='c 226:* rmw' --device-cgroup-rule='c 199:* rmw' \
brunomellotoradex/imx8-vpu-poc:imx8mp bash

root@verdin-imx8mp-07320826:/# apt update
root@verdin-imx8mp-07320826:/# apt install v4l-utils -y
root@verdin-imx8mp-07320826:/# v4l2-ctl --device=/dev/video2 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture Multiplanar

        [0]: 'UYVY' (UYVY 4:2:2)
                Size: Discrete 640x480
                        Interval: Discrete 0.019s (53.000 fps)
                Size: Discrete 1280x720
                        Interval: Discrete 0.014s (70.000 fps)
                Size: Discrete 1280x960
                        Interval: Discrete 0.019s (53.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.015s (65.000 fps)
                Size: Discrete 2560x1440
                        Interval: Discrete 0.026s (38.000 fps)
                Size: Discrete 2592x1944
                        Interval: Discrete 0.036s (28.000 fps)
        [1]: 'RGBP' (16-bit RGB 5-6-5)
        [2]: 'RGB3' (24-bit RGB 8-8-8)
        [3]: 'BGR3' (24-bit BGR 8-8-8)
        [4]: 'YUYV' (YUYV 4:2:2)
        [5]: 'YUV4' (32-bit A/XYUV 8-8-8-8)
        [6]: 'NV12' (Y/CbCr 4:2:0)
        [7]: 'NM12' (Y/CbCr 4:2:0 (N-C))
        [8]: 'YM24' (Planar YUV 4:4:4 (N-C))
        [9]: 'XR24' (32-bit BGRX 8-8-8-8)
        [10]: 'AR24' (32-bit BGRA 8-8-8-8)

However, the camera stream can not be brought up by gstreamer pipeline. I will look into it and keep you updated.

root@verdin-imx8mp-07320826:/# gst-launch-1.0 v4l2src device='/dev/video2'  ! "video/x-raw, format=RGB16, framerate=30/1, width=1920, height=1080" ! fpsdisplaysink video-sink=waylandsink text-overlay=false sync=false -vvv
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstWaylandSink:waylandsink0: sync = false
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, colorimetry=(string)sRGB
/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, interlace-mode=(string)progressive, colorimetry=(string)sRGB
/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, interlace-mode=(string)progressive, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0.GstGhostPad:sink: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)RGB16, framerate=(fraction)30/1, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, colorimetry=(string)sRGB
^Chandling interrupt.
Interrupt: Stopping pipeline ...

I’m also working with this particular camera. Yesterday, I managed to get it to stream video succesfully.

  • I’ve used my own yocto image, compiled using these instructions and installed using Easy Installer.
  • I’ve used the weston and gstreamer example docker containers as instructed in this documentation. If you want to skip building the gstreamer docker (it is not complicated, though), you could use the command below to start the version I’ve pushed to docker hub.
  • I’ve used the gstreamer command from this section.

With that, I’ve managed to get output on my HDMI screen. I’ve also managed to capture into a flv file, see below for the command.

The output that @benjamin.tx posts also seems familiar - everything seems to be set up correctly, but streaming does not start (gstreamer should display a timecode once it actually starts streaming). I’ve run into this situation with an IMX219 I’ve been trying to get to work (without success so far), but I’ve also seen it with the AR0521 yesterday: after I wiggled the camera a bit, it would end up in the same situation (not fixed by a reboot). I managed to fix the situation by unplugging and replugging all CSI cabling (with no changes to software), which suggests to me that signal integrity problems on the CSI lines might prevent CSI frames from being decoded succesfully, and then you end up in the “everything looks ok, but streaming does not start” scenario. Of course, there might be other causes of this symptom as well.

Here’s some commands from my notes that I’ve been using that might be useful for you:

docker run --rm -it -v /tmp:/tmp -v /var/run/dbus:/var/run/dbus -v /dev:/dev -v /sys:/sys --device /dev/video0 --device /dev/video1 --device /dev/video2 --device /dev/media0 --device-cgroup-rule='c 199:* rmw' matthijskooijman/torizon_gst_example
v4l2-ctl --list-devices
v4l2-ctl --device /dev/video2 -D
media-ctl -p
v4l2-ctl --device /dev/video2 --list-formats-ext
gst-launch-1.0 v4l2src device='/dev/video2'  ! "video/x-raw, format=YUY2, framerate=5/1, width=640, height=480" ! fpsdisplaysink video-sink=waylandsink text-overlay=false sync=false

gst-launch-1.0 v4l2src device='/dev/video2' ! "video/x-raw, format=YUY2, framerate=5/1, width=640, height=480" ! videoconvert ! x264enc ! flvmux ! filesink location=xyz.flv

 # from https://raspberrypi.stackexchange.com/questions/112743/v4l2-ctl-single-frame-capture-produces-image-with-green-ending
v4l2-ctl --device /dev/video2 --set-fmt-video=width=1920,height=1080,pixelformat=RGB3 --stream-mmap --stream-to=frame.raw --stream-count=1

# convert to be run on your own system
# truncated to 106 lines, since the file is somehow truncated to 614400 bytes
convert -size 1920x106 -depth 8 rgb:frame.raw frame.png

Hi Shanfeng,

Yes please look into it as we purchased the camera and toradex module with the premise of being able to actually use it ! We obviously want to incorporate it into our own application so some specifics on the docker-compose.yml file, Dockerfile and code would be useful :slight_smile:

Hi @matthijs ,

after I wiggled the camera a bit, it would end up in the same situation (not fixed by a reboot).

You save my day. Thanks. This is the same issue with my FFC cable. After reconnecting the FFC cable, I can see the camera video on the screen. @btj2 please have a try with the commands in my last thread.

1 Like

Hi there,

I need to get that Torizon V6.4.0 image you sent a few months back. I seemed to have misplaced it on another computer and cannot find the file. Can you please resend or post that image again please?

Kind regards,

Ben

Hi @btj2 , I find a copy of the image from my build server. But I’m not sure if it is the same one. You can down it from here.

Hi there,

The download link is still saying 404 not found. Also we are having issues with our AR0521 camera, it will run for a day in our docker container perfectly fine. Then after a while, i.e a day the camera fails to capture frames even though the ls /dev/video* is there. May you please do the latest torizon image with the camera layers added to see if that fixes the issue?

Kind regards,

Ben