diff --git a/avrdude/avrdude.1 b/avrdude/avrdude.1 index a7743dd6..ff1bf79b 100644 --- a/avrdude/avrdude.1 +++ b/avrdude/avrdude.1 @@ -250,6 +250,10 @@ Intel Hex Motorola S-record .It Ar r raw binary; little-endian byte order, in the case of the flash ROM data +.It Ar m +immediate; actual byte values specified on the command line, seperated +by commas or spaces. This is good for programming fuse bytes without +having to create a single-byte file or enter terminal mode. .It Ar a auto detect; valid for input only, and only if the input is not provided at diff --git a/avrdude/fileio.c b/avrdude/fileio.c index 83727725..d70e427a 100644 --- a/avrdude/fileio.c +++ b/avrdude/fileio.c @@ -728,6 +728,49 @@ int fileio_rbin(struct fioparms * fio, } +int fileio_imm(struct fioparms * fio, + char * filename, FILE * f, unsigned char * buf, int size) +{ + int rc; + char * e, * p; + unsigned long b; + int loc; + + switch (fio->op) { + case FIO_READ: + loc = 0; + p = strtok(filename, " ,"); + while (p != NULL && loc < size) { + b = strtoul(p, &e, 0); + if (*e != 0) { + fprintf(stderr, + "%s: invalid byte value (%s) specified for immediate mode\n", + progname, p); + return -1; + } + buf[loc++] = b; + p = strtok(NULL, " ,"); + rc = loc; + } + break; + default: + fprintf(stderr, "%s: fileio: invalid operation=%d\n", + progname, fio->op); + return -1; + } + + if (rc < 0 || (fio->op == FIO_WRITE && rc < size)) { + fprintf(stderr, + "%s: %s error %s %s: %s; %s %d of the expected %d bytes\n", + progname, fio->iodesc, fio->dir, filename, strerror(errno), + fio->rw, rc, size); + return -1; + } + + return rc; +} + + int fileio_ihex(struct fioparms * fio, char * filename, FILE * f, unsigned char * buf, int size) { @@ -907,6 +950,18 @@ int fileio(int op, char * filename, FILEFMT format, if (rc < 0) return -1; + /* point at the requested memory buffer */ + buf = mem->buf; + if (fio.op == FIO_READ) + size = mem->size; + + if (fio.op == FIO_READ) { + /* 0xff fill unspecified memory */ + for (i=0; ibuf; - if (fio.op == FIO_READ) - size = mem->size; - - if (fio.op == FIO_READ) { - /* 0xff fill unspecified memory */ - for (i=0; i