Strange AVRIspmkii issue

I have some very strange avrispmkii issue running Ubuntu 9.10.
I can upload exactly once and then the isp hangs. If I disconnect the USB plug and plug it in again it will work once and then stop. Now if I install vmware and run winxp and install avrstudio inside the vm it can connect to the ISP and it works 100% perfect. Even several times in a row. If I tell vmware to release the ISP to the host (=Ubuntu) it will work once more and hang. If I grab control back with the vm, it will immediately work again. If I grab control and do nothing but release control to the host it will work once and hang again.

So two question:

  • Has anyone an idea what is happening here?
  • How can I tell Ubuntu in software to disconnect / reconnect the ispmkii? (I just want to run this everytime I want to flash).

Any hints for this strange behaviour are highly appreciated.

Udo

Is there anything in dmsg?

I have no clue what to search for. This is the tail of dmesg:

[ 5069.797339] /dev/vmmon[5889]: PTSC: initialized at 2534000000 Hz using TSC
[ 5070.051881] /dev/vmmon[5889]: HV check: anyNotCapable=0 anyUnlocked=0 anyEnabled=0 anyDisabled=1
[ 5070.456622] i2c-adapter i2c-2: unable to read EDID block.
[ 5070.456631] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5070.461073] i2c-adapter i2c-2: unable to read EDID block.
[ 5070.461076] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5070.466030] i2c-adapter i2c-4: unable to read EDID block.
[ 5070.466032] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5070.470693] i2c-adapter i2c-4: unable to read EDID block.
[ 5070.470696] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5070.630953] i2c-adapter i2c-2: unable to read EDID block.
[ 5070.630956] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5070.635353] i2c-adapter i2c-2: unable to read EDID block.
[ 5070.635355] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5070.639782] i2c-adapter i2c-4: unable to read EDID block.
[ 5070.639784] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5070.644201] i2c-adapter i2c-4: unable to read EDID block.
[ 5070.644203] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5094.698318] i2c-adapter i2c-2: unable to read EDID block.
[ 5094.698321] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5094.703200] i2c-adapter i2c-2: unable to read EDID block.
[ 5094.703202] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5094.707905] i2c-adapter i2c-4: unable to read EDID block.
[ 5094.707907] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5094.712589] i2c-adapter i2c-4: unable to read EDID block.
[ 5094.712591] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5094.871837] i2c-adapter i2c-2: unable to read EDID block.
[ 5094.871840] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5094.876570] i2c-adapter i2c-2: unable to read EDID block.
[ 5094.876573] i915 0000:00:02.0: HDMI Type A-1: no EDID data
[ 5094.881092] i2c-adapter i2c-4: unable to read EDID block.
[ 5094.881094] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5094.886037] i2c-adapter i2c-4: unable to read EDID block.
[ 5094.886040] i915 0000:00:02.0: HDMI Type A-2: no EDID data
[ 5276.381412] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5276.693413] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5280.298609] usb 6-1.4: usbfs: process 5889 (vmware-vmx) did not claim interface 0 before use
[ 5320.729421] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5320.950418] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5323.789384] usb 6-1.4: usbfs: process 5889 (vmware-vmx) did not claim interface 0 before use
[ 5371.473425] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5371.714423] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5374.451193] usb 6-1.4: usbfs: process 5889 (vmware-vmx) did not claim interface 0 before use
[ 5415.069432] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5415.351365] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5523.909450] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 5524.169458] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 6305.108472] type=1503 audit(1272481594.617:22): operation="open" pid=6163 parent=6148 profile="/usr/sbin/cupsd" requested_mask="w::" denied_mask="w::" fsuid=0 ouid=0 name="/dev/ttyUSB0"
[ 6374.887585] usb 6-1.4: usbfs: process 6188 (avrdude) did not claim interface 0 before use
[ 6375.368574] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 6375.649560] usb 6-1.4: reset full speed USB device using uhci_hcd and address 13
[ 8184.664199] usb 6-1: USB disconnect, address 11
[ 8184.664207] usb 6-1.1: USB disconnect, address 12
[ 8184.664699] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[ 8184.664739] ftdi_sio 6-1.1:1.0: device disconnected
[ 8184.665107] usb 6-1.4: USB disconnect, address 13
[ 8185.896113] usb 6-1: new full speed USB device using uhci_hcd and address 14
[ 8186.061940] usb 6-1: configuration #1 chosen from 1 choice
[ 8186.063860] hub 6-1:1.0: USB hub found
[ 8186.065771] hub 6-1:1.0: 4 ports detected
[ 8186.345776] usb 6-1.1: new full speed USB device using uhci_hcd and address 15
[ 8186.501943] usb 6-1.1: configuration #1 chosen from 1 choice
[ 8186.509861] ftdi_sio 6-1.1:1.0: FTDI USB Serial Device converter detected
[ 8186.509919] usb 6-1.1: Detected FT232RL
[ 8186.509924] usb 6-1.1: Number of endpoints 2
[ 8186.509929] usb 6-1.1: Endpoint 1 MaxPacketSize 64
[ 8186.509934] usb 6-1.1: Endpoint 2 MaxPacketSize 64
[ 8186.509939] usb 6-1.1: Setting MaxPacketSize 64
[ 8186.510854] usb 6-1.1: FTDI USB Serial Device converter now attached to ttyUSB0
[ 8186.589778] usb 6-1.4: new full speed USB device using uhci_hcd and address 16
[ 8186.714932] usb 6-1.4: configuration #1 chosen from 1 choice

