ov9281 dtbo with balena fin

Hi,

I’ve got the same arducam B0165 MIPI camera with ov9281 chipset. You have helped me [1] get it working in the past using the arducam userspace library. I have since switched to using it via the v4l2 linux kernel subsystem on the RPi 3B, and now I want to switch to that on the balena as well.

The switch is accomplished via a single dtoverlay line in config.txt: dtoverlay=ov9281.

However, that does not work on the balena fin - for the same reason presumably, that the overlay is rpi-3b specific, and needs to be updated for the balena fin.

Has anyone done this already? i.e. gotten ov9281.dtbo working on balena fin?

Thanks in advance,
Alon

[1] Arducam B0165 not working on Balena Fin v1.1 (The Raspberry Pi Camera Module v1 does)

Hey

I remember that ticket - I’ll set up a device with the hardware and the overlay by tomorrow and give it a shot.

That’s great. Let me know if I can help in any way.

Alon

Just to update, I tried on a limb to build the latest kernel from raspberrypi (5.10.33-v7+) because the reported error, “Unsupported sensor id” was similar to a report that ended up being fixed by it (a long shot that didn’t pan out).

So adding that running 96110e96f1a82e236afb9a248258f1ef917766e9 (git describe --tags gives raspberrypi-kernel_1.20210303-1-2218-g96110e96f1a8) from https://github.com/raspberrypi/linux.git still results in the error. (used default config, i.e. make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfigper Kernel building - Raspberry Pi Documentation)

Additionally, repeatedly unloading and reloading the ov9281 module results in the same error, but with different read values from the I2C bus:

[   89.481688] ov9281 10-0060 Unexpected sensor id(42dc3c00), ret(-5)
[  108.230681] ov9281 10-0060 Unexpected sensor id(9b1c3c00), ret(-5)
[  109.830790] ov9281 10-0060 Unexpected sensor id(9b1c3c00), ret(-5)
[  111.154344] ov9281 10-0060 Unexpected sensor id(723c3c00), ret(-5)
[  112.312128] ov9281 10-0060 Unexpected sensor id(723c3c00), ret(-5)
[  113.350073] ov9281 10-0060 Unexpected sensor id(299c3c00), ret(-5)
[  114.373747] ov9281 10-0060 Unexpected sensor id(383c3c00), ret(-5)
[  115.310245] ov9281 10-0060 Unexpected sensor id(babc3c00), ret(-5)
[  116.360306] ov9281 10-0060 Unexpected sensor id(aa7c3c00), ret(-5)
[  117.290401] ov9281 10-0060 Unexpected sensor id(b6bc3c00), ret(-5)
[  118.182629] ov9281 10-0060 Unexpected sensor id(405c3c00), ret(-5)
[  119.012934] ov9281 10-0060 Unexpected sensor id(413c3c00), ret(-5)
[  119.794808] ov9281 10-0060 Unexpected sensor id(2b5c3c00), ret(-5)
[  120.632320] ov9281 10-0060 Unexpected sensor id(3bdc3c00), ret(-5)

Perhaps the fact that the lower 20 bits are always c3c00 is important.

Any progress on your side? /fingers crossed/

Alon
p.s. tried to upload the overlay, beyond message size (32K), will try to attach it (dtc -I fs /proc/device-tree) instead.


Just a small update, in case you are working on this - I’ve managed to get the I2C side working, but then when I try to stream I get no results. Turning on the verbosity on the bcm2835_unicam kernel module shows that the ISR routine is never called. I can share the dt-blob & the changes I’ve done to the dts files (I’ve not yet figured out how to use the overlays so I ended up changing the dts sources in the kernel tree).

@anujdeshpande Hi again. Any progress on this?

Hi, are you able to use the device with the overlay on a rpi 3b running balenaOS

hmm, missed this, sorry: I did not try the balena OS, but raspbian works fine on rpi 3b.

