6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15329
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Arducam camera mux boards

Thu Aug 25, 2022 11:37 am

Minor announcement: there are now overlays that allow use of Arducam Doubleplexer 2 port (Rev C) and 4 port (V2.2) multiplexers such that the cameras are all detected and can be selected within libcamera.

You do have to manually specify which type of sensor is on each of the ports, but it also supports having different sensors on each port (unlike when used with the firmware).
Help text at https://github.com/raspberrypi/linux/bl ... EADME#L689
eg IMX219 on CAMERA A, and IMX477 on CAMERA B of a Doubleplexer

Code: Select all

dtoverlay=camera-mux-2port,cam0-imx219,cam1-imx477
or IMX219 on CAMERA A, IMX477 on CAMERA B, OV9281 on CAMERA C, and OV5647 on CAMERA D of a 4 port multiplexer.

Code: Select all

dtoverlay=camera-mux-4port,cam0-imx219,cam1-imx477,cam2-ov9281,cam3-ov5647
There are a couple of quirks:
- The Arducam boards bridge the camera/display I2C bus with i2c-1 (GPIOs 2&3). Be careful also using i2c-1, or cut the two traces from pins 4 & 6 of the header connection.
- The ordering of the sensors in libcamera is dictate by probe order, and can end up being near random. We will look into whether this can be solved in the kernel, or allow choosing the camera via an alternative to index (eg device name).
- I've only included the sensors that Raspberry Pi provide support for. Third parties can add their modules if following the same pattern, but we're not taking on the support burden for them.

It hasn't changed that the sensors can only be run sequentially, not simultaneously.

The same mechanism can not be used to support the Waveshare Camera Scheduler as that switches CSI and I2C via the same GPIO, and can't currently be made to work with the kernel mux framework.

The kernel changes are largely merged, except I missed one module option so it's not fully hit rpi-update as yet.
Feel free to report issues.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ketai
Posts: 30
Joined: Mon Jun 27, 2022 8:24 am

Re: Arducam camera mux boards

Fri Aug 26, 2022 9:36 am

First of all, I want to express that I like this feature very much.
I can learn a lot of ideas from it.

I tried it right away but ran into some difficulties.
1.jpg
1.jpg (23.91 KiB) Viewed 1115 times
You can see in dmesg that the device is recognized
but i didn't find video0.
2.jpg
2.jpg (6.14 KiB) Viewed 1115 times
But I see that subdevice is not registered successfully.

my config.txt:
3.jpg
3.jpg (61.63 KiB) Viewed 1115 times

ketai
Posts: 30
Joined: Mon Jun 27, 2022 8:24 am

Re: Arducam camera mux boards

Fri Aug 26, 2022 9:37 am

Below is the complete dmesg log
dmesg.zip
(10.76 KiB) Downloaded 32 times

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15329
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Arducam camera mux boards

Fri Aug 26, 2022 10:23 am

The kernel changes are largely merged, except I missed one module option so it's not fully hit rpi-update as yet.
Did you build the kernel after https://github.com/raspberrypi/linux/pull/5147 (or https://github.com/raspberrypi/linux/pull/5146 if building rpi-5.18.y)
I'm guessing not, and "sudo cat /sys/kernel/debug/v4l2-async/pending_async_subdevices" will report unicam waiting for the mux.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

ketai
Posts: 30
Joined: Mon Jun 27, 2022 8:24 am

Re: Arducam camera mux boards

Sat Aug 27, 2022 3:10 am

I did a manual compilation before.

I updated the kernel. Now its works perfectly.

Again, thank you for that.

chrisruk
Posts: 29
Joined: Mon Jan 10, 2022 11:49 am

Re: Arducam camera mux boards

Thu Sep 08, 2022 3:26 pm

Hi,

The new overlay seems very handy, not having to use I2C directly to switch cameras :)

I'm just wondering if anyone has got the following error 'Unable to request 0 buffers: Device or resource busy', when using the
mux overlays, the image still captures in both cases below though -

I used:

Code: Select all

dtoverlay=camera-mux-4port,cam0-ov5647,cam1-ov5647,cam2-ov5647,cam3-ov5647
And just compiled a kernel -

Code: Select all

5.15.65-v7l+ #1 SMP Thu Sep 8 14:48:08 BST 2022 armv7l GNU/Linux