Udo

For the sake of completeness (maybe it helps the analysis):

udo@laptop:~$ lsusb
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 006: ID 046a:0011 Cherry GmbH G83 (RS 6000) Keyboard
Bus 002 Device 005: ID 1267:0201 Logic3 / SpectraVideo plc A4Tech SWOP-3 Mouse
Bus 002 Device 004: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 002 Device 003: ID 0c0b:b159 Dura Micro, Inc. (Acomdata) 
Bus 002 Device 002: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 016: ID 03eb:2104 Atmel Corp. AVR ISP mkII
Bus 006 Device 015: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 006 Device 014: ID 058f:9254 Alcor Micro Corp. Hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0a5c:2145 Broadcom Corp. 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Hi Udo,
Is this a new phenomenon on Ubuntu 9.10, or is this the first time you run the Ardunio software on Ubuntu?

Did you run a AVRISP firmware upgrade from Avrstudio recently?

I sometimes have problems with the order of powering up the progammer and the board itself. I have to power up the board first, and then plug in the programmer (or was it the other way round?)

Is there any hint in the messages printed from the IDE? (Hold down the shift-key when clicking upload to see verbose messages)

Could you do the 'dmesg' part again:
Start up your computer
open the console window
run 'sudo dmesg -c' once; this clears all the previous messages from booting up
now run the IDE until uploading fails again.
run dmesg (without arguments) to see what happend since you started up the IDE.

Eberhard

Hi Eberhard,

thanks for the hints. I have to AVRispmkII here. Let's call them 6 and 10. 6 has a 6 pin connector and 10 has a 10 pin connector. In the past I used most often 10 because the target had a 10 pin header. Now I am using mostly 6 because I am breadboarding. Switching from 10 to 6 happened almost the same time as my upgrade Ubuntu 9.04 to 9.10.

Today I tried 10 again and it never fails at all. So now 6 is suspected to cause the issue. Still it is strange that 6 fails to work reliably with the Ubuntu host OS / avrdude but works perfectly well with a hosted Windows XP.

Dmesg showed the following

[  503.856663] usb 6-1: USB disconnect, address 2                                                
[  503.856672] usb 6-1.1: USB disconnect, address 3                                              
[  503.857019] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0  
[  503.857057] ftdi_sio 6-1.1:1.0: device disconnected
[  503.857351] usb 6-1.4: USB disconnect, address 4
[  505.336135] usb 6-1: new full speed USB device using uhci_hcd and address 5
[  505.502812] usb 6-1: configuration #1 chosen from 1 choice
[  505.504728] hub 6-1:1.0: USB hub found
[  505.508586] hub 6-1:1.0: 4 ports detected
[  505.789658] usb 6-1.1: new full speed USB device using uhci_hcd and address 6
[  505.945834] usb 6-1.1: configuration #1 chosen from 1 choice
[  505.953735] ftdi_sio 6-1.1:1.0: FTDI USB Serial Device converter detected
[  505.953789] usb 6-1.1: Detected FT232RL
[  505.953795] usb 6-1.1: Number of endpoints 2
[  505.953801] usb 6-1.1: Endpoint 1 MaxPacketSize 64
[  505.953806] usb 6-1.1: Endpoint 2 MaxPacketSize 64
[  505.953811] usb 6-1.1: Setting MaxPacketSize 64
[  505.958321] usb 6-1.1: FTDI USB Serial Device converter now attached to ttyUSB0
[  506.033659] usb 6-1.4: new full speed USB device using uhci_hcd and address 7
[  506.162716] usb 6-1.4: configuration #1 chosen from 1 choice

