rust-embedded / discovery

Discover the world of microcontrollers through Rust!
https://docs.rust-embedded.org/discovery/
Apache License 2.0
1.49k stars 515 forks source link

hidapi error: Permission denied #490

Open John-Toohey opened 1 year ago

John-Toohey commented 1 year ago

When I run the following command:

$ cargo embed --features v1 --target thumbv6m-none-eabi

I get:

       Error Probe could not be created

             Caused by:
                 0: hidapi error: Permission denied
                 1: hidapi error: Permission denied

Despite having:

$ cat /etc/udev/rules.d/99-microbit.rules

# CMSIS-DAP for microbit
SUBSYSTEM=="usb", ATTR{idVendor}=="0d28", ATTR{idProduct}=="0204", MODE:="666"

I have rebooted several times and even checked the file permission on my device (/dev/bus/usb/001/010):

$ ls /dev/bus/usb/001/010
crw-rw-rw- 189,9 root  4 Dec 07:17 /dev/bus/usb/001/010

My kernel is 6.0.10 and I run archlinux. Any help would be much apreciated.

sudoBash418 commented 1 year ago

Not sure if this will fix your issue, but I was facing the same error and fixed it with the following udev rule:

# CMSIS-DAP for microbit
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0204", MODE="0660", TAG+="uaccess"

I also needed to use /etc/udev/rules.d/70-microbit.rules, as recommended by the probe-rs docs.

According to the Arch Wiki:

The modern recommended approach for systemd systems is to use a MODE of 660 to let the group use the device, and then attach a TAG named uaccess.

After editing the file, I ran sudo udevadm control --reload and replugged the micro:bit; at which point I was able to run cargo embed without issue.

Vortoman commented 1 year ago

Had the exact same problem, solution worked. Thanks a lot!

eldruin commented 1 year ago

Nice to see that you found a solution. Could one of you put together a PR adding this to the book?

bcpeinhardt commented 1 year ago

Same fix worked on Ubuntu, with a udevadm trigger instead of replugging in. :)

l-0-l commented 5 months ago

Didn't work for me with a v1, not sure why. On Debian 12. Provided my solution here.

BartMassey commented 5 months ago

@l-0-l Thanks for that.

Note that we are currently planning to remove Microbit v1 from this guide to reduce confusion. If folks feel strongly that we need to continue to support this board, please comment on https://github.com/rust-embedded/wg/pull/759