-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PICKit 4, SNAP, Atmel ICE and Power Debugger only work with hidapi but not libusb (low priority) #1221
Comments
Same result under Windows. I built avrdude without hidapi and readline support in this test. I also tried with the default Windows HID driver (libusb-1.0 under Windows supports HID driver), or with WinUSB driver. The results are the same.
|
I'll assume the SNAP is also affected. But how about other, "older" JTAG3 compatible programmers such as the Xplained Mini ATtiny817? |
It seems to work with WinUSB driver. I am using the Xplained Pro Attiny817 for this test.
|
It also works under Linux even though there is a warning.
|
Cool! I think we're on our own though. IIRC, no JTAG3 programmer will work with Microchip Studio if not using the hidapi driver. |
Yes we are on our own as Microchip Studio and MPLAB X use native Windows HID API under Windows and not hidapi/libusb. But I think we should be able to figure out the issue as hidapi-libusb works under Linux -- therefore libusb should also work. MPLAB X under macOS and Linux may use HIDAPI (I need to double check) for HID device. They for sure use libusb-1.0 under macOS and Linux with generic USB devices (not HID devices). And this is not an important issue either as HIDAPI works, so Windows/macOS/Linux all work. FreeBSD should also work. |
BTW, this is not only applicable to UPDI, but also ISP. Tested under Windows with either WinUSB driver.
|
Yes it is also affected.
|
More detailed debug log under Linux.
Debug log for working version with hidapi-libusb.
|
Simple troubleshooting patch (to bypass the first warning and error) does not help too much.
|
Just revisit this issue again. I tested ATmega328pb-xmini with both the defaut HID driver (using hidapi library) or WinUSB driver, both works fine, even though there is a warning for using WinUSB driver (libusb library). There is a warning when using WinUSB/libusb.
No warnings with the default HID driver.
|
Somehow for PICKit 4, the warning becomes an error when using WinUSB driver/libusb. Need to dig further.
|
In any case, this is not of high priority since the interface is an HID interface and we should use HIDAPI anyway and not libusb. |
From hidapi hidtest utility (under Windows, which only generate simulated HID report, I will test under Linux later which will dump the real HID report. Input report size should only be 64 bytes. No idea why
Feed the above through an online HID report parser
|
Under Linux. The HID report will be the correct one. Again input report size should only be 64 bytes. No idea why 912 bytes was there in the libusb output.
HID report patser output
|
Full debug log under Linux using hidapi. Correct run log with hidapi
|
I will need to debug the issue under Linux a bit further. The error output is actually as expected since avrdude did not detach the kernel HID driver, that is why we have the warning like this.
I will try later to manually detach the kernel HID driver. |
The following is the step to manually unbind kernel usbhid driver. Ref: Manual driver binding and unbinding
|
After detaching the kernel usbhid driver, default avrdude build will still work as it is using hidapi-libusb (because of CMake library search order.
Buf if I change the sequence and use hidapi-hidraw, then it will not work with hidapi as the hidraw driver has been detached. Then it will fall back to libusb and it does not work.
|
It is very strange that the code path for the fall-back libusb is different from the normal hidapi code path mentioned above
|
@MCUdude and @stefanrueger |
I am not so sure why we get the following error under libusb. It seems to me wrong packet size is used somehow.
912 comes from the following code in
There is a code when using hidapi which seems to be missing when using libusb. Not so sure if this is the reason.
At least for xplainedpro, I got the following warning.
|
I think we need to set PICKIt4 and SNAP max packet size to 64 to see if that helps. |
@MCUdude and @stefanrueger, I believe I have found the root cause of the issue, however, I do not know how to fix the issue. Just wondering if you can look at my comments above to see if there is a simple fix or not. Thanks. |
Close this one as not planned until someone is actibely working on this issue. This issue is also linked here. |
Please take a look at this issue and my comments to see if you can come out with a patch. Thanks. |
Descriptor when ATMELICE3 is recognized at High-Speed on macos/M1/sonoma14.5
We can see that the "HID Report Descriptor" allows a fixed payload of 512 bytes.
And endpoint 0x01/0x82 allows 512 bytes per communication.
On the other hand, the descriptor for Full-Speed exists as "Other Speed Configuration Descriptor".
In this case, will HID communication be performed using 8 sets of 64 bytes? The "HID Report Descriptor" for Full-Speed is not listed here. You should be able to select/switch which one is active in the "Device Qualifier Descriptor". That means there should be an API somewhere to downgrade/upgrade between High-Speed and Full-Speed, and you should be able to distinguish between them. The Windows API should be able to do it. But I don't know about HIDAPI or libusb. This display is displayed by the usbdiagnose command on macos, but it can be used without privileges, so it's clear that there is an API that can be used with user privileges at the OS level. It's probably not built into HIDAPI for policy reasons. And libusb's descriptor-related API requires privileges, so we can see that there is a problem somewhere in the implementation. |
I do not think you can chage the speed using libusb or hidapi. And for Windows, I do not think it is possible to change the negotiated speed by the OS either. @Youw |
I'm not aware if such method. |
@mcuee So best to close this issue again? |
No, there is a bug here in avrdude abut packet size and we need to fix that. Not able to detect Atmel ICE or Power Debugger when they are not connected to high speed USB is a minor issue which we can live with. |
This is still good to be fixed as hdiapi does not work under NetBSD/OpenBSD. BTW, there is an hidapi enhancement for NetBSD but I have not tested it myself. |
On Ubuntu 24 x86_64 with PICkit 4 doesn't works. Why? Am I forget to edit rules like How to build
Let's try to use pickit4 in avrdude. Why "USB device with VID: 0x03eb and PID: 0x2177 not found"?
But Linux can detect pickit4 as device with VID: 0x03eb and PID: 0x2177
|
From here:
For this test, I build avrdude without hidapi support. And I make sure the hid drver is already detached and then libusb is used.
hidapi version works fine (with hidapi-libusb backend). So there is a bug here in git main.
The text was updated successfully, but these errors were encountered: