From: Gerhard Sittig Date: Sat, 26 Feb 2022 10:48:40 +0000 (+0100) Subject: sigrok-cross-mingw: move libusb1 manipulation out of "MXE fixes" X-Git-Url: http://sigrok.org/gitweb/?p=sigrok-util.git;a=commitdiff_plain;h=ca121a83b883db5547108740b875d87a9ad4c92a sigrok-cross-mingw: move libusb1 manipulation out of "MXE fixes" Factor the libusb1 related tweaking out of the "MXE fixes" patch file. It is assumed that binutils and glib issues are rather different from the libusb manipulation. A separate libusb patch also simplifies its maintenance. Add comments discussing how the "event abstraction" branch reference may have become obsolete when libusb1 1.0.24 was released. Which only leaves RAW_IO as an essential motivation for a modified version (which is also being submitted towards mainline libusb). --- diff --git a/cross-compile/mingw/README b/cross-compile/mingw/README index 3d979a8..43d05f2 100644 --- a/cross-compile/mingw/README +++ b/cross-compile/mingw/README @@ -41,6 +41,7 @@ First, get the MXE cross-compile environment for MinGW-w64/Windows: Apply some fixes that are currently required for a proper build: $ patch -p1 < mxe_fixes.patch + $ patch -p1 < libusb1_upgrade.patch Build all required packages: diff --git a/cross-compile/mingw/libusb1_upgrade.patch b/cross-compile/mingw/libusb1_upgrade.patch new file mode 100644 index 0000000..ac350c3 --- /dev/null +++ b/cross-compile/mingw/libusb1_upgrade.patch @@ -0,0 +1,90 @@ +The sigrok build references an older libusb1 library version, which +addresses two specific aspects: + + - Presence of an "event abstraction" is desired. Which once was + available as a branch on top of 1.0.20-rc3, but has gone away + in the meantime and got archived locally. -- Library versions + 1.0.24 and above may provide that feature under the common API + but are yet to get verified. + + - For performance reasons the RAW_IO feature is enabled. libusb1 + mainline may provide such an approach later (automatically, after + checking more conditions for improved reliability), but does not + in versions up to and including 1.0.25 yet. + +Manipulation of the libusb1 configuration in the MXE setup avoids the +necessity for a custom libusb1 build as a step in the sigrok procedure. + +Ideally the sigrok build would use libusb1 version 1.0.25+ to benefit +from the many portability and robustness and feature set improvements. +Regardless of which libusb1 version ships with mainline MXE. That is +why this file is called "libusb1_upgrade.patch". Until then it patches +the local archive of the older library version. + +diff --git a/src/libusb1.mk b/src/libusb1.mk +index ab01bf69..53aed36e 100644 +--- a/src/libusb1.mk ++++ b/src/libusb1.mk +@@ -4,11 +4,11 @@ PKG := libusb1 + $(PKG)_WEBSITE := https://libusb.info/ + $(PKG)_DESCR := LibUsb-1.0 + $(PKG)_IGNORE := +-$(PKG)_VERSION := 1.0.24 +-$(PKG)_CHECKSUM := 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a +-$(PKG)_SUBDIR := libusb-$($(PKG)_VERSION) +-$(PKG)_FILE := libusb-$($(PKG)_VERSION).tar.bz2 +-$(PKG)_URL := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE) ++$(PKG)_VERSION := 1.0.20-rc3-event-abstraction-v4 ++$(PKG)_CHECKSUM := 58fee7f3f05fda209d14c55763df36ab86028bd9ab82c9bb74f1d5ab3208bcfd ++$(PKG)_SUBDIR := libusb-event-abstraction-v4 ++$(PKG)_FILE := libusb-event-abstraction-v4.zip ++$(PKG)_URL := https://github.com/uwehermann/libusb/archive/event-abstraction-v4.zip + $(PKG)_DEPS := cc + + define $(PKG)_UPDATE +@@ -19,7 +19,7 @@ define $(PKG)_UPDATE + endef + + define $(PKG)_BUILD +- cd '$(1)' && ./configure \ ++ cd '$(1)' && autoreconf -i && ./configure \ + $(MXE_CONFIGURE_OPTS) \ + CFLAGS=-D_WIN32_WINNT=0x0500 + $(MAKE) -C '$(1)' -j '$(JOBS)' install +diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch +new file mode 100644 +index 00000000..6cdeb0c4 +--- /dev/null ++++ b/src/libusb1-1-fixes.patch +@@ -0,0 +1,31 @@ ++From d4f7a49d77bd8f4ac871a999fc9ec898cb22b8c3 Mon Sep 17 00:00:00 2001 ++From: Vlad Ivanov ++Date: Tue, 9 Feb 2016 10:35:23 +0300 ++Subject: [PATCH] windows_usb: enable RAW_IO policy by default ++ ++libusb should set RAW_IO policy unconditionally because it ++implements the buffer management itself. ++ ++Signed-off-by: Vlad Ivanov ++--- ++ libusb/os/windows_usb.c | 4 ++++ ++ 1 file changed, 4 insertions(+) ++ ++diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c ++index 6640ad5..12fdab0 100644 ++--- a/libusb/os/windows_usb.c +++++ b/libusb/os/windows_usb.c ++@@ -2890,6 +2890,10 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle ++ AUTO_CLEAR_STALL, sizeof(UCHAR), &policy)) { ++ usbi_dbg("failed to enable AUTO_CLEAR_STALL for endpoint %02X", endpoint_address); ++ } +++ if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, endpoint_address, +++ RAW_IO, sizeof(UCHAR), &policy)) { +++ usbi_dbg("failed to enable RAW_IO for endpoint %02X", endpoint_address); +++ } ++ } ++ ++ return LIBUSB_SUCCESS; ++-- ++2.5.0 ++ diff --git a/cross-compile/mingw/mxe_fixes.patch b/cross-compile/mingw/mxe_fixes.patch index 61df3af..72a4dd0 100644 --- a/cross-compile/mingw/mxe_fixes.patch +++ b/cross-compile/mingw/mxe_fixes.patch @@ -1,11 +1,6 @@ These patches are currently required to get a properly working MXE setup for sigrok usage. - - libsigrok currently requires a special libusb branch. - - - Add an additional libusb RAW_IO patch in MXE directly, which obsoletes - the need to build a custom libusb in sigrok-cross-mingw. - - We're reverting to glib 2.44.1 for now since more recent versions (e.g. 2.50.2) seem to have a bug. Details: https://sigrok.org/bugzilla/show_bug.cgi?id=1232 @@ -18,6 +13,8 @@ MXE setup for sigrok usage. - Bump MXE's binutils to version 2.35, which added -mbig-obj support for 32bit Windows (64bit was supported already). Required for PulseView. +See the other file for a libusb discussion. + diff --git a/src/binutils-1-fixes.patch b/src/binutils-1-fixes.patch deleted file mode 100644 index 357428fe..00000000 @@ -186,73 +183,6 @@ index 9721b581..8eab8bf3 100644 $(PKG)_SUBDIR := binutils-$($(PKG)_VERSION) $(PKG)_FILE := binutils-$($(PKG)_VERSION).tar.bz2 $(PKG)_URL := https://ftp.gnu.org/gnu/binutils/$($(PKG)_FILE) -diff --git a/src/libusb1.mk b/src/libusb1.mk -index ab01bf69..53aed36e 100644 ---- a/src/libusb1.mk -+++ b/src/libusb1.mk -@@ -4,11 +4,11 @@ PKG := libusb1 - $(PKG)_WEBSITE := https://libusb.info/ - $(PKG)_DESCR := LibUsb-1.0 - $(PKG)_IGNORE := --$(PKG)_VERSION := 1.0.24 --$(PKG)_CHECKSUM := 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a --$(PKG)_SUBDIR := libusb-$($(PKG)_VERSION) --$(PKG)_FILE := libusb-$($(PKG)_VERSION).tar.bz2 --$(PKG)_URL := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE) -+$(PKG)_VERSION := 1.0.20-rc3-event-abstraction-v4 -+$(PKG)_CHECKSUM := 58fee7f3f05fda209d14c55763df36ab86028bd9ab82c9bb74f1d5ab3208bcfd -+$(PKG)_SUBDIR := libusb-event-abstraction-v4 -+$(PKG)_FILE := libusb-event-abstraction-v4.zip -+$(PKG)_URL := https://github.com/uwehermann/libusb/archive/event-abstraction-v4.zip - $(PKG)_DEPS := cc - - define $(PKG)_UPDATE -@@ -19,7 +19,7 @@ define $(PKG)_UPDATE - endef - - define $(PKG)_BUILD -- cd '$(1)' && ./configure \ -+ cd '$(1)' && autoreconf -i && ./configure \ - $(MXE_CONFIGURE_OPTS) \ - CFLAGS=-D_WIN32_WINNT=0x0500 - $(MAKE) -C '$(1)' -j '$(JOBS)' install -diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch -new file mode 100644 -index 00000000..6cdeb0c4 ---- /dev/null -+++ b/src/libusb1-1-fixes.patch -@@ -0,0 +1,31 @@ -+From d4f7a49d77bd8f4ac871a999fc9ec898cb22b8c3 Mon Sep 17 00:00:00 2001 -+From: Vlad Ivanov -+Date: Tue, 9 Feb 2016 10:35:23 +0300 -+Subject: [PATCH] windows_usb: enable RAW_IO policy by default -+ -+libusb should set RAW_IO policy unconditionally because it -+implements the buffer management itself. -+ -+Signed-off-by: Vlad Ivanov -+--- -+ libusb/os/windows_usb.c | 4 ++++ -+ 1 file changed, 4 insertions(+) -+ -+diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c -+index 6640ad5..12fdab0 100644 -+--- a/libusb/os/windows_usb.c -++++ b/libusb/os/windows_usb.c -+@@ -2890,6 +2890,10 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle -+ AUTO_CLEAR_STALL, sizeof(UCHAR), &policy)) { -+ usbi_dbg("failed to enable AUTO_CLEAR_STALL for endpoint %02X", endpoint_address); -+ } -++ if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, endpoint_address, -++ RAW_IO, sizeof(UCHAR), &policy)) { -++ usbi_dbg("failed to enable RAW_IO for endpoint %02X", endpoint_address); -++ } -+ } -+ -+ return LIBUSB_SUCCESS; -+-- -+2.5.0 -+ diff --git a/src/glib-1-fixes.patch b/src/glib-1-fixes.patch index 764ece9e..428cc6a9 100644 --- a/src/glib-1-fixes.patch