mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-12-16 02:31:06 +00:00
Fix reset=dedicated|io; in avrdude.conf.in
Done by adding code in developer_opts.c that allows to inject part or memory parameters into a semi-automated rewrite of avrdude.conf This is a generic method, whereby an external program can, eg., scrape atdf files for the right parameters and put them into a source table into developer_opts.c - Then write parts description with -p*/i - Use the output in a new avrdude.conf - Output again with -p* (no /i) and use that for final avrdude.conf - Remove table entries
This commit is contained in:
@@ -53,6 +53,27 @@
|
||||
#include "developer_opts.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"},
|
||||
};
|
||||
|
||||
static struct {
|
||||
const char *mcu, *mem, *var, *value;
|
||||
} meminj[] = {
|
||||
// Add quadruples here, eg, {"ATmega328P", "flash", "page_size", "128"},
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Return 0 if op code would encode (essentially) the same SPI command
|
||||
static int opcodecmp(const OPCODE *op1, const OPCODE *op2, int opnum) {
|
||||
char *opstr1, *opstr2, *p;
|
||||
@@ -525,7 +546,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);
|
||||
COMMENT *cp;
|
||||
|
||||
@@ -690,6 +711,12 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base) {
|
||||
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);
|
||||
|
||||
if(injct)
|
||||
for(size_t i=0; i<sizeof meminj/sizeof*meminj; i++)
|
||||
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) {
|
||||
dev_cout(m->comments, ";", 0, 0);
|
||||
dev_info(" ;\n");
|
||||
@@ -706,6 +733,12 @@ 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(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) {
|
||||
dev_cout(p->comments, ";", 0, 0);
|
||||
dev_info(";\n");
|
||||
@@ -742,7 +775,7 @@ void dev_output_pgm_part(int dev_opt_c, char *programmer, int dev_opt_p, char *p
|
||||
|
||||
// -p */[dASsrcow*t]
|
||||
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;
|
||||
int nprinted;
|
||||
AVRPART *nullpart = avr_new_part();
|
||||
@@ -753,7 +786,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||
if(!flags && !strcmp(partdesc, "*")) // Treat -p * as if it was -p */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(
|
||||
"Wildcard examples (these need protecting in the shell through quoting):\n"
|
||||
@@ -772,6 +805,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||
" w wd_... constants for ISP parts\n"
|
||||
" * all of the above except s and S\n"
|
||||
" t use tab separated values as much as possible\n"
|
||||
" i inject assignments from source code table\n"
|
||||
"Examples:\n"
|
||||
" $ avrdude -p ATmega328P/s\n"
|
||||
" $ avrdude -p m328*/st | grep chip_erase_delay\n"
|
||||
@@ -798,6 +832,7 @@ void dev_output_part_defs(char *partdesc) {
|
||||
strct = !!strchr(flags, 'S');
|
||||
cmpst = !!strchr(flags, 's');
|
||||
tsv = !!strchr(flags, 't');
|
||||
injct = !!strchr(flags, 'i');
|
||||
|
||||
|
||||
// Go through all memories and add them to the memory order list
|
||||
@@ -834,7 +869,8 @@ void dev_output_part_defs(char *partdesc) {
|
||||
dev_part_strct(p, tsv,
|
||||
astrc? NULL:
|
||||
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)
|
||||
dev_part_raw(p);
|
||||
|
||||
Reference in New Issue
Block a user