How to set up Rust for BBC micro:bit on Ubuntu

Hi, I followed this video to set up an environment to write Rust code for the BBC micro:bit

I was successful until running cargo embed. I get the error message:

cargo embed --chip nRF52833_xxAA
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
      Config default
      Target /home/markus/dev/rust/hello/target/thumbv7em-none-eabihf/debug/hello
       Error Probe could not be created
             
             Caused by:
                 0: hidapi error: Failed to open a device with path '/dev/hidraw3': Permission denied
                 1: hidapi error: Failed to open a device with path '/dev/hidraw3': Permission denied

/dev/hidraw* are all owned by root. So far, so good. But I don't know which permissions I should set.

I changed the owner to my user, which works. But wouldn't it be better to change the group? But which group?

Try running ls -l /dev/hidraw* and look which group they belong to. Also check whether your distro is using udev and if they have rules for your device.

Group is also root. I'm running Ubuntu and I don't know of any udev rules for the micro:bit

I have this in /etc/udev/rules.d/99-microbit.rules, and it is now working:

SUBSYSTEM=="usb", ATTR{idVendor}=="0d28", ATTR{idProduct}=="0204", MODE:="666"
SUBSYSTEM=="hidraw", MODE:="666"

I confess I don't know how all this works.
I think the second line will give RW permissions on all hidraw devices, but I couldn't work out a way to make it more specific.
Leaving the idVendor and idProduct stuff on there as well didn't work, I guess because they're identifiers for the USB subsystem.
Anyway, this got me working, hopefully you too.

You are right. Sometimes it could be so easy

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.