Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
larryvc
PostPosted: Dec 05, 2013 - 12:31 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

This device works fine with avrdude 5.10 but when I try to use it with avrdude 6.0.1 it fails. The same command line is used for both versions.

Here is a partial list of the errors received.

Code:
C:\>avrdude -c avrispmkii -p t2313
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: stk500v2_getsync(): timeout communicating with programmer


Edit: I am using the avrdude Windows binaries dated September 18, 2013

_________________


Last edited by larryvc on Dec 05, 2013 - 05:54 AM; edited 2 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
physicist
PostPosted: Dec 05, 2013 - 04:23 AM
Hangaround


Joined: Jul 06, 2009
Posts: 124
Location: Heppner, OR

This happens to me as well, on both Windows XP and Win7-64, with LUFA 130901. I believe I also had problems with AVRDUDE 6.0.1 on Linux, but I would need to do more testing.

EDIT: My problems with Linux are not related to this issue. AVRDUDE 6.0.1 is reported to work fine with Linux.

On Windows XP, AVRDUDE is able to read the serial number but is unable to get any further:
Code:
avrdude: Version 6.0.1, compiled on Sep 18 2013 at 08:20:41
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\avrdude\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : avrisp2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200012345
avrdude: Sent: . [01]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_submit_async: submitting request failed, win error: The parameter is incorrect.

avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: Sent: . [01]
avrdude: usbdev_recv_frame(): usb_bulk_read(): usb_submit_async: submitting request failed, win error: The parameter is incorrect.
 


On Win7-64, a customer reports:
Code:
avrdude.exe: usb_open(): cannot read serial number "libusb0-dll:err [control_msg] sending control message failed, win error: The I/O operation has been aborted because of either a thread exit or an application request.


EDIT: The customer also reports that the official Atmel AVRISP mkII works.


Last edited by physicist on Dec 07, 2013 - 02:24 AM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 05, 2013 - 06:20 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Just to clarify the details:

Tested on:
Windows 7 and Windows 8.1
LUFA 120219 and 130901 AVRISP-MKII
avrdude 5.10 and 6.0.1

Both LUFA AVRISP-MKII versions 120219 and 130901 work correctly with avrdude 5.10 but fail when run on avrdude 6.0.1.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Dec 05, 2013 - 09:05 AM
Moderator


Joined: Jan 23, 2004
Posts: 10204
Location: Melbourne, Australia

You need to compile the code either in "LIBUSB_DRIVER_COMPAT" or "RESET_TOGGLES_LIBUSB_COMPAT" enabled in the AppConfig.h file (see documentation). AVRDude doesn't like the way I fake bidirectional endpoints in the AVRISP-MKII, requiring alternative firmware to make it work.

- Dean Twisted Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 05, 2013 - 09:13 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Both versions are compiled with the RESET_TOGGLES_LIBUSB_COMPAT enabled. Remember that you gave me that when you were first working on implementing that feature.

The drivers swap correctly when the reset button is pressed. Studio uses it fine.

Like I said, both LUFA AVRISP-MKII versions work correctly with avrdude 5.10.

They do not work with avrdude 6.0.1.

Off to bed. Have a good day!

EDIT: I will try the LIBUSB_DRIVER_COMPAT setting tomorrow to see if it makes any difference. I do have a feeling that this is due to changes made in avrdude 6.0.1.

_________________


Last edited by larryvc on Dec 05, 2013 - 06:23 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Dec 05, 2013 - 09:35 AM
Moderator


Joined: Jan 23, 2004
Posts: 10204
Location: Melbourne, Australia

Well nuts - my only test hardware is currently on a ship heading towards England and eventually Australia, so I can't try it out. Sounds like AVRDUDE's internals have changed and I need to figure out another fix.

- Dean Twisted Evil

_________________
Make Atmel Studio better with my free extensions. Open source and feedback welcome!
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 05, 2013 - 06:25 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Thanks Dean,

