2013.11.21 - avr programming as non-root

avr prog i use usb avr prog for flashing AVRs for some time now. what has always been annoying is that this was done from root account, since direct r/w access to hid /dev/ was required. there is however a nice way to overcome this, since udev allows to define per-device rules.

first step is to create group, that will have access to this device:

addgroup --system avrdev

then add your user to this group:

adduser johndoe avrdev

next step is to check what are the device's vendor and product IDs:

# make sure the device is unplugged
$ lsusb | sort > PRE
# plug in the device and wait 1-3 seconds, until it is visible in the system
$ lsusb | sort > POST
$ diff --suppress-common-lines PRE POST
12a13                            
> Bus 008 Device 007: ID 16c0:05df Van Ooijen Technische Informatica HID device except mice, keyboards, and joysticks

so the vendor ID is 16c0 and product ID is 05df.

next create dedicated rule file for this device – say /etc/udev/rules.d/49-avrprog.rules – for udev, with the following content:

# AVRPROG USB v2
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", \
  GROUP:="avrdev", \
  MODE:="0660", \
  SYMLINK+="avrprog_%n"

now reload udev's rules:

udevadm control --reload

next time you plug your programmer in, system will detect it, assign proper group and permissions and add a nice link, like this:

$ l /dev/avrprog_1 
lrwxrwxrwx 1 root root 11 Nov 21 10:27 /dev/avrprog_1 -> usb/hiddev1
$ l `readlink -e /dev/avrprog_1`
crw-rw---- 1 root avrdev 180, 1 Nov 21 10:27 /dev/usb/hiddev1

now you're able to flash software as non-root. note that you need to relog in order to make yourself visible as a member of the new group, visible to the system. or

exec su - -c "su - johndoe"

on the console you want to program on.

have fun! :)

blog/2013/11/21/avr_programming_as_non-root.txt · Last modified: 2021/06/15 20:09 by 127.0.0.1
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0