Jetson Orin Nano Jetpack 6.2.2/ 36.5: nvarguscamerasrc fails to load when launched for a second time

Good day, I am having an issue where I am unable to launch a camera for a second time (I have to restart the Jetson Orin Nano to launch it again).
I initially used dual IMX219 cameras and it was working fine and at one point (after like 3 days of development) this bug just started to happen.
Currently I am using a IMX477 and a IMX219 and I am still having this issue.
I do reconfigure pins when changing cameras.

Launch using:
gst-launch-1.0 nvarguscamerasrc sensor-id=1 ! nveglglessink
or
gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nveglglessink
close it using ctrl+C

In python:
camASet='nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=1920, height=1080, format=NV12, framerate=30/1 ! nvvidconv flip-method='+str(displayFlip)+' ! video/x-raw, width='+str(displayWidth)+', height='+str(displayHeight)+', format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink'
camA = cv2.VideoCapture(camASet, cv2.CAP_GSTREAMER)
and close with:
camA.release()
cv2.destroyAllWindows()

When I test now in terminal:
Cam0 (IMX477)
Launch1: Opens and displays image.
Close → ctrl+C
Launch2: Opens and displays black screen. Closes

Cam1 (IMX219)
Continuously working now

Previously:
Cam1 (IMX477)
Launch1: Opens and displays image.
Close → ctrl+C
Launch2: Opens and displays black screen. Closes
Cam0 (IMX219)
Launch1: Opens and displays image.
Close → ctrl+C
Launch2: Opens and displays black screen. Closes

as well as
Cam1 (IMX219)
Launch1: Opens and displays image.
Close → ctrl+C
Launch2: Opens and displays black screen. Closes
Cam0 (IMX219)
Launch1: Opens and displays image.
Close → ctrl+C
Launch2: Opens and displays black screen. Closes

Any advice will be appreciated.

*** Please note that this reply is generated by LLM automatically ***

The issue you’re experiencing with the Jetson Orin Nano, where you’re unable to launch a camera for a second time without restarting the device, seems to be related to the camera configuration and the way you’re launching and closing the camera.

Firstly, it’s essential to note that the Jetson Orin Nano has a limited number of CSI lanes, which can cause issues when using multiple cameras. In your case, you’re using a combination of IMX219 and IMX477 cameras.

When you launch the camera for the first time, it seems to work fine. However, when you try to launch it again, you’re getting a black screen. This could be due to the camera not being properly released or the CSI lanes not being correctly configured.

Here are a few potential solutions you can try:

  1. Check the camera configuration: Ensure that the camera configuration is correct, and the CSI lanes are properly assigned. You can check the device tree configuration to verify this.
  2. Release the camera properly: When closing the camera, make sure to release it properly using the close() method. This will ensure that the camera is released, and the CSI lanes are available for the next launch.
  3. Use a different camera launch method: Try using a different camera launch method, such as v4l2 API, as suggested by @khang.l4es. This might help resolve the issue.
  4. Check for conflicts with other devices: Ensure that there are no conflicts with other devices on the CSI lanes. You can check the device tree configuration to verify this.
  5. Restart the camera service: Try restarting the camera service after closing the camera. This might help resolve the issue.

In comparison to other Jetson devices, the Jetson Orin Nano has a similar camera configuration. However, the Jetson Orin NX has a more advanced camera configuration, with more CSI lanes available.

To troubleshoot the issue further, you can try the following:

  • Check the kernel logs for any camera-related errors.
  • Use the v4l2-ctl command to verify the camera configuration and check for any errors.
  • Try launching the camera using a different method, such as gst-launch.

By trying these potential solutions and troubleshooting steps, you should be able to resolve the issue and launch the camera successfully for the second time without restarting the Jetson Orin Nano.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

I have checked all the configurations. And I ensure to release the camera properly as I have also tested with gst-launch-1.0 -e nvarguscamerasrc sensor-id=0 ! nveglglessink. For v4l2 I get streaming stopped, reason not-negotiated (-4) ERROR: pipeline doesn’t want to preroll. Restarting the camera service also yielded no success.

Could you try below to clarify,

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nveglglessink
v4l2-ctl --stream-mmap
gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nveglglessink

Okay I did gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nveglglessink and the camera launched. I then tried v4l2-ctl --stream-mmap, but nothing happend.
I then restarted and did v4l2-ctl --stream-mmap and got: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps, however when I then stopped it and tried to launch the camera again I got the black screen + close again.

Also interesting to note (both when the cam works and fails):
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 1
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 59.999999

(^Chandling interrupt.:99.
Interrupt: Stopping pipeline …
Execution ended after 0:00:13.902100919
Setting pipeline to NULL …
GST_ARGUS: Cleaning up
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: CANCELLED
Additional debug info:
Argus Correctable Error Status
An error happened while waiting for EOS
ERROR: from element /GstPipeline:pipeline0/GstNvArgusCameraSrc:nvarguscamerasrc0: CANCELLED
Additional debug info:
Argus Correctable Error Status
An error happened while waiting for EOS
CONSUMER: Done Success
GST_ARGUS: Done Success
Freeing pipeline …)

  1. Please check by v4l2-ctl to check if able run second time.
