LUFA based AVRISP-MKII doesn't work with avrdude 6.0.1

17 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

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:

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Dean,

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

Have a very safe trip home!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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:

/* 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?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for doing the testing.

physicist wrote:
I looked at the AVRDUDE source code, and in the file usbdevs.h:

/* 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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> 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.

Pages