Merge pull request #1086 from stefanrueger/config_file
Rewrite avrdude.conf.in with developer options
This commit is contained in:
commit
eb7bdfd422
15232
src/avrdude.conf.in
15232
src/avrdude.conf.in
File diff suppressed because it is too large
Load Diff
|
@ -53,6 +53,29 @@
|
||||||
#include "developer_opts.h"
|
#include "developer_opts.h"
|
||||||
#include "developer_opts_private.h"
|
#include "developer_opts_private.h"
|
||||||
|
|
||||||
|
// Inject part parameters into a semi-automated rewrite of avrdude.conf
|
||||||
|
// - Add entries to the tables below; they get written on -p*/i
|
||||||
|
// - Use the output in a new avrdude.conf
|
||||||
|
// - Output again with -p* (no /i) and use that for final avrdude.conf
|
||||||
|
// - Remove entries from below tables
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
const char *mcu, *var, *value;
|
||||||
|
} ptinj[] = {
|
||||||
|
// Add triples here, eg, {"ATmega328P", "mcuid", "999"},
|
||||||
|
{NULL, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
const char *mcu, *mem, *var, *value;
|
||||||
|
} meminj[] = {
|
||||||
|
// Add quadruples here, eg, {"ATmega328P", "flash", "page_size", "128"},
|
||||||
|
{NULL, NULL, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return 0 if op code would encode (essentially) the same SPI command
|
// Return 0 if op code would encode (essentially) the same SPI command
|
||||||
static int opcodecmp(const OPCODE *op1, const OPCODE *op2, int opnum) {
|
static int opcodecmp(const OPCODE *op1, const OPCODE *op2, int opnum) {
|
||||||
char *opstr1, *opstr2, *p;
|
char *opstr1, *opstr2, *p;
|
||||||
|
@ -308,7 +331,7 @@ static int dev_part_strct_entry(bool tsv, // Print as spreadsheet?
|
||||||
} else { // Grammar conform
|
} else { // Grammar conform
|
||||||
int indent = col2 && strcmp(col2, "part");
|
int indent = col2 && strcmp(col2, "part");
|
||||||
dev_cout(comms, n, 0, 0); // Print comments before the line
|
dev_cout(comms, n, 0, 0); // Print comments before the line
|
||||||
dev_info("%*s%-*s = %s;", indent? 8: 4, "", indent? 15: 19, n, c);
|
dev_info("%*s%-*s = %s;", indent? 8: 4, "", indent? 18: 22, n, c);
|
||||||
dev_cout(comms, n, 1, 1); // Print comments on rhs
|
dev_cout(comms, n, 1, 1); // Print comments on rhs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +361,7 @@ static void dev_stack_out(bool tsv, const AVRPART *p, const char *name, const un
|
||||||
dev_info(".pt\t%s\t%s\t", p->desc, name);
|
dev_info(".pt\t%s\t%s\t", p->desc, name);
|
||||||
else {
|
else {
|
||||||
dev_cout(p->comments, name, 0, 0);
|
dev_cout(p->comments, name, 0, 0);
|
||||||
dev_info(" %-19s =%s", name, ns <=8? " ": "");
|
dev_info(" %-22s =%s", name, ns <=8? " ": "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ns <= 0)
|
if(ns <= 0)
|
||||||
|
@ -525,7 +548,7 @@ static void dev_part_raw(const AVRPART *part) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base) {
|
static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool injct) {
|
||||||
char *descstr = cfg_escape(p->desc);
|
char *descstr = cfg_escape(p->desc);
|
||||||
COMMENT *cp;
|
COMMENT *cp;
|
||||||
|
|
||||||
|
@ -690,6 +713,13 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base) {
|
||||||
if(!bm || opcodecmp(bm->op[i], m->op[i], i))
|
if(!bm || opcodecmp(bm->op[i], m->op[i], i))
|
||||||
dev_part_strct_entry(tsv, ".ptmmop", p->desc, m->desc, opcodename(i), opcode2str(m->op[i], i, !tsv), m->comments);
|
dev_part_strct_entry(tsv, ".ptmmop", p->desc, m->desc, opcodename(i), opcode2str(m->op[i], i, !tsv), m->comments);
|
||||||
|
|
||||||
|
if(injct)
|
||||||
|
for(size_t i=0; i<sizeof meminj/sizeof*meminj; i++)
|
||||||
|
if(meminj[i].mcu)
|
||||||
|
if(strcmp(meminj[i].mcu, p->desc) == 0 && strcmp(meminj[i].mem, m->desc) == 0)
|
||||||
|
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc,
|
||||||
|
meminj[i].var, cfg_strdup("meminj", meminj[i].value), NULL);
|
||||||
|
|
||||||
if(!tsv) {
|
if(!tsv) {
|
||||||
dev_cout(m->comments, ";", 0, 0);
|
dev_cout(m->comments, ";", 0, 0);
|
||||||
dev_info(" ;\n");
|
dev_info(" ;\n");
|
||||||
|
@ -706,6 +736,13 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(injct)
|
||||||
|
for(size_t i=0; i<sizeof ptinj/sizeof*ptinj; i++)
|
||||||
|
if(ptinj[i].mcu)
|
||||||
|
if(strcmp(ptinj[i].mcu, p->desc) == 0)
|
||||||
|
dev_part_strct_entry(tsv, ".pt", p->desc, NULL,
|
||||||
|
ptinj[i].var, cfg_strdup("ptinj", ptinj[i].value), NULL);
|
||||||
|
|
||||||
if(!tsv) {
|
if(!tsv) {
|
||||||
dev_cout(p->comments, ";", 0, 0);
|
dev_cout(p->comments, ";", 0, 0);
|
||||||
dev_info(";\n");
|
dev_info(";\n");
|
||||||
|
@ -742,7 +779,7 @@ void dev_output_pgm_part(int dev_opt_c, char *programmer, int dev_opt_p, char *p
|
||||||
|
|
||||||
// -p */[dASsrcow*t]
|
// -p */[dASsrcow*t]
|
||||||
void dev_output_part_defs(char *partdesc) {
|
void dev_output_part_defs(char *partdesc) {
|
||||||
bool cmdok, waits, opspi, descs, astrc, strct, cmpst, raw, all, tsv;
|
bool cmdok, waits, opspi, descs, astrc, strct, cmpst, injct, raw, all, tsv;
|
||||||
char *flags;
|
char *flags;
|
||||||
int nprinted;
|
int nprinted;
|
||||||
AVRPART *nullpart = avr_new_part();
|
AVRPART *nullpart = avr_new_part();
|
||||||
|
@ -753,7 +790,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||||
if(!flags && !strcmp(partdesc, "*")) // Treat -p * as if it was -p */s
|
if(!flags && !strcmp(partdesc, "*")) // Treat -p * as if it was -p */s
|
||||||
flags = "s";
|
flags = "s";
|
||||||
|
|
||||||
if(!*flags || !strchr("cdoASsrw*t", *flags)) {
|
if(!*flags || !strchr("cdoASsrw*ti", *flags)) {
|
||||||
dev_info("%s: flags for developer option -p <wildcard>/<flags> not recognised\n", progname);
|
dev_info("%s: flags for developer option -p <wildcard>/<flags> not recognised\n", progname);
|
||||||
dev_info(
|
dev_info(
|
||||||
"Wildcard examples (these need protecting in the shell through quoting):\n"
|
"Wildcard examples (these need protecting in the shell through quoting):\n"
|
||||||
|
@ -772,6 +809,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||||
" w wd_... constants for ISP parts\n"
|
" w wd_... constants for ISP parts\n"
|
||||||
" * all of the above except s and S\n"
|
" * all of the above except s and S\n"
|
||||||
" t use tab separated values as much as possible\n"
|
" t use tab separated values as much as possible\n"
|
||||||
|
" i inject assignments from source code table\n"
|
||||||
"Examples:\n"
|
"Examples:\n"
|
||||||
" $ avrdude -p ATmega328P/s\n"
|
" $ avrdude -p ATmega328P/s\n"
|
||||||
" $ avrdude -p m328*/st | grep chip_erase_delay\n"
|
" $ avrdude -p m328*/st | grep chip_erase_delay\n"
|
||||||
|
@ -798,6 +836,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||||
strct = !!strchr(flags, 'S');
|
strct = !!strchr(flags, 'S');
|
||||||
cmpst = !!strchr(flags, 's');
|
cmpst = !!strchr(flags, 's');
|
||||||
tsv = !!strchr(flags, 't');
|
tsv = !!strchr(flags, 't');
|
||||||
|
injct = !!strchr(flags, 'i');
|
||||||
|
|
||||||
|
|
||||||
// Go through all memories and add them to the memory order list
|
// Go through all memories and add them to the memory order list
|
||||||
|
@ -834,7 +873,8 @@ void dev_output_part_defs(char *partdesc) {
|
||||||
dev_part_strct(p, tsv,
|
dev_part_strct(p, tsv,
|
||||||
astrc? NULL:
|
astrc? NULL:
|
||||||
strct? nullpart:
|
strct? nullpart:
|
||||||
p->parent_id && *p->parent_id? locate_part(part_list, p->parent_id): nullpart);
|
p->parent_id && *p->parent_id? locate_part(part_list, p->parent_id): nullpart,
|
||||||
|
injct);
|
||||||
|
|
||||||
if(raw)
|
if(raw)
|
||||||
dev_part_raw(p);
|
dev_part_raw(p);
|
||||||
|
@ -1129,7 +1169,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas
|
||||||
dev_info(".prog\t%s\tid\t", id);
|
dev_info(".prog\t%s\tid\t", id);
|
||||||
else {
|
else {
|
||||||
dev_cout(pgm->comments, "id", 0, 0);
|
dev_cout(pgm->comments, "id", 0, 0);
|
||||||
dev_info(" %-19s = ", "id");
|
dev_info(" %-22s = ", "id");
|
||||||
}
|
}
|
||||||
for(firstid=1, ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
|
for(firstid=1, ln=lfirst(pgm->id); ln; ln=lnext(ln)) {
|
||||||
if(!firstid)
|
if(!firstid)
|
||||||
|
@ -1147,6 +1187,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas
|
||||||
}
|
}
|
||||||
|
|
||||||
_if_pgmout_str(strcmp, cfg_escape(pgm->desc), desc);
|
_if_pgmout_str(strcmp, cfg_escape(pgm->desc), desc);
|
||||||
|
if(!base || base->initpgm != pgm->initpgm)
|
||||||
_pgmout_fmt("type", "\"%s\"", locate_programmer_type_id(pgm->initpgm));
|
_pgmout_fmt("type", "\"%s\"", locate_programmer_type_id(pgm->initpgm));
|
||||||
if(!base || base->conntype != pgm->conntype)
|
if(!base || base->conntype != pgm->conntype)
|
||||||
_pgmout_fmt("connection_type", "%s", connstr(pgm->conntype));
|
_pgmout_fmt("connection_type", "%s", connstr(pgm->conntype));
|
||||||
|
@ -1159,7 +1200,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas
|
||||||
dev_info(".prog\t%s\tusbpid\t", id);
|
dev_info(".prog\t%s\tusbpid\t", id);
|
||||||
else {
|
else {
|
||||||
dev_cout(pgm->comments, "usbpid", 0, 0);
|
dev_cout(pgm->comments, "usbpid", 0, 0);
|
||||||
dev_info(" %-19s = ", "usbpid");
|
dev_info(" %-22s = ", "usbpid");
|
||||||
}
|
}
|
||||||
for(firstid=1, ln=lfirst(pgm->usbpid); ln; ln=lnext(ln)) {
|
for(firstid=1, ln=lfirst(pgm->usbpid); ln; ln=lnext(ln)) {
|
||||||
if(!firstid)
|
if(!firstid)
|
||||||
|
@ -1182,10 +1223,13 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas
|
||||||
|
|
||||||
for(int i=0; i<N_PINS; i++) {
|
for(int i=0; i<N_PINS; i++) {
|
||||||
char *str = pins_to_strdup(pgm->pin+i);
|
char *str = pins_to_strdup(pgm->pin+i);
|
||||||
if(str && *str)
|
char *bstr = base? pins_to_strdup(base->pin+i): NULL;
|
||||||
|
if(!base || strcmp(bstr, str))
|
||||||
_pgmout_fmt(avr_pin_lcname(i), "%s", str);
|
_pgmout_fmt(avr_pin_lcname(i), "%s", str);
|
||||||
if(str)
|
|
||||||
free(str);
|
free(str);
|
||||||
|
if(bstr)
|
||||||
|
free(bstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pgm->hvupdi_support && lfirst(pgm->hvupdi_support)) {
|
if(pgm->hvupdi_support && lfirst(pgm->hvupdi_support)) {
|
||||||
|
@ -1193,7 +1237,7 @@ static void dev_pgm_strct(const PROGRAMMER *pgm, bool tsv, const PROGRAMMER *bas
|
||||||
dev_info(".prog\t%s\thvupdu_support\t", id);
|
dev_info(".prog\t%s\thvupdu_support\t", id);
|
||||||
else {
|
else {
|
||||||
dev_cout(pgm->comments, "hvupdi_support", 0, 0);
|
dev_cout(pgm->comments, "hvupdi_support", 0, 0);
|
||||||
dev_info(" %-19s = ", "hvupdi_support");
|
dev_info(" %-22s = ", "hvupdi_support");
|
||||||
}
|
}
|
||||||
for(firstid=1, ln=lfirst(pgm->hvupdi_support); ln; ln=lnext(ln)) {
|
for(firstid=1, ln=lfirst(pgm->hvupdi_support); ln; ln=lnext(ln)) {
|
||||||
if(!firstid)
|
if(!firstid)
|
||||||
|
|
|
@ -350,7 +350,7 @@ const char * pins_to_str(const struct pindef_t * const pindef) {
|
||||||
* This function returns a string of defined pins, eg, ~1, 2, ~4, ~5, 7 or ""
|
* This function returns a string of defined pins, eg, ~1, 2, ~4, ~5, 7 or ""
|
||||||
*
|
*
|
||||||
* @param[in] pindef the pin definition for which we want the string representation
|
* @param[in] pindef the pin definition for which we want the string representation
|
||||||
* @returns a pointer to a string, which was created by strdup
|
* @returns a pointer to a string, which was created by cfg_strdup()
|
||||||
*/
|
*/
|
||||||
char *pins_to_strdup(const struct pindef_t * const pindef) {
|
char *pins_to_strdup(const struct pindef_t * const pindef) {
|
||||||
char buf[6*(PIN_MAX+1)], *p = buf;
|
char buf[6*(PIN_MAX+1)], *p = buf;
|
||||||
|
|
Loading…
Reference in New Issue