Merge pull request #1205 from janegilruud/jtag3-tpi-jer
Added TPI support for Microchip tools
This commit is contained in:
commit
9bd4dee254
|
@ -372,6 +372,9 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
AVRMEM *mem = mems[i].mem;
|
||||
AVR_Cache *cp = mems[i].cp;
|
||||
|
||||
if(!mem)
|
||||
continue;
|
||||
|
||||
if(!cp->cont) // Ensure cache is initialised from now on
|
||||
if(initCache(cp, pgm, p) < 0) {
|
||||
if(quell_progress)
|
||||
|
@ -380,7 +383,7 @@ int avr_flush_cache(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return LIBAVRDUDE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
if(chiperase || !mem || mems[i].zopaddr < 0)
|
||||
if(chiperase || mems[i].zopaddr < 0)
|
||||
continue;
|
||||
|
||||
int n=mems[i].zopaddr;
|
||||
|
|
|
@ -2131,6 +2131,19 @@ programmer
|
|||
hvupdi_support = 1;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# xplainedmini_tpi
|
||||
#------------------------------------------------------------
|
||||
|
||||
programmer
|
||||
id = "xplainedmini_tpi";
|
||||
desc = "Atmel AVR XplainedMini in TPI mode";
|
||||
type = "jtagice3_tpi";
|
||||
prog_modes = PM_TPI;
|
||||
connection_type = usb;
|
||||
usbpid = 0x2145;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# atmelice
|
||||
#------------------------------------------------------------
|
||||
|
@ -2197,6 +2210,19 @@ programmer
|
|||
usbpid = 0x2141;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# atmelice_tpi
|
||||
#------------------------------------------------------------
|
||||
|
||||
programmer
|
||||
id = "atmelice_tpi";
|
||||
desc = "Atmel-ICE (ARM/AVR) in TPI mode";
|
||||
type = "jtagice3_tpi";
|
||||
prog_modes = PM_TPI;
|
||||
connection_type = usb;
|
||||
usbpid = 0x2141;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# powerdebugger
|
||||
#------------------------------------------------------------
|
||||
|
@ -2263,6 +2289,19 @@ programmer
|
|||
usbpid = 0x2144;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# powerdebugger_tpi
|
||||
#------------------------------------------------------------
|
||||
|
||||
programmer
|
||||
id = "powerdebugger_tpi";
|
||||
desc = "Atmel PowerDebugger (ARM/AVR) in TPI mode";
|
||||
type = "jtagice3_tpi";
|
||||
prog_modes = PM_TPI;
|
||||
connection_type = usb;
|
||||
usbpid = 0x2144;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# pickit4_updi
|
||||
#------------------------------------------------------------
|
||||
|
@ -2303,6 +2342,19 @@ programmer
|
|||
usbpid = 0x2177, 0x2178, 0x2179;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# pickit4_tpi
|
||||
#------------------------------------------------------------
|
||||
|
||||
programmer
|
||||
id = "pickit4_tpi";
|
||||
desc = "MPLAB(R) PICkit 4 in TPI mode";
|
||||
type = "jtagice3_tpi";
|
||||
prog_modes = PM_TPI;
|
||||
connection_type = usb;
|
||||
usbpid = 0x2177, 0x2178, 0x2179;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# snap_updi
|
||||
#------------------------------------------------------------
|
||||
|
@ -2343,6 +2395,19 @@ programmer
|
|||
usbpid = 0x2180, 0x217f, 0x2181;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# snap_tpi
|
||||
#------------------------------------------------------------
|
||||
|
||||
programmer
|
||||
id = "snap_tpi";
|
||||
desc = "MPLAB(R) SNAP in TPI mode";
|
||||
type = "jtagice3_tpi";
|
||||
prog_modes = PM_TPI;
|
||||
connection_type = usb;
|
||||
usbpid = 0x2180, 0x217f, 0x2181;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
# pkobn_updi
|
||||
#------------------------------------------------------------
|
||||
|
@ -13440,12 +13505,6 @@ part
|
|||
offset = 0x3f00;
|
||||
;
|
||||
|
||||
memory "lockbits"
|
||||
size = 1;
|
||||
page_size = 16;
|
||||
offset = 0x3f00;
|
||||
;
|
||||
|
||||
memory "signature"
|
||||
size = 3;
|
||||
page_size = 16;
|
||||
|
@ -13539,6 +13598,14 @@ part parent ".reduced_core_tiny"
|
|||
offset = 0x4000;
|
||||
blocksize = 128;
|
||||
;
|
||||
|
||||
memory "fuse"
|
||||
size = 1;
|
||||
page_size = 16;
|
||||
n_word_writes = 2;
|
||||
offset = 0x3f40;
|
||||
blocksize = 4;
|
||||
;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
|
@ -13559,6 +13626,14 @@ part parent ".reduced_core_tiny"
|
|||
offset = 0x4000;
|
||||
blocksize = 128;
|
||||
;
|
||||
|
||||
memory "fuse"
|
||||
size = 1;
|
||||
page_size = 16;
|
||||
n_word_writes = 4;
|
||||
offset = 0x3f40;
|
||||
blocksize = 4;
|
||||
;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
|
@ -13578,6 +13653,12 @@ part parent ".reduced_core_tiny"
|
|||
offset = 0x4000;
|
||||
blocksize = 128;
|
||||
;
|
||||
|
||||
memory "sigrow"
|
||||
size = 16;
|
||||
page_size = 16;
|
||||
offset = 0x3fc6;
|
||||
;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
|
@ -13597,6 +13678,12 @@ part parent ".reduced_core_tiny"
|
|||
offset = 0x4000;
|
||||
blocksize = 128;
|
||||
;
|
||||
|
||||
memory "sigrow"
|
||||
size = 16;
|
||||
page_size = 16;
|
||||
offset = 0x3fc6;
|
||||
;
|
||||
;
|
||||
|
||||
#------------------------------------------------------------
|
||||
|
|
1024
src/jtag3.c
1024
src/jtag3.c
File diff suppressed because it is too large
Load Diff
12
src/jtag3.h
12
src/jtag3.h
|
@ -31,23 +31,25 @@ int jtag3_recv(const PROGRAMMER *pgm, unsigned char **msg);
|
|||
void jtag3_close(PROGRAMMER * pgm);
|
||||
int jtag3_getsync(const PROGRAMMER *pgm, int mode);
|
||||
int jtag3_getparm(const PROGRAMMER *pgm, unsigned char scope,
|
||||
unsigned char section, unsigned char parm,
|
||||
unsigned char *value, unsigned char length);
|
||||
unsigned char section, unsigned char parm,
|
||||
unsigned char *value, unsigned char length);
|
||||
int jtag3_setparm(const PROGRAMMER *pgm, unsigned char scope,
|
||||
unsigned char section, unsigned char parm,
|
||||
unsigned char *value, unsigned char length);
|
||||
unsigned char section, unsigned char parm,
|
||||
unsigned char *value, unsigned char length);
|
||||
int jtag3_command(const PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen,
|
||||
unsigned char **resp, const char *descr);
|
||||
unsigned char **resp, const char *descr);
|
||||
void jtag3_print_parms1(const PROGRAMMER *pgm, const char *p, FILE *fp);
|
||||
int jtag3_set_vtarget(const PROGRAMMER *pgm, double voltage);
|
||||
extern const char jtag3_desc[];
|
||||
extern const char jtag3_dw_desc[];
|
||||
extern const char jtag3_pdi_desc[];
|
||||
extern const char jtag3_updi_desc[];
|
||||
extern const char jtag3_tpi_desc[];
|
||||
void jtag3_initpgm(PROGRAMMER *pgm);
|
||||
void jtag3_dw_initpgm(PROGRAMMER *pgm);
|
||||
void jtag3_pdi_initpgm(PROGRAMMER *pgm);
|
||||
void jtag3_updi_initpgm(PROGRAMMER *pgm);
|
||||
void jtag3_tpi_initpgm(PROGRAMMER *pgm);
|
||||
|
||||
/*
|
||||
* These functions are referenced from stk500v2.c for JTAGICE3 in
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
#define SCOPE_GENERAL 0x01
|
||||
#define SCOPE_AVR_ISP 0x11
|
||||
#define SCOPE_AVR 0x12
|
||||
#define SCOPE_AVR_TPI 0x14
|
||||
|
||||
/* Info scope */
|
||||
#define CMD3_GET_INFO 0x00
|
||||
|
@ -314,6 +315,60 @@
|
|||
#define UPDI_ADDRESS_MODE_24BIT 1
|
||||
#define FUSES_SYSCFG0_OFFSET 5
|
||||
|
||||
// TPI Protocol commands
|
||||
#define XPRG_CMD_ENTER_PROGMODE 0x01
|
||||
#define XPRG_CMD_LEAVE_PROGMODE 0x02
|
||||
#define XPRG_CMD_ERASE 0x03
|
||||
#define XPRG_CMD_WRITE_MEM 0x04
|
||||
#define XPRG_CMD_READ_MEM 0x05
|
||||
#define XPRG_CMD_CRC 0x06
|
||||
#define XPRG_CMD_SET_PARAM 0x07
|
||||
|
||||
// TPI Protocol responses
|
||||
// Success
|
||||
#define XPRG_ERR_OK 0x00
|
||||
// Errors
|
||||
#define XPRG_ERR_FAILED 0x01
|
||||
#define XPRG_ERR_COLLISION 0x02
|
||||
#define XPRG_ERR_TIMEOUT 0x03
|
||||
#define XPRG_ERR_ILLEGAL_PARAM 0x04
|
||||
#define XPRG_ERR_UNKNOWN_COMMAND 0x10
|
||||
|
||||
// TPI Memory types
|
||||
#define XPRG_MEM_TYPE_APPL 0x01
|
||||
#define XPRG_MEM_TYPE_BOOT 0x02
|
||||
#define XPRG_MEM_TYPE_EEPROM 0x03
|
||||
#define XPRG_MEM_TYPE_FUSE 0x04
|
||||
#define XPRG_MEM_TYPE_LOCKBITS 0x05
|
||||
#define XPRG_MEM_TYPE_USERSIG 0x06
|
||||
#define XPRG_MEM_TYPE_FACTORY_CALIBRATION 0x07
|
||||
|
||||
// TPI Erase modes
|
||||
#define XPRG_ERASE_CHIP 0x01
|
||||
#define XPRG_ERASE_APP 0x02
|
||||
#define XPRG_ERASE_BOOT 0x03
|
||||
#define XPRG_ERASE_EEPROM 0x04
|
||||
#define XPRG_ERASE_APP_PAGE 0x05
|
||||
#define XPRG_ERASE_BOOT_PAGE 0x06
|
||||
#define XPRG_ERASE_EEPROM_PAGE 0x07
|
||||
#define XPRG_ERASE_USERSIG 0x08
|
||||
// Erase types for Tiny XPROG
|
||||
#define XPRG_ERASE_CONFIG 0x09
|
||||
|
||||
// TPI Parameters
|
||||
// XPROG parameters of different sizes
|
||||
// 4-byte address
|
||||
#define XPRG_PARAM_NVMBASE 0x01
|
||||
// 2-byte page size
|
||||
#define XPRG_PARAM_EEPPAGESIZE 0x02
|
||||
// tiny TPI, 1-byte address
|
||||
#define XPRG_PARAM_NVMCMD_ADDR 0x03
|
||||
#define XPRG_PARAM_NVMCSR_ADDR 0x04
|
||||
|
||||
#define TPI_NVMCMD_ADDRESS 0x33
|
||||
#define TPI_NVMCSR_ADDRESS 0x32
|
||||
|
||||
|
||||
#if !defined(JTAG3_PRIVATE_EXPORTED)
|
||||
|
||||
struct mega_device_desc {
|
||||
|
|
|
@ -87,6 +87,7 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th
|
|||
{"jtagice3_updi", jtag3_updi_initpgm, jtag3_updi_desc}, // "JTAGICE3_UPDI"
|
||||
{"jtagice3_dw", jtag3_dw_initpgm, jtag3_dw_desc}, // "JTAGICE3_DW"
|
||||
{"jtagice3_isp", stk500v2_jtag3_initpgm, stk500v2_jtag3_desc}, // "JTAG3_ISP"
|
||||
{"jtagice3_tpi", jtag3_tpi_initpgm, jtag3_tpi_desc}, // "JTAGICE3_TPI"
|
||||
{"linuxgpio", linuxgpio_initpgm, linuxgpio_desc}, // "linuxgpio"
|
||||
{"linuxspi", linuxspi_initpgm, linuxspi_desc}, // LINUXSPI
|
||||
{"micronucleus", micronucleus_initpgm, micronucleus_desc}, // "micronucleus" or "Micronucleus V2.0"
|
||||
|
|
|
@ -3605,18 +3605,18 @@ static int stk600_xprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p)
|
|||
return -1;
|
||||
|
||||
buf[0] = XPRG_CMD_SET_PARAM;
|
||||
buf[1] = XPRG_PARAM_TPI_3;
|
||||
buf[1] = XPRG_PARAM_NVMCMD_ADDR;
|
||||
buf[2] = 51;
|
||||
if (stk600_xprog_command(pgm, buf, 3, 2) < 0) {
|
||||
pmsg_error("XPRG_CMD_SET_PARAM(XPRG_PARAM_TPI_3) failed\n");
|
||||
pmsg_error("XPRG_CMD_SET_PARAM(XPRG_PARAM_NVMCMD_ADDR) failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf[0] = XPRG_CMD_SET_PARAM;
|
||||
buf[1] = XPRG_PARAM_TPI_4;
|
||||
buf[1] = XPRG_PARAM_NVMCSR_ADDR;
|
||||
buf[2] = 50;
|
||||
if (stk600_xprog_command(pgm, buf, 3, 2) < 0) {
|
||||
pmsg_error("XPRG_CMD_SET_PARAM(XPRG_PARAM_TPI_4) failed\n");
|
||||
pmsg_error("XPRG_CMD_SET_PARAM(XPRG_PARAM_NVMCSR_ADDR) failed\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -223,35 +223,6 @@
|
|||
#define XPRG_MODE_JTAG 1
|
||||
#define XPRG_MODE_TPI 2
|
||||
|
||||
// XPROG commands
|
||||
#define XPRG_CMD_ENTER_PROGMODE 0x01
|
||||
#define XPRG_CMD_LEAVE_PROGMODE 0x02
|
||||
#define XPRG_CMD_ERASE 0x03
|
||||
#define XPRG_CMD_WRITE_MEM 0x04
|
||||
#define XPRG_CMD_READ_MEM 0x05
|
||||
#define XPRG_CMD_CRC 0x06
|
||||
#define XPRG_CMD_SET_PARAM 0x07
|
||||
|
||||
// Memory types
|
||||
#define XPRG_MEM_TYPE_APPL 1
|
||||
#define XPRG_MEM_TYPE_BOOT 2
|
||||
#define XPRG_MEM_TYPE_EEPROM 3
|
||||
#define XPRG_MEM_TYPE_FUSE 4
|
||||
#define XPRG_MEM_TYPE_LOCKBITS 5
|
||||
#define XPRG_MEM_TYPE_USERSIG 6
|
||||
#define XPRG_MEM_TYPE_FACTORY_CALIBRATION 7
|
||||
|
||||
// Erase types
|
||||
#define XPRG_ERASE_CHIP 1
|
||||
#define XPRG_ERASE_APP 2
|
||||
#define XPRG_ERASE_BOOT 3
|
||||
#define XPRG_ERASE_EEPROM 4
|
||||
#define XPRG_ERASE_APP_PAGE 5
|
||||
#define XPRG_ERASE_BOOT_PAGE 6
|
||||
#define XPRG_ERASE_EEPROM_PAGE 7
|
||||
#define XPRG_ERASE_USERSIG 8
|
||||
#define XPRG_ERASE_CONFIG 9 // TPI only, prepare fuse write
|
||||
|
||||
// Write mode flags
|
||||
#define XPRG_MEM_WRITE_ERASE 0
|
||||
#define XPRG_MEM_WRITE_WRITE 1
|
||||
|
@ -261,22 +232,6 @@
|
|||
#define XPRG_CRC_BOOT 2
|
||||
#define XPRG_CRC_FLASH 3
|
||||
|
||||
// Error codes
|
||||
#define XPRG_ERR_OK 0
|
||||
#define XPRG_ERR_FAILED 1
|
||||
#define XPRG_ERR_COLLISION 2
|
||||
#define XPRG_ERR_TIMEOUT 3
|
||||
|
||||
// XPROG parameters of different sizes
|
||||
// 4-byte address
|
||||
#define XPRG_PARAM_NVMBASE 0x01
|
||||
// 2-byte page size
|
||||
#define XPRG_PARAM_EEPPAGESIZE 0x02
|
||||
// 1-byte, undocumented TPI param
|
||||
#define XPRG_PARAM_TPI_3 0x03
|
||||
// 1-byte, undocumented TPI param
|
||||
#define XPRG_PARAM_TPI_4 0x04
|
||||
|
||||
// *****************[ STK answer constants ]***************************
|
||||
|
||||
#define ANSWER_CKSUM_ERROR 0xB0
|
||||
|
|
Loading…
Reference in New Issue