avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
734 stars 136 forks source link

Rework HID support for Windows #881

Closed mariusgreuel closed 2 years ago

mariusgreuel commented 2 years ago

@MCUdude noted that the MinGW builds broke recently. Apparently, MinGW started shipping libhid.a (the Window SDK hid.lib equivalent), which enabled the HAVE_LIBHID detection. Another theory is, that libhid.a was present, but CMake did not find it previously.

Whatever the cause, this enabled and broke the PicKit2 programmer, which requires libhid on Windows (as opposed to libhidapi).

For the short-term, we need to adapt the CMake project to include libhid in the list of libraries for the linker.

Long-term, it would probably wise to remove support for libhid altogether and use libhidapi instead. libhidapi is using the libhid internally, and since libhidapi is readily available for all Windows platforms, we do not need the Windows HID library as a fallback.

ser_avrdoper.c is already setup for libhidapi, but pickit2.c relies on libhid on Windows.

Interestingly, CMake seems to have sometimes trouble finding libhid.a. For the MSVC builds, hid.lib is part of the Windows SDK, yet it shows HAVE_LIBHID: HAVE_LIBHID-NOTFOUND in the CI builds. On my machine at home, it says HAVE_LIBHID: C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/um/x64/hid.lib, as one would expect.

mariusgreuel commented 2 years ago

CMake project fixed in e31be88ce06d8011f34b314c2e30618db33045de. I created #883 for the remaining rework.