Skip to content

Commit

Permalink
PICkit 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
MX682X authored and MX682X committed Aug 2, 2024
1 parent 2089199 commit 88e7856
Show file tree
Hide file tree
Showing 14 changed files with 2,358 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ add_library(libavrdude
pgm_type.c
pickit2.c
pickit2.h
pickit5.c
pickit5.h
pindefs.c
ppi.c
scripts_lut.c
scripts_lut.h
ppi.h
ppiwin.c
serbb.h
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ libavrdude_a_SOURCES = \
pgm_type.c \
pickit2.c \
pickit2.h \
pickit5.c \
pickit5.h \
pindefs.c \
ppi.c \
ppi.h \
Expand All @@ -165,6 +167,8 @@ libavrdude_a_SOURCES = \
ser_posix.c \
ser_win32.c \
serialadapter.c \
scripts_lut.c \
scripts_lut.h \
solaris_ecpp.h \
stk500.c \
stk500.h \
Expand Down
9 changes: 9 additions & 0 deletions src/avr.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,15 @@ int avr_read_mem(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, con
}
}

if (pgm->read_array != NULL) { // if possible, try to read all bytes at once
rc = pgm->read_array(pgm, p, mem, 0, mem->size, mem->buf);
if (rc < 0)
report_progress(1, -1, NULL);
else
report_progress(mem->size, mem->size, NULL);
return rc;
}

for (i=0; i < (unsigned long) mem->size; i++) {
if (vmem == NULL || (vmem->tags[i] & TAG_ALLOCATED) != 0) {
rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i);
Expand Down
40 changes: 40 additions & 0 deletions src/avrdude.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -2993,6 +2993,46 @@ programmer # pickit4_tpi
usbpid = 0x2177, 0x2178, 0x2179;
;


# Microchip PICkit 5. See
# https://www.microchip.com/en-us/development-tool/PG164150
# for details.
#
# Currently, avrdude only supports UPDI Programming
# with the PICkit 5
#
# Interface: Programmer name:
# UPDI pickit5
#
#
# PIN UPDI
# > 1 HVRST
# 2 VCC
# 3 GND
# 4 UPDI
# 5
# 6
# 7
# 8
#

#------------------------------------------------------------
# pickit5
#------------------------------------------------------------

programmer # pickit5
id = "pickit5";
desc = "MPLAB(R) PICkit 5";
type = "pickit5";
prog_modes = PM_UPDI;
extra_features = HAS_VTARG_READ;
connection_type = usb;
usbpid = 0x9035, 0x9036;
baudrate = 200000; # UPDI default clock
;



#------------------------------------------------------------
# snap /snap_jtag
#------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/libavrdude.h
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,8 @@ typedef struct programmer {
int (*read_sig_bytes) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m);
int (*read_sib) (const PROGRAMMER *pgm, const AVRPART *p, char *sib);
int (*read_chip_rev) (const PROGRAMMER *pgm, const AVRPART *p, unsigned char *chip_rev);
int (*write_array) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, int len, unsigned char *value);
int (*read_array) (const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, int len, unsigned char *value);
int (*term_keep_alive)(const PROGRAMMER *pgm, const AVRPART *p);
int (*end_programming)(const PROGRAMMER *pgm, const AVRPART *p);

Expand Down
2 changes: 2 additions & 0 deletions src/pgm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ void pgm_init_functions(PROGRAMMER *pgm) {
pgm->teardown = NULL;
pgm->readonly = NULL;
pgm->flash_readhook = NULL;
pgm->write_array = NULL;
pgm->read_array = NULL;
}


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", 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 88e7856

Please sign in to comment.