IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.61k stars 4.83k forks source link

librealsense fails to claim USB interface on MacOS Monterey #9916

Open dominiccarrano opened 3 years ago

dominiccarrano commented 3 years ago

Required Info
Camera Model D415
Firmware Version N/A
Operating System & Version MacOS Monterey (12.0.1)
SDK Version 2.49
Language python

Issue Description

After upgrading my machine from macOS Catalina (10.15.6) to Monterey (12.0.1), all RealSense applications I have and pyrealsense2 code I’ve written -- which all previously ran without issue -- are broken. They all give me the same error message: failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS. I’ve verified both physically and via System Preferences that the D415 is connected to the machine with a USB 3 connection using the same cable that the D415 was shipped with.

When I run rs-enumerate-devices, I get:

> rs-enumerate-devices
Could not create device - failed to set power state . Check SDK logs for details
 02/11 16:49:13,578 ERROR [0x70000cff3000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS

When I run realsense-viewer, I get:

> realsense-viewer
 02/11 16:52:08,669 ERROR [0x70000c115000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
 02/11 16:52:08,669 ERROR [0x70000bf8c000] (sensor.cpp:537) acquire_power failed: failed to set power state
 02/11 16:52:08,673 WARNING [0x70000bf8c000] (rs.cpp:308) null pointer passed for argument “device”
 02/11 16:52:08,673 WARNING [0x70000bf8c000] (rs.cpp:2621) Couldn’t refresh devices - failed to set power state

I wondered if something was wrong with the device firmware and tried updating it, which gives me:

> rs-fw-update -l
connected devices:
 03/11 14:56:46,495 ERROR [0x70000b0b1000] (handle-libusb.h:95) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
RealSense error calling rs2_create_device(info_list:0x600003554e70, index:0):
    failed to set power state
 03/11 14:56:46,497 ERROR [0x119b34600] (sensor.cpp:537) acquire_power failed: failed to set power state

I uninstalled and then rebuilt librealsense from scratch for Monterey using the newest version of Xcode that’s Monterey compatible, but these issues still persist even after that. The librealsense homebrew page indicates that Monterey is supported. I’d greatly appreciate any guidance on fixing the failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS problem for Monterey, thank you!

destr0ya commented 2 years ago

Hi everyone, does anyone known the true reason why sudo execution is now required on MacOS 12? Is this something that we can work on and expect to correct for the future? Having to launch apps using the terminal is kind of a showstopper for a standard app user. Thanks!

Totally agree - as a developer it's a huge burden. I can't run Unity in sudo on Mac, so need to create a package every time to run from command line on sudo. As a result, I can't debug my scripts in Visual Studio. Currently trying to migrate my dev environment to root user to get around this

jen-co commented 2 years ago

Also would love to know if there is a workaround or way to access the realsense device without having to use sudo.

YounkHo commented 2 years ago

First python build for version 3.6, 3.7, 3.8, 3.9, 3.10 is done. You can download the pre-built wheel packages here: https://github.com/cansik/pyrealsense2-macosx/releases/tag/macosx-v2.50.0

I can only test it on my own M1 Macbook, so would be great if someone could give it a try. Please be aware to run your python script with sudo, otherwise RealSense tells you that no device is connected.

I want to know if it works fine on 12.0 if I install 11.0 pre-built wheel on my M1 pro MacBook. I've tried it but it exactly says that no device is connected.

cansik commented 2 years ago

@Dreamcreationman Yes it runs fine, 11 is just the deployment target. On some systems it is still necessary to run your software as sudo.

cansik commented 2 years ago

@Dreamcreationman This is not the right place to ask those kind of questions! There are more than 29 people subscribed to this issue to get information about the librealsense problem and everyone gets notified when you write a message about your independent issue with pyrealsense2-macosx. Please open and discuss your issue at the correct repository, which would be: https://github.com/cansik/pyrealsense2-macosx/issues

cansik commented 2 years ago

Support for macOS (and others) now seems to be officially discontinued:

Official support for Windows 7, 8, MacOS, and Android is removed (the code is still compilable, but collaterals are no longer generated or tested)

https://github.com/IntelRealSense/librealsense/wiki/Release-Notes#release-2511

animaonline commented 2 years ago

@MartyG-RealSense why on earth would you drop macOS support?

MartyG-RealSense commented 2 years ago

Hi @cansik and @animaonline There is the option of continuing to use SDK version 2.50.0 for those who are concerned about the removal of official support for MacOS from 2.51.1 onwards.

Official MacOS updates for the RealSense SDK ceased after MacOS High Sierra (10.13) and the SDK continued to work with newer MacOS versions such as Catalina and Big Sur. Whilst there were issues with Apple Silicon M1 and with MacOS Monterey, Mac users in the RealSense community developed solutions for these.

As the SDK is open source, there is the possibility for RealSense Mac community members to create a custom GitHub 'fork' version of the SDK and add user-created updates if future MacOS versions cannot work with the SDK.

timprepscius commented 2 years ago

Is the code for the firmware now opensource? It wasn't before.

If it is opensource, this is super awesome, and it true, we don't need to you support OSX.

If it is closed source, this is a problem. Realsense has previously removed some firmware bins (or at least I could not access them) and created a situation where I was forced to update.

-tim

On 8/24/22, MartyG-RealSense @.***> wrote:

Hi @cansik and @animaonline There is the option of continuing to use SDK version 2.50.0 for those who are concerned about the removal of official support for MacOS from 2.51.1 onwards.

Official MacOS updates for the RealSense SDK ceased after MacOS High Sierra (10.13) and the SDK continued to work with newer MacOS versions such as Catalina and Big Sur. Whilst there were issues with Apple Silicon M1 and with MacOS Monterey, Mac users in the RealSense community developed solutions for these.

As the SDK is open source, there is the possibility for RealSense Mac community members to create a custom GitHub 'fork' version of the SDK and add user-created updates for future MacOS versions cannot work with the SDK.

-- Reply to this email directly or view it on GitHub: https://github.com/IntelRealSense/librealsense/issues/9916#issuecomment-1225970687 You are receiving this because you commented.

Message ID: @.***>

MartyG-RealSense commented 2 years ago

Hi @timprepscius The RealSense SDK is open source but firmware drivers are not.

Since SDK 2.34.0 it has been possible though to override the firmware URL to allow on-site mirroring. You can also write your own firmware checking and updating script. https://github.com/IntelRealSense/librealsense/issues/7093 and https://github.com/IntelRealSense/librealsense/pull/6098 have details about this.

timprepscius commented 2 years ago

Here's a question..

Now that the Realsense is dead. And all of this code is going to decay in the nether reaches of the void- pretty soon a fond memory, like the Vic20. Why not release the code for the firmware?

Why not let us use the camera in the way that we actually want to?

For instance, I want to get the highest bit quality pixels at 90fps. Your firmware right now restricts this. I don't care about anything else, except for luminosity at 90fps. I want more than 8 bit.

I'm sure other people have other specific needs which the firmware restricts.

Who will it hurt to release the firmware?

On 8/24/22, MartyG-RealSense @.***> wrote:

Hi @timprepscius The RealSense SDK is open source but firmware drivers are not.

Since SDK 2.34.0 it has been possible to override the firmware URL to allow on-site mirroring. You can also write your own firmware checking and updating script. https://github.com/IntelRealSense/librealsense/issues/7093 and https://github.com/IntelRealSense/librealsense/pull/6098 have details about this.

-- Reply to this email directly or view it on GitHub: https://github.com/IntelRealSense/librealsense/issues/9916#issuecomment-1226138030 You are receiving this because you were mentioned.

Message ID: @.***>

MartyG-RealSense commented 2 years ago

@timprepscius RealSense 400 Series cameras and the RealSense SDK are continuing. The support change relates to Android and MacOS specifically. Support for PC and Arm computing devices is unaffected. I do genuinely understand and appreciate your concern.

RealSense firmware drivers remain closed-source unfortunately.

The SDK does offer a Low Level Device API for communicating directly with the sensor hardware.

https://dev.intelrealsense.com/docs/api-architecture#low-level-device-api

A C++ example program that uses the low level API is rs-data-collect

https://github.com/IntelRealSense/librealsense/tree/master/tools/data-collect

fpelegri commented 2 years ago

First python build for version 3.6, 3.7, 3.8, 3.9, 3.10 is done. You can download the pre-built wheel packages here: https://github.com/cansik/pyrealsense2-macosx/releases/tag/macosx-v2.50.0

I can only test it on my own M1 Macbook, so would be great if someone could give it a try. Please be aware to run your python script with sudo, otherwise RealSense tells you that no device is connected.

I had an issue running the Intel realSense D435i camera when I updated my MacBook Pro Intel chip based with BigSur OS version to Monterrey version. Running python script or any command related to camera functions with sudo solved my problem. Thanks for remarking that! 🙂

MJKingsbury commented 1 year ago

After HOURS of digging I found this rather useful thread, and thanks for the info @Vangos, however now while following your personal tutorial on an M1 MacBook Pro running Ventura 13.0.1 I have an issue...

I receive the following error trying to run the 'Git Checkout' command after cloning the repo:

Screenshot 2023-02-14 at 13 20 27

Any advice would be greatly appreciated, thanks!

Vangos commented 1 year ago

I receive the following error trying to run the 'Git Checkout' command after cloning the repo:

Hi! Seems like it's a Git issue. I would try git fetch before the checkout command. Also, ensure you are in the librealsense directory.

Vangos commented 1 year ago

You need to replace the existing libusb header location with the custom-built one. Refer to this screenshot:

image

mora200217 commented 1 year ago

Any update on this ? Still only working with sudo. I'm trying to use it with ROS noetic but it still not working.

When running rs-enumerate-devices

 15/04 13:17:09,000 ERROR [0x70000ef08000] (handle-libusb.h:125) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
 15/04 13:17:09,000 ERROR [0x11cdb6600] (sensor.cpp:664) acquire_power failed: failed to set power state

Env specs

jackjansen commented 1 year ago

Because this issue has become large and unwieldy (with various unrelated issues thrown in) I have created #11815 in the hope of starting a fresh discussion on what the root cause is that librealsense needs root privileges on macOS Monterey and later. If you have any insights on the specific issue of requiring root privilege please share them in #11815.

AkshajGupta commented 1 year ago

I am getting a Killed: 9 error when I run 'sudo rs-enumerate-devices' on Ventura. How can I fix the problem?

MartyG-RealSense commented 1 year ago

Hi @AkshajGupta There have been reports of problems such as a non-detected camera with Ventura. An example of this is at https://github.com/IntelRealSense/librealsense/issues/9687#issuecomment-1596135006

https://github.com/IntelRealSense/librealsense/issues/11815 is the central place on this support forum where I am directing Ventura users who are having problems so that they can discuss it amongst themselves, and you will therefore be notified automatically of any solutions that the RealSense Mac community comes up with for getting librealsense working on Ventura if you have left a comment there.

spindlewhorls commented 7 months ago

@rowungiles did you have any luck with this? I have this usb problem on Ventura and I was considering downgrading to Big Sur to solve it until I saw your case

On macOS Big Sur 11.6.1, I am also seeing this issue using an M1 Mac mini.

This install of Big Sur is absolutely fresh (a downgrade from macOS 12.0), I have only installed Xcode and the brew installs outlined on the Intel Dev site. The install was a downgrade from Monterrey specifically to get librealsense working.

I have the following output from Starting Xcode Running realsense-viewer Initial fail and then Unplugging and re-plugging the camera in several times:

2021-11-29 12:52:33.855654+0000 realsense-viewer[18210:105475] Metal API Validation Enabled
2021-11-29 12:52:33.880607+0000 realsense-viewer[18210:105475] fopen failed for data file: errno = 2 (No such file or directory)
2021-11-29 12:52:33.880635+0000 realsense-viewer[18210:105475] Errors found! Invalidating cache...
2021-11-29 12:52:33.927411+0000 realsense-viewer[18210:105475] +[MTLIOAccelDevice registerDevices]: Zero Metal services found
 29/11 12:52:34,132 ERROR [0x17062f000] (handle-libusb.h:61) failed to set kernel driver auto detach: 0, error: RS2_USB_STATUS_NOT_SUPPORTED
 29/11 12:52:34,133 ERROR [0x17048b000] (sensor.cpp:572) acquire_power failed: failed to set power state
 29/11 12:52:34,134 WARNING [0x17048b000] (rs.cpp:310) null pointer passed for argument "device"
 29/11 12:52:34,134 WARNING [0x17048b000] (rs.cpp:2691) Couldn't refresh devices - failed to set power state
 29/11 12:53:38,472 ERROR [0x1706bb000] (handle-libusb.h:61) failed to set kernel driver auto detach: 0, error: RS2_USB_STATUS_NOT_SUPPORTED
 29/11 12:53:38,472 ERROR [0x101fefd40] (sensor.cpp:572) acquire_power failed: failed to set power state
 29/11 12:53:38,473 WARNING [0x101fefd40] (rs.cpp:310) null pointer passed for argument "device"
 29/11 12:53:38,473 WARNING [0x101fefd40] (rs.cpp:2691) Couldn't refresh devices - failed to set power state
 29/11 12:53:54,563 ERROR [0x1706bb000] (handle-libusb.h:61) failed to set kernel driver auto detach: 0, error: RS2_USB_STATUS_NOT_SUPPORTED
 29/11 12:53:54,563 ERROR [0x101fefd40] (sensor.cpp:572) acquire_power failed: failed to set power state
 29/11 12:53:54,564 WARNING [0x101fefd40] (rs.cpp:310) null pointer passed for argument "device"
 29/11 12:53:54,564 WARNING [0x101fefd40] (rs.cpp:2691) Couldn't refresh devices - failed to set power state
 29/11 12:54:45,116 ERROR [0x1706bb000] (handle-libusb.h:61) failed to set kernel driver auto detach: 0, error: RS2_USB_STATUS_NOT_SUPPORTED
 29/11 12:54:45,116 ERROR [0x101fefd40] (sensor.cpp:572) acquire_power failed: failed to set power state
 29/11 12:54:45,118 WARNING [0x101fefd40] (rs.cpp:310) null pointer passed for argument "device"
 29/11 12:54:45,118 WARNING [0x101fefd40] (rs.cpp:2691) Couldn't refresh devices - failed to set power state

I built the latest using master which I downloaded as a zip today.

I followed the build instructions from the Intel Dev site. Except for using the cmake command from #9999

Code is sitting in and running from my ~/Downloads folder

huyyxy commented 6 months ago

in MacBook Pro, 16-inch, 2019, 2.6 GHz 六核Intel Core i7, Ventura 13.4 (22F66):

realsense-viewer
GLFW Driver Error: Cocoa: Regular windows do not have icons on macOS
 08/05 17:33:12,435 INFO [0x7ff84ab58640] (context.cpp:116) ... 1-2.1-2
 08/05 17:33:12,435 INFO [0x7ff84ab58640] (context.cpp:129) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)
zsh: segmentation fault  realsense-viewer
sudo ./realsense-viewer
Password:
GLFW Driver Error: Cocoa: Regular windows do not have icons on macOS
 08/05 17:39:31,016 INFO [0x7ff84ab58640] (context.cpp:116) ... 1-2.1-2
 08/05 17:39:31,016 INFO [0x7ff84ab58640] (context.cpp:129) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)
