Benutzer:Robomu

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche

Ethersex Development using Eclipse Ganymede on Ubuntu 8.04 LTS

Eclipse may be used on Ubuntu 8.04 to work with the Ethersex Source Tree and even to directly flash the target from within Eclipse. However make menuconfig has to be run outside Eclipse since Eclipse does not provide a terminal window for running external tools. This article shows installation and configuration of

  1. avrdude with USB support for Atmel AVRISP mkII
  2. Eclipse Ganymede

and reports operating experiance.

Build avrdude with USB support from sources and configure udev to allow it access to AVRISP mkII

To use the ATMEL USB programmer AVRISP mkII avrdude requires libusb support. Here is how to build it from sources:

  1. Make sure that libusb and libusb-dev is installed on your system
  2. Make sure that flex (substitute for lex) and bison (substitute for yacc) are installed on your system
  3. Download source package (avrdude-5.10.tar.gz) from savannah.nongnu.org and transfer it to a local install folder and unpack it with tar -xvf
  4. cd to your extracted avrdude-5.10 folder and run ./configure
  5. check config.log and if no errors reportet run make and make config to install avrdude to /usr/local/bin/avrdude

Since avrdude does not run under root during normal development you need to make sure that it is allowed to access the USB device associated to the AVRISP mkII.

Use the command lsusb to identify the usb device associated to the Programmer showing it's name and the VendorID of ATMEL (03eb) and the Device ID of the AVRISP mkII (2104)

Bus 002 Device 001: ID 0000:0000  
Bus 001 Device 003: ID 0e0f:0002  
Bus 001 Device 002: ID 03eb:2104 Atmel Corp. AVR ISP mkII
Bus 001 Device 001: ID 0000:0000  

The Programmer is on bus 001 device 002. Then identify the usb devices by issuing ls -al /dev/usb*:

crw-rw---- 1 root root 254, 0 2010-02-05 16:30 /dev/usbdev1.1_ep00
crw-rw---- 1 root root 254, 1 2010-02-05 16:30 /dev/usbdev1.1_ep81
crw-rw---- 1 root root 254, 4 2010-02-05 16:30 /dev/usbdev1.2_ep00
crw-rw---- 1 root root 254, 6 2010-02-05 16:30 /dev/usbdev1.2_ep02
crw-rw---- 1 root root 254, 5 2010-02-05 16:30 /dev/usbdev1.2_ep82
crw-rw---- 1 root root 254, 7 2010-02-05 16:30 /dev/usbdev1.3_ep00
crw-rw---- 1 root root 254, 8 2010-02-05 16:30 /dev/usbdev1.3_ep81
crw-rw---- 1 root root 254, 2 2010-02-05 16:30 /dev/usbdev2.1_ep00
crw-rw---- 1 root root 254, 3 2010-02-05 16:30 /dev/usbdev2.1_ep81

This output shows, that device 002 on bus 001 uses /dev/usbdev1.2* device files. It further shows, that these devices are owned by root and belong to group root and do not allow ordinary users any access. Next task is to tell the kernel through a udev rule to assign access rights to the programmers usb device that grants non-root users rw access. To accomplish this one needs to know the information the kernel has about the programmer's usb device. Use udevinfo command to do so looking up data for the device file identified from above as follows:
udevinfo -a -p $(udevinfo -q path -n /dev/usbdev1.2_ep00)

A lot of info on the USB Bus is provided but pick only the section dealing with your programmer. Depending on your system, the output may look different.

    looking at parent device '/devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb1':

    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{dev}=="189:1"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="10"
    ATTRS{idVendor}=="03eb"
    ATTRS{idProduct}=="2104"
    ATTRS{bcdDevice}=="0200"
    ATTRS{bDeviceClass}=="ff"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="16"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="2"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="ATMEL"
    ATTRS{product}=="AVRISP mkII"
    ATTRS{serial}=="000200021047"

From the udev info above one could setup a udev rule in a file named /etc/udev/rules.d/50-usb-dev-access.rules as follows that matches the programmer's usb device only and assigns it a device file named /dev/avrispmkII with rw access for the developer group dev but it turned out that avrdude wants to parse all usb devices and shows an error if access rights do not allow this. Therefore the udev rule in line 2 had to be changed to that below assigning all usb devices plugged in to group dev which allows avrdude to check for the programmer and use it.

#Define group for AVRISP MKII attached to USB to be adm and allow rw for user, group and others
#SUBSYSTEMS=="usb",  ATTRS{manufacturer}=="ATMEL",  ATTRS{product}=="AVRISP mkII", NAME="avrispmkii" GROUP="dev", MODE="0660"
SUBSYSTEMS=="usb", GROUP="dev", MODE="0660"

After assigning the udev rule activate it by sudo /etc/init.d/udev restart and check the results with another ls -al /dev/usb*.

Installation of Eclipse Ganymede and AVR Plugin

  1. Download Eclipse C/C++ Ganymede project package eclipse-cpp-ganymede-SR2-linux-gtk.tar.gz
  2. make sure that sun-java6-bin is installed
  3. copy eclipse-cpp-ganymede-SR2-linux-gtk.tar.gz to /home/devel/opt assuming that /home/devel is your home account
  4. unpack it there using tar -xvf eclipse-cpp-ganymede-SR2-linux-gtk.tar.gz
  5. Create the eclipse startup script mkdir /home/devel/bin/eclipse as follows:
export MOZILLA_FIVE_HOME="/usr/lib/mozilla"
export ECLIPSE_HOME="$HOME/opt"
$ECLIPSE_HOME/eclipse $*
  1. Don't forget to make the script executable with chmod +x ~/bin/eclipse
  2. and add your local executables directory to the path in .bashrc like this: export PATH=$HOME/bin:$PATH
  3. If you like add an Eclipse menu item with an icon to the gnome desktop or start eclipse from the shell with eclipsae


Now you have to add the AVR Plugin to Eclipse. You can start eclipse and use its own update function to do so. Use Menu Help, Software Updates, Available Software, Add Site... http://avr-eclipse.sourceforge.net/updatesite/. Then use Manage Sites... button and activate the site which then shows up under the available software tab. From this you can install the PlugIn automatically.

If you prefer to install it manually download de.innot.avreclipse-2.3.1.20081204PRD.zip from http://avr-eclipse.sourceforge.net/wiki/index.php/Plugin_Download and unzip it to the eclipse folder like this:
unzip -v de.innot.avreclipse-2.3.1.20081204PRD.zip -d /home/fdevel/opt/eclipse
Now start eclipse and notice the AVR Menu and the AVR section in Preferences. See the Eclipse Help for a detailed description of the AVR PlugIn.

Configure Eclipse and the AVR Plugin

to be continued soon....