Skip to content

Commit

Permalink
PICkit 5 support (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
MX682X authored Aug 14, 2024
1 parent 418e454 commit beaebd9
Show file tree
Hide file tree
Showing 12 changed files with 3,386 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ set(SOURCES
pgm_type.c
pickit2.c
pickit2.h
pickit5_updi_lut.c
pickit5_lut.h
pickit5.c
pickit5.h
pindefs.c
ppi.c
ppi.h
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ libavrdude_la_SOURCES = \
pgm_type.c \
pickit2.c \
pickit2.h \
pickit5_updi_lut.c \
pickit5_lut.h \
pickit5.c \
pickit5.h \
pindefs.c \
ppi.c \
ppi.h \
Expand Down
41 changes: 39 additions & 2 deletions src/avrdude.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -2948,9 +2948,8 @@ programmer # powerdebugger_tpi
# pickit4 / pickit4_jtag
#------------------------------------------------------------

# Microchip PICkit 4. See
# Microchip PICkit 4. For details see
# https://www.microchip.com/en-us/development-tool/pg164140
# for details.
#
# The PICkit 4 supports the following programming modes
# using different programmer names:
Expand Down Expand Up @@ -3055,6 +3054,44 @@ programmer # pickit4_tpi
usbpid = 0x2177, 0x2178, 0x2179;
;


# Microchip PICkit 5. For details, see
# https://www.microchip.com/en-us/development-tool/PG164150
#
# Currently -c pickit5 only supports UPDI programming
#
# PIN UPDI
# > 1 !RST(*)
# 2 VCC
# 3 GND
# 4 UPDI(*)
# 5
# 6
# 7
# 8
#
# (*): The PICkit5 can generate a High-Voltage (12V) Pulse on this pins
# to restore the UPDI Pin functionality, if it was changed through fuses.
# AVRDUDE automatically selects the correct pin, if the HV pulse is
# enabled through the '-x hvupdi' flag.

#------------------------------------------------------------
# pickit5 /pickit5_updi
#------------------------------------------------------------

programmer # pickit5_updi
id = "pickit5_updi";
desc = "MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC mode)";
type = "pickit5_updi";
prog_modes = PM_UPDI;
extra_features = HAS_VTARG_READ;
connection_type = usb;
baudrate = 200000; # UPDI default clock
usbvid = 0x04d8;
usbpid = 0x9036, 0x9012, 0x9018; # PK5, PK4 (pic mode), snap (pic mode)
hvupdi_support = 0, 1, 2;
;

#------------------------------------------------------------
# snap /snap_jtag
#------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions src/doc/avrdude.texi
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ See below for some hints about FLIP version 1 protocol behaviour.
The MPLAB(R) PICkit 4 and MPLAB(R) SNAP are supported in JTAG, TPI, ISP, PDI and UPDI mode.
The Curiosity Nano board is supported in UPDI mode. It is dubbed ``PICkit on
Board'', thus the name @code{pkobn_updi}.
The MPLAB(R) PICkit 5 is currently only supported in UPDI mode.

SerialUPDI programmer implementation is based on Microchip's
@emph{pymcuprog} (@url{https://github.com/microchip-pic-avr-tools/pymcuprog})
Expand Down Expand Up @@ -1305,6 +1306,27 @@ for switching to PIC mode.
Show help menu and exit.
@end table

@cindex Option @code{-x} PICkit 5
@item PICkit 5
@item PICkit 4 (PIC Mode)

The PICkit 5 and PICkit 4 (PIC Mode) programmer can accept following extended parameters
@table @code
@item @samp{vtarg=VALUE}
Specify a voltage between 1.8 and 5.5@w{ }V that the programmer should supply
to the target. If there is already a valid voltage applied to the VTG Pin,
this setting will be ignored. When AVRDUDE detects an external voltage outside
of this range, it will terminate the operation. You can disable this by
setting the voltage to 0@w{ }V.
@item @samp{hvupdi}
High-voltage UPDI programming is used to enable a UPDI pin that has previously
been set to RESET or GPIO mode. Use @samp{-x hvupdi} to enable high-voltage UPDI
initialization for supported targets. Depending on the target, the HV pulse will
be applied either on the RST pin, or the UPDI pin.
@item @samp{help}
Show help menu and exit.
@end table

@cindex Option @code{-x} Xplained Mini
@item Xplained Mini

Expand Down Expand Up @@ -2220,6 +2242,7 @@ Valid programmers for part AVR32EA32 are:
jtag2updi = JTAGv2 to UPDI bridge via UPDI
jtag3updi = Atmel AVR JTAGICE3 via UPDI
pickit4_updi = MPLAB(R) PICkit 4 via UPDI
pickit5_updi = MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC mode) via UPDI
pkobn_updi = Curiosity nano (nEDBG) via UPDI
powerdebugger_updi = Atmel PowerDebugger (ARM/AVR) via UPDI
serialupdi = SerialUPDI via UPDI
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ int main(int argc, char * argv [])
else
imsg_error(" - use -B to set lower the bit clock frequency, e.g. -B 125kHz\n");

if (str_starts(pgm->type, "pickit5"))
imsg_error(" - reset the programmer by unplugging it");

if (!ovsigck) {
imsg_error(" - use -F to override this check\n");
exitrc = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/pgm_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "micronucleus.h"
#include "par.h"
#include "pickit2.h"
#include "pickit5.h"
#include "ppi.h"
#include "serbb.h"
#include "serialupdi.h"
Expand Down Expand Up @@ -99,6 +100,7 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th
{"micronucleus", micronucleus_initpgm, micronucleus_desc}, // "micronucleus" or "Micronucleus V2.0"
{"par", par_initpgm, par_desc}, // "PPI"
{"pickit2", pickit2_initpgm, pickit2_desc}, // "pickit2"
{"pickit5_updi", pickit5_initpgm, pickit5_desc}, // "pickit5"
{"serbb", serbb_initpgm, serbb_desc}, // "SERBB"
{"serialupdi", serialupdi_initpgm, serialupdi_desc}, // "serialupdi"
{"serprog", serprog_initpgm, serprog_desc}, // "serprog"
Expand Down
Loading

0 comments on commit beaebd9

Please sign in to comment.