zsh: segmentation fault  sudo ./realsense-viewer

who can help me?

huyyxy commented 6 months ago

in MacBook Pro, 16-inch, 2019, 2.6 GHz 六核Intel Core i7, Ventura 13.4 (22F66):在 MacBook Pro,16 英寸,2019 年,2.6 GHz 六核Intel Core i7,Ventura 13.4 (22F66) 中:

realsense-viewer
GLFW Driver Error: Cocoa: Regular windows do not have icons on macOS
 08/05 17:33:12,435 INFO [0x7ff84ab58640] (context.cpp:116) ... 1-2.1-2
 08/05 17:33:12,435 INFO [0x7ff84ab58640] (context.cpp:129) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)
zsh: segmentation fault  realsense-viewer
sudo ./realsense-viewer
Password:
GLFW Driver Error: Cocoa: Regular windows do not have icons on macOS
 08/05 17:39:31,016 INFO [0x7ff84ab58640] (context.cpp:116) ... 1-2.1-2
 08/05 17:39:31,016 INFO [0x7ff84ab58640] (context.cpp:129) Found 1 RealSense devices (0xff requested & 0xff from device-mask in settings)
zsh: segmentation fault  sudo ./realsense-viewer

who can help me?谁能帮助我?

./rs-fw-update

Nothing to do, run again with -h for help

