Not able to capture with argus and v4l2 api simultaneously

Hi,

I have a Jetson platform with 6 MIPI CSI cameras, each one enumerated as a separate /dev/videoX device.

My requirement is:

  • Use 3 cameras through Argus
  • Use the other 3 cameras through raw V4L2 capture api in the same system, from a different application.

When I try to do this, I observe the following:

If an Argus-based application is already running** (using /dev/video3, /dev/video4, /dev/video5 for sensor-id 0,1,2), and I try to open another camera (e.g., /dev/video0, /dev/video1, /dev/video2) using v4l2src, the pipeline fails to start with:

VIDIOC_REQBUFS: Cannot allocate memory
Failed to allocate required memory


* `fuser /dev/video*` shows that `/dev/video0` is not open by any process, but the error still happens as soon as Argus is running.
* All six cameras are **MIPI CSI sensors

My questions:

1. **Is it possible on Jetson to use 3 CSI cameras with Argus and 3 different CSI cameras with raw V4L2 capture concurrently (from different processes)?**
2. Does Argus reserve VI/CSI resources globally, preventing any raw V4L2 access, even for cameras not being used by Argus?
3. If this is not supported, what is the recommended architecture to use 3 cameras with ISP/Argus features and the other 3 for raw frames?


Any guidance or official confirmation would be appreciated.

any solution to above problem?

any update?

Shouldn’t have problem for it.
Suppose it could be your device tree conflict cause the problem.

Hi @shivlal12345,

Are you sure that the sensor devices used by the Argus application (sensor-id 0,1, 2) are /dev/video3, /dev/video4, /dev/video5?

I suggest you to run tests to debug the problem:

  • First, make sure you can run all the 6 cameras with v4l2. You can use v4l2-ctl to validate.
  • Then, I suggest you to test 2 camera combinations one using v4l2 and another argus. I recommend you to use a basic gstreamer pipeline instead of using your application for debugging. For example: video1-v4l2 and video2-argus, then test another combination. With this test it could tell us if there are dependencies between specific video devices.
  • You can also test the 6 cameras using argus only to make sure they all can run.

Regards,

Enrique Ramirez
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com
Website: www.ridgerun.com

Hi enrique,

I followed your suggestions and here are my observations:

Setup:

  • /dev/video0/1/2 = ov5693
  • /dev/video3/4/5 = imx390

Tests performed:

  1. All 6 with V4L2
    Verified using

v4l2-ctl -d /dev/videoX --stream-mmap --stream-count=100

All six cameras stream correctly.
2. All 6 with Argus:
Verified using
gst-launch-1.0 nvarguscamerasrc sensor-id=N ! fakesink sync=false async=false

Argus works fine for the three imx390 cameras. (ov5693 is not Argus-supported on this BSP.)
3. Mixed Argus + V4L2:
Case A – Start Argus first (3 cameras) and then start V4L2:
* The first V4L2 pipeline may start successfully.
* The second or third V4L2 pipeline fails with
VIDIOC_REQBUFS: Cannot allocate memory

So mixed streaming fails in above mentioned order.

Case B – Start V4L2 first (3 cameras) and then start Argus:
* In this order, all 3 V4L2 cameras and all 3 Argus cameras can run simultaneously without immediate error.
* However, this order doesn’t seem reliable if number of non argus cameras increase in future.

Conclusion:

  • When Argus is started first, V4L2 streams fail due to buffer allocation errors.
  • When V4L2 is started first, both can run, but this depends on resource allocation and is not guaranteed.
  • It appears to be due to VI/CMA resource contention rather than a /dev/videoX mapping issue.

Would you like me to also test increasing CMA size as a next step, or should I move towards using Argus for all cameras to avoid this conflict?

What’s your version?

cat /etc/nv_tegra_release

Please upgrade to latest version to confirm.

Thanks

is it possible to capture using argus for some cameras and v4l2 for other cameras simultaneously on xavier? what could be possible reason of this error when capturing with v4l2.

VIDIOC_REQBUFS: Cannot allocate memory
Failed to allocate required memory

I can confirm if the camera connect to different CSI port shouldn’t have problem to run them simultaneously.

Thanks

Could you try again, but boosting the clocks first?

echo 1 > /sys/kernel/debug/bpmp/debug/clk/vi/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/isp/mrq_rate_locked
echo 1 > /sys/kernel/debug/bpmp/debug/clk/nvcsi/mrq_rate_locked
cat /sys/kernel/debug/bpmp/debug/clk/vi/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/vi/rate
cat /sys/kernel/debug/bpmp/debug/clk/isp/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/isp/rate
cat /sys/kernel/debug/bpmp/debug/clk/nvcsi/max_rate | tee /sys/kernel/debug/bpmp/debug/clk/nvcsi/rate

Enrique Ramirez
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com
Website: www.ridgerun.com

didn’t help. we have total 12 cameras connected to xavier through d3 fpd-link 16 ports board. if i launch more than 7-8 cameras there is “cannot allocate memory/no buffers available “ errors.

when i first run argus for 6 cameras and then this pipeline for 6 other mipi 1 lane cameras, I get this error. device node /dev/videox are not share between cameras.

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video2 ! video/ x-raw, width=640, height=480 ! videoconvert ! ximagesink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
0:00:02.336658677 15011 0x557c4d5b20 ERROR v4l2bufferpool gstv4l2buffe rpool.c:677:gst_v4l2_buffer_pool_streamon:v4l2src0:pool:src error with STREAMO N 22 (Invalid argument)
0:00:02.336727610 15011 0x557c4d5b20 ERROR bufferpool gstbufferpoo l.c:564:gst_buffer_pool_set_active:v4l2src0:pool:src start failed
0:00:02.336900391 15011 0x557c4d5b20 WARN v4l2src gstv4l2src.c :658:gst_v4l2src_decide_allocation: error: Failed to allocate required memory.
0:00:02.337049233 15011 0x557c4d5b20 WARN v4l2src gstv4l2src.c :658:gst_v4l2src_decide_allocation: error: Buffer pool activation fail ed
0:00:02.337436142 15011 0x557c4d5b20 WARN basesrc gstbasesrc.c :3275:gst_base_src_prepare_allocation: Subclass failed to decide alloc ation
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to alloca te required memory.
0:00:02.337531764 15011 0x557c4d5b20 WARN basesrc gstbasesrc.c :3055:gst_base_src_loop: error: Internal data stream error.
Additional debug info:
gstv4l2src.c(658): gst_v4l2src_decide_allocation (): /GstPipeline:pipeline0/GstV 4l2Src:v4l2src0:
Buffer pool activation failed
Execution ended after 0:00:00.142071327
Setting pipeline to PAUSED …
0:00:02.337793255 15011 0x557c4d5b20 WARN basesrc gstbasesrc.c :3055:gst_base_src_loop: error: streaming stopped, reason not-negotiat ed (-4)
Setting pipeline to READY …
Setting pipeline to NULL …

If I run 6 Argus cameras with 6 v4l2 cameras capture. initially they all run fine but after a few minutes one or two of v4l2 cameras start freezing with “select timeout“ errors , one or two cpu cores remains at 100 percent and argus camera capture also fails because of that.

is it because of VI resources starvation? or something else? csi and virtual channels mapping is correct. argus camera is imx390(1920x1080 bayer format) and v4l2 camera is ov5693(640x480 YUYV format).

@JerryChang please let us know what is the solution? it seems moving to other jetpack version or even from xavier to orin won’t help. why we are not able to run 12 cameras(6 argus and 6 non argus v4l2 capture) simultaneously? d3 fpd link board has 16 ports. we have connected only 12.

we have connected 3 cameras to each deserializer. total 12 cameras to 4 deserializers on d3 board.

6 argus camera imx390(1920x1080 bayer format 4 lane) and 6 v4l2 ov5693(640x480 yuyv 1 lane).

if I start capturing from v4l2 cameras first and then from argus cameras. capturing works for few minutes but later some of v4l2 capture fails with “select timeout errors”. but if I start argus capture first , v4l2 capture works only for one or two cameras. there seems to be resources starvation issue?

please let us know asap so we can decide next course of action. we have a customer demo scheduled.

hello shivlal12345,

please refer to Applications Using V4L2 IOCTL Directly.
let’s check you’re able to fetch those 12 camera streams via v4l2 IOCTL to verify the camera functionality.

this may require our camera partner to do the support,
please contact with sensor vendor for further helps.

Hi @enrique.ramirez If we run argus cameras first and non argus/v4l2 cameras later, both argus and v4l2 captures fails and if we run cameras with v4l2 capture first and argus camera later, everything works initially but later both streams start freezing after few minutes and i am getting “select timeout errors“ for v4l2 capture cameras. is VI resource exhaust issue?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.