ok, tested with balena os, works fine:

  1. Installed release of GitHub - balena-io-examples/balena-rust-hello-world: Example of how to deploy Rust code on a balena supported device.
  2. Device configuration:
    a. Define DT overlays = ov9281
    b. BALENA_HOST_CONFIG_start_x=1
    c. Define device GPU memory in megabytes = 128
  3. ssh inside
    a. apt update
    b. apt install -y v4l-utils
    c.
v4l2-ctl  --stream-mmap --stream-count=100
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

d.

v4l2-ctl  --list-devices | head -3
unicam (platform:3f801000.csi):
        /dev/video0
        /dev/video1

Used balenaOS 2.77.0+rev1, supervisor version 12.5.10.
Kernel (uname -a): Linux 2321c48 5.4.83-v7 #1 SMP Mon Dec 14 12:43:54 UTC 2020 armv7l GNU/Linux

Hey @floion, sorry to bug you, I could use all the help I can get! Thanks in advance.

Hey

I am looking at this now, and was wondering if you tried this using Raspbian on the balenaFin. You can find the release here : Releases · balena-os/pi-gen · GitHub

Also, if you have any shareable code for Raspbian on 3B+ that you know to work - it will help too.

Thanks for getting around to it. I would love to use v4l again, it is a standard interface, would make our code more portable, and has more tooling.
I have tested as I wrote above - have not touched it since. To recap: balena os works fine on rpi3b, but not on the balena fin. I have not tried raspbian on the balenaFin.

Awaiting updates,
Alon

Hi

Do you have a small app or test code that you have verified as working on the Pi3? Would be great if you can share that

Is the comment from May 24th satisfactory?

  • used balenaos
  • installed v4l-utils
  • set in config.txt (via the Device configuration UI): BALENA_HOST_CONFIG_start_x=1, DT overlays=ov9281, GPU memory 128 megabytes
  • ran v4l2-ctl --stream-mmap --stream-count=100

Hi

Apologies for the delay. There’s definitely something up as the same app on RPi3 running balenaOS gave me a different output, as compared to the balenaFin. I am going to discuss this internally and figure if it’s a software issue or a hardware - as there’s some additional overlay stuff for the balena-fin that’s in play.

Just to add more details, based on our previous forum thread w/ this camera, I did the following

  • increases the gpu memory to 396
  • set i2c_vc=on in my device tree params for both the fin and pi3

Thanks for your efforts. When you say “gave me a different output” can you say if you managed to capture images with the balenaFin and the ov9281 using the kernel driver, i.e. v4l2 driver?

I was able to get raw data, which I assumed was good enough to verify if it works. I’ll check if the ffmpeg can convert that image fine.

raw data is just fine. I did not manage to do that. Can you share what you did?

I tried v4l2-ctl --stream-mmap --stream-count=1 --stream-to=file.raw and then downloaded the image to my machine and used hexdump to see that the file wasn’t empty.
I am now trying ffmpeg along v4l2 to capture a stream in one of the supported formats

root@069d068:/usr/src/app# ffmpeg -f v4l2 -list_formats all -i /dev/video0
ffmpeg version 3.2.15-0+deb9u4 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
  configuration: --prefix=/usr --extra-version=0+deb9u4 --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libavresample   3.  1.  0 /  3.  1.  0
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100
[video4linux2,v4l2 @ 0xda2570] Raw       : Unsupported : 10-bit Greyscale (MIPI Packed) : 1280x800
[video4linux2,v4l2 @ 0xda2570] Raw       : Unsupported :     10-bit Greyscale : 1280x800
[video4linux2,v4l2 @ 0xda2570] Raw       :        gray :      8-bit Greyscale : 1280x800
/dev/video0: Immediate exit requested
root@069d068:/usr/src/app#

This output was from the RPi3 device, when I asked ffmpeg to tell me what all formats it supported. There’s some issue here because the device threw an error at the end of the log. But I atleast know now that raw greyscale output is supported. So that’s what I am targetting