mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 15:27:53 +00:00
Merge pull request #331 from denis2342/master
updated the pkg-config patches, now with mingw support and tested
This commit is contained in:
commit
833ecf9b28
29
configure.ac
29
configure.ac
@ -343,16 +343,29 @@ if test "x$bitforce$modminer" != xnono; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
|
AM_CONDITIONAL([HAVE_LIBUDEV], [test x$libudev != xno])
|
||||||
|
|
||||||
if test "x$ztex" != xno; then
|
|
||||||
AC_CHECK_LIB(usb-1.0, libusb_init, ,
|
|
||||||
AC_MSG_ERROR([Could not find usb library - please install libusb]))
|
|
||||||
AC_DEFINE([HAVE_LIBUSB], [1], [Defined to 1 if libusb is wanted])
|
|
||||||
USB_LIBS="-lusb-1.0"
|
|
||||||
USB_FLAGS=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
PKG_PROG_PKG_CONFIG()
|
PKG_PROG_PKG_CONFIG()
|
||||||
|
|
||||||
|
if test "x$ztex" != xno; then
|
||||||
|
case $target in
|
||||||
|
*-*-mingw*)
|
||||||
|
# workaround for libusbx windows binaries not including a .pc file
|
||||||
|
LIBUSB_LIBS="-LC:/MinGW/lib -lusb-1.0"
|
||||||
|
LIBUSB_CFLAGS="-IC:/MinGW/include/libusb-1.0"
|
||||||
|
AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0])
|
||||||
|
;;
|
||||||
|
*-*-freebsd*)
|
||||||
|
LIBUSB_LIBS="-lusb"
|
||||||
|
LIBUSB_CFLAGS=""
|
||||||
|
AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
PKG_CHECK_MODULES(LIBUSB, libusb-1.0, [AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0])], [AC_MSG_ERROR([Could not find usb library - please install libusb-1.0])])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
USB_LIBS="$LIBUSB_LIBS"
|
||||||
|
USB_FLAGS="$LIBUSB_CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
|
PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.18.2], ,[AC_MSG_ERROR([Missing required libcurl dev >= 7.18.2])])
|
||||||
AC_SUBST(LIBCURL_LIBS)
|
AC_SUBST(LIBCURL_LIBS)
|
||||||
|
|
||||||
|
32
libztex.c
32
libztex.c
@ -409,6 +409,7 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
|
|||||||
struct libztex_device *newdev;
|
struct libztex_device *newdev;
|
||||||
int i, cnt, err;
|
int i, cnt, err;
|
||||||
unsigned char buf[64];
|
unsigned char buf[64];
|
||||||
|
uint16_t langid;
|
||||||
|
|
||||||
newdev = malloc(sizeof(struct libztex_device));
|
newdev = malloc(sizeof(struct libztex_device));
|
||||||
newdev->bitFileName = NULL;
|
newdev->bitFileName = NULL;
|
||||||
@ -436,13 +437,40 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = libusb_get_string_descriptor_ascii (newdev->hndl, newdev->descriptor.iSerialNumber, newdev->snString,
|
/* We open code string descriptor retrieval and ASCII decoding here
|
||||||
LIBZTEX_SNSTRING_LEN + 1);
|
* in order to work around that libusb_get_string_descriptor_ascii()
|
||||||
|
* in the FreeBSD libusb implementation hits a bug in ZTEX firmware,
|
||||||
|
* where the device returns more bytes than requested, causing babble,
|
||||||
|
* which makes FreeBSD return an error to us.
|
||||||
|
*
|
||||||
|
* Avoid the mess by doing it manually the same way as libusb-1.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
cnt = libusb_control_transfer(newdev->hndl, LIBUSB_ENDPOINT_IN,
|
||||||
|
LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | 0,
|
||||||
|
0x0000, buf, sizeof(buf), 1000);
|
||||||
|
if (unlikely(cnt < 0)) {
|
||||||
|
applog(LOG_ERR, "Ztex check device: Failed to read device LANGIDs with err %d", cnt);
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
langid = libusb_le16_to_cpu(((uint16_t *)buf)[1]);
|
||||||
|
|
||||||
|
cnt = libusb_control_transfer(newdev->hndl, LIBUSB_ENDPOINT_IN,
|
||||||
|
LIBUSB_REQUEST_GET_DESCRIPTOR,
|
||||||
|
(LIBUSB_DT_STRING << 8) | newdev->descriptor.iSerialNumber,
|
||||||
|
langid, buf, sizeof(buf), 1000);
|
||||||
if (unlikely(cnt < 0)) {
|
if (unlikely(cnt < 0)) {
|
||||||
applog(LOG_ERR, "Ztex check device: Failed to read device snString with err %d", cnt);
|
applog(LOG_ERR, "Ztex check device: Failed to read device snString with err %d", cnt);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* num chars = (all bytes except bLength and bDescriptorType) / 2 */
|
||||||
|
for (i = 0; i <= (cnt - 2) / 2 && i < sizeof(newdev->snString)-1; i++)
|
||||||
|
newdev->snString[i] = buf[2 + i*2];
|
||||||
|
|
||||||
|
newdev->snString[i] = 0;
|
||||||
|
|
||||||
cnt = libusb_control_transfer(newdev->hndl, 0xc0, 0x22, 0, 0, buf, 40, 500);
|
cnt = libusb_control_transfer(newdev->hndl, 0xc0, 0x22, 0, 0, buf, 40, 500);
|
||||||
if (unlikely(cnt < 0)) {
|
if (unlikely(cnt < 0)) {
|
||||||
applog(LOG_ERR, "Ztex check device: Failed to read ztex descriptor with err %d", cnt);
|
applog(LOG_ERR, "Ztex check device: Failed to read ztex descriptor with err %d", cnt);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef __LIBZTEX_H__
|
#ifndef __LIBZTEX_H__
|
||||||
#define __LIBZTEX_H__
|
#define __LIBZTEX_H__
|
||||||
|
|
||||||
#include <libusb-1.0/libusb.h>
|
#include <libusb.h>
|
||||||
|
|
||||||
#define LIBZTEX_MAX_DESCRIPTORS 512
|
#define LIBZTEX_MAX_DESCRIPTORS 512
|
||||||
#define LIBZTEX_SNSTRING_LEN 10
|
#define LIBZTEX_SNSTRING_LEN 10
|
||||||
|
Loading…
Reference in New Issue
Block a user