Connected devices:
 08/05 17:32:07,361 ERROR [0x70000bba7000] (handle-libusb.h:127) failed to claim usb interface: 0, error: RS2_USB_STATUS_ACCESS
 08/05 17:32:07,361 ERROR [0x7ff84ab58640] (uvc-sensor.cpp:412) acquire_power failed: failed to set power state
 08/05 17:32:07,365 ERROR [0x7ff84ab58640] (rs.cpp:237) [rs2_create_device( info_list:0x600003bf8000, index:0 ) UNKNOWN] failed to set power state
 08/05 17:32:07,366 ERROR [0x7ff84ab58640] (rs.cpp:237) [rs2_delete_device( device:nullptr ) UNKNOWN] null pointer passed for argument "device"
 08/05 17:32:07,366 WARNING [0x7ff84ab58640] (rs.cpp:373) null pointer passed for argument "device"
 08/05 17:32:09,296 ERROR [0x70000b99b000] (context-libusb.cpp:16) libusb_init failed
zsh: segmentation fault  ./rs-fw-update
MartyG-RealSense commented 6 months ago

Hi @huyyxy I have just responded to a case of the MacOS icon problem at https://github.com/IntelRealSense/librealsense/issues/12890#issuecomment-2100196975

MartyG-RealSense commented 2 months ago

Hi everyone,

The current latest 2.56.1 version of the librealsense SDK contains a fix for SDK compilation on MacOS Apple Silicon 'M' processors and also an update for MacOS 14 (Sonoma).

These changes are confirmed in 2.56.1's release notes.

image

2.56.1 is currently an 'interim beta' release of the SDK which can only be installed by source code compilation.

https://github.com/IntelRealSense/librealsense/releases/tag/v2.56.1

cansik commented 2 months ago

@MartyG-RealSense Thanks for this update. If you are interested to try it out in python, I have already prebuilt the wheels of the beta: https://github.com/cansik/pyrealsense2-macosx/releases/tag/macosx-v2.56.1-beta

However, the PR does not fix all the issue we are having with MacOS. It seems that the issue regarding power-settings is gone (at least here in my machine / camera) 🎉. But we still need sudo to start the device because of the os kext ( https://github.com/IntelRealSense/librealsense/issues/11815#issuecomment-1557960723). Now sudo is also needed to just list the device count.

MartyG-RealSense commented 2 months ago

Thanks so much @cansik - I have passed on your feedback to my Intel RealSense developer colleague who worked on PR #12972. They welcome Mac customers developing solutions for issues and sharing them. It helps Intel and the customers to work together on Mac support.

My colleague added that a segfault is still thrown when querying devices and that according to users, Apple changed the USB policy and LibUSB is no longer working on Mac.

OxO-7 commented 2 months ago

@cansik @MartyG-RealSense It's already solved a big problem!!Thanks!!

jackjansen commented 1 month ago

This is very good news!

@MartyG-RealSense as to helping out: I would really really love to, but I simply don't have the time at the moment:-(

But: if you could pass on my comment in the other bug, https://github.com/IntelRealSense/librealsense/issues/11815#issuecomment-1557960723, I still have the feeling that Intel (the company), as the owner of the USB VID of the Realsense cameras, should be able to tell Apple (the company) not to use the standard CoreMedia driver for this specific VID/PID combination, and then the Realsense camera will just be sitting there driverless and libusb can open it without sudo. I hope.

I vaguely remember that at some point in the past I have read that this is possible, there is a way that companies (or actually official owners of the VID as per the USB consortium or whatever) can communicate that to Apple, but I am not able to find a reference at the moment, sorry.

MartyG-RealSense commented 1 month ago

@jackjansen I will certainly pass on your feedback. Thanks very much!