TL866/wine
2025-04-18 11:49:57 +03:00
..
build_static.sh Added static libusb build 2025-02-26 10:54:50 +02:00
Makefile Added static libusb build 2025-02-26 10:54:50 +02:00
readme.md Added static libusb build 2025-02-26 10:54:50 +02:00
setupapi.c Fix wrong comments 2025-04-18 11:49:57 +03:00
setupapi.dll Update setupapi.dll 2025-04-16 20:44:36 +03:00
setupapi.spec Update setupapi.dll 2025-04-16 20:44:36 +03:00

Simple low level winelib usb wrapper for the Minipro TL866A/CS, TL866II+, Xgecu T48, T56 and T76 programmers.

Installing the udev rules:

Add the following rules to the udev subsystem:

sudo cp ./udev/* /etc/udev/rules.d/ && sudo udevadm control --reload-rules && sudo udevadm trigger  

This will grant you permission to run the software as regular user, otherwise you must be a superuser.

How to install:

  1. Install wine, libusb and libudev packages
    You should install the 32 bit version of LibUsb and libudev and create a 32 bit wine prefix:
sudo apt install libusb-1.0-0:i386 libudev1:i386   
WINEPREFIX="$HOME/wine32" WINEARCH=win32 wine wineboot      
  1. Copy the provided setupapi.dll file in the Minipro or Xgpro folder

  2. Run the Minipro.exe, Xgpro.exe or Xgpro_T76.exe using wine:

WINEPREFIX="$HOME/wine32" wine ./Xgpro.exe 2>/dev/null

If you already have a default 32 bit wine prefix located in $HOME/.wine you can use it without creating a new one:

wine ./Xgpro.exe 2>/dev/null    

How to compile:

  1. Install wine, wine-devel, libusb-1.0-0-dev:i386, libudev-dev:i386 packages

  2. Run make to compile the setupapi.dll using libusb library for hotplug events. You can also use libudev to compile the setupapi.dll using libudev library for handling hotplug events which can
    be useful if libusb hotplug events arenot available in your OS by running make hotplug=udev

  3. Copy the resulted setupapi.dll file in the Minipro/Xgpro folder

Debugging:

Running this in a terminal session:

TL_DEBUG=1 wine ./Xgpro.exe or TL_DEBUG=1 wine ./Xgpro.exe 2>/dev/null

will dump all usb communication to the console which can be very useful when something goes wrong.
The 2>/dev/null will redirect the stderr to /dev/null thus cancelling the wine debugging messages which can be
very annoying sometime.

You can also use gdb GNU debugger for debugging:

WINEDEBUG=fixme-all,-ALL WINELOADERNOEXEC=1 gdb -q --args wine ./Xgpro.exe
(gdb) run

Issues on some Linux distros

Some Linux distros will compile its system libraries with SSE instruction set enabled to increase the performance.
This is a good thing but, using a Libusb compiled with SSE will crash our wine wrapper library because the SSE intruction
set requires the memory address to be 16-byte aligned and, our setupapi.dll uses 4 bytes stack alignment because
the 32bit Windows software is also using this 4 byte alignment. See issue #51.

This is the case for Arch/ManjaroGentoo and its derivatives and perhaps other distros i have not tested yet.
In this case we must compile our Libusb and use it to link the setupapi.dll against it.

This is for Arch/Manjaro users, Gentoo users please adapt the needed packages as i don't test it in Gentoo.

First install the necessary tools:

sudo pacman -S autoconf automake libtool git base-devel lib32-libusb

Then grab these git repos:

mkdir build_temp && cd build_temp
git clone https://github.com/radiomanV/TL866.git && cd TL866/wine
git clone https://github.com/libusb/libusb.git && cd libusb

Now configure and build the static 32bit libUsb:

./bootstrap.sh  && ./configure CFLAGS="-m32 -mstackrealign -fPIC" --prefix="$(dirname "$(pwd)")" --disable-shared && make install && cd ../

And finally (assuming the wine is installed) compile our setupapi.dll against the static LibUsb:

make CFLAGS="-Iinclude/ -m32 -mstackrealign" LIBS="-Wl,--whole-archive lib/libusb-1.0.a -Wl,--no-whole-archive -ludev"

You can automate this by using the accompanying build_static.sh script
which will invoke all above commands and build the statically linked setupapi.dll

./build_static.sh

If all was okay we should have the setupapi.dll in the current directory.
You can always download the already compiled setupapi.dll from this git repository, but sometimes depending on your Linux distro
and glib version it will not work and you must recompile it.