avrdude icon indicating copy to clipboard operation
avrdude copied to clipboard

Rework PicKit2 programmer to use libhidapi instead of libhid

Open mariusgreuel opened this issue 4 years ago • 4 comments

Assuming the PicKit2 programmer is a HID device, I suggest to rework the code to use libhidapi, which is available on all platforms. Then we can drop the remaining libhid support for Windows, including the CMake/Automake support.

#882 already removed libhid support for ser_avrdoper, so the pickit.c code is the last one to reference libhid.

mariusgreuel avatar Feb 18 '22 19:02 mariusgreuel

This will be great.

We at libusb project recommend to use hidapi for HID device.

Impact of this issue -- PICKit 2 is not supported under macOS, as there is no easy way to detach the kernel HID driver.

mcuee avatar May 08 '22 13:05 mcuee

PICKit 2 is an HID device and for sure hidapi is the right cross-platform library to use. Unfortunately I am not not programmer, but at least I can help testing if someone works on this.

mcuee avatar May 09 '22 12:05 mcuee

Not so sure if the following enhancement patch can be of some reference value here.

  • https://github.com/avrdudes/avrdude/issues/692

mcprog uses the MCP2210 USB-to-SPI interface. This code was successfully tested on Linux and MAC.

The patch started as a copy of the pickit2 code already shipped with avrdude, but as the libusb backend seems to be dysfunctional on MAC for quite some time, I replaced libusb by libhidapi.

mcuee avatar Jun 22 '22 11:06 mcuee

+1!

I was thinking I could help out with #1004, but my PICkit2 doesn't work with MacOS + Avrdude:

$ sudo ./avrdude -cpickit2 -patmega328p
Password:
Could not claim interface. Error code -13, Permission denied
You may need to run avrdude as root or set up correct usb port permissions.
pickit2_write_report failed (ec -2). No such file or directory
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

I'm not capable of doing this job by myself, but I can help out with testing if somebody is ready for a task like this!

MCUdude avatar Jul 07 '22 08:07 MCUdude

Related request after this is done.

  • https://github.com/avrdudes/avrdude/issues/958

mcuee avatar Mar 11 '23 11:03 mcuee

Close this one as not planned until someone is actibely working on this issue.

This issue is also linked here. https://github.com/avrdudes/avrdude/discussions/1710

mcuee avatar Mar 03 '24 04:03 mcuee