Page 1 of 1

Need for root privilege when flashing

Posted: Tue Nov 29, 2016 10:38 am
by pythoncoder
Has anyone found a way to avoid this? I tried the following udev rule without success

Code: Select all

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666", GROUP="adminpete"
Also various tweaks using visudo, but nothing seems to work.

Re: Need for root privilege when flashing

Posted: Tue Nov 29, 2016 12:38 pm
by platforma
All the boards I have work without root using udev rules.
I am assuming you are in the adminpete group. The easiest option is to set the GROUP="users". Otherwise everything seems correct.

Re: Need for root privilege when flashing

Posted: Tue Nov 29, 2016 5:35 pm
by Roberthh
I had to use sudo all the time. Reading now this post gave me the impetus for another try. Adding this line:

Code: Select all

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666"
made it now work, for whatever reason. My /etc/udev/rules.d/49-pyboard.rules file now looks like:

Code: Select all

# f055:9800, 9801, 9802 MicroPython pyboard
ATTRS{idVendor}=="f055", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="f055", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="f055", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="f055", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666"

# Add lines like the following to create custom named device nodes based on the
# serial number.
# KERNEL=="ttyACM*", ATTRS{idVendor}=="f055", ATTRS{serial}=="385435603432", SYMLINK+="pyboard", MODE:="0666"

Re: Need for root privilege when flashing

Posted: Tue Nov 29, 2016 5:36 pm
by dhylands
I have this in my rules:

Code: Select all

# 0483:df11 - STM32F4 Discovery in DFU mode (CN5)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666"
The way that I check the permissions is that I do lsusb when the device is in DFU mode:

Code: Select all

940 >lsusb
...
Bus 005 Device 072: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
...
and then do a find command using the 3 digit device number:

Code: Select all

941 >find /dev -name 072 -ls
      696      0 crw-rw-rw-   1 root     root     189, 583 Nov 29 09:44 /dev/bus/usb/005/072
and that's the permissions of the usb node used by libusb.

Re: Need for root privilege when flashing

Posted: Tue Nov 29, 2016 5:56 pm
by pythoncoder
Thanks! The key was getting rid of the GROUP clause altogether.

Re: Need for root privilege when flashing

Posted: Wed Nov 30, 2016 10:04 am
by platforma
pythoncoder wrote:Thanks! The key was getting rid of the GROUP clause altogether.
I'd keep the GROUP="plugdev" or GROUP="users" if I were you. But if you're not OCD like I am, not having one is also fine :)
Glad you got it working!

Re: Need for root privilege when flashing

Posted: Wed Nov 30, 2016 1:45 pm
by torwag
Well, I usually go the other way around....

1. check with
ls -la /dev/tty*
The user and group of the desired usb device.
2. Add yourself to the group by
usermod -a -G <group> <user>
3. reboot (that's one of the very few cases a linux machine needs a reboot, you can do it without (logout and in) but usually on a desktop machine a reboot is the most painless and successful way)
4. check with

Code: Select all

id
that you belong now to the group with access permission to the usb-device.

From here you should be able to access the usb device without root permission.

This method has the benefit that one do not have to maintain a self-written udev-rule in the system, which at a later time might fire back whenever the distro changes stuff, which conflicts with the home-made udev rule. Usually this happens exactly after you forgot about the udev rule and keeps you busy for a few hours debugging your problem which nobody else seems to be able to reproduce. ;)

Re: Need for root privilege when flashing

Posted: Wed Nov 30, 2016 5:13 pm
by dhylands
That works when the device creates a /dev/ttyXXX node, but when the device is in DFU mode it doesn't. So tools like dfu-util use libusb to directly open the USB device.