Self-document hvupdi_variant

This commit is contained in:
stefanrueger
2025-03-11 11:17:50 +01:00
parent a10911d427
commit 39ac5e88b3
6 changed files with 29 additions and 20 deletions

View File

@@ -49,7 +49,7 @@ avrdude_conf_version = "@AVRDUDE_FULL_VERSION@";
# usbvendor = <vendorname> ; # USB Vendor Name
# usbproduct = <productname> ; # USB Product Name
# usbsn = <serialno> ; # USB Serial Number
# hvupdi_support = <num> [, <num>, ... ] ; # UPDI HV Variants Support
# hvupdi_support = <num> [, <num>, ... ] ; # HV support for enabling UPDI
# ;
#
# # Notes
@@ -110,7 +110,7 @@ avrdude_conf_version = "@AVRDUDE_FULL_VERSION@";
# n_page_erase = <num>; # if set, number of pages erased during SPM erase
# n_boot_sections = <num>; # Number of boot sections
# boot_section_size = <num>; # Size of (smallest) boot section, if any
# hvupdi_variant = <num> ; # numeric -1 (n/a) or 0..2
# hvupdi_variant = <num> ; # numeric: -1 or 0..3; how to enable UPDI with HV
# stk500_devcode = <num> ; # numeric
# avr910_devcode = <num> ; # numeric
# is_at90s1200 = <yes/no> ; # AT90S1200 part

View File

@@ -3668,7 +3668,7 @@ programmer
usbvendor = <vendorname>; # USB Vendor Name
usbproduct = <productname>; # USB Product Name
usbsn = <serialno>; # USB Serial Number
hvupdi_support = <num> [, <num>, ... ]; # UPDI HV Variants Support
hvupdi_support = <num> [, <num>, ... ]; # HV support for enabling UPDI
;
@end smallexample
@@ -3836,7 +3836,7 @@ part
n_page_erase = <num>; # if set, number of pages erased during SPM erase
n_boot_sections = <num>; # Number of boot sections
boot_section_size = <num>; # Size of (smallest) boot section, if any
hvupdi_variant = <num>; # numeric -1 (n/a) or 0..2
hvupdi_variant = <num>; # numeric: -1 or 0..3; how to enable UPDI with HV
stk500_devcode = <num>; # numeric
avr910_devcode = <num>; # numeric
is_at90s1200 = <yes/no>; # AT90S1200 part

View File