v4l2-ctl --stream-mmap --set-fmt-video=width=1920,height=1080 -c bypass_mode=0
  1. Verify by MMAPI sample APP like argus_camera instead of gst-launch-.10

The following was done with: Dual IMX477 pin configuration and only one cam connected on cam1.
$ v4l2-ctl --stream-mmap --set-fmt-video=width=1920,height=1080 -c bypass_mode=0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 30.00 fps

$ ./argus_camera_jpeg
[INFO] (NvEglRenderer.cpp:110) Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
PRODUCER: [1] W=1920 H=1080
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
CONSUMER: Done.
CONSUMER: Done.
PRODUCER: Done – exiting.
I tried it a couple times, but got the same thing.

I then ran v4l2-ctl --stream-mmap agin and got this
$ v4l2-ctl --stream-mmap --set-fmt-video=width=1920,height=1080 -c bypass_mode=0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 29.88 fps
and
$ ./argus_camera_jpeg -s 1

[INFO] (NvEglRenderer.cpp:110)  Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
PRODUCER: [1] W=1920 H=1080
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
NvMMLiteBlockCreate : Block : BlockType = 1
CONSUMER: Argus::STATUS_DISCONNECTED
CONSUMER: Done.
----------- Element = jpenenc -----------
Total units processed = 18
Average latency(usec) = 4494
Minimum latency(usec) = 2572
Maximum latency(usec) = 33331

CONSUMER: Done.
----------- Element = renderer0 -----------
Total Profiling time = 0.559352
Average FPS = 30.3923
Total units processed = 18
Num. of late units = 0

PRODUCER: Done – exiting.

I ran it a second time and it worked

[INFO] (NvEglRenderer.cpp:110)  Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
PRODUCER: [1] W=1920 H=1080
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
NvMMLiteBlockCreate : Block : BlockType = 1
CONSUMER: Argus::STATUS_DISCONNECTED
CONSUMER: Done.
----------- Element = renderer0 -----------
Total Profiling time = 0.594691
Average FPS = 30.2678
Total units processed = 19
Num. of late units = 12

CONSUMER: Done.
----------- Element = jpenenc -----------
Total units processed = 19
Average latency(usec) = 3323
Minimum latency(usec) = 2589
Maximum latency(usec) = 11656

PRODUCER: Done – exiting.

however when I tried a third time I got the following:

[INFO] (NvEglRenderer.cpp:110)  Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
PRODUCER: [1] W=1920 H=1080
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
CONSUMER: Done.
----------- Element = renderer0 -----------
Total Profiling time = CONSUMER: Done.
----------- Element = 0jpenenc -----------
Average FPS = 0
Total units processed =
Total units processed = 0
0Average latency(usec) = 0
Minimum latency(usec) = 0
Maximum latency(usec) = 0

Num. of late units = 0

PRODUCER: Done – exiting.

Afterwards I tried v4l2-ctl --stream-mmap, but nothing happend.

After waiting a few minutes while I was typing this reply I tried v4l2-ctl --stream-mmap again and got 29.88fps again and ./argus_camera_jpeg -s 1 produced the following:

[INFO] (NvEglRenderer.cpp:110)  Setting Screen width 640 height 480
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected…
CONSUMER: Waiting until producer is connected…
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
PRODUCER: [1] W=1920 H=1080
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
NvMMLiteBlockCreate : Block : BlockType = 1
CONSUMER: Argus::STATUS_DISCONNECTED
CONSUMER: Done.
----------- Element = jpenenc -----------
Total units processed = 19
Average latency(usec) = 3266
Minimum latency(usec) = 2528
Maximum latency(usec) = 12049

CONSUMER: Done.
----------- Element = renderer0 -----------
Total Profiling time = 0.592632
Average FPS = 30.373
Total units processed = 19
Num. of late units = 3

PRODUCER: Done – exiting.

Followed by another failed ./argus_camera_jpeg -s 1 attempt afterwards.
I saw when waiting a bit then running v4l2-ctl --stream-mmap first then ./argus_camera_jpeg -s 1 it seems to mostly work.

What does this imply?
And thank you for all the effort thus far.

Okay sorry for the spam, I just changed my pin config to IMX477 only on cam1 and I was able to consecutively run ./argus_camera_jpeg -s 1 succesfully after running 4l2-ctl --stream-mmap once.

Does that means problem fixed?

Do you verify without running v4l2-ctl command?

I did try it without v4l2, but then it just black screened again.

Do you use default IMX477 driver enable by jetson-io?

Thanks

Yes I did

That’s weird!! We don’t see this kind of problem with IMX477.

BTW, could you try reboot the system and have below command before start the argus APP.

sudo su
echo on > /sys/devices/platform/*rtcpu/power/control

I did this and I was able to launch ./argus_camera_jpeg -s 1 directly and repeatedly as well as gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nveglglessink. Thank you for the help. Might I enquire exactly how this fix works (or should I just go read and find out xd)?

Only the IMX477 have problem?

Do you try connect the IMX477 to another connector to confirm?