Let me know if I can be of assistance during the testing phase.

Have a very safe trip home!

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
physicist
PostPosted: Dec 06, 2013 - 11:10 AM
Hangaround


Joined: Jul 06, 2009
Posts: 124
Location: Heppner, OR

I used a software USB protocol analyzer, and it looks like AVRDUDE is expecting responses from the AVRISP mkII on the same endpoint as the requests. It looks like the mkII is receiving the V2 protocol sign-on command [01], because it writes the appropriate response which includes the programmer ID "AVRISP_MK2" and it then clears the IN endpoint. However, AVRDUDE never gets this response. I looked at the AVRDUDE source code, and in the file usbdevs.h:
Code:
/* JTAGICEmkII, AVRISPmkII */
#define USBDEV_BULK_EP_WRITE_MKII 0x02
#define USBDEV_BULK_EP_READ_MKII  0x82
#define USBDEV_MAX_XFER_MKII 64

That is not going to work. The read endpoint must be 0x83 to work in libusb compatibility mode. I don't have a proper build system right now to test if this is indeed the problem. Any ideas?

_________________
http://www.mattairtech.com/
Gentoo Linux
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 06, 2013 - 06:16 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Thanks for doing the testing.
physicist wrote:
I looked at the AVRDUDE source code, and in the file usbdevs.h:
Code:
/* JTAGICEmkII, AVRISPmkII */
#define USBDEV_BULK_EP_WRITE_MKII 0x02
#define USBDEV_BULK_EP_READ_MKII  0x82
#define USBDEV_MAX_XFER_MKII 64

That is not going to work. The read endpoint must be 0x83 to work in libusb compatibility mode. I don't have a proper build system right now to test if this is indeed the problem. Any ideas?

Those are the same defines as in the avrdude versions 5.10 and 5.11.1 and they work fine. I've been looking through the USB code in all three versions of avrdude and also Dean's 2011 and 2013 code to see what has changed in regard to the USB handling. So far nothing has caught my eye that would account for this issue.

I am going to ping Joerg to see if he can weigh in on what, if any, changes he has made that may account for this.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: Dec 06, 2013 - 08:21 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

I found that usbdev_recv_frame, in avrdude file usb_libusb.c has been changed. This code appears to be specifically written for the AVRisp mkII device. It includes new code that looks for an event EP and handle it first if data is pending.

In an off note, I have attempted to build avrdude 6.0.1 in a MinGW environment, as I had successfully done with 5.10 and 5.11.1, but I have been unsuccessful in my attempts. I can do the build but evidently some libraries are not included in it. Mainly I need to know how to specify the build to include usb, ftdi, pthread, and libraries in general.


Last edited by larryvc on Dec 07, 2013 - 01:00 AM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
dl8dtl
PostPosted: Dec 06, 2013 - 09:19 PM
Raving lunatic


Joined: Dec 20, 2002
Posts: 7370
Location: Dresden, Germany

> It includes new code that looks for an event EP and handle it first if data is pending.

This is needed for the JTAGICE3 (at least, those that still use PID 0x2110, didn't
look at the new firmware yet).

If that breaks something, please file a bug report, with as many USB traces you could
get to demonstrate the issue.

> Mainly I need to know how to specify the build to include usb, ftdi, pthread,
> and libraries in general.

