1# BTstack Port for Windows Systems using the WinUSB Driver 2 3The Windows-WinUSB port uses the native run loop and WinUSB API to access a USB Bluetooth dongle. 4 5The port provides both a regular Makefile as well as a CMake build file. It uses native Win32 APIs for file access and does not require the Cygwin or mingw64 build/runtine. All examples can also be build with Visual Studio 2022 (e.g. Community Edition). 6 7## Access to Bluetooth USB Dongle with Zadig 8 9To allow libusb or WinUSB to access an USB Bluetooth dongle, you need to install a special device driver to make it accessible to user space processes. 10 11It works like this: 12 13- Download [Zadig](http://zadig.akeo.ie) 14- Start Zadig 15- Select Options -> “List all devices” 16- Select USB Bluetooth dongle in the big pull down list 17- Select WinUSB (libusb) in the right pull pull down list 18- Select “Replace Driver” 19 20## Visual Studio 2022 21 22Visual Studio can directly open the provided `port/windows-windows-h4-zephyr/CMakeLists.txt` and allows to compile and run all examples. 23 24## mingw64 25 26It can also be compiles with a regular Unix-style toolchain like [mingw-w64](https://www.mingw-w64.org). 27mingw64-w64 is based on [MinGW](https://en.wikipedia.org/wiki/MinGW), which '...provides a complete Open Source programming tool set which is suitable for the development of native MS-Windows applications, and which do not depend on any 3rd-party C-Runtime DLLs.' 28 29In the MSYS2 shell, you can install everything with pacman: 30 31 $ pacman -S git 32 $ pacman -S make 33 $ pacman -S mingw-w64-x86_64-toolchain 34 $ pacman -S python 35 $ pacman -S winpty 36 37## Compilation 38 39With mingw64-w64 installed, just go to the port/windows-winusb directory and run make 40 41 $ cd btstack/port/windows-winusb 42 $ make 43 44Note: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails 45as `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now. 46 47## Console Output 48 49When running the examples in the MSYS2 shell, the console input (via btstack_stdin_support) doesn't work. It works in the older MSYS and also the regular CMD.exe environment. Another option is to install WinPTY and then start the example via WinPTY like this: 50 51 $ winpty ./spp_and_le_counter.exe 52 53