134fd36daSMatthias Ringwald# BTstack Port for Windows Systems using the WinUSB Driver 2a1a1af71SMatthias Ringwald 3c7558746SMatthias RingwaldThe Windows-WinUSB port uses the native run loop and WinUSB API to access a USB Bluetooth dongle. 4a1a1af71SMatthias Ringwald 5*98918ebdSMatthias RingwaldThe 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*98918ebdSMatthias Ringwald 73cda7aedSMatthias Ringwald## Access to Bluetooth USB Dongle with Zadig 83cda7aedSMatthias Ringwald 9a1a1af71SMatthias RingwaldTo 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. 10a1a1af71SMatthias Ringwald 11a1a1af71SMatthias RingwaldIt works like this: 123cda7aedSMatthias Ringwald 13c7558746SMatthias Ringwald- Download [Zadig](http://zadig.akeo.ie) 14c7558746SMatthias Ringwald- Start Zadig 15a1a1af71SMatthias Ringwald- Select Options -> “List all devices” 16a1a1af71SMatthias Ringwald- Select USB Bluetooth dongle in the big pull down list 17a1a1af71SMatthias Ringwald- Select WinUSB (libusb) in the right pull pull down list 18a1a1af71SMatthias Ringwald- Select “Replace Driver” 19a1a1af71SMatthias Ringwald 20*98918ebdSMatthias Ringwald## Visual Studio 2022 213cda7aedSMatthias Ringwald 22*98918ebdSMatthias RingwaldVisual Studio can directly open the provided `port/windows-windows-h4-zephyr/CMakeLists.txt` and allows to compile and run all examples. 233cda7aedSMatthias Ringwald 24*98918ebdSMatthias Ringwald## mingw64 25*98918ebdSMatthias Ringwald 26*98918ebdSMatthias RingwaldIt can also be compiles with a regular Unix-style toolchain like [mingw-w64](https://www.mingw-w64.org). 27*98918ebdSMatthias Ringwaldmingw64-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.' 283cda7aedSMatthias Ringwald 29b5674ee2SMatthias RingwaldIn the MSYS2 shell, you can install everything with pacman: 303cda7aedSMatthias Ringwald 313cda7aedSMatthias Ringwald $ pacman -S git 32b5674ee2SMatthias Ringwald $ pacman -S make 33b5674ee2SMatthias Ringwald $ pacman -S mingw-w64-x86_64-toolchain 343cda7aedSMatthias Ringwald $ pacman -S python 355b53c16eSMatthias Ringwald $ pacman -S winpty 363cda7aedSMatthias Ringwald 373cda7aedSMatthias Ringwald## Compilation 383cda7aedSMatthias Ringwald 395b53c16eSMatthias RingwaldWith mingw64-w64 installed, just go to the port/windows-winusb directory and run make 403cda7aedSMatthias Ringwald 413cda7aedSMatthias Ringwald $ cd btstack/port/windows-winusb 423cda7aedSMatthias Ringwald $ make 433cda7aedSMatthias Ringwald 440af1bfd9SMatthias RingwaldNote: When compiling with msys2-32 bit and/or the 32-bit toolchain, compilation fails 450af1bfd9SMatthias Ringwaldas `conio.h` seems to be mission. Please use msys2-64 bit with the 64-bit toolchain for now. 460af1bfd9SMatthias Ringwald 473cda7aedSMatthias Ringwald## Console Output 483cda7aedSMatthias Ringwald 49a1a1af71SMatthias RingwaldWhen 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: 50a1a1af71SMatthias Ringwald 513cda7aedSMatthias Ringwald $ winpty ./spp_and_le_counter.exe 52a1a1af71SMatthias Ringwald 53