@@ -1246,11 +1246,11 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
}
// Generate UPDI high-voltage pulse if user asks for it and hardware supports it
if(my.use_hvupdi == true && p->hvupdi_variant != HV_UPDI_VARIANT_1) {
if(my.use_hvupdi == true && p->hvupdi_variant != UPDI_ENABLE_ALWAYS) {
parm[0] = PARM3_UPDI_HV_NONE;
for(LNODEID ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln)) {
if(*(int *) ldata(ln) == p->hvupdi_variant) {
pmsg_notice("sending HV pulse to targets %s pin\n", p->hvupdi_variant == HV_UPDI_VARIANT_0? "UPDI": "RESET");
pmsg_notice("sending HV pulse to targets %s pin\n", p->hvupdi_variant == UPDI_ENABLE_HV_UPDI? "UPDI": "RESET");
parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE;
break;
}

View File

@@ -470,6 +470,6 @@ struct updi_device_desc {
unsigned char address_mode; // 0x00 = 16-bit mode, 0x01 = 24-bit mode
unsigned char hvupdi_variant; // Indicates the target UPDI HV implementation
unsigned char hvupdi_variant; // How the target's UPDI can be enabled with HV
};
#endif // JTAG3_PRIVATE_EXPORTED

View File

@@ -19,6 +19,9 @@
#ifndef libavrdude_h
#define libavrdude_h
// #define TO_BE_DEPRECATED_IN_2026
// #define TO_BE_DEPRECATED_IN_2027
#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
@@ -280,9 +283,15 @@ typedef struct opcode {
#define both_awire(pgm, p) (!!(joint_pm(pgm, p) & PM_aWire))
#define both_classic(pgm, p) (!!(joint_pm(pgm, p) & PM_Classic))
#define HV_UPDI_VARIANT_0 0 // Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)
#define HV_UPDI_VARIANT_1 1 // Dedicated UPDI pin, no HV (megaAVR0/AVR-Dx)
#define HV_UPDI_VARIANT_2 2 // Shared UPDI pin, HV on _RESET (AVR-DD/AVR-Ex)
#define UPDI_ENABLE_HV_UPDI 0 // Shared UPDI/GPIO/RESET pin, HV on UPDI pin (tinyAVR0/1/2)
#define UPDI_ENABLE_ALWAYS 1 // Dedicated UPDI pin, no HV needed (megaAVR0/AVR-DA/DB)
#define UPDI_ENABLE_HV_RESET 2 // Shared UPDI/GPIO pin, HV on RESET (AVR-DD/DUEA/EB)
#ifndef TO_BE_DEPRECATED_IN_2027
#define HV_UPDI_VARIANT_0 UPDI_ENABLE_HV_UPDI
#define HV_UPDI_VARIANT_1 UPDI_ENABLE_ALWAYS
#define HV_UPDI_VARIANT_2 UPDI_ENABLE_HV_RESET
#endif
#define HAS_SUFFER 1
#define HAS_VTARG_SWITCH 2
@@ -322,7 +331,7 @@ typedef struct avrpart {
int n_page_erase; // If set, number of pages erased during NVM erase
int n_boot_sections; // Number of boot sections
int boot_section_size; // Size of (smallest) boot section, if any
int hvupdi_variant; // HV pulse on UPDI pin, no pin or RESET pin
int hvupdi_variant; // HV pulse: on UPDI pin (0), not needed (1), on RESET (2/3)
int stk500_devcode; // Stk500 device code
int avr910_devcode; // Avr910 device code
int chip_erase_delay; // Microseconds
@@ -989,7 +998,7 @@ typedef struct programmer {
const char *usbsn;
const char *usbvendor;
const char *usbproduct;
LISTID hvupdi_support; // List of UPDI HV variants the tool supports, see HV_UPDI_VARIANT_x
LISTID hvupdi_support; // List of UPDI HV variants the tool supports, see UPDI_ENABLE_x
// Values below are not set by config_gram.y; ensure fd is first for dev_pgm_raw()
union filedescriptor fd;

View File

@@ -830,9 +830,9 @@ static int pickit5_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
}
if(my.hvupdi_enabled > 0) {
if(p->hvupdi_variant == 0)
if(p->hvupdi_variant == UPDI_ENABLE_HV_UPDI)
pmsg_notice("high-voltage SYSCFG0 override on UPDI pin enabled\n");
if(p->hvupdi_variant == 2)
if(p->hvupdi_variant == UPDI_ENABLE_HV_RESET)
pmsg_notice("high-voltage SYSCFG0 override on RST pin enabled\n");
}
@@ -937,11 +937,11 @@ static int pickit5_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
const unsigned char *enter_prog = my.scripts.EnterProgMode;
unsigned int enter_prog_len = my.scripts.EnterProgMode_len;
if(my.hvupdi_enabled && (my.pgm_type != PGM_TYPE_SNAP)) { // SNAP has no HV generation
if(p->hvupdi_variant == HV_UPDI_VARIANT_0) { // High voltage generation on UPDI line
if(my.hvupdi_enabled && (my.pgm_type != PGM_TYPE_SNAP)) { // SNAP has no HV generation
if(p->hvupdi_variant == UPDI_ENABLE_HV_UPDI) { // High voltage generation on UPDI line
enter_prog = my.scripts.EnterProgModeHvSp;
enter_prog_len = my.scripts.EnterProgModeHvSp_len;
} else if(p->hvupdi_variant == HV_UPDI_VARIANT_2) { // High voltage generation on RST line
} else if(p->hvupdi_variant == UPDI_ENABLE_HV_RESET) { // High voltage generation on RST line
enter_prog = my.scripts.EnterProgModeHvSpRst;
enter_prog_len = my.scripts.EnterProgModeHvSpRst_len;
}
@@ -1358,11 +1358,11 @@ static int pickit5_read_dev_id(const PROGRAMMER *pgm, const AVRPART *p) {
if(len == 0x03 || len == 0x04) { // just DevId or UPDI with revision
memcpy(my.devID, &my.rxBuf[24], len);
} else {
if(my.hvupdi_enabled && p->hvupdi_variant == HV_UPDI_VARIANT_2) {
pmsg_info("failed to get DeviceID with activated HV Pulse on RST");
if(my.hvupdi_enabled && p->hvupdi_variant == UPDI_ENABLE_HV_RESET) {
pmsg_info("failed to get DeviceID with activated HV Pulse on RST\n");
msg_info("if the wiring is correct, try connecting a 16 V, 1 uF cap between RST and GND\n");
} else {
pmsg_error("length (%u) mismatch of returned Device ID.\n", len);
pmsg_error("length (%u) mismatch of returned Device ID\n", len);
}
return -1;
}