General, in autoconf, this is done by pre-assigning appropriate values (like -I
options to extend the include search path, and -L options to extend the library
search path) through environment variables. Those variables are CPPFLAGS
(where "CPP" doesn't mean "C++", but "C preprocessor"), and LDFLAGS, respectively.

Have a look at my mingw32 build script under tools/. While it's targetted towards
Unix systems (it's the script I'm using to build the mingw32-based .exe file that
is in the download area), you should be able to get the idea from that.

In general, you'll get much faster responses for questions like this by subscribing
to the avrdude-dev mailinglist, and asking there. I've been a little sick lately,
so I didn't monitor avrfreaks for a number of days.

_________________
Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
tfeldman
PostPosted: Dec 06, 2013 - 10:03 PM
Newbie


Joined: Sep 14, 2013
Posts: 6


I have a USBTINY MKII programmer that seems to work with avrdude 6.0.1, on Linux, without issue. The LUFA image was furnished by the seller (Tom Light) so I don't know the details about that build. I believe it was built against the 120318 LUFA. Avrdude was compiled with, ../configure --enable-linuxgpio. Perhaps the problem is Windows specific? I hope this helps a bit.
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: Dec 07, 2013 - 12:57 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Thanks Jörg, that information was very helpful and I was able to build avrdude with USB capabilities. That is sufficient at this point to enable debugging. Hope you feel better.

@tfeldman, thanks for letting me know that this is working on Linux. It is a problem with the avrdude Windows binary and the LUFA AVRISP-MKII. Not sure why yet.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
physicist
PostPosted: Dec 07, 2013 - 02:20 AM
Hangaround


Joined: Jul 06, 2009
Posts: 124
Location: Heppner, OR

Quote:
Those are the same defines as in the avrdude versions 5.10 and 5.11.1 and they work fine.

Although I did not know those defines were present before, I should have mentioned that I had gotten to those defines by looking through the usb_libusb.c code. Previously, the define was effectively ignored, because a search for a read endpoint was always performed (by looking at the endpoint direction). The new code will only perform this search if the endpoint wasn't already assigned (which it is, in stk500v2.c to the aforementioned define).

I also had the same dependency issues with MinGW, but I will try again tonight. I will try forcing the read endpoint search.

@tfeldman, that's good to know. Now that I think of it, AVRDUDE 5.x always worked for me regardless of whether or not libusb compatibility mode was enabled.

_________________
http://www.mattairtech.com/
Gentoo Linux
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 07, 2013 - 02:37 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Success!!!

I found the problem in usbdev_open in file usb_libusb.c.

The if statement:
Code:
        if (fd->usb.rep) == 0)
        {

prevents Dean's masqueraded endpoint from being discovered.

Here is the output with the if statement removed and debug statement showing the original read endpoint.
Code:
C:\avrdudenew>avrdude -c avrispmkii -p t2313 -P usb -vv

avrdude: Version 6.0.1, compiled on Dec  6 2013 at 15:33:18
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\avrdudenew\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : avrispmkii
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200312345
avrdude: usbdev_open(): original read endpoint fd->usb.rep 0x82
avrdude: usbdev_open(): using read endpoint 0x83
         AVR Part                      : ATtiny2313
         Chip Erase delay              : 9000 us
         PAGEL                         : PD4
         BS2                           : PD6
         RESET disposition             : possible i/o
         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     6     4    0 no        128    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      2048   32     64  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel AVR ISP mkII
         Programmer Model: AVRISP mkII
         Hardware Version: 0
         Firmware Version Master : 1.23
         Vtarget         : 4.9 V
         SCK period      : 1.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e910a
avrdude: safemode: lfuse reads as A4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF

avrdude: safemode: lfuse reads as A4
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (H:FF, E:DF, L:A4)

avrdude done.  Thank you.

I will follow up by filing a bug report.

EDIT: I come back after working the code to find the problem and to file this and discover that both physicist and I had found the problem. Cosmic. Wink


Last edited by larryvc on Dec 07, 2013 - 02:48 AM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
physicist
PostPosted: Dec 07, 2013 - 02:44 AM
Hangaround


Joined: Jul 06, 2009
Posts: 124
Location: Heppner, OR

Excellent! I was just about to try the same exact thing (see above post).

_________________
http://www.mattairtech.com/
Gentoo Linux
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Dec 07, 2013 - 03:14 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 3162
Location: Redmond, WA USA

Bug report is #40831.

Cascadia rocks again!
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits