avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] AVRDUDE+libusb, compiling and running on Windows


From: Didrik Madheden
Subject: Re: [avrdude-dev] AVRDUDE+libusb, compiling and running on Windows
Date: Tue, 15 Apr 2014 09:54:59 +0200

On 12 April 2014 01:15, Jason Hecker <address@hidden> wrote:
> I too am having (mental) issues building avrdude for Win32 using
> mingw32/msys.  I *used* to be able to build and use it for supporting ftdi.
>
> I have:
>
>    - Run Zadig to install the necessary libusb DLLs.
>    - Copied over lusb0_usb.h to the mingw32 include path.
>    - From the premade stuff in libftdi_0.20git_win32.zip copied to mingw32
>    paths the libftdi.h header and the associated .a library files files.

The current 6.1 build on Savannah seems to have the same problem
actually. So after some more wrestling. I found out that even though
configure reports that we...

> DO HAVE    libusb
and
> DO HAVE    libftdi

...there is a slight problem. Newer versions of libusb0 calls the
usb.h file lusb0_usb.h. While most of the programmer definitions can
use either by using of a conditional like this:

#if defined(HAVE_USB_H)
#  include <usb.h>
#elif defined(HAVE_LUSB0_USB_H)
#  include <lusb0_usb.h>
#else
#  error "libusb needs either <usb.h> or <lusb0_usb.h>"
#endif

the ft245 and avrftdi programmers only accept usb.h:

#elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H)

And for slightly good reason, as the following line reveals this:

/* ftdi.h includes usb.h */
#include <ftdi.h>

In other words, ftdi.h (the header from libftdi, not part of avrdude)
includes ftdi.h, but never lusb0_usb.h. And so we get the else case:

#else
#warning No libftdi or libusb support. Install libftdi1/libusb-1.0 or
libftdi/libusb and run configure/make again.
#define DO_NOT_BUILD_FT245R
#endif

You have two choices.

The simple way: (Aka, just compile, damn it!)
Rename lusb0_usb.h in MinGW/includes/ to usb.h and rerun configure.
This will cause configure to find what it needs, and the usb.h should
work and, as far as I can tell, have no other side effects.

The complicated way: (In which we patch libftdi.)
Patch ft245r.c and avrftdi_private.h to replace

#elif defined(HAVE_LIBFTDI) && defined(HAVE_USB_H)
/* ftdi.h includes usb.h */
#include <ftdi.h>

with

#elif defined(HAVE_LIBFTDI) && (defined(HAVE_USB_H) ||
defined(HAVE_LUSB0_USB_H))
/* ftdi.h includes usb.h or lusb0_usb.h */
#include <ftdi.h>

Correspondigly, ftdi.h needs fixing. Replacing the single usb.h
include with something like this is a possiblity:

#if defined(HAVE_USB_H)
#  include <usb.h>
#elif defined(HAVE_LUSB0_USB_H)
#  include <lusb0_usb.h>
#else
#  error "libftdi needs either <usb.h> or <lusb0_usb.h>"
#endif

But HAVE_* is produced by the autoconf and it wouldn't be safe to
assume it's there in any project. The libftdi maintainer might solve
this by (ugh) providing two separate include files. Or by deprecating
libusb versions 1.2.4 and older by including only lusb0_usb.h. Or by
not care about something as old as frickin' libusb 0.1 and not do
anything until someone forks libftdi just to solve this issue. (Again,
ugh.)

Now the problem that I'm having on *my* end is that I'm unable to
access the FTDI chip.

$ avrdude -c ft232r -P ft0 -p m162
can't open ftdi device 0. (device not found)

avrdude.exe done.  Thank you.

I believe I have signed all driver files with DSEO as needed on
Windows 7 64-bit, so that I should be good to go. I have a binary blob
of avrdude 5.8 from somewhere which *does* work on Windows, but it's
linking to FTDI's ftd2xx dll (the serjtag patch) so it's no indication
of anything with regard to this discussion.

/Didrik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]