Pages: [1]   Go Down
Author Topic: Notes on Windows, avrdude, libusb, WinAVR, and AVR  (Read 2567 times)
0 Members and 1 Guest are viewing this topic.
Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 9
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

[posted in part so that next time I Google for a similar issue, I'll find my own notes but also in the hope that they might be useful to others]

The version of avrdude that comes with WinAVR 20070525 is built against libusb (version 0.1.10.1) and requires libusb0.dll (in the current working directory or windows\system32 or similar).  When using it with the AVRISP mkII, I get repeated "error in usb receive" messages (it still works, though).  

Compiling avrdude with support for libusb:
- download libusb-win32 binary distribution (version 0.1.12.1 - the latest version of avrdude won't build against 0.1.10.1)
- copy usb.h to /usr/local/include and libusb.a to /usr/local/lib of cygwin
- in avrdude-5.4-arduino:
  ./configure -CFLAGS="-I /usr/local/include" LDFLAGS="-L /usr/local/lib -lusb"
- run as usual: make
- resulting avrdude.exe requires libusb0.dll (either in its current working directory or in windows\system32)

Installing libusb (by plugging in the avrispmkii and pointing Windows at the directory containing libusb0.dll, etc.) copies these files: windows\system32\libusb0.dll and windows\system32\libusb0.sys.  Deleting those files doesn't uninstall the driver, it just puts it into a non-working state.  Nor does uninstalling the driver remove those files.  If the driver is not installed, then the AVRISP mkII does not appear as a device, even if libusb0.dll is present (either in the same directory as avrdude or in windows\system32).  

avrdude runs without the libusb driver installed as long libusb0.dll is in the current working directory; it can't talk to an avrisp mkii though.  Then, after installing the libusb driver, avrdude still works (even with libusb0.dll in the current working directory) and can talk to the avrispmkii.  

Uploading with avrdude via the bootloader works with the AVR studio jungo usb drivers for the AVRISP mkII installed (which makes sense, since it should be using the FTDI drivers, which are completely unrelated).  It seems, however, that the AVRISP mkII must be disconnected from the board.  

If you've already installed AVR Studio's USB drivers for the AVRISP mkII, you need to uninstall them before you can use the AVRISP mkII with libusb and avrdude.  Run the AVR Studio setup, select Modify, uncheck the USB drivers, and proceed through the following steps (it's not enough to uninstall the driver from the Device Mananger).  Then disconnect and reconnect the AVRISP mkII (this step may not be needed).  The Windows Add New Hardware wizard will appear.  Ignore it for the moment and run run the inf-wizard in libusb's bin directory.  Select the AVRISP mkII and save the .inf file in the libusb bin directory.  Then go back to the Add New Hardware wizard, tell it you want to search for the driver manually, and point it to libusb's bin directory.  

In general, it seems like you need to disconnect and reconnect the board after burning the bootloader before uploading sketches.
« Last Edit: July 25, 2007, 06:22:05 pm by mellis » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

um, how about having a nice summary as to the main goal that these notes reflect? I agree its much more fun to try to guess and or assume what the notes try to accomplish, boy so fun indeed. smiley
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 69
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tripped over this post because somebody said you need a different USB driver for AVRISPmkII to work from Arduino IDE for burning bootloaders.

I think what the OP is saying here is that Arduino can't use the AVRISPmkII to burn bootloaders, like it should, as it's offered in that menu, and if you do magic on usb drivers it might.  

I'm going to ask, can't I just grab the bootloader file from the Arduino directory structure and blast it into a virgin chip using the native programming environment called AVR Studio 4?  (Forget about trying to do it from Arduino IDE if it can't handle it, as it seems it can't).

And the answer is yes: http://www.arduino.cc/playground/Learning/Burn168

Not every nail needs a hammer, but it seems my problem is solved.

FWIW, I think the whole bootloader thing for Arduino is getting a little old.  It's just as easy to skip that design concept and just have a little wee programmer buried in the Arduino IDE that zaps straight code into the little darlings.


Regards
Scott

« Last Edit: October 25, 2009, 12:53:50 am by scottmcphee » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 15
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Except you can't use the serial port to do it, which is in itself pretty stupid - the 8052 processors nearly all have a serial boot loader, so you dont have to mess about with special programming tools.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi mellis,
the notes would be of interest to Arduino users who'd use an AVRISP mkII to burn a bootloader.

Any chance you can organise these into a more meaningful instruction set?. (or FAQ)
Logged

Pages: [1]   Go Up
Jump to: