Add new component variants to parts in avrdude.conf

This is a list of strings each signifying an alternative part name and some of
the part's properties, eg:
  "ATmega328P-AU: 'TQFP32', Fmax=20000000 Hz, temp=[-40 C, 85 C], Vcc=[1.8 V, 5.5 V]"
This commit is contained in:
Stefan Rueger
2023-04-17 00:32:31 +01:00
parent 22bed55ebe
commit 6c6081ebda
7 changed files with 62 additions and 10 deletions

View File

@@ -75,8 +75,9 @@
# # (3) Not all programmer types can process a list of PIDs
#
# part
# desc = <description> ; # quoted string
# id = <id> ; # quoted string
# desc = <description> ; # quoted string, the long part name, eg, "ATmega328p"
# id = <id> ; # quoted string, normally an abbreviated part name
# variants = <str1> [, <str2> ...]; # quoted strings, each starts with "<alt-name>: ..."
# family_id = <id> ; # quoted string, eg, "megaAVR" or "tinyAVR"
# prog_modes = PM_<i/f> {| PM_<i/f>} # interfaces, eg, PM_SPM|PM_ISP|PM_HVPP|PM_debugWIRE
# mcuid = <num>; # unique id in 0..2039 for 8-bit AVRs

View File

@@ -574,6 +574,7 @@ AVRPART *avr_new_part(void) {
p->config_file = nulp;
p->mem = lcreat(NULL, 0);
p->mem_alias = lcreat(NULL, 0);
p->variants = lcreat(NULL, 0);
// Default values
p->mcuid = -1;
@@ -597,10 +598,10 @@ AVRPART *avr_dup_part(const AVRPART *d) {
if(d) {
*p = *d;
// Duplicate the memory and alias chains
// Leave variants list empty but duplicate the memory and alias chains
p->variants = lcreat(NULL, 0);
p->mem = lcreat(NULL, 0);
p->mem_alias = lcreat(NULL, 0);
for(LNODEID ln=lfirst(d->mem); ln; ln=lnext(ln)) {
AVRMEM *m = ldata(ln);
AVRMEM *m2 = avr_dup_mem(m);
@@ -630,6 +631,9 @@ void avr_free_part(AVRPART * d)
d->mem = NULL;
ldestroy_cb(d->mem_alias, (void(*)(void *))avr_free_memalias);
d->mem_alias = NULL;
ldestroy_cb(d->variants, free);
d->variants = NULL;
/* do not free d->parent_id and d->config_file */
for(size_t i=0; i<sizeof(d->op)/sizeof(d->op[0]); i++) {
if (d->op[i] != NULL) {

View File

@@ -111,6 +111,7 @@ static int pin_name;
%token K_USB
%token K_USBPID
%token K_TYPE
%token K_VARIANTS
%token K_VCC
%token K_VFYLED
@@ -603,6 +604,18 @@ part_parm :
free_token($3);
} |
K_VARIANTS TKN_EQUAL string_list {
{
ldestroy_cb(current_part->variants, free);
current_part->variants = lcreat(NULL, 0);
while (lsize(string_list)) {
TOKEN *t = lrmv_n(string_list, 1);
ladd(current_part->variants, cfg_strdup("config_gram.y", t->value.string));
free_token(t);
}
}
} |
K_DEVICECODE TKN_EQUAL numexpr {
{
yyerror("devicecode is deprecated, will be removed in v8.0, use stk500_devcode instead");

View File

@@ -496,6 +496,7 @@ typedef struct {
char descbuf[64];
char idbuf[32];
char family_idbuf[16];
char variants[1536-16];
AVRPART base;
OPCODE ops[AVR_OP_MAX];
AVRMEMdeep mems[40];
@@ -522,12 +523,16 @@ static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) {
d->base.lineno = 0;
// Copy over desc, id, and family_id
memset(d->descbuf, 0, sizeof d->descbuf);
strncpy(d->descbuf, p->desc, sizeof d->descbuf-1);
memset(d->idbuf, 0, sizeof d->idbuf);
strncpy(d->idbuf, p->id, sizeof d->idbuf-1);
memset(d->family_idbuf, 0, sizeof d->family_idbuf);
strncpy(d->family_idbuf, p->family_id, sizeof d->family_idbuf-1);
char *vp = d->variants;
for(LNODEID ln=lfirst(p->variants); ln; ln=lnext(ln)) {
if(vp < d->variants+sizeof d->variants-2) {
strncpy(vp, (char *)ldata(ln), d->variants+sizeof d->variants-vp-1);
vp += strlen(vp)+1;
}
}
// Zap address values
d->base.desc = NULL;
@@ -535,11 +540,11 @@ static int avrpart_deep_copy(AVRPARTdeep *d, const AVRPART *p) {
d->base.family_id = NULL;
d->base.mem = NULL;
d->base.mem_alias = NULL;
d->base.variants = NULL;
for(int i=0; i<AVR_OP_MAX; i++)
d->base.op[i] = NULL;
// Copy over all used SPI operations
memset(d->ops, 0, sizeof d->ops);
for(int i=0; i<AVR_OP_MAX; i++)
if(p->op[i])
d->ops[i] = *p->op[i];
@@ -603,6 +608,7 @@ static void dev_part_raw(const AVRPART *part) {
AVRPARTdeep dp;
int di = avrpart_deep_copy(&dp, part);
dev_raw_dump(&dp, (char *)&dp.base-(char *)&dp, part->desc, "part.intro", 0);
dev_raw_dump(&dp.base, sizeof dp.base, part->desc, "part", 0);
for(int i=0; i<AVR_OP_MAX; i++)
if(!_is_all_zero(dp.ops+i, sizeof*dp.ops))
@@ -644,6 +650,31 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool
_if_partout_str(strcmp, descstr, desc);
_if_partout_str(strcmp, cfg_escape(p->id), id);
if(lsize(p->variants)) {
int firstid = 1;
if(tsv)
dev_info(".pt\t%s\tvariants\t", p->desc);
else {
dev_cout(p->comments, "variants", 0, 0);
dev_info(" %-22s =\n", "variants");
}
for(LNODEID ln=lfirst(p->variants); ln; ln=lnext(ln)) {
if(!firstid)
dev_info(tsv? ", ": ",\n");
firstid = 0;
char *str = cfg_escape(ldata(ln));
dev_info("%*s%s", tsv? 0: 8, "", str);
free(str);
}
if(tsv)
dev_info("\n");
else {
dev_info(";");
dev_cout(p->comments, "variants", 1, 1);
}
}
_if_partout_str(strcmp, cfg_escape(p->family_id), family_id);
_if_partout_str(intcmp, cfg_strdup("dev_part_strct()", prog_modes_str(p->prog_modes)), prog_modes);
_if_partout(intcmp, "%d", mcuid);

View File

@@ -2112,8 +2112,9 @@ The following programmer types are currently implemented:
@smallexample
part
desc = <description> ; # quoted string
id = <id> ; # quoted string
desc = <description> ; # quoted string, the long part name, eg, "ATmega328p"
id = <id> ; # quoted string, normally an abbreviated part name
variants = <str1> [, <str2> ...]; # quoted strings, each starts so "<alt-name>: ..."
family_id = <id> ; # quoted string, e.g., "megaAVR" or "tinyAVR"
prog_modes = PM_<i/f> @{| PM_<i/f>@} # interfaces, e.g., PM_SPM|PM_ISP|PM_HVPP|PM_debugWIRE
mcuid = <num>; # unique id in 0..2039 for 8-bit AVRs

View File

@@ -213,6 +213,7 @@ spi { yylval=NULL; return K_SPI; }
type { yylval=NULL; ccap(); return K_TYPE; }
usb { yylval=NULL; return K_USB; }
usbpid { yylval=NULL; ccap(); return K_USBPID; }
variants { yylval=NULL; ccap(); return K_VARIANTS; }
vcc { yylval=NULL; ccap(); return K_VCC; }
vfyled { yylval=NULL; ccap(); return K_VFYLED; }
write { yylval=new_token(K_WRITE); ccap(); return K_WRITE; }

View File

@@ -236,6 +236,7 @@ typedef struct avrpart {
const char * desc; /* long part name */
const char * id; /* short part name */
LISTID comments; // Used by developer options -p*/[ASsr...]
LISTID variants; /* String with variant name and chip properties */
const char * parent_id; /* Used by developer options */
const char * family_id; /* family id in the SIB (avr8x) */
int prog_modes; /* Programming interfaces, see #define PM_... */