patchAVR Downloader/UploaDEr - Patches: patch #8954, Enable usage of libusb-1.0 for...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #8954: Enable usage of libusb-1.0 for stk500v2 (aka avrispmkii)

Submitter:  Michael Böhme <michaelboehme>
Submitted:  Thu 24 Mar 2016 12:32:46 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Need Info Privacy:  Public
Assigned to:  None Open/Closed:  Open

Sun 21 Jan 2018 10:21:05 PM UTC, comment #1: 

This does unfortunately not compile under FreeBSD where the OS
offers a libusb-1.0 API compatible USB library:


usb_libusb.c:265:17: warning: implicit declaration of function 'libusb_has_capability' is invalid in C99
      [-Wimplicit-function-declaration]
            if (libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER))
                ^
usb_libusb.c:265:39: error: use of undeclared identifier 'LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER'
            if (libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER))
                                      ^
usb_libusb.c:723:62: warning: passing 'char *' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
      errcode = libusb_interrupt_transfer(udev, fd->usb.wep, (char *)bp, tx_size, &rv, 10000);
                                                             ^~~~~~~~~~
/usr/include/libusb.h:549:87: note: passing argument to parameter 'data' here
int     libusb_interrupt_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *trans...
                                                                                          ^
usb_libusb.c:725:57: warning: passing 'char *' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
      errcode = libusb_bulk_transfer(udev, fd->usb.wep, (char *)bp, tx_size, &rv, 10000);
                                                        ^~~~~~~~~~
/usr/include/libusb.h:548:82: note: passing argument to parameter 'data' here
int     libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferre...
                                                                                     ^
usb_libusb.c:792:51: warning: passing 'char [512]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
    errcode = libusb_interrupt_transfer(udev, ep, usbbuf, maxsize, &rv, 10000);
                                                  ^~~~~~
/usr/include/libusb.h:549:87: note: passing argument to parameter 'data' here
int     libusb_interrupt_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *trans...
                                                                                          ^
usb_libusb.c:794:46: warning: passing 'char [512]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
    errcode = libusb_bulk_transfer(udev, ep, usbbuf, maxsize, &rv, 10000);
                                             ^~~~~~
/usr/include/libusb.h:548:82: note: passing argument to parameter 'data' here
int     libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferre...
                                                                                     ^
usb_libusb.c:897:57: warning: passing 'char [512]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
      errcode = libusb_bulk_transfer(udev, fd->usb.eep, usbbuf,
                                                        ^~~~~~
/usr/include/libusb.h:548:82: note: passing argument to parameter 'data' here
int     libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferre...
                                                                                     ^
usb_libusb.c:923:64: warning: passing 'char [512]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
        errcode = libusb_interrupt_transfer(udev, fd->usb.rep, usbbuf,
                                                               ^~~~~~
/usr/include/libusb.h:549:87: note: passing argument to parameter 'data' here
int     libusb_interrupt_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *trans...
                                                                                          ^
usb_libusb.c:926:59: warning: passing 'char [512]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
        errcode = libusb_bulk_transfer(udev, fd->usb.rep, usbbuf,
                                                          ^~~~~~
/usr/include/libusb.h:548:82: note: passing argument to parameter 'data' here
int     libusb_bulk_transfer(libusb_device_handle * devh, uint8_t endpoint, uint8_t *data, int length, int *transferre...
                                                                                     ^


So it seems the libusb_has_capability() needs an explicit
probing in configure.ac as it has not always been part of
the libusb-1.0 API.  (Unfortunately, LIBUSB_CAP_HAS_CAPABILITY
is part of an enum rather than a #define, so it cannot be
tested at compile-time.  Seems someone didn't really think
about that detail before.)

The warnings about char vs. uint8_t * can probably safely
be silenced using typecasts.

Joerg Wunsch <joerg_wunsch>
Group administrator
Thu 24 Mar 2016 12:32:46 PM UTC, original submission:  

I tried using an AVRISPmkII in Windows 10 with avrdude 6.3, but libusb couldn't find the device ("avrdude.exe: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)").

Since libusb 0.1 is marked deprecated in cygwin, I installed libusb-1.0 and had a look at usbasp.c, where v1.0 is already in use. I then added support for libusb-1.0 in usb_libusb.c, and expanded the corresponding preprocessor conditions in jtag3.c, jtagmkII.c and stk500v2.c.

After replacing the ATMEL driver of the AVRISP by the WinUSB driver using Zadig avrdude is once more able to flash my AVRs using AVRISPmkII.

I also successfully applied and tested my patch with said AVRISPmkII in a virtual machine running xubuntu 14.04.

Michael Böhme <michaelboehme>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #36745:  libusb.patch added by michaelboehme (23KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by michaelboehme (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-01-21 joerg_wunsch StatusNone Need Info
    2016-03-24 michaelboehme Attached File- Added libusb.patch, #36745

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code