This is after disconnecting / connecting the hub and the isp. dmesg shows nothing after the failure.

Calling avrdude from the command line looks perfectly well, the second call just hangs.

In the first call with very verbose mode I get

avrdude: Version 5.8, compiled on Jul 20 2009 at 13:58:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch                       

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/udo/.avrduderc"    
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200036499
         AVR Part                      : ATMEGA48P            
         Chip Erase delay              : 45000 us             
         PAGEL                         : PD7                  
         BS2                           : PC2                  
         RESET disposition             : dedicated            
         RETRY pulse                   : SCK                  
         serial program mode           : yes                  
         parallel program mode         : yes                  
         Timeout                       : 200                  
         StabDelay                     : 100                  
         CmdexeDelay                   : 25                   
         SyncLoops                     : 32                   
         ByteDelay                     : 0                    
         PollIndex                     : 3                    
         PollValue                     : 0x53                 
         Memory Detail                 :                      

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no        256    4      0  3600  3600 0xff 0xff
           flash         65     6    64    0 yes      4096   64     64  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: AVRISP mkII                      
         Hardware Version: 1                                
         Firmware Version Master : 1.05                     
         Vtarget         : 4.9 V                            
         SCK period      : 154.37 us                        

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e920a
avrdude: safemode: lfuse reads as E3
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1 
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.                        
avrdude: erasing chip                                                           
avrdude: reading input file "PicoTrigger.hex"                                   
avrdude: writing flash (402 bytes):                                             

Writing | ################################################## | 100% 2.21s

avrdude: 402 bytes of flash written

avrdude: safemode: lfuse reads as E3
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1 
avrdude: safemode: Fuses OK         

avrdude done.  Thank you.

Subsequent calls with -v -v do not fail. One call without -v and it fails. Then -v -v subsequently fails as well and gives:

avrdude: Version 5.8, compiled on Jul 20 2009 at 13:58:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch                       

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/udo/.avrduderc"    
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2

to be continued

continued part of previous post

It can happen that it recovers after some time giving

avrdude: Version 5.8, compiled on Jul 20 2009 at 13:58:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch                       

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/udo/.avrduderc"    
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200036499
avrdude: usbdev_open(): using read endpoint 0x82              
avrdude: usbdev_recv_frame(): usb_bulk_read(): No error       
avrdude: stk500v2_recv_mk2: error in USB receive              
avrdude: usbdev_recv_frame(): usb_bulk_read(): No error       
avrdude: stk500v2_recv_mk2: error in USB receive              
         AVR Part                      : ATMEGA48P            
         Chip Erase delay              : 45000 us             
         PAGEL                         : PD7                  
         BS2                           : PC2                  
         RESET disposition             : dedicated            
         RETRY pulse                   : SCK                  
         serial program mode           : yes                  
         parallel program mode         : yes                  
         Timeout                       : 200                  
         StabDelay                     : 100                  
         CmdexeDelay                   : 25                   
         SyncLoops                     : 32                   
         ByteDelay                     : 0                    
         PollIndex                     : 3                    
         PollValue                     : 0x53                 
         Memory Detail                 :                      

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no        256    4      0  3600  3600 0xff 0xff
           flash         65     6    64    0 yes      4096   64     64  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel STK500 Version 2.x firmware
         Programmer Model: AVRISP mkII
         Hardware Version: 1
         Firmware Version Master : 1.05
         Vtarget         : 4.8 V
         SCK period      : 154.37 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e920a
avrdude: safemode: lfuse reads as E3
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "PicoTrigger.hex"
avrdude: writing flash (402 bytes):

Writing | ################################################## | 100% 2.21s

avrdude: 402 bytes of flash written

avrdude: safemode: lfuse reads as E3
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Conclusion: for some strange reason calling avrdude with -v avoids the issue → I now have a good workaround but I wonder why the heck this happens. Maybe the ISPs are flashed to different firmare releases. I will try to get isp 6 to the same release as 10 and report what I find out.

Udo

