Use -xmode to switch PICkit4 and SNAP application modes (#1596)

* Use libusb to switch a PICkit4 or SNAP to AVR mode

* Fix case

* implement -xmode=pic
Thanks Wireshark

* Print PIC switch info messages

* Fix typo

* Rename SNAP and PICkit4 USB PID

* Make it possible to enter avr mode even when the tool is in bootloader/recovery mode

* Add -xmode to docs

* Tweak grammar

* Add -xmode support for pickit4_isp and snap_isp
still need to figure out how to actually trigger the mode switch form stk500v2.c

* Don't print "unable to open port" error on pgm->open softfail

* Add const

* Simplify SNAP/PICkit4 mode switching code

* Formatting

* Add extra argument to jtag3_open_common
This makes it possible to switch SNAP/PK4 modes from stk500v2.c as well, using pickit4_isp and snap_isp

* Improve extended parameter parsing

* Improve error message

* Improve extended parameter parsing

* Immediately exit after a mode switch

* Remove unnecessary line

* Add missing serial_close

* Remove unnecessary else

* Minor code tweaks

* Update docs

* Formatting

* Improve external parameter parsing and error handling

* Remove unused parameter
This commit is contained in:
Hans
2024-01-03 14:02:24 +01:00
committed by GitHub
parent 06156d9c33
commit a245cd5370
9 changed files with 259 additions and 107 deletions

View File

@@ -41,10 +41,10 @@
#define USB_DEVICE_PKOBN 0x2175
#define USB_DEVICE_PICKIT4_AVR_MODE 0x2177
#define USB_DEVICE_PICKIT4_PIC_MODE 0x9012
#define USB_DEVICE_PICKIT4_PIC_MODE_ALT 0x9017
#define USB_DEVICE_PICKIT4_PIC_MODE_BL 0x9017 // PICkit4 in bootloader mode
#define USB_DEVICE_SNAP_AVR_MODE 0x2180
#define USB_DEVICE_SNAP_PIC_MODE 0x9018
#define USB_DEVICE_SNAP_PIC_MODE_ALT 0x9019
#define USB_DEVICE_SNAP_PIC_MODE_BL 0x9019 // SNAP in bootloader mode
#define USB_VENDOR_FTDI 0x0403
#define USB_DEVICE_FT2232 0x6010