Skip to content
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

Detect PICkit4 and SNAP in PIC mode #1138

Merged
merged 6 commits into from
Oct 23, 2022

Conversation

MCUdude
Copy link
Collaborator

@MCUdude MCUdude commented Oct 20, 2022

This PR makes it possible for Avrdude to detect a PICkit4 or SNAP programmer in PIC programming mode, and prints a reasonable error that this (currently) has to be changed over to AVR mode using either MPLAB X or Microchip Studio.

Hopefully, @janegilruud will have time to look into #1027 someday, which is the ultimate solution to the entire "PIC programming mode problem". However, this PR makes it obvious to the USER why their brand new PICkit4/SNAP doesn't work as expected.

Avrdude output:

$ ./avrdude -csnap_updi -patmega4808

avrdude warning: MPLAB SNAP in PIC mode detected!
        Use MPLAB X or Microchip Studio to switch to AVR mode

avrdude error: unable to open programmer snap_updi on port usb

avrdude done.  Thank you.

#1027 related

Resolves #1135

@mcuee mcuee added the enhancement New feature or request label Oct 20, 2022
Copy link
Collaborator

@stefanrueger stefanrueger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool PR, thanks for this.

One comment: I am not keen on the open device function to comment failure with the notice2 level in some instances and error in others. IMO this should be either warnings/errors throughout or nothing/notice2 shifting the responsibility to the caller for communication.

https://github.com/avrdudes/avrdude/pull/1138/files#diff-c7816f81017dc84e71af87907727ebcf157b7b206bf75dec9bd0b176e6f5aaa3

Note: there is a pre-existing case (line 97) with return -1 and no message. Whilst looking at this we should probably deal with this case in the same way, too.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Oct 20, 2022

One comment: I am not keen on the open device function to comment failure with the notice2 level in some instances and error in others. IMO this should be either warnings/errors throughout or nothing/notice2 shifting the responsibility to the caller for communication.

Sure! It's just that we don't really need to see that message when not in verbose mode. but msg_warning is probably OK.

Note: there is a pre-existing case (line 97) with return -1 and no message. Whilst looking at this we should probably deal with this case in the same way, too.

I'll look into it. And I'll see if I can replace tabs with spaces in a separate commit. The formatting in usb_hidapi.c is a bit all over the place.

@mcuee
Copy link
Collaborator

mcuee commented Oct 20, 2022

The commit Let Avrdude use the valid SNAP USB PID first is a good one as it will fix #1135:
b083416

The hidapi change Print error message if no HID device is connected when using hidapi is also good to have:
867d83c

@stefanrueger stefanrueger merged commit 4f6bab6 into avrdudes:main Oct 23, 2022
@mcuee
Copy link
Collaborator

mcuee commented Oct 28, 2022

Tested with a PICkit 4 borrowed from local Microchip office.

C:\work\avr\avrdude_test\avrdude_bin> ./avrdude -c pickit4_updi -patmega4808
avrdude warning: USB device with VID: 0x03eb and PID: 0x2177 not found
avrdude warning: USB device with VID: 0x03eb and PID: 0x2178 not found
avrdude warning: USB device with VID: 0x03eb and PID: 0x2179 not found

avrdude error: PICkit4 in PIC mode detected!
        Use MPLAB X or Microchip Studio to switch to AVR mode

avrdude error: unable to open programmer pickit4_updi on port usb

avrdude done.  Thank you.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Oct 28, 2022

Cool! The PR works as it should then 👍

@mcuee
Copy link
Collaborator

mcuee commented Oct 28, 2022

Cool! The PR works as it should then 👍

Yes it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

To supress the warning for Microchip SNAP
3 participants