By now I upgrades the mkii "6" to the newest software level. Still the same issue. I will stick to the -v workaround. Still I wonder why this helps.

Udo

By chance I found the following today

http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01173.html

From that on I found other hits for "avrdude patch #5655". Seems this is a notorius bug. I did not find any really good resolution of this issue. Probably the best for me is to downgrade isp #6.

Udo

By now I found a solution for this issue that defers any explanation. However it seems to work 100% reliable so far. So I post it. Maybe somebody else finds it helpful as well.

If anyone comes up with a good explanation why this happens I would be very happy to understand what is going on here.

Ok, here comes the call that erratically hangs:

/usr/bin/avrdude -V -v -v -p atmega48p -c avrispmkII -P usb -U flash:w:Test.hex:i

And here what so far works 100%

/usr/bin/avrdude -V -p atmega48p -c stk500v2 -P usb -U flash:w:Test.hex:i

Interesting enough: if the first call "poisoned" the ISP then the seconds will hang as well. That is the second call will hang ~10s before it starts. Once it succeeds subsequent calls are 100% OK.

Strange but at least it works now.

Udo

P.S. The issue is not with the ISP. I have two mkIIs and both work 100% with Avrstudio and both work with the seconds command and fail erratically with the first.

One more thing I noticed: both the avrispmkii option and the -v options seem to induce the erratic behaviour.

One additional thing I noticed: if I capture the USB bus with wireshark I see that the programmers consistently send 2 malformed responses. However this happens in both cases.

Udo

Now I looked up avrdude.conf and found the following entries:

programmer
  id    = "avrispmkII";
  desc  = "Atmel AVR ISP mkII";
  type  =  stk500v2;
;

programmer
  id    = "avrisp2";
  desc  = "Atmel AVR ISP mkII";
  type  =  stk500v2;
;

programmer
  id    = "stk500v2";
  desc  = "Atmel STK500 Version 2.x firmware";
  type  = stk500v2;
;

Needless to say that this implies that it should make no differency if I specify the avrispmkII the avrisp2 or the stk500v2. This looks more than strange to me.

Udo

Today the ISP shows erratic behaviour in both modes. I just do not get it. If I would not see it I would not believe it. Hopefully I can nail this down somehow.

Any suggestions for an ISP that supports slow programming speeds (down to 1kHz) and that works better?

Udo

So what I found out so far is that the behaviour never occurs after the following two things:

  1. Immediately after plugging in the ispmkii
  2. Immediately after attaching it to a vm and detaching it

I also found out that I can manually attach/detach USB device drivers as described here:

So the next step is how to figure out automatically which device the avrisp actually is. That is what to bind/unbind.

I see the following:

#lsusb -vvv -d 03eb:2104

Bus 006 Device 005: ID 03eb:2104 Atmel Corp. AVR ISP mkII
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        16
  idVendor           0x03eb Atmel Corp.
  idProduct          0x2104 AVR ISP mkII
  bcdDevice            2.00
  iManufacturer           1 ATMEL
  iProduct                2 AVRISP mkII
  iSerial                 3 000200012678
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
Device Status:     0x0001
  Self Powered
# lsusb
Bus 003 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0a5c:2145 Broadcom Corp. 
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 005: ID 03eb:2104 Atmel Corp. AVR ISP mkII
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 007: ID 1267:0201 Logic3 / SpectraVideo plc A4Tech SWOP-3 Mouse
Bus 002 Device 006: ID 0c0b:b159 Dura Micro, Inc. (Acomdata) 
Bus 002 Device 005: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 002 Device 004: ID 046a:0011 Cherry GmbH G83 (RS 6000) Keyboard
Bus 002 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@laptop:/tmp# tree /sys/bus/usb/devices/
/sys/bus/usb/devices/
|-- 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1/1-0:1.0
|-- 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-0:1.0
|-- 2-2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2
|-- 2-2.2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2
|-- 2-2.2:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.2/2-2.2:1.0
|-- 2-2.3 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3
|-- 2-2.3.2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3/2-2.3.2
|-- 2-2.3.2:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3/2-2.3.2/2-2.3.2:1.0
|-- 2-2.3.3 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3/2-2.3.3
|-- 2-2.3.3:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3/2-2.3.3/2-2.3.3:1.0
|-- 2-2.3:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.3/2-2.3:1.0
|-- 2-2:1.0 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2:1.0
|-- 3-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3/3-0:1.0
|-- 3-1 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1
|-- 3-1:1.0 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1:1.0
|-- 4-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-0:1.0
|-- 4-2 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-2
|-- 4-2:1.0 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.0
|-- 4-2:1.1 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.1
|-- 4-2:1.2 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.2
|-- 4-2:1.3 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4/4-2/4-2:1.3
|-- 5-0:1.0 -> ../../../devices/pci0000:00/0000:00:1a.2/usb5/5-0:1.0
|-- 6-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb6/6-0:1.0
|-- 6-1 -> ../../../devices/pci0000:00/0000:00:1d.0/usb6/6-1
|-- 6-1:1.0 -> ../../../devices/pci0000:00/0000:00:1d.0/usb6/6-1/6-1:1.0
|-- 7-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.1/usb7/7-0:1.0
|-- 8-0:1.0 -> ../../../devices/pci0000:00/0000:00:1d.2/usb8/8-0:1.0
|-- usb1 -> ../../../devices/pci0000:00/0000:00:1a.7/usb1
|-- usb2 -> ../../../devices/pci0000:00/0000:00:1d.7/usb2
|-- usb3 -> ../../../devices/pci0000:00/0000:00:1a.0/usb3
|-- usb4 -> ../../../devices/pci0000:00/0000:00:1a.1/usb4
|-- usb5 -> ../../../devices/pci0000:00/0000:00:1a.2/usb5
|-- usb6 -> ../../../devices/pci0000:00/0000:00:1d.0/usb6
|-- usb7 -> ../../../devices/pci0000:00/0000:00:1d.1/usb7
`-- usb8 -> ../../../devices/pci0000:00/0000:00:1d.2/usb8

35 directories, 0 files

So I infered that "-- 6-1 -> ../../../devices/pci0000:00/0000:00:1d.0/usb6/6-1" points to the ISP what it actually does. However what would be the proper way to conclude this in an autmated way? I just do not to get it. The issue that confuses me is that lsusb says that the ISP is device 5. However the file system says it is device 1. Where is the missing connection that I do not seem to see? Has anyone any hints for me?

Udo

Hi Udo,

I have no explanation for your problem withn the programmer but, Linux drivers are bound to USB-devices on the USB-interface level,

This is the part in your listing that starts with Interface Descriptor:

#lsusb -vvv -d 03eb:2104

........

Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval              10

The bInterfaceClass value tell the system that this device needs a custom driver (it is not a mouse or a storage device for which standard drivers are available )

Since there is not specific driver for the AvrIspMk2 in the kernel, nothing is bound here that can be unbound.
In other words there is no need to detach a driver from the interface.

AvrDude uses libusb to communicate with the device from user-space.

So I don't think that your problem is driver related.
Eberhard

OK, I see. So basically either AVRdude or the MKII is the culprit. Since the MKII works fine with Avrstudio and since the MKII worked fine with AVRDude prior to the latest upgrade I fear that the ISP upgrade caused the issue.

So either I downgrade or I find a way to automatically disconnect/reconnect the MKII from USB. I would prefer the second approach. Do you have any hints for me how this could be achieved? That is: without adding another microcontroller to control disconnection?

Udo

Hi Udo,
theoretically you could write a small libusb-based tool that resets the device/the programmer. This might work but I never needed that function so I'm not sure about that.

I have a MKII too and when I bought an XMega based board I was tempted to do the firmware upgrade for the programmer from AVRStudio to enable the PDI-programming. But since nobody could tell me if this in any way influences the ISP programming part, I orderd a AVR Dragon instead,

But here is a report on the avrdude-development mailing list that looks similar to your problem.
http://www.mail-archive.com/avrdude-dev@nongnu.org/msg02217.html

According to this report you should be able to solve this by upgrading the libusb-1.0 package to a recent version, or upgrade Ubuntu itself to 10.04.

Eberhard

Hmm, I have two Ubuntu setups here. So my next step will be to run the ISP with 10.4. It just never occured to me that this might help. I will try it out and post the results. May take till the weekend though.

Thanks a lot!

With regard to the upgrade: before I upgraded AVR studio (and the ISPs) I did not have any issues. I did not expect that the upgrade would break the AVRdude setup but obviously it messes with it.

Udo

Eberhard, the upgrade to 10.4 solved the issue. 10 uploads in a row without any glitch. Hopefully this persists :slight_smile:

Thanks a lot for this hint.

Udo