quarta-feira, 28 de outubro de 2015

Installing and giving permission to JTAGICE mkII and others USB programmers on Linux

If you're receiving errors like these:
avrdude: usbdev_open(): cannot open device: Permission denied
avrdude: usbdev_open(): did not find any USB device "usb"


Maybe you have to give the right permission for your programmer.
In my case I'm using the JTAGICE mkII-CN on USB.

First of all, check if your JTAG was recognized:
  • Open the terminal and type lsusb 

Note that in my case was found on BUS 002 and DEVICE 004, so, let's check the permissions of this DEVICE:
  • On the terminal type: ls -l /dev/bus/usb/002/004
Note that in my case I don't have permission to this device. So, let's create a UDEV rules for a permanent permission:

  • Create a new file named 60-avrisp.rules on the folder /etc/udev/rules.d/ with this content:
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avrisp_end"
# JTAGICE mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", GROUP="dialout", MODE="0666"
# AVRISP mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", GROUP="dialout", MODE="0666"
# Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2105", GROUP="dialout", MODE="0666"
LABEL="avrisp_end"

  • Now, let's reload the UDEV rules. Open the terminal and write:
sudo udevadm control --reload-rules
sudo service udev restart
sudo udevadm trigger

  •  Unplug the USB device and plug again
  •  Let's check our USB devices again typing lsusb


 Note that in my case now was found on BUS 002 and DEVICE 009 (changed from 004 to 009), so, let's check the permissions of this DEVICE again:
  • On the terminal type: ls -l /dev/bus/usb/002/009

 PERFECT!
 Now let's check if our user are in the "dialout" group
  • on the Terminal write groups and check if if you're at dialout group


If didn't appears the dialout group, add your user to this group typing on the Terminalsudo adduser yourusername dialout and reboot your computer