Code: Select all

libcamera-still --camera 0 -o a.jpg
Made DRM preview window
[0:04:51.158710019] [1549]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:04:51.194770543] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.205985900] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.218726424] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@2/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.229890948] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@3/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.230696902] [1549]  INFO Camera camera.cpp:1035 configuring streams: (0) 1296x972-YUV420
[0:04:51.231101546] [1550]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
[0:04:56.367800947] [1549]  INFO Camera camera.cpp:1035 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-SGBRG10_CSI2P
[0:04:56.369302134] [1550]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAA
Still capture image received

Code: Select all

libcamera-still --camera 1 -o b.jpg
Made DRM preview window
[0:04:20.311237976] [1533]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:04:20.349288274] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.360902869] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.372043953] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@2/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.384402112] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@3/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.385143954] [1533]  INFO Camera camera.cpp:1035 configuring streams: (0) 1296x972-YUV420
[0:04:20.385541893] [1534]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
[0:04:25.519434070] [1533]  INFO Camera camera.cpp:1035 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-SGBRG10_CSI2P
[0:04:25.520868625] [1534]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAA
Still capture image received
[0:04:26.168000307] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168092639] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video13[15:out]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168138249] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video14[16:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168181582] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video15[17:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168224896] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video16[18:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168306136] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video16[18:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168365654] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video15[17:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168422042] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video14[16:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168477856] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video13[15:out]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168552133] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 0 buffers: Device or resource busy
The error appears when using camera numbers greater than 0

Many thanks!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15329
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Arducam camera mux boards

Thu Sep 08, 2022 4:00 pm

chrisruk wrote:
Thu Sep 08, 2022 3:26 pm
I'm just wondering if anyone has got the following error 'Unable to request 0 buffers: Device or resource busy', when using the
mux overlays, the image still captures in both cases below though -

I used:

Code: Select all

dtoverlay=camera-mux-4port,cam0-ov5647,cam1-ov5647,cam2-ov5647,cam3-ov5647
And just compiled a kernel -

Code: Select all

5.15.65-v7l+ #1 SMP Thu Sep 8 14:48:08 BST 2022 armv7l GNU/Linux

Code: Select all

libcamera-still --camera 0 -o a.jpg
Made DRM preview window
[0:04:51.158710019] [1549]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:04:51.194770543] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.205985900] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.218726424] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@2/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.229890948] [1550]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@3/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:51.230696902] [1549]  INFO Camera camera.cpp:1035 configuring streams: (0) 1296x972-YUV420
[0:04:51.231101546] [1550]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
[0:04:56.367800947] [1549]  INFO Camera camera.cpp:1035 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-SGBRG10_CSI2P
[0:04:56.369302134] [1550]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAA
Still capture image received

Code: Select all

libcamera-still --camera 1 -o b.jpg
Made DRM preview window
[0:04:20.311237976] [1533]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:04:20.349288274] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@0/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.360902869] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.372043953] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@2/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.384402112] [1534]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/pca@70/i2c@3/ov5647@36 to Unicam device /dev/media1 and ISP device /dev/media0
[0:04:20.385143954] [1533]  INFO Camera camera.cpp:1035 configuring streams: (0) 1296x972-YUV420
[0:04:20.385541893] [1534]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
[0:04:25.519434070] [1533]  INFO Camera camera.cpp:1035 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-SGBRG10_CSI2P
[0:04:25.520868625] [1534]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/pca@70/i2c@1/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAA
Still capture image received
[0:04:26.168000307] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168092639] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video13[15:out]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168138249] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video14[16:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168181582] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video15[17:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168224896] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video16[18:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168306136] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video16[18:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168365654] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video15[17:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168422042] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video14[16:cap]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168477856] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video13[15:out]: Unable to request 0 buffers: Device or resource busy
[0:04:26.168552133] [1534] ERROR V4L2 v4l2_videodevice.cpp:1234 /dev/video0[14:cap]: Unable to request 0 buffers: Device or resource busy
The error appears when using camera numbers greater than 0
It shouldn't really make a difference what camera number is used - it configures the links, and then should leave them alone.

Requesting 0 buffers is normally on tearing things down, and this is after "Still capture image received", so I'm wondering if it's largely just noise in the logging. I'm afraid I won't really have a chance to look for a little over a week though.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”