Skip to content

Commit beaebd9

Browse files
authored
PICkit 5 support (#1863)
1 parent 418e454 commit beaebd9

File tree

12 files changed

+3386
-2
lines changed

12 files changed

+3386
-2
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ set(SOURCES
229229
pgm_type.c
230230
pickit2.c
231231
pickit2.h
232+
pickit5_updi_lut.c
233+
pickit5_lut.h
234+
pickit5.c
235+
pickit5.h
232236
pindefs.c
233237
ppi.c
234238
ppi.h

src/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ libavrdude_la_SOURCES = \
156156
pgm_type.c \
157157
pickit2.c \
158158
pickit2.h \
159+
pickit5_updi_lut.c \
160+
pickit5_lut.h \
161+
pickit5.c \
162+
pickit5.h \
159163
pindefs.c \
160164
ppi.c \
161165
ppi.h \

src/avrdude.conf.in

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,9 +2948,8 @@ programmer # powerdebugger_tpi
29482948
# pickit4 / pickit4_jtag
29492949
#------------------------------------------------------------
29502950

2951-
# Microchip PICkit 4. See
2951+
# Microchip PICkit 4. For details see
29522952
# https://www.microchip.com/en-us/development-tool/pg164140
2953-
# for details.
29542953
#
29552954
# The PICkit 4 supports the following programming modes
29562955
# using different programmer names:
@@ -3055,6 +3054,44 @@ programmer # pickit4_tpi
30553054
usbpid = 0x2177, 0x2178, 0x2179;
30563055
;
30573056

3057+
3058+
# Microchip PICkit 5. For details, see
3059+
# https://www.microchip.com/en-us/development-tool/PG164150
3060+
#
3061+
# Currently -c pickit5 only supports UPDI programming
3062+
#
3063+
# PIN UPDI
3064+
# > 1 !RST(*)
3065+
# 2 VCC
3066+
# 3 GND
3067+
# 4 UPDI(*)
3068+
# 5
3069+
# 6
3070+
# 7
3071+
# 8
3072+
#
3073+
# (*): The PICkit5 can generate a High-Voltage (12V) Pulse on this pins
3074+
# to restore the UPDI Pin functionality, if it was changed through fuses.
3075+
# AVRDUDE automatically selects the correct pin, if the HV pulse is
3076+
# enabled through the '-x hvupdi' flag.
3077+
3078+
#------------------------------------------------------------
3079+
# pickit5 /pickit5_updi
3080+
#------------------------------------------------------------
3081+
3082+
programmer # pickit5_updi
3083+
id = "pickit5_updi";
3084+
desc = "MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC mode)";
3085+
type = "pickit5_updi";
3086+
prog_modes = PM_UPDI;
3087+
extra_features = HAS_VTARG_READ;
3088+
connection_type = usb;
3089+
baudrate = 200000; # UPDI default clock
3090+
usbvid = 0x04d8;
3091+
usbpid = 0x9036, 0x9012, 0x9018; # PK5, PK4 (pic mode), snap (pic mode)
3092+
hvupdi_support = 0, 1, 2;
3093+
;
3094+
30583095
#------------------------------------------------------------
30593096
# snap /snap_jtag
30603097
#------------------------------------------------------------

src/doc/avrdude.texi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ See below for some hints about FLIP version 1 protocol behaviour.
325325
The MPLAB(R) PICkit 4 and MPLAB(R) SNAP are supported in JTAG, TPI, ISP, PDI and UPDI mode.
326326
The Curiosity Nano board is supported in UPDI mode. It is dubbed ``PICkit on
327327
Board'', thus the name @code{pkobn_updi}.
328+
The MPLAB(R) PICkit 5 is currently only supported in UPDI mode.
328329

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

1309+
@cindex Option @code{-x} PICkit 5
1310+
@item PICkit 5
1311+
@item PICkit 4 (PIC Mode)
1312+
1313+
The PICkit 5 and PICkit 4 (PIC Mode) programmer can accept following extended parameters
1314+
@table @code
1315+
@item @samp{vtarg=VALUE}
1316+
Specify a voltage between 1.8 and 5.5@w{ }V that the programmer should supply
1317+
to the target. If there is already a valid voltage applied to the VTG Pin,
1318+
this setting will be ignored. When AVRDUDE detects an external voltage outside
1319+
of this range, it will terminate the operation. You can disable this by
1320+
setting the voltage to 0@w{ }V.
1321+
@item @samp{hvupdi}
1322+
High-voltage UPDI programming is used to enable a UPDI pin that has previously
1323+
been set to RESET or GPIO mode. Use @samp{-x hvupdi} to enable high-voltage UPDI
1324+
initialization for supported targets. Depending on the target, the HV pulse will
1325+
be applied either on the RST pin, or the UPDI pin.
1326+
@item @samp{help}
1327+
Show help menu and exit.
1328+
@end table
1329+
13081330
@cindex Option @code{-x} Xplained Mini
13091331
@item Xplained Mini
13101332

@@ -2220,6 +2242,7 @@ Valid programmers for part AVR32EA32 are:
22202242
jtag2updi = JTAGv2 to UPDI bridge via UPDI
22212243
jtag3updi = Atmel AVR JTAGICE3 via UPDI
22222244
pickit4_updi = MPLAB(R) PICkit 4 via UPDI
2245+
pickit5_updi = MPLAB(R) PICkit 5, PICkit 4 and SNAP (PIC mode) via UPDI
22232246
pkobn_updi = Curiosity nano (nEDBG) via UPDI
22242247
powerdebugger_updi = Atmel PowerDebugger (ARM/AVR) via UPDI
22252248
serialupdi = SerialUPDI via UPDI

src/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,9 @@ int main(int argc, char * argv [])
15451545
else
15461546
imsg_error(" - use -B to set lower the bit clock frequency, e.g. -B 125kHz\n");
15471547

1548+
if (str_starts(pgm->type, "pickit5"))
1549+
imsg_error(" - reset the programmer by unplugging it");
1550+
15481551
if (!ovsigck) {
15491552
imsg_error(" - use -F to override this check\n");
15501553
exitrc = 1;

src/pgm_type.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "micronucleus.h"
4747
#include "par.h"
4848
#include "pickit2.h"
49+
#include "pickit5.h"
4950
#include "ppi.h"
5051
#include "serbb.h"
5152
#include "serialupdi.h"
@@ -99,6 +100,7 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th
99100
{"micronucleus", micronucleus_initpgm, micronucleus_desc}, // "micronucleus" or "Micronucleus V2.0"
100101
{"par", par_initpgm, par_desc}, // "PPI"
101102
{"pickit2", pickit2_initpgm, pickit2_desc}, // "pickit2"
103+
{"pickit5_updi", pickit5_initpgm, pickit5_desc}, // "pickit5"
102104
{"serbb", serbb_initpgm, serbb_desc}, // "SERBB"
103105
{"serialupdi", serialupdi_initpgm, serialupdi_desc}, // "serialupdi"
104106
{"serprog", serprog_initpgm, serprog_desc}, // "serprog"

0 commit comments